Skip to content

Maint: New method of updating globals #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading