Skip to content

Commit

Permalink
Maint: New method of updating globals (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
dipinknair authored Jun 27, 2024
1 parent 1d0a68a commit 15e4fc2
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 133 deletions.
18 changes: 2 additions & 16 deletions examples/basic/bolt_pretension.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# Embed mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)

cwd = os.path.join(os.getcwd(), "out")
Expand Down Expand Up @@ -525,21 +525,7 @@ def update(frame):
# Project tree
# ~~~~~~~~~~~~


def print_tree(node, indentation=""):
print(f"{indentation}├── {node.Name}")

if (
hasattr(node, "Children")
and node.Children is not None
and node.Children.Count > 0
):
for child in node.Children:
print_tree(child, indentation + "| ")


root_node = DataModel.Project
print_tree(root_node)
app.print_tree(DataModel.Project)

# %%
# Cleanup
Expand Down
18 changes: 2 additions & 16 deletions examples/basic/fracture_analysis_contact_debonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Embed mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)

cwd = os.path.join(os.getcwd(), "out")
Expand Down Expand Up @@ -425,21 +425,7 @@ def write_file_contents_to_console(path):
# Project tree
# ~~~~~~~~~~~~


def print_tree(node, indentation=""):
print(f"{indentation}├── {node.Name}")

if (
hasattr(node, "Children")
and node.Children is not None
and node.Children.Count > 0
):
for child in node.Children:
print_tree(child, indentation + "| ")


root_node = DataModel.Project
print_tree(root_node)
app.print_tree(DataModel.Project)

# %%
# Cleanup
Expand Down
19 changes: 1 addition & 18 deletions examples/basic/harmonic_acoustics.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,24 +498,7 @@ def write_file_contents_to_console(path):
# Project tree
# ~~~~~~~~~~~~


def print_tree(node, indentation=""):
if hasattr(node, "Suppressed") and node.Suppressed is True:
print(f"{indentation}├── {node.Name} (Suppressed)")
else:
print(f"{indentation}├── {node.Name}")

if (
hasattr(node, "Children")
and node.Children is not None
and node.Children.Count > 0
):
for child in node.Children:
print_tree(child, indentation + "| ")


root_node = DataModel.Project
print_tree(root_node)
app.print_tree(DataModel.Project)

# %%
# Cleanup
Expand Down
18 changes: 2 additions & 16 deletions examples/basic/modal_acoustics_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# Embed mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)

cwd = os.path.join(os.getcwd(), "out")
Expand Down Expand Up @@ -523,21 +523,7 @@ def update(frame):
# Project tree
# ~~~~~~~~~~~~


def print_tree(node, indentation=""):
print(f"{indentation}├── {node.Name}")

if (
hasattr(node, "Children")
and node.Children is not None
and node.Children.Count > 0
):
for child in node.Children:
print_tree(child, indentation + "| ")


root_node = DataModel.Project
print_tree(root_node)
app.print_tree(DataModel.Project)

# %%
# Cleanup
Expand Down
18 changes: 2 additions & 16 deletions examples/basic/steady_state_thermal_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Embed mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)

cwd = os.path.join(os.getcwd(), "out")
Expand Down Expand Up @@ -463,21 +463,7 @@ def write_file_contents_to_console(path):
# Project tree
# ~~~~~~~~~~~~


def print_tree(node, indentation=""):
print(f"{indentation}├── {node.Name}")

if (
hasattr(node, "Children")
and node.Children is not None
and node.Children.Count > 0
):
for child in node.Children:
print_tree(child, indentation + "| ")


root_node = DataModel.Project
print_tree(root_node)
app.print_tree(DataModel.Project)

# %%
# Cleanup
Expand Down
18 changes: 2 additions & 16 deletions examples/basic/topology_optimization_cantilever_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Embed Mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)


Expand Down Expand Up @@ -252,21 +252,7 @@ def write_file_contents_to_console(path):
# Project tree
# ~~~~~~~~~~~~


def print_tree(node, indentation=""):
print(f"{indentation}├── {node.Name}")

if (
hasattr(node, "Children")
and node.Children is not None
and node.Children.Count > 0
):
for child in node.Children:
print_tree(child, indentation + "| ")


root_node = DataModel.Project
print_tree(root_node)
app.print_tree(DataModel.Project)

# %%
# Cleanup
Expand Down
18 changes: 2 additions & 16 deletions examples/basic/valve.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Embed mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)

cwd = os.path.join(os.getcwd(), "out")
Expand Down Expand Up @@ -252,21 +252,7 @@ def write_file_contents_to_console(path):
# Project tree
# ~~~~~~~~~~~~


def print_tree(node, indentation=""):
print(f"{indentation}├── {node.Name}")

if (
hasattr(node, "Children")
and node.Children is not None
and node.Children.Count > 0
):
for child in node.Children:
print_tree(child, indentation + "| ")


root_node = DataModel.Project
print_tree(root_node)
app.print_tree(DataModel.Project)

# %%
# Cleanup
Expand Down
2 changes: 1 addition & 1 deletion examples/technology_showcase/Rotor_Blade_Inverse_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
# Embed mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)

cwd = os.path.join(os.getcwd(), "out")
Expand Down
19 changes: 2 additions & 17 deletions examples/technology_showcase/conact_wear_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Embed mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)

cwd = os.path.join(os.getcwd(), "out")
Expand Down Expand Up @@ -381,22 +381,7 @@ def update(frame):
# Project tree
# ~~~~~~~~~~~~


def print_tree(node, indentation=""):
print(f"{indentation}├── {node.Name}")

if (
hasattr(node, "Children")
and node.Children is not None
and node.Children.Count > 0
):
for child in node.Children:
print_tree(child, indentation + "| ")


root_node = DataModel.Project
print_tree(root_node)

app.print_tree(DataModel.Project)

# %%
# Cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# Embed mechanical and set global variables

app = mech.App(version=241)
globals().update(mech.global_variables(app, True))
app.update_globals(globals())
print(app)

cwd = os.path.join(os.getcwd(), "out")
Expand Down

0 comments on commit 15e4fc2

Please sign in to comment.