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: Permanent macro


From: Yves Renard
Subject: [Getfem-commits] [getfem-commits] branch master updated: Permanent macros Div(u) and Hess(u) : change of implementation for model objec and test
Date: Sat, 14 Mar 2020 07:43:09 -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 7439750  Permanent macros Div(u) and Hess(u) : change of 
implementation for model objec and test
7439750 is described below

commit 74397504fdad8b46d439fa8b60137e9cbdc73585
Author: Yves Renard <address@hidden>
AuthorDate: Sat Mar 14 12:42:50 2020 +0100

    Permanent macros Div(u) and Hess(u) : change of implementation for model 
objec and test
---
 interface/tests/python/check_asm.py |  5 +++++
 src/getfem_models.cc                | 28 ++++++++++++++++++++++++++--
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/interface/tests/python/check_asm.py 
b/interface/tests/python/check_asm.py
index 3264ee7..bdb6a71 100644
--- a/interface/tests/python/check_asm.py
+++ b/interface/tests/python/check_asm.py
@@ -237,3 +237,8 @@ if (res != "(Grad_w(2, 2))"):
 
 str = "Grad(u*Test_u)"; print('\nAssembly string "%s" gives:' % str)
 res = gf.asm('expression analysis', str,  mim, 1, md)
+
+str = "Hess(u)"; print('\nAssembly string "%s" gives:' % str)
+res = gf.asm('expression analysis', str,  mim, 1, md)
+if (res != "(Hess_u)"):
+  print("Should be Hess_u"); exit(1)
diff --git a/src/getfem_models.cc b/src/getfem_models.cc
index 867bd97..74e1f39 100644
--- a/src/getfem_models.cc
+++ b/src/getfem_models.cc
@@ -29,6 +29,8 @@
 #include "getfem/getfem_derivatives.h"
 #include "getfem/getfem_interpolation.h"
 #include "getfem/getfem_generic_assembly.h"
+#include "getfem/getfem_generic_assembly_tree.h"
+
 
 namespace getfem {
 
@@ -41,8 +43,30 @@ namespace getfem {
       ("neighbour_elt", interpolate_transformation_neighbor_instance());
     add_interpolate_transformation
       ("neighbor_element", interpolate_transformation_neighbor_instance());
-    add_macro("Hess(u)", "Hess_u");
-    add_macro("Div(u)", "Div_u");
+
+    ga_tree tree1;
+    pstring s1 = std::make_shared<std::string>("Hess_u");
+    tree1.add_name(s1->c_str(), 6, 0, s1);
+    tree1.root->name = "u";
+    tree1.root->op_type = GA_NAME;
+    tree1.root->node_type = GA_NODE_MACRO_PARAM;
+    tree1.root->nbc1 = 0;
+    tree1.root->nbc2 = ga_parse_prefix_operator(*s1);
+    tree1.root->nbc3 = ga_parse_prefix_test(*s1);
+    ga_macro gam1("Hess", tree1, 1);
+    macro_dict.add_macro(gam1);
+
+    ga_tree tree2;
+    pstring s2 = std::make_shared<std::string>("Div_u");
+    tree2.add_name(s2->c_str(), 5, 0, s2);
+    tree2.root->name = "u";
+    tree2.root->op_type = GA_NAME;
+    tree2.root->node_type = GA_NODE_MACRO_PARAM;
+    tree2.root->nbc1 = 0;
+    tree2.root->nbc2 = ga_parse_prefix_operator(*s2);
+    tree2.root->nbc3 = ga_parse_prefix_test(*s2);
+    ga_macro gam2("Div", tree2, 1);
+    macro_dict.add_macro(gam2);
   }
 
   void model::var_description::set_size() {



reply via email to

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