Skip to content

Commit

Permalink
not using global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
luisaFelixSalles committed Oct 21, 2024
1 parent c9f3aa5 commit 354b8ca
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions examples/01-mathematical-operations/matrix-operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
my_avg_stress = dpf.operators.averaging.to_elemental_fc(
fields_container=my_stress, mesh=my_mesh
).eval()
print(my_avg_stress, my_avg_stress[0])

print(my_avg_stress)
print(my_avg_stress[0])
#########################################################
# Separating tensor by component
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -74,10 +74,13 @@
# :func:'select_component()<ansys.dpf.core.fields_container.FieldsContainer.select_component>'.
# Here, the stress tensor has 6 components per elementary data (symmetrical tensor XX,YY,ZZ,XY,YZ,XZ).

for i in range(
0, 6
): # Separating the results in different fields containers for each stress tensor component
globals()[f"stress_{i + 1}"] = my_avg_stress.select_component(i)
# Separating the results in different fields containers for each stress tensor component
stress_1 = my_avg_stress.select_component(0)
stress_2 = my_avg_stress.select_component(1)
stress_3 = my_avg_stress.select_component(2)
stress_4 = my_avg_stress.select_component(3)
stress_5 = my_avg_stress.select_component(4)
stress_6 = my_avg_stress.select_component(5)

################################################################################
# Mathematical operation on each field
Expand Down Expand Up @@ -117,4 +120,5 @@
xx=stress_1, yy=stress_2, zz=stress_3, xy=stress_4, yz=stress_5, xz=stress_6, symmetrical=True
).eval()

print(re_assemble, re_assemble[0])
print(re_assemble)
print(re_assemble[0])

0 comments on commit 354b8ca

Please sign in to comment.