getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] [getfem-commits] branch master updated: using macros in


From: Yves Renard
Subject: [Getfem-commits] [getfem-commits] branch master updated: using macros in that demo file
Date: Wed, 29 Apr 2020 09:40:59 -0400

This is an automated email from the git hooks/post-receive script.

renard pushed a commit to branch master
in repository getfem.

The following commit(s) were added to refs/heads/master by this push:
     new a501150  using macros in that demo file
a501150 is described below

commit a50115014db40cb9225158b5a66d1a7e7ac8c1c9
Author: Yves Renard <address@hidden>
AuthorDate: Wed Apr 29 15:40:47 2020 +0200

    using macros in that demo file
---
 interface/tests/python/demo_nonlinear_elasticity.py | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/interface/tests/python/demo_nonlinear_elasticity.py 
b/interface/tests/python/demo_nonlinear_elasticity.py
index ff092db..f3aae75 100644
--- a/interface/tests/python/demo_nonlinear_elasticity.py
+++ b/interface/tests/python/demo_nonlinear_elasticity.py
@@ -84,16 +84,13 @@ if (not(explicit_potential)):
 else:
     print("Explicit elastic potential")
     K = 1.2; mu = 3.0;
-    _F_ = "(Id(3)+Grad_u)"
-    _J_= "Det{F}".format(F=_F_)
-    _be_ = "(Left_Cauchy_Green{F})".format(F=_F_)
-
-    _expr_1 = "{K_over_2}*sqr(log({J}))+{mu_over_2}*(Matrix_j1{be}-3)"\
-              .format(K_over_2=K/2., J=_J_, mu_over_2=mu/2., be=_be_)
-
-    _expr_2 = 
"{K_over_2}*sqr(log({J}))+{mu_over_2}*(pow(Det{be},-1./3.)*Trace{be}-3)"\
-              .format(K_over_2=K/2., J=_J_, mu_over_2=mu/2., be=_be_)
-
+    md.add_macro('F_',  '(Id(meshdim)+Grad_u)')
+    md.add_macro('J_',  'Det(F_)')
+    md.add_macro('be_', 'Left_Cauchy_Green(F_)')
+    md.add_initialized_data('K',  [K])
+    md.add_initialized_data('mu', [mu])
+    _expr_1 = "(K/2)*sqr(log(J_))+(mu/2)*(Matrix_j1(be_)-3)";
+    _expr_2 = "(K/2)*sqr(log(J_))+(mu/2)*(pow(Det(be_),-1./3.)*Trace(be_)-3)"
     md.add_nonlinear_term(mim, _expr_2);
 
 



reply via email to

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