getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] r5055 - in /trunk/getfem: contrib/xfem_contact/ contrib


From: logari81
Subject: [Getfem-commits] r5055 - in /trunk/getfem: contrib/xfem_contact/ contrib/xfem_stab_unilat_contact/ src/ src/getfem/
Date: Mon, 27 Jul 2015 08:24:54 -0000

Author: logari81
Date: Mon Jul 27 10:24:53 2015
New Revision: 5055

URL: http://svn.gna.org/viewcvs/getfem?rev=5055&view=rev
Log:
minor changes

Modified:
    trunk/getfem/contrib/xfem_contact/xfem_dirichlet.cc
    trunk/getfem/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
    trunk/getfem/src/getfem/getfem_generic_assembly.h
    trunk/getfem/src/getfem_generic_assembly.cc

Modified: trunk/getfem/contrib/xfem_contact/xfem_dirichlet.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/contrib/xfem_contact/xfem_dirichlet.cc?rev=5055&r1=5054&r2=5055&view=diff
==============================================================================
--- trunk/getfem/contrib/xfem_contact/xfem_dirichlet.cc (original)
+++ trunk/getfem/contrib/xfem_contact/xfem_dirichlet.cc Mon Jul 27 10:24:53 2015
@@ -409,7 +409,11 @@
 template<class MAT>
 void asm_stabilization_patch_term
 (const MAT &RM_, const getfem::mesh &mesh, const getfem::mesh_im 
&mimbounddown, const getfem::mesh_fem &mf_mult,
- scalar_type ratio_size, scalar_type h ){
+ scalar_type ratio_size, scalar_type
+#ifdef GETFEM_HAVE_METIS
+h
+#endif
+){
   MAT &M1 = const_cast<MAT &>(RM_);
   
   /****************************************************/

Modified: 
trunk/getfem/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc?rev=5055&r1=5054&r2=5055&view=diff
==============================================================================
--- trunk/getfem/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc   
(original)
+++ trunk/getfem/contrib/xfem_stab_unilat_contact/xfem_stab_unilat_contact.cc   
Mon Jul 27 10:24:53 2015
@@ -442,7 +442,11 @@
 template<class MAT>
 void asm_stabilization_patch_term
 (const MAT &RM_, const getfem::mesh &mesh, const getfem::mesh_im 
&mimbounddown, const getfem::mesh_fem &mf_mult,
- scalar_type ratio_size, scalar_type /*h*/ ){
+ scalar_type ratio_size, scalar_type
+#ifdef GETFEM_HAVE_METIS
+h
+#endif
+){
   MAT &M1 = const_cast<MAT &>(RM_);
   
   /****************************************************/

Modified: trunk/getfem/src/getfem/getfem_generic_assembly.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_generic_assembly.h?rev=5055&r1=5054&r2=5055&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_generic_assembly.h   (original)
+++ trunk/getfem/src/getfem/getfem_generic_assembly.h   Mon Jul 27 10:24:53 2015
@@ -36,7 +36,7 @@
  */
 
 
-#ifndef GETFEM_GENERIC_ASSEMBLY_H__ 
+#ifndef GETFEM_GENERIC_ASSEMBLY_H__
 #define GETFEM_GENERIC_ASSEMBLY_H__
 
 #include <map>
@@ -70,7 +70,7 @@
                              bgeot::multi_index &sizes) const = 0;
 
     virtual void value(const arg_list &args, base_tensor &result) const = 0;
-    
+
     virtual void derivative(const arg_list &args, size_type i,
                             base_tensor &result) const = 0;
 
@@ -83,7 +83,7 @@
   struct ga_predef_operator_tab {
     typedef std::map<std::string, ga_nonlinear_operator*> T;
     std::map<std::string, ga_nonlinear_operator*> tab;
-    
+
    void add_method(const std::string &name, ga_nonlinear_operator *pt)
     { tab[name] = pt; }
     ~ga_predef_operator_tab() {
@@ -95,7 +95,7 @@
   //=========================================================================
   // For user predefined scalar functions.
   //=========================================================================
-  
+
   typedef scalar_type (*pscalar_func_onearg)(scalar_type);
   typedef scalar_type (*pscalar_func_twoargs)(scalar_type, scalar_type);
 
@@ -107,7 +107,7 @@
   void ga_define_function(const std::string name, pscalar_func_twoargs f2,
                           const std::string &der1="",
                           const std::string &der2="");
- 
+
   void ga_undefine_function(const std::string name);
   bool ga_function_exists(const std::string name);
 
@@ -140,12 +140,12 @@
         return q;
       }
 
-      var_description(bool is_var, bool is_fem, 
+      var_description(bool is_var, bool is_fem,
                       const mesh_fem *mmf, gmm::sub_interval I_,
                       const model_real_plain_vector *v, const im_data *imd_,
                       size_type Q)
         : is_variable(is_var), is_fem_dofs(is_fem), mf(mmf), I(I_), V(v),
-          imd(imd_), qdims(1) { 
+          imd(imd_), qdims(1) {
         GMM_ASSERT1(Q > 0, "Bad dimension");
         qdims[0] = Q;
       }
@@ -180,7 +180,7 @@
     mutable std::map<std::string, gmm::sub_interval> int_disabled_variables;
 
     std::map<const mesh *, std::list<mesh_region> > registred_mims;
-    
+
     const mesh_region &register_region(const mesh &m,const mesh_region 
&region);
 
     typedef std::map<std::string, var_description> VAR_SET;
@@ -201,7 +201,7 @@
       m_tree(void) : ptree(0) {}
       ~m_tree(void);
     };
-    
+
     mutable std::map<std::string, m_tree> macro_trees;
 
 
@@ -282,7 +282,7 @@
     model_real_sparse_matrix &unreduced_matrix(void)
     { return unreduced_K; }
     base_vector &unreduced_vector(void) { return unreduced_V; }
-    
+
     /** Add an expression, perform the semantic analysis, split into
      *  terms in separated test functions, derive if necessary to obtain
      *  the tangent terms. Return the maximal order found in the expression.
@@ -300,52 +300,32 @@
 
     /** Delete all previously added expressions. */
     void clear_expressions(void);
-    
+
     /** Print some information about all previously added expressions. */
     void print(std::ostream &str);
 
     void add_aux_tree(ga_tree &tree);
     size_type nb_trees(void) const;
     tree_description &tree_info(size_type i);
-        
+
     void add_fem_variable(const std::string &name, const mesh_fem &mf,
                           const gmm::sub_interval &I,
-                          const model_real_plain_vector &VV)
-    { variables[name] = var_description(true, true, &mf, I, &VV, 0, 1); }
-    
+                          const model_real_plain_vector &VV);
     void add_fixed_size_variable(const std::string &name,
                                  const gmm::sub_interval &I,
-                                 const model_real_plain_vector &VV) {
-      variables[name] = var_description(true, false, 0, I, &VV, 0,
-                                        dim_type(gmm::vect_size(VV)));
-    }
-
+                                 const model_real_plain_vector &VV);
     void add_fem_constant(const std::string &name, const mesh_fem &mf,
-                          const model_real_plain_vector &VV) { 
-      variables[name] = var_description(false, true, &mf,
-                                        gmm::sub_interval(), &VV, 0,
-                                        gmm::vect_size(VV)/(mf.nb_dof()));
-    }
-    
+                          const model_real_plain_vector &VV);
     void add_fixed_size_constant(const std::string &name,
-                                 const model_real_plain_vector &VV) {
-      variables[name] = var_description(false, false, 0,
-                                        gmm::sub_interval(), &VV, 0,
-                                        gmm::vect_size(VV));
-    }
-
+                                 const model_real_plain_vector &VV);
     void add_im_data(const std::string &name, const im_data &imd,
-                     const model_real_plain_vector &VV) {
-      variables[name] = var_description
-        (false, false, 0, gmm::sub_interval(), &VV, &imd,
-         gmm::vect_size(VV)/(imd.nb_filtered_index() * imd.nb_tensor_elem()));
-    }
+                     const model_real_plain_vector &VV);
 
     std::string extract_constant_term(const mesh &m);
     std::string extract_order1_term(const std::string &varname);
     std::string extract_order0_term();
     std::string extract_Neumann_term(const std::string &varname);
-  
+
 
     bool used_variables(model::varnamelist &vl, model::varnamelist &vl_test1,
                         model::varnamelist &vl_test2, model::varnamelist &dl,
@@ -391,7 +371,7 @@
       GMM_ASSERT1(t.size(), "Variable group " << name << " has no variable");
       return t[0];
     }
-    
+
     bool macro_exists(const std::string &name) const {
       if (macros.find(name) != macros.end()) return true;
       if (md && md->macro_exists(name)) return true;
@@ -402,7 +382,7 @@
 
     void add_macro(const std::string &name, const std::string &expr)
     { macros[name] = expr; }
-   
+
     const std::string& get_macro(const std::string &name) const {
       std::map<std::string, std::string>::const_iterator it=macros.find(name);
       if (it != macros.end()) return it->second;
@@ -604,7 +584,7 @@
     mutable ga_workspace local_workspace;
     std::string expr;
     mutable ga_instruction_set *gis;
-    
+
   public:
     ga_function(void) : gis(0) {}
     ga_function(const model &md, const std::string &e);
@@ -637,19 +617,19 @@
     virtual const mesh &linked_mesh(void) = 0;
     virtual ~ga_interpolation_context() {}
   };
-  
+
 
   //=========================================================================
   // Interpolation functions
   //=========================================================================
 
-  
+
   void ga_interpolation(ga_workspace &workspace,
                         ga_interpolation_context &gic);
 
   void ga_interpolation_Lagrange_fem
   (ga_workspace &workspace, const mesh_fem &mf, base_vector &result);
-  
+
   void ga_interpolation_Lagrange_fem
   (const getfem::model &md, const std::string &expr, const mesh_fem &mf,
    base_vector &result, const mesh_region &rg=mesh_region::all_convexes());
@@ -673,7 +653,7 @@
       high-level generic assembly expression which may contains some
       variable of the model. CAUTION: For the moment, the derivative of the
       transformation with respect to the eventual variables used is not
-      taken into account in the model solve. 
+      taken into account in the model solve.
   */
   void add_interpolate_transformation_from_expression
   (model &md, const std::string &transname, const mesh &source_mesh,
@@ -682,7 +662,7 @@
   void add_interpolate_transformation_from_expression
   (ga_workspace &workspace, const std::string &transname,
    const mesh &source_mesh, const mesh &target_mesh, const std::string &expr);
-  
+
 }  /* end of namespace getfem.                                             */
 
 

Modified: trunk/getfem/src/getfem_generic_assembly.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_generic_assembly.cc?rev=5055&r1=5054&r2=5055&view=diff
==============================================================================
--- trunk/getfem/src/getfem_generic_assembly.cc (original)
+++ trunk/getfem/src/getfem_generic_assembly.cc Mon Jul 27 10:24:53 2015
@@ -437,7 +437,7 @@
       test_function_type = 0;
     }
     void init_fourth_order_tensor(size_type n, size_type m,
-                                size_type l, size_type k) {
+                                  size_type l, size_type k) {
       t.adjust_sizes(bgeot::multi_index(n,m,l,k));
       test_function_type = 0;
     }
@@ -1461,7 +1461,7 @@
             size_type nbc1 = 0, nbc2 = 0, nbc3 = 0, n1 = 0, n2 = 0, n3 = 0;
             bool foundsemi = false, founddcomma = false, founddsemi = false;
             tree.add_matrix(token_pos);
-            for(;;) {
+            do {
               r_type = ga_read_term(expr, pos, sub_tree);
               ++n1; ++n2; ++n3;
               if (!foundsemi) ++nbc1;
@@ -1497,8 +1497,8 @@
               }
 
               tree.add_sub_tree(sub_tree);
-              if (r_type == GA_RBRACKET) break;
-            }
+
+            } while (r_type != GA_RBRACKET);
             state = 2;
           }
           break;
@@ -4497,6 +4497,49 @@
   // functions, operators.
   //=========================================================================
 
+  void ga_workspace::add_fem_variable
+  (const std::string &name, const mesh_fem &mf,
+   const gmm::sub_interval &I, const model_real_plain_vector &VV)
+  {
+    variables[name] = var_description(true, true, &mf, I, &VV, 0, 1);
+  }
+
+  void ga_workspace::add_fixed_size_variable
+  (const std::string &name,
+   const gmm::sub_interval &I, const model_real_plain_vector &VV)
+  {
+    variables[name] = var_description(true, false, 0, I, &VV, 0,
+                                      dim_type(gmm::vect_size(VV)));
+  }
+
+  void ga_workspace::add_fem_constant
+  (const std::string &name, const mesh_fem &mf,
+   const model_real_plain_vector &VV)
+  {
+    GMM_ASSERT1(mf.nb_dof(), "The provided mesh_fem of variable" << name
+                             << "has zero degrees of freedom.");
+    size_type Q = gmm::vect_size(VV)/mf.nb_dof();
+    if (Q == 0) Q = size_type(1);
+    variables[name] = var_description(false, true, &mf,
+                                      gmm::sub_interval(), &VV, 0, Q);
+  }
+    
+  void ga_workspace::add_fixed_size_constant
+  (const std::string &name, const model_real_plain_vector &VV)
+  {
+    variables[name] = var_description(false, false, 0,
+                                      gmm::sub_interval(), &VV, 0,
+                                      gmm::vect_size(VV));
+  }
+
+  void ga_workspace::add_im_data(const std::string &name, const im_data &imd,
+                                 const model_real_plain_vector &VV)
+  {
+    variables[name] = var_description
+      (false, false, 0, gmm::sub_interval(), &VV, &imd,
+       gmm::vect_size(VV)/(imd.nb_filtered_index() * imd.nb_tensor_elem()));
+  }
+
   const mesh_region &ga_workspace::register_region(const mesh &m,
                                                    const mesh_region &region) {
     if (&m == &dummy_mesh) return dummy_region;
@@ -4511,43 +4554,43 @@
   }
 
   bgeot::multi_index ga_workspace::qdims(const std::string &name) const {
-      VAR_SET::const_iterator it = variables.find(name);
-      if (it != variables.end()) {
-        const mesh_fem *mf =  it->second.is_fem_dofs ? it->second.mf : 0;
-        const im_data *imd = it->second.imd;
-        size_type n = it->second.qdim();
-        if (mf) {
-          bgeot::multi_index mi = mf->get_qdims();
-          if (n > 1 || it->second.qdims.size() > 1) {
-            size_type i = 0;
-            if (mi.back() == 1) { mi.back() *= it->second.qdims[0]; ++i; }
-            for (; i < it->second.qdims.size(); ++i)
-              mi.push_back(it->second.qdims[i]);
-          }
-          return mi;
-        } else if (imd) {
-          bgeot::multi_index mi = imd->tensor_size();
-          size_type q = n / imd->nb_filtered_index();
-          GMM_ASSERT1(q % imd->nb_tensor_elem() == 0,
-                      "Invalid mesh im data vector");
-          if (n > 1 || it->second.qdims.size() > 1) {
-            size_type i = 0;
-            if (mi.back() == 1) { mi.back() *= it->second.qdims[0]; ++i; }
-            for (; i < it->second.qdims.size(); ++i)
-              mi.push_back(it->second.qdims[i]);
-          }
-          return mi;
-        }
-        return it->second.qdims;
-      }
-      if (md && md->variable_exists(name))
-        return md->qdims_of_variable(name);
-      if (parent_workspace && parent_workspace->variable_exists(name))
-        return parent_workspace->qdims(name);
-      if (variable_group_exists(name))
-        return qdims(first_variable_of_group(name));
-      GMM_ASSERT1(false, "Undefined variable or group " << name);
-    }
+    VAR_SET::const_iterator it = variables.find(name);
+    if (it != variables.end()) {
+      const mesh_fem *mf =  it->second.is_fem_dofs ? it->second.mf : 0;
+      const im_data *imd = it->second.imd;
+      size_type n = it->second.qdim();
+      if (mf) {
+        bgeot::multi_index mi = mf->get_qdims();
+        if (n > 1 || it->second.qdims.size() > 1) {
+          size_type i = 0;
+          if (mi.back() == 1) { mi.back() *= it->second.qdims[0]; ++i; }
+          for (; i < it->second.qdims.size(); ++i)
+            mi.push_back(it->second.qdims[i]);
+        }
+        return mi;
+      } else if (imd) {
+        bgeot::multi_index mi = imd->tensor_size();
+        size_type q = n / imd->nb_filtered_index();
+        GMM_ASSERT1(q % imd->nb_tensor_elem() == 0,
+                    "Invalid mesh im data vector");
+        if (n > 1 || it->second.qdims.size() > 1) {
+          size_type i = 0;
+          if (mi.back() == 1) { mi.back() *= it->second.qdims[0]; ++i; }
+          for (; i < it->second.qdims.size(); ++i)
+            mi.push_back(it->second.qdims[i]);
+        }
+        return mi;
+      }
+      return it->second.qdims;
+    }
+    if (md && md->variable_exists(name))
+      return md->qdims_of_variable(name);
+    if (parent_workspace && parent_workspace->variable_exists(name))
+      return parent_workspace->qdims(name);
+    if (variable_group_exists(name))
+      return qdims(first_variable_of_group(name));
+    GMM_ASSERT1(false, "Undefined variable or group " << name);
+  }
   
   size_type ga_workspace::qdim(const std::string &name) const {
     VAR_SET::const_iterator it = variables.find(name);
@@ -6806,7 +6849,8 @@
             mi1[i] = size_type(round(pnode->children[i+1]->t[0])-1);
             if (mi1[i] >= child0->tensor_proper_size(i))
               ga_throw_error(expr, pnode->children[i+1]->pos,
-                              "Index out of range.");
+                             "Index out of range, " << mi1[i]+1 << " > "
+                             << child0->tensor_proper_size(i) << " .");
           }
         }
         mi.resize(0);




reply via email to

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