From 354b8ca87c80d80b29b7f95820056c1b30c8fb35 Mon Sep 17 00:00:00 2001 From: luisaFelixSalles Date: Mon, 21 Oct 2024 15:48:58 +0200 Subject: [PATCH] not using global variable --- .../matrix-operations.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/01-mathematical-operations/matrix-operations.py b/examples/01-mathematical-operations/matrix-operations.py index cee08947fd..7ca507d4c8 100644 --- a/examples/01-mathematical-operations/matrix-operations.py +++ b/examples/01-mathematical-operations/matrix-operations.py @@ -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 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -74,10 +74,13 @@ # :func:'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 @@ -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])