getfem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Getfem-commits] (no subject)


From: Yves Renard
Subject: [Getfem-commits] (no subject)
Date: Sun, 5 Jan 2020 10:12:27 -0500 (EST)

branch: devel-logari81-internal-variables
commit afe03f8c42f915354f8fc5504326b86c182744b1
Author: Yves Renard <address@hidden>
Date:   Sun Jan 5 16:11:55 2020 +0100

    adding a test
---
 interface/tests/python/Makefile.am                 |  1 +
 .../demo_thermo_elasticity_electrical_coupling.py  | 26 +++++++++++++++++-----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/interface/tests/python/Makefile.am 
b/interface/tests/python/Makefile.am
index 982f573..40d7d4d 100644
--- a/interface/tests/python/Makefile.am
+++ b/interface/tests/python/Makefile.am
@@ -73,6 +73,7 @@ TESTS =                                               \
        demo_laplacian.py                               \
        demo_laplacian_HHO.py                           \
        demo_elasticity_HHO.py                          \
+       demo_thermo_elasticity_electrical_coupling.py   \
        $(optpy)
 
 AM_TESTS_ENVIRONMENT = \
diff --git 
a/interface/tests/python/demo_thermo_elasticity_electrical_coupling.py 
b/interface/tests/python/demo_thermo_elasticity_electrical_coupling.py
index a9f2ed3..6567083 100644
--- a/interface/tests/python/demo_thermo_elasticity_electrical_coupling.py
+++ b/interface/tests/python/demo_thermo_elasticity_electrical_coupling.py
@@ -79,10 +79,11 @@ alpha = 0.0039     # Second resistance temperature 
coefficient.
 #
 # Numerical parameters
 #
-h = 2.                     # Approximate mesh size
-elements_degree = 2        # Degree of the finite element methods
-export_mesh = True         # Draw the mesh after mesh generation or not
-solve_in_two_steps = True  # Solve the elasticity problem separately or not
+h = 2.                    # Approximate mesh size
+elements_degree = 2       # Degree of the finite element methods
+export_mesh = True        # Draw the mesh after mesh generation or not
+solve_in_two_steps = 2    # Solve the elasticity problem separately (1)
+                          # or in a coupled way (0) or both and compare (2)
 
 #
 # Mesh generation. Meshes can also been imported from several formats.
@@ -191,7 +192,8 @@ md.add_linear_term(mim, 
'beta*(T0-theta)*Trace(Grad_Test_u)')
 #
 # Model solve
 #
-if (solve_in_two_steps):
+
+if (solve_in_two_steps >= 1):
   md.disable_variable('u')
   print('First problem with', md.nbdof(), ' dofs')
   md.solve('max_res', 1E-9, 'max_iter', 100, 'noisy')
@@ -200,10 +202,22 @@ if (solve_in_two_steps):
   md.disable_variable('V')
   print('Second problem with ', md.nbdof(), ' dofs')
   md.solve('max_res', 1E-9, 'max_iter', 100, 'noisy')
-else:
+  md.enable_variable('theta')
+  md.enable_variable('V')
+  U1 = md.variable('u')
+  
+if (solve_in_two_steps == 0):
   print('Global problem with ', md.nbdof(), ' dofs')
   md.solve('max_res', 1E-9, 'max_iter', 100, 'noisy')
 
+if (solve_in_two_steps == 2):
+  print('Global problem with ', md.nbdof(), ' dofs')
+  md.set_variable('u', md.variable('u')*0.);
+  md.solve('max_res', 1E-9, 'max_iter', 100, 'noisy')
+  U2 = md.variable('u')
+  print (np.linalg.norm(U2-U1));
+  if (np.linalg.norm(U2-U1) > 1E-10):
+      print("Too big difference between solve in one and two steps"); exit(1)
 
 #
 # Solution export



reply via email to

[Prev in Thread] Current Thread [Next in Thread]