getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] (no subject)


From: Konstantinos Poulios
Subject: [Getfem-commits] (no subject)
Date: Sun, 13 Jan 2019 03:05:03 -0500 (EST)

branch: integration-point-variables
commit 04f0d40643c99b1a196dd30fc238836b4c0c2ed9
Author: Konstantinos Poulios <address@hidden>
Date:   Sun Jan 13 09:04:53 2019 +0100

    Code cleanup
---
 src/getfem/getfem_generic_assembly.h               | 29 ++++---
 .../getfem_generic_assembly_compile_and_exec.h     | 35 +++-----
 src/getfem_generic_assembly_compile_and_exec.cc    | 91 ++++++++-------------
 src/getfem_generic_assembly_interpolation.cc       | 27 ++++--
 src/getfem_generic_assembly_workspace.cc           | 95 +++++++++++-----------
 5 files changed, 132 insertions(+), 145 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index 88f50db..5f4e2e6 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -145,7 +145,7 @@ namespace getfem {
 
     const mesh_im &mim(void) const { return mim_; }
     virtual const mesh_region &give_region(const mesh &m,
-                                    size_type cv, short_type f) const = 0;
+                                     size_type cv, short_type f) const = 0;
     // virtual void init(const ga_workspace &workspace) const = 0;
     // virtual void finalize() const = 0;
 
@@ -303,13 +303,16 @@ namespace getfem {
 
   public:
 
+    enum operation_type {ASSEMBLY,
+                         PRE_ASSIGNMENT,
+                         POST_ASSIGNMENT};
+
     struct tree_description { // CAUTION: Specific copy constructor
-      size_type order; // 0: potential, 1: weak form, 2: tangent operator
-      // -1 : interpolation/ assignment all order,
-      // -2 : assignment on potential, -3 : assignment on weak form
-      // -3 : assignment on tangent operator
-      size_type interpolation; // O : assembly, 1 : interpolate before assembly
-                               // 2 : interpolate after assembly. 
+      size_type order; //  0 : potential
+                       //  1 : residual
+                       //  2 : tangent operator
+                       // -1 : any
+      operation_type operation;
       std::string varname_interpolation; // Where to interpolate
       std::string name_test1, name_test2;
       std::string interpolate_name_test1, interpolate_name_test2;
@@ -319,7 +322,7 @@ namespace getfem {
       const mesh_region *rg;
       ga_tree *ptree;
       tree_description()
-        : interpolation(0), varname_interpolation(""),
+        : operation(ASSEMBLY), varname_interpolation(""),
           name_test1(""), name_test2(""),
           interpolate_name_test1(""), interpolate_name_test2(""),
           mim(0), m(0), rg(0), ptree(0) {}
@@ -368,8 +371,8 @@ namespace getfem {
     void add_tree(ga_tree &tree, const mesh &m, const mesh_im &mim,
                   const mesh_region &rg,
                   const std::string &expr, size_type add_derivative_order,
-                  bool scalar_expr, size_type for_interpolation,
-                 const std::string varname_interpolation);
+                  bool scalar_expr, operation_type op_type=ASSEMBLY,
+                  const std::string varname_interpolation="");
 
 
     std::shared_ptr<model_real_sparse_matrix> K;
@@ -411,7 +414,7 @@ namespace getfem {
     size_type add_expression(const std::string &expr, const mesh_im &mim,
                              const mesh_region &rg=mesh_region::all_convexes(),
                              size_type add_derivative_order = 2,
-                            const std::string &secondary_dom = "");
+                             const std::string &secondary_dom = "");
     /* Internal use */
     void add_function_expression(const std::string &expr);
     /* Internal use */
@@ -453,9 +456,9 @@ namespace getfem {
                      const model_real_plain_vector &VV);
 
     bool used_variables(std::vector<std::string> &vl,
-                       std::vector<std::string> &vl_test1,
+                        std::vector<std::string> &vl_test1,
                         std::vector<std::string> &vl_test2,
-                       std::vector<std::string> &dl,
+                        std::vector<std::string> &dl,
                         size_type order);
 
     bool variable_exists(const std::string &name) const;
diff --git a/src/getfem/getfem_generic_assembly_compile_and_exec.h 
b/src/getfem/getfem_generic_assembly_compile_and_exec.h
index 6da88d8..5674272 100644
--- a/src/getfem/getfem_generic_assembly_compile_and_exec.h
+++ b/src/getfem/getfem_generic_assembly_compile_and_exec.h
@@ -72,9 +72,7 @@ namespace getfem {
   };
 
   typedef std::shared_ptr<ga_instruction> pga_instruction;
-  typedef std::vector<pga_instruction> ga_instruction_list;
 
-  
   struct gauss_pt_corresp { // For neighbour interpolation transformation
     bgeot::pgeometric_trans pgt1, pgt2;
     papprox_integration pai;
@@ -187,25 +185,22 @@ namespace getfem {
       std::map<std::string, elementary_trans_info> elementary_trans_infos;
       secondary_domain_info secondary_domain_infos;
 
-      // Instructions being executed at the first Gauss point after
-      // a change of integration method only.
-      ga_instruction_list begin_instructions;
-      // Instructions executed once per element
-      ga_instruction_list elt_instructions;
-      // Instructions executed on each integration/interpolation point
-      ga_instruction_list instructions;
+      std::vector<pga_instruction>
+        begin_instructions,  // Instructions being executed at the first Gauss
+                             // point after a change of integration method 
only.
+        elt_instructions,    // Instructions executed once per element
+        instructions;        // Instructions executed on each
+                             // integration/interpolation point
       std::map<scalar_type, std::list<pga_tree_node> > node_list;
 
-    region_mim_instructions(): m(0), im(0) {}
+      region_mim_instructions(): m(0), im(0) {}
     };
 
     std::list<ga_tree> trees; // The trees are stored mainly because they
                               // contain the intermediary tensors.
     std::list<ga_tree> interpolation_trees;
 
-    typedef std::map<region_mim, region_mim_instructions> instructions_set;
-
-    instructions_set  whole_instructions;
+    std::map<region_mim, region_mim_instructions> all_instructions;
 
     ga_instruction_set() { max_dof = nb_dof = 0; need_elt_size = false; ipt=0; 
}
   };
@@ -214,18 +209,14 @@ namespace getfem {
   void ga_exec(ga_instruction_set &gis, ga_workspace &workspace);
   void ga_function_exec(ga_instruction_set &gis);
   void ga_compile(ga_workspace &workspace, ga_instruction_set &gis,
-                         size_type order);
+                  size_type order);
   void ga_compile_function(ga_workspace &workspace,
-                                  ga_instruction_set &gis, bool scalar);
+                           ga_instruction_set &gis, bool scalar);
   void ga_compile_interpolation(ga_workspace &workspace,
-                               ga_instruction_set &gis);
+                                ga_instruction_set &gis);
   void ga_interpolation_exec(ga_instruction_set &gis,
-                            ga_workspace &workspace,
-                            ga_interpolation_context &gic);
-  void ga_interpolation_single_point_exec
-    (ga_instruction_set &gis, ga_workspace &workspace,
-     const fem_interpolation_context &ctx_x, const base_small_vector &Normal,
-     const mesh &interp_mesh);
+                             ga_workspace &workspace,
+                             ga_interpolation_context &gic);
   
 } /* end of namespace */
 
diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index abc7e9e..5c32f28 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -6591,17 +6591,17 @@ namespace getfem {
         GMM_ASSERT1(!scalar || (root->tensor().size() == 1),
                     "The result of the given expression is not a scalar");
         ga_instruction_set::region_mim rm(td.mim, td.rg, 0);
-        gis.whole_instructions[rm].m = td.m;
+        gis.all_instructions[rm].m = td.m;
         ga_if_hierarchy if_hierarchy;
-        ga_compile_node(root, workspace, gis,
-                        gis.whole_instructions[rm],*(td.m),true,if_hierarchy);
+        ga_compile_node(root, workspace, gis, gis.all_instructions[rm],
+                        *(td.m), true, if_hierarchy);
 
         gis.coeff = scalar_type(1);
         pga_instruction pgai;
         workspace.assembled_tensor() = root->tensor();
         pgai = std::make_shared<ga_instruction_add_to_coeff>
           (workspace.assembled_tensor(), root->tensor(), gis.coeff);
-        gis.whole_instructions[rm].instructions.push_back(std::move(pgai));
+        gis.all_instructions[rm].instructions.push_back(std::move(pgai));
       }
     }
   }
@@ -6695,10 +6695,10 @@ namespace getfem {
   void ga_compile_interpolation(ga_workspace &workspace,
                                 ga_instruction_set &gis) {
     gis.transformations.clear();
-    gis.whole_instructions.clear();
+    gis.all_instructions.clear();
     for (size_type i = 0; i < workspace.nb_trees(); ++i) {
       const ga_workspace::tree_description &td = workspace.tree_info(i);
-      if (td.interpolation > 0) {
+      if (td.operation != ga_workspace::ASSEMBLY) {
         gis.trees.push_back(*(td.ptree));
 
         // Semantic analysis mainly to evaluate fixed size variables and data
@@ -6710,8 +6710,7 @@ namespace getfem {
         if (root) {
           // Compile tree
           ga_instruction_set::region_mim rm(td.mim, td.rg, 0);
-          ga_instruction_set::region_mim_instructions &rmi
-            = gis.whole_instructions[rm];
+          auto &rmi = gis.all_instructions[rm];
           rmi.m = td.m;
           rmi.im = td.mim;
           // rmi.interpolate_infos.clear();
@@ -6732,22 +6731,24 @@ namespace getfem {
   void ga_compile(ga_workspace &workspace,
                   ga_instruction_set &gis, size_type order) {
     gis.transformations.clear();
-    gis.whole_instructions.clear();
-    for (size_type version : std::array<size_type, 3>{1, 0, 2}) {
+    gis.all_instructions.clear();
+    std::array<ga_workspace::operation_type,3>
+      phases{ga_workspace::PRE_ASSIGNMENT,
+             ga_workspace::ASSEMBLY,
+             ga_workspace::POST_ASSIGNMENT};
+    for (const auto &phase : phases) {
       for (size_type i = 0; i < workspace.nb_trees(); ++i) {
         ga_workspace::tree_description &td = workspace.tree_info(i);
 
-        if ((version == td.interpolation) &&
-            ((version == 0 && td.order == order) || // Assembly
-             ((version > 0 && (td.order == size_type(-1) || // Assignment
-                               td.order == size_type(-2) - order))))) {
+        if (phase == td.operation &&
+            (td.order == order || td.order == size_type(-1))) {
           ga_tree *added_tree = 0;
-          if (td.interpolation) {
-            gis.interpolation_trees.push_back(*(td.ptree));
-            added_tree = &(gis.interpolation_trees.back());
-          } else {
+          if (td.operation == ga_workspace::ASSEMBLY) {
             gis.trees.push_back(*(td.ptree));
             added_tree = &(gis.trees.back());
+          } else {
+            gis.interpolation_trees.push_back(*(td.ptree));
+            added_tree = &(gis.interpolation_trees.back());
           }
 
           // Semantic analysis mainly to evaluate fixed size variables and data
@@ -6764,8 +6765,7 @@ namespace getfem {
             if (added_tree->secondary_domain.size())
               psd = workspace.secondary_domain(added_tree->secondary_domain);
             ga_instruction_set::region_mim rm(td.mim, td.rg, psd);
-            ga_instruction_set::region_mim_instructions &rmi
-              = gis.whole_instructions[rm];
+            auto &rmi = gis.all_instructions[rm];
             rmi.m = td.m;
             rmi.im = td.mim;
             // rmi.interpolate_infos.clear();
@@ -6775,8 +6775,8 @@ namespace getfem {
             // cout << "compilation finished "; ga_print_node(root, cout);
             // cout << endl;
 
-            if (version > 0) { // Assignment OR interpolation
-              if(td.varname_interpolation.size() != 0) {// assignment
+            if (phase != ga_workspace::ASSEMBLY) { // Assignment OR 
interpolation
+              if (!td.varname_interpolation.empty()) { // assignment
                 auto *imd
                   = workspace.associated_im_data(td.varname_interpolation);
                 auto &V = const_cast<model_real_plain_vector &>
@@ -6962,8 +6962,7 @@ namespace getfem {
                 }
               }
               if (pgai)
-                gis.whole_instructions[rm].instructions.push_back
-                  (std::move(pgai));
+                
gis.all_instructions[rm].instructions.push_back(std::move(pgai));
             }
           }
         }
@@ -6980,8 +6979,8 @@ namespace getfem {
 
   void ga_function_exec(ga_instruction_set &gis) {
 
-    for (auto &&instr : gis.whole_instructions) {
-      ga_instruction_list &gil = instr.second.instructions;
+    for (auto &&instr : gis.all_instructions) {
+      const auto &gil = instr.second.instructions;
       for (size_type j = 0; j < gil.size(); ++j) j += gil[j]->exec();
     }
   }
@@ -6995,16 +6994,16 @@ namespace getfem {
     for (const std::string &t : gis.transformations)
       workspace.interpolate_transformation(t)->init(workspace);
 
-    for (auto &&instr : gis.whole_instructions) {
+    for (auto &&instr : gis.all_instructions) {
 
       const getfem::mesh_im &mim = *(instr.first.mim());
       const mesh_region &region = *(instr.first.region());
       const getfem::mesh &m = *(instr.second.m);
       GMM_ASSERT1(&m == &(gic.linked_mesh()),
                   "Incompatibility of meshes in interpolation");
-      ga_instruction_list &gilb = instr.second.begin_instructions;
-      ga_instruction_list &gile = instr.second.elt_instructions;
-      ga_instruction_list &gil = instr.second.instructions;
+      const auto &gilb = instr.second.begin_instructions;
+      const auto &gile = instr.second.elt_instructions;
+      const auto &gil = instr.second.instructions;
 
       // iteration on elements (or faces of elements)
       std::vector<size_type> ind;
@@ -7076,30 +7075,6 @@ namespace getfem {
     gic.finalize();
   }
 
-  void ga_interpolation_single_point_exec
-  (ga_instruction_set &gis, ga_workspace &workspace,
-   const fem_interpolation_context &ctx_x, const base_small_vector &Normal,
-   const mesh &interp_mesh) {
-    gis.ctx = ctx_x;
-    gis.Normal = Normal;
-    gmm::clear(workspace.assembled_tensor().as_vector());
-    gis.nbpt = 1;
-    gis.ipt = 0;
-    gis.pai = 0;
-
-    for (auto &&instr : gis.whole_instructions) {
-      const getfem::mesh &m = *(instr.second.m);
-      GMM_ASSERT1(&m == &interp_mesh,
-                  "Incompatibility of meshes in interpolation");
-      ga_instruction_list &gilb = instr.second.begin_instructions;
-      for (size_type j = 0; j < gilb.size(); ++j) j += gilb[j]->exec();
-      ga_instruction_list &gile = instr.second.elt_instructions;
-      for (size_type j = 0; j < gile.size(); ++j) j+=gile[j]->exec();
-      ga_instruction_list &gil = instr.second.instructions;
-      for (size_type j = 0; j < gil.size(); ++j) j += gil[j]->exec();
-    }
-  }
-
   void ga_exec(ga_instruction_set &gis, ga_workspace &workspace) {
     base_matrix G1, G2;
     base_small_vector un;
@@ -7108,14 +7083,14 @@ namespace getfem {
     for (const std::string &t : gis.transformations)
       workspace.interpolate_transformation(t)->init(workspace);
 
-    for (auto &instr : gis.whole_instructions) {
+    for (auto &instr : gis.all_instructions) {
       const getfem::mesh_im &mim = *(instr.first.mim());
       psecondary_domain psd = instr.first.psd();
       const getfem::mesh &m = *(instr.second.m);
       GMM_ASSERT1(&m == &(mim.linked_mesh()), "Incompatibility of meshes");
-      const ga_instruction_list &gilb = instr.second.begin_instructions;
-      const ga_instruction_list &gile = instr.second.elt_instructions;
-      const ga_instruction_list &gil = instr.second.instructions;
+      const auto &gilb = instr.second.begin_instructions;
+      const auto &gile = instr.second.elt_instructions;
+      const auto &gil = instr.second.instructions;
 
       // if (gilb.size()) cout << "Begin instructions\n";
       // for (size_type j = 0; j < gilb.size(); ++j)
diff --git a/src/getfem_generic_assembly_interpolation.cc 
b/src/getfem_generic_assembly_interpolation.cc
index 08ad1e8..bce6ae8 100644
--- a/src/getfem_generic_assembly_interpolation.cc
+++ b/src/getfem_generic_assembly_interpolation.cc
@@ -570,7 +570,7 @@ namespace getfem {
                         var.varname, var.transname, 1);
           if (tree.root)
             ga_semantic_analysis(tree, local_workspace, dummy_mesh(),
-                                1, false, true);
+                                 1, false, true);
           ga_compile_interpolation(pwi.workspace(), pwi.gis());
         }
       }
@@ -637,8 +637,23 @@ namespace getfem {
                   bool compute_derivatives) const {
       int ret_type = 0;
 
-      ga_interpolation_single_point_exec(local_gis, local_workspace, ctx_x,
-                                         Normal, m);
+      local_gis.ctx = ctx_x;
+      local_gis.Normal = Normal;
+      local_gis.nbpt = 1;
+      local_gis.ipt = 0;
+      local_gis.pai = 0;
+      gmm::clear(local_workspace.assembled_tensor().as_vector());
+
+      for (auto &&instr : local_gis.all_instructions) {
+        GMM_ASSERT1(instr.second.m == &m,
+                    "Incompatibility of meshes in interpolation");
+        auto &gilb = instr.second.begin_instructions;
+        for (size_type j = 0; j < gilb.size(); ++j) j += gilb[j]->exec();
+        auto &gile = instr.second.elt_instructions;
+        for (size_type j = 0; j < gile.size(); ++j) j+=gile[j]->exec();
+        auto &gil = instr.second.instructions;
+        for (size_type j = 0; j < gil.size(); ++j) j += gil[j]->exec();
+      }
 
       GMM_ASSERT1(local_workspace.assembled_tensor().size() == m.dim(),
                   "Wrong dimension of the transformation expression");
@@ -815,8 +830,8 @@ namespace getfem {
                  m_x.trans_of_convex(adj_face.cv));
         bool converged = true;
         gic.invert(ctx_x.xreal(), P_ref, converged);
-       bool is_in = (ctx_x.pgt()->convex_ref()->is_in(P_ref) < 1E-4);
-       GMM_ASSERT1(is_in && converged, "Geometric transformation inversion "
+        bool is_in = (ctx_x.pgt()->convex_ref()->is_in(P_ref) < 1E-4);
+        GMM_ASSERT1(is_in && converged, "Geometric transformation inversion "
                     "has failed in neighbour transformation");
         face_num = adj_face.f;
         cv = adj_face.cv;
@@ -962,7 +977,7 @@ namespace getfem {
   public:
 
     virtual const mesh_region &give_region(const mesh &,
-                                          size_type, short_type) const
+                                           size_type, short_type) const
     { return region; }
     // virtual void init(const ga_workspace &workspace) const = 0;
     // virtual void finalize() const = 0;
diff --git a/src/getfem_generic_assembly_workspace.cc 
b/src/getfem_generic_assembly_workspace.cc
index f92bf5e..ad781c4 100644
--- a/src/getfem_generic_assembly_workspace.cc
+++ b/src/getfem_generic_assembly_workspace.cc
@@ -306,7 +306,7 @@ namespace getfem {
       GMM_ASSERT1(false, "A secondary domain with the same "
                   "name already exists");
     if (transformations.find(name) != transformations.end())
-      GMM_ASSERT1(name.compare("neighbour_elt"), "neighbour_elt is a "
+      GMM_ASSERT1(name != "neighbour_elt", "neighbour_elt is a "
                   "reserved interpolate transformation name");
     transformations[name] = ptrans;
   }
@@ -380,9 +380,6 @@ namespace getfem {
   }
 
 
-
-  
-
   const mesh_region &
   ga_workspace::register_region(const mesh &m, const mesh_region &region) {
     if (&m == &dummy_mesh())
@@ -395,12 +392,11 @@ namespace getfem {
     return lmr.back();
   }
 
-
   void ga_workspace::add_tree(ga_tree &tree, const mesh &m,
                               const mesh_im &mim, const mesh_region &rg,
                               const std::string &expr,
                               size_type add_derivative_order,
-                              bool function_expr, size_type for_interpolation,
+                              bool function_expr, operation_type op_type,
                               const std::string varname_interpolation) {
     if (tree.root) {
       // Eliminate the term if it corresponds to disabled variables
@@ -417,8 +413,8 @@ namespace getfem {
       bool remain = true;
       size_type order = 0, ind_tree = 0;
 
-      if (for_interpolation)
-        order = size_type(-1) - add_derivative_order;
+      if (op_type != ga_workspace::ASSEMBLY)
+        order = add_derivative_order;
       else {
         switch(tree.root->test_function_type) {
         case 0: order = 0; break;
@@ -431,17 +427,19 @@ namespace getfem {
 
       bool found = false;
       for (size_type i = 0; i < trees.size(); ++i) {
-        if (trees[i].mim == &mim && trees[i].m == &m &&
-           trees[i].secondary_domain.compare(tree.secondary_domain) == 0 &&
+        if (trees[i].mim == &mim &&
+            trees[i].m == &m &&
+            trees[i].secondary_domain == tree.secondary_domain &&
             trees[i].order == order &&
-            trees[i].name_test1.compare(tree.root->name_test1) == 0 &&
-            trees[i].interpolate_name_test1.compare
-            (tree.root->interpolate_name_test1) == 0 &&
-            trees[i].name_test2.compare(tree.root->name_test2) == 0 &&
-            trees[i].interpolate_name_test2.compare
-            (tree.root->interpolate_name_test2) == 0 &&
-            trees[i].rg == &rg && trees[i].interpolation == for_interpolation 
&&
-            trees[i].varname_interpolation.compare(varname_interpolation)==0) {
+            trees[i].name_test1 == tree.root->name_test1 &&
+            trees[i].interpolate_name_test1
+              == tree.root->interpolate_name_test1 &&
+            trees[i].name_test2 == tree.root->name_test2 &&
+            trees[i].interpolate_name_test2
+              == tree.root->interpolate_name_test2 &&
+            trees[i].rg == &rg &&
+            trees[i].operation == op_type &&
+            trees[i].varname_interpolation == varname_interpolation) {
           ga_tree &ftree = *(trees[i].ptree);
 
           ftree.insert_node(ftree.root, GA_NODE_OP);
@@ -456,11 +454,13 @@ namespace getfem {
       }
 
       if (!found) {
-        ind_tree = trees.size(); remain = false;
+        ind_tree = trees.size();
+        remain = false;
         trees.push_back(tree_description());
-        trees.back().mim = &mim; trees.back().m = &m;
+        trees.back().mim = &mim;
+        trees.back().m = &m;
         trees.back().rg = &rg;
-       trees.back().secondary_domain = tree.secondary_domain;
+        trees.back().secondary_domain = tree.secondary_domain;
         trees.back().ptree = new ga_tree;
         trees.back().ptree->swap(tree);
         pga_tree_node root = trees.back().ptree->root;
@@ -469,11 +469,11 @@ namespace getfem {
         trees.back().interpolate_name_test1 = root->interpolate_name_test1;
         trees.back().interpolate_name_test2 = root->interpolate_name_test2;
         trees.back().order = order;
-        trees.back().interpolation = for_interpolation;
+        trees.back().operation = op_type;
         trees.back().varname_interpolation = varname_interpolation;
        }
 
-      if (for_interpolation == 0 && order < add_derivative_order) {
+      if (op_type == ga_workspace::ASSEMBLY && order < add_derivative_order) {
         std::set<var_trans_pair> expr_variables;
         ga_extract_variables((remain ? tree : *(trees[ind_tree].ptree)).root,
                              *this, m, expr_variables, true);
@@ -491,7 +491,7 @@ namespace getfem {
             GA_TOCTIC("Analysis after Derivative time");
             // cout << "after analysis "  << ga_tree_to_string(dtree) << endl;
             add_tree(dtree, m, mim, rg, expr, add_derivative_order,
-                     function_expr, for_interpolation, varname_interpolation);
+                     function_expr, op_type, varname_interpolation);
           }
         }
       }
@@ -513,7 +513,7 @@ namespace getfem {
                                          const mesh_im &mim,
                                          const mesh_region &rg_,
                                          size_type add_derivative_order,
-                                        const std::string &secondary_dom) {
+                                         const std::string &secondary_dom) {
     const mesh_region &rg = register_region(mim.linked_mesh(), rg_);
     // cout << "adding expression " << expr << endl;
     GA_TIC;
@@ -522,7 +522,7 @@ namespace getfem {
     ga_read_string(expr, ltrees[0], macro_dictionary());
     if (secondary_dom.size()) {
       GMM_ASSERT1(secondary_domain_exists(secondary_dom),
-                 "Unknow secondary domain " << secondary_dom);
+                  "Unknown secondary domain " << secondary_dom);
       ltrees[0].secondary_domain = secondary_dom;
     }
     // cout << "read : " << ga_tree_to_string(ltrees[0])  << endl;
@@ -558,7 +558,7 @@ namespace getfem {
           // cout << "adding tree " << ga_tree_to_string(ltrees[i]) << endl;
           max_order = std::max(ltrees[i].root->nb_test_functions(), max_order);
           add_tree(ltrees[i], mim.linked_mesh(), mim, rg, expr,
-                   add_derivative_order, true, 0, "");
+                   add_derivative_order, true);
         }
       }
     }
@@ -574,7 +574,7 @@ namespace getfem {
       // GMM_ASSERT1(tree.root->nb_test_functions() == 0,
       //            "Invalid function expression");
       add_tree(tree, dummy_mesh(), dummy_mesh_im(), dummy_mesh_region(),
-               expr, 0, true, 0, "");
+               expr, 0, true);
     }
   }
 
@@ -589,7 +589,8 @@ namespace getfem {
     if (tree.root) {
       // GMM_ASSERT1(tree.root->nb_test_functions() == 0,
       //            "Invalid expression containing test functions");
-      add_tree(tree, m, dummy_mesh_im(), rg, expr, 0, false, 1, "");
+      add_tree(tree, m, dummy_mesh_im(), rg, expr, 0, false,
+               ga_workspace::PRE_ASSIGNMENT);
     }
   }
 
@@ -605,7 +606,8 @@ namespace getfem {
     if (tree.root) {
       GMM_ASSERT1(tree.root->nb_test_functions() == 0,
                   "Invalid expression containing test functions");
-      add_tree(tree, m, mim, rg, expr, 0, false, 1, "");
+      add_tree(tree, m, mim, rg, expr, 0, false,
+               ga_workspace::PRE_ASSIGNMENT);
     }
   }
 
@@ -623,7 +625,9 @@ namespace getfem {
     if (tree.root) {
       GMM_ASSERT1(tree.root->nb_test_functions() == 0,
                   "Invalid expression containing test functions");
-      add_tree(tree, m, mim, rg, expr, order+1, false, (before ? 1 : 2),
+      add_tree(tree, m, mim, rg, expr, order+1, false,
+               before ? ga_workspace::PRE_ASSIGNMENT
+                      : ga_workspace::POST_ASSIGNMENT,
                varname);
     }
   }
@@ -651,11 +655,10 @@ namespace getfem {
       bool fv = ga_extract_variables(td.ptree->root, *this, *(td.m),
                                      dllaux, false);
 
-      if (td.order == order) {
-        for (std::set<var_trans_pair>::iterator it = dllaux.begin();
-             it!=dllaux.end(); ++it)
-          dll.insert(*it);
-      }
+      if (td.order == order)
+        for (const auto &t : dllaux)
+          dll.insert(t);
+
       switch (td.order) {
       case 0:  break;
       case 1:
@@ -669,7 +672,7 @@ namespace getfem {
           }
           bool found = false;
           for (const std::string &t : vl_test1)
-            if (td.name_test1.compare(t) == 0)
+            if (td.name_test1 == t)
               found = true;
           if (!found)
             vl_test1.push_back(td.name_test1);
@@ -693,8 +696,8 @@ namespace getfem {
           }
           bool found = false;
           for (size_type j = 0; j < vl_test1.size(); ++j)
-            if ((td.name_test1.compare(vl_test1[j]) == 0) &&
-                (td.name_test2.compare(vl_test2[j]) == 0))
+            if ((td.name_test1 == vl_test1[j]) &&
+                (td.name_test2 == vl_test2[j]))
               found = true;
           if (!found) {
             vl_test1.push_back(td.name_test1);
@@ -707,11 +710,11 @@ namespace getfem {
     }
     vl.clear();
     for (const auto &var : vll)
-      if (vl.size() == 0 || var.varname.compare(vl.back()))
+      if (vl.size() == 0 || var.varname != vl.back())
         vl.push_back(var.varname);
     dl.clear();
     for (const auto &var : dll)
-      if (dl.size() == 0 || var.varname.compare(dl.back()))
+      if (dl.size() == 0 || var.varname != dl.back())
         dl.push_back(var.varname);
 
     return islin;
@@ -896,7 +899,7 @@ namespace getfem {
 
   void ga_workspace::tree_description::copy(const tree_description& td) {
     order = td.order;
-    interpolation = td.interpolation;
+    operation = td.operation;
     varname_interpolation = td.varname_interpolation;
     name_test1 = td.name_test1;
     name_test2 = td.name_test2;
@@ -916,7 +919,7 @@ namespace getfem {
   { if (ptree) delete ptree; ptree = 0; }
 
   ga_workspace::ga_workspace(const getfem::model &md_,
-                            bool enable_all_variables)
+                             bool enable_all_variables)
     : md(&md_), parent_workspace(0),
       enable_all_md_variables(enable_all_variables),
       macro_dict(md_.macro_dictionary())
@@ -981,8 +984,8 @@ namespace getfem {
   std::string ga_workspace::extract_order1_term(const std::string &varname) {
     std::string term;
     for (size_type i = 0; i < trees.size(); ++i) {
-      ga_workspace::tree_description &td =  trees[i];
-      if (td.order == 1 && td.name_test1.compare(varname) == 0) {
+      ga_workspace::tree_description &td = trees[i];
+      if (td.order == 1 && td.name_test1 == varname) {
         ga_tree &local_tree = *(td.ptree);
         if (term.size())
           term += "+("+ga_tree_to_string(local_tree)+")";
@@ -1001,7 +1004,7 @@ namespace getfem {
     std::string result;
     for (size_type i = 0; i < trees.size(); ++i) {
       ga_workspace::tree_description &td =  trees[i];
-      if (td.order == 1 && td.name_test1.compare(varname) == 0) {
+      if (td.order == 1 && td.name_test1 == varname) {
         ga_tree &local_tree = *(td.ptree);
         if (local_tree.root)
           ga_extract_Neumann_term(local_tree, varname, *this,



reply via email to

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