Skip to content

Commit 354b8ca

Browse files
not using global variable
1 parent c9f3aa5 commit 354b8ca

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

examples/01-mathematical-operations/matrix-operations.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
my_avg_stress = dpf.operators.averaging.to_elemental_fc(
6565
fields_container=my_stress, mesh=my_mesh
6666
).eval()
67-
print(my_avg_stress, my_avg_stress[0])
68-
67+
print(my_avg_stress)
68+
print(my_avg_stress[0])
6969
#########################################################
7070
# Separating tensor by component
7171
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -74,10 +74,13 @@
7474
# :func:'select_component()<ansys.dpf.core.fields_container.FieldsContainer.select_component>'.
7575
# Here, the stress tensor has 6 components per elementary data (symmetrical tensor XX,YY,ZZ,XY,YZ,XZ).
7676

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

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

120-
print(re_assemble, re_assemble[0])
123+
print(re_assemble)
124+
print(re_assemble[0])

0 commit comments

Comments
 (0)