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)
Date: Fri, 13 Mar 2020 15:19:37 -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 a1d607b  permanent macros Div(u) and Hess(u)
a1d607b is described below

commit a1d607b60c2a7fc24883553550e16250a03a4602
Author: Yves Renard <address@hidden>
AuthorDate: Fri Mar 13 20:19:26 2020 +0100

    permanent macros Div(u) and Hess(u)
---
 contrib/aposteriori/aposteriori.cc                 |  4 +-
 contrib/xfem_contact/xfem_dirichlet.cc             |  6 +--
 .../xfem_stab_unilat_contact.cc                    |  2 +-
 src/getfem_generic_assembly_tree.cc                | 40 +++++++++++++---
 src/getfem_generic_assembly_workspace.cc           | 53 ++++++++++------------
 5 files changed, 63 insertions(+), 42 deletions(-)

diff --git a/contrib/aposteriori/aposteriori.cc 
b/contrib/aposteriori/aposteriori.cc
index 2accd9c..1485f29 100644
--- a/contrib/aposteriori/aposteriori.cc
+++ b/contrib/aposteriori/aposteriori.cc
@@ -444,12 +444,12 @@ void crack_problem::error_estimate(const plain_vector &U, 
plain_vector &ERR) {
     // }
     //  ee = ERR[cv];
  
-    // jump of the stress between the element ant its neighbours.
+    // jump of the stress between the element ant its neighbors.
     for (short_type f1=0; f1 < mesh.structure_of_convex(cv)->nb_faces(); ++f1) 
{
 
       if 
(gmm::abs((*mmls)(mesh.trans_of_convex(cv)->convex_ref()->points_of_face(f1)[0]))
 < 1E-7 * radius) continue;
 
-      size_type cvn = mesh.neighbour_of_convex(cv, f1);
+      size_type cvn = mesh.neighbor_of_convex(cv, f1);
       if (cvn == size_type(-1)) continue;
        
       bgeot::pgeometric_trans pgt2 = mesh.trans_of_convex(cvn);
diff --git a/contrib/xfem_contact/xfem_dirichlet.cc 
b/contrib/xfem_contact/xfem_dirichlet.cc
index d12d060..6104152 100644
--- a/contrib/xfem_contact/xfem_dirichlet.cc
+++ b/contrib/xfem_contact/xfem_dirichlet.cc
@@ -457,7 +457,7 @@ h
     vwgtt[indelt[ic]] = Patch_Vector[ind_dof_patch];
     xadj[j] = k;
     bgeot::mesh_structure::ind_set s;
-    mesh.neighbours_of_convex(ic, s);
+    mesh.neighbors_of_convex(ic, s);
     for (bgeot::mesh_structure::ind_set::iterator it = s.begin(); it != 
s.end(); ++it) {
       if (Patch_element_list.is_in(*it)) { adjncy.push_back(indelt[*it]); ++k; 
}
     }
@@ -870,7 +870,7 @@ int main(int argc, char *argv[]) {
        vwgtt[indelt[ic]] = Patch_Vector[ind_dof_patch];
        xadj[j] = k;
        bgeot::mesh_structure::ind_set s;
-       mesh.neighbours_of_convex(ic, s);
+       mesh.neighbors_of_convex(ic, s);
        for (bgeot::mesh_structure::ind_set::iterator it = s.begin(); it != 
s.end(); ++it) {
          if (Patch_element_list.is_in(*it)) { adjncy.push_back(indelt[*it]); 
++k; }
        }
@@ -1035,7 +1035,7 @@ int main(int argc, char *argv[]) {
       bgeot::mesh_structure::ind_set is;
       base_matrix Mloc;
       for (dal::bv_visitor i(elt_black_list); !i.finished(); ++i) {
-       mesh.neighbours_of_convex(i, is);
+       mesh.neighbors_of_convex(i, is);
        size_type cv2 = size_type(-1);
        scalar_type ratio = scalar_type(0);
        for (size_type j = 0; j < is.size(); ++j) {
diff --git a/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc 
b/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
index b360884..d4f4ebb 100644
--- a/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
+++ b/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
@@ -490,7 +490,7 @@ h
     vwgtt[indelt[ic]] = Patch_Vector[ind_dof_patch];
     xadj[j] = k;
     bgeot::mesh_structure::ind_set s;
-    mesh.neighbours_of_convex(ic, s);
+    mesh.neighbors_of_convex(ic, s);
     for (bgeot::mesh_structure::ind_set::iterator it = s.begin(); it != 
s.end(); ++it) {
       if (Patch_element_list.is_in(*it)) { adjncy.push_back(indelt[*it]); ++k; 
}
     }
diff --git a/src/getfem_generic_assembly_tree.cc 
b/src/getfem_generic_assembly_tree.cc
index c495efe..38b0e45 100644
--- a/src/getfem_generic_assembly_tree.cc
+++ b/src/getfem_generic_assembly_tree.cc
@@ -1269,19 +1269,18 @@ namespace getfem {
   // 2 : reserved prefix Grad, Hess, Div, Derivative_ Test and Test2
   // 3 : reserved prefix Dot and Previous
   int ga_check_name_validity(const std::string &name) {
-
     if (name.compare(0, 11, "Derivative_") == 0)
       return 2;
-
-    const ga_predef_function_tab &PREDEF_FUNCTIONS
-      = dal::singleton<ga_predef_function_tab>::instance(0);
+    
     const ga_predef_operator_tab &PREDEF_OPERATORS
       = dal::singleton<ga_predef_operator_tab>::instance(0);
     const ga_spec_function_tab &SPEC_FUNCTIONS
       = dal::singleton<ga_spec_function_tab>::instance(0);
     const ga_spec_op_tab &SPEC_OP
       = dal::singleton<ga_spec_op_tab>::instance(0);
-    
+    const ga_predef_function_tab &PREDEF_FUNCTIONS
+      = dal::singleton<ga_predef_function_tab>::instance(0);
+
     if (SPEC_OP.find(name) != SPEC_OP.end())
       return 1;
 
@@ -1321,7 +1320,6 @@ namespace getfem {
 //     if (name.size() >= 12 && name.compare(0, 12, "Previous1_2_") == 0)
 //       return 3;
 
-
     return 0;
   }
 
@@ -1509,6 +1507,34 @@ namespace getfem {
       ga_expand_macro(gam.tree(), gam.tree().root, macro_dict);
     }
   }
+
+  bool ga_macro_dictionary::macro_exists(const std::string &name) const {
+    if (macros.find(name) != macros.end()) return true;
+    if (parent && parent->macro_exists(name)) return true;
+    return false;
+  }
+
+  const ga_macro &
+  ga_macro_dictionary::get_macro(const std::string &name) const {
+    auto it = macros.find(name);
+    if (it != macros.end()) return it->second;
+    if (parent) return parent->get_macro(name);
+    GMM_ASSERT1(false, "Undefined macro");
+  }
+
+  void ga_macro_dictionary::add_macro(const ga_macro &gam)
+  { macros[gam.name()] = gam; }
+
+  void ga_macro_dictionary::add_macro(const std::string &name,
+                                      const std::string &expr)
+  { ga_tree tree; ga_read_string_reg("Def "+name+":="+expr, tree, *this); }
+
+  void ga_macro_dictionary::del_macro(const std::string &name) {
+    auto it = macros.find(name);
+    GMM_ASSERT1(it != macros.end(), "Undefined macro (at this level)");
+    macros.erase(it);
+  }
+  
   
   //=========================================================================
   // Syntax analysis for the generic assembly language
@@ -1613,7 +1639,7 @@ namespace getfem {
             if (params.size())
               ga_mark_macro_params(gam, params, macro_dict);
             macro_dict.add_macro(gam);
-
+            
             // cout << "macro \"" << gam.name() << "\" registered with "
             //      << gam.nb_params() << " params  := "
             //      << ga_tree_to_string(gam.tree()) << endl;
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index 5c53862..7a82c8b 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -31,34 +31,7 @@ namespace getfem {
   // functions, operators.
   //=========================================================================
 
-  bool ga_macro_dictionary::macro_exists(const std::string &name) const {
-    if (macros.find(name) != macros.end()) return true;
-    if (parent && parent->macro_exists(name)) return true;
-    return false;
-  }
-
-  const ga_macro &
-  ga_macro_dictionary::get_macro(const std::string &name) const {
-    auto it = macros.find(name);
-    if (it != macros.end()) return it->second;
-    if (parent) return parent->get_macro(name);
-    GMM_ASSERT1(false, "Undefined macro");
-  }
-
-  void ga_macro_dictionary::add_macro(const ga_macro &gam)
-  {
-    macros[gam.name()] = gam; }
-
-  void ga_macro_dictionary::add_macro(const std::string &name,
-                                      const std::string &expr)
-  { ga_tree tree; ga_read_string_reg("Def "+name+":="+expr, tree, *this); }
 
-  void ga_macro_dictionary::del_macro(const std::string &name) {
-    auto it = macros.find(name);
-    GMM_ASSERT1(it != macros.end(), "Undefined macro (at this level)");
-    macros.erase(it);
-  }
-  
   void ga_workspace::init() {
     // allocate own storage for K an V to be used unless/until external
     // storage is provided with set_assembled_matrix/vector
@@ -69,8 +42,30 @@ namespace getfem {
       ("neighbour_elt", interpolate_transformation_neighbor_instance());
     add_interpolate_transformation
       ("neighbor_element", interpolate_transformation_neighbor_instance());
-    // if (!(macro_exists("Hess"))) add_macro("Hess(u)", "Hess_u");
-    // if (!(macro_exists("Div"))) add_macro("Div(u)", "Hess_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);
   }
 
   // variables and variable groups



reply via email to

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