getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] r4953 - in /trunk/getfem/src: ./ getfem/


From: Yves . Renard
Subject: [Getfem-commits] r4953 - in /trunk/getfem/src: ./ getfem/
Date: Tue, 14 Apr 2015 18:46:00 -0000

Author: renard
Date: Tue Apr 14 20:46:00 2015
New Revision: 4953

URL: http://svn.gna.org/viewcvs/getfem?rev=4953&view=rev
Log:
introducing multiplier that are filtered both by a region and a variable

Modified:
    trunk/getfem/src/getfem/getfem_models.h
    trunk/getfem/src/getfem/getfem_partial_mesh_fem.h
    trunk/getfem/src/getfem_generic_assembly.cc
    trunk/getfem/src/getfem_models.cc
    trunk/getfem/src/getfem_nonlinear_elasticity.cc
    trunk/getfem/src/getfem_partial_mesh_fem.cc

Modified: trunk/getfem/src/getfem/getfem_models.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_models.h?rev=4953&r1=4952&r2=4953&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_models.h     (original)
+++ trunk/getfem/src/getfem/getfem_models.h     Tue Apr 14 20:46:00 2015
@@ -162,16 +162,17 @@
     // Variables and parameters of the model
 
     enum  var_description_filter {
-      VDESCRFILTER_NO,     // Variable being directly the dofs of a given fem
-      VDESCRFILTER_REGION, /* Variable being the dofs of a fem on a mesh region
-                            * (uses mf.dof_on_region). */
-      VDESCRFILTER_INFSUP, /* Variable being the dofs of a fem on a mesh region
-                            * with an additional filter on a mass matrix with
-                            * respect to another fem. */
-      VDESCRFILTER_CTERM   /* Variable being the dofs of a fem on a mesh region
-                            * with an additional filter with the coupling
-                            * term with respect to another variable. */
-    };
+      VDESCRFILTER_NO = 0, // Variable being directly the dofs of a given fem
+      VDESCRFILTER_REGION = 1, /* Variable being the dofs of a fem on a mesh
+                            *  region (uses mf.dof_on_region). */
+      VDESCRFILTER_INFSUP = 2, /* Variable being the dofs of a fem on a mesh
+                            * region with an additional filter on a mass
+                            * matrix with respect to another fem. */
+      VDESCRFILTER_CTERM = 4, /* Variable being the dofs of a fem on a mesh
+                            * region with an additional filter with the
+                            * coupling term with respect to another variable.*/
+      VDESCRFILTER_REGION_CTERM = 5,  /* both region and cterm. */
+    }; // INFSUP and CTERM are incompatible
 
     struct var_description {
 
@@ -904,6 +905,17 @@
         for time integration schemes. */
     void add_multiplier(const std::string &name, const mesh_fem &mf,
                         const std::string &primal_name,
+                        size_type niter = 1);
+
+    /** Adds a particular variable linked to a fem being a multiplier with
+        respect to a primal variable and a region. The dof will be filtered
+        both with the gmm::range_basis function applied on the terms of
+        the model which link the multiplier and the primal variable and on
+        the dof on the given region. Optimized for boundary
+        multipliers. niter is the number of version of the data stored,
+        for time integration schemes. */
+    void add_multiplier(const std::string &name, const mesh_fem &mf,
+                        size_type region, const std::string &primal_name,
                         size_type niter = 1);
 
     /** Adds a particular variable linked to a fem being a multiplier with

Modified: trunk/getfem/src/getfem/getfem_partial_mesh_fem.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_partial_mesh_fem.h?rev=4953&r1=4952&r2=4953&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_partial_mesh_fem.h   (original)
+++ trunk/getfem/src/getfem/getfem_partial_mesh_fem.h   Tue Apr 14 20:46:00 2015
@@ -134,7 +134,8 @@
     dal::bit_vector basic_dof_on_region(const mesh_region &b) const
     { return mf.basic_dof_on_region(b); }
 
-    dal::bit_vector retrieve_kept_dofs() const;
+    // invalid function for a mesh change.
+    // dal::bit_vector retrieve_kept_dofs() const;
 
     void read_from_file(std::istream &)
     { GMM_ASSERT1(false, "You cannot directly read this kind of mesh_fem"); }

Modified: trunk/getfem/src/getfem_generic_assembly.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_generic_assembly.cc?rev=4953&r1=4952&r2=4953&view=diff
==============================================================================
--- trunk/getfem/src/getfem_generic_assembly.cc (original)
+++ trunk/getfem/src/getfem_generic_assembly.cc Tue Apr 14 20:46:00 2015
@@ -414,8 +414,7 @@
     }
 
     void init_scalar_tensor(scalar_type v) {
-      bgeot::multi_index mi(1); mi[0]=1;
-      t.adjust_sizes(mi);
+      t.adjust_sizes(bgeot::multi_index());
       t[0] = v;
       test_function_type = 0;
     }
@@ -6230,8 +6229,11 @@
 
             size_type n = gmm::vect_size(workspace.value(name));
             if (n == 1) {
-              pnode->init_scalar_tensor(test ? scalar_type(1)
-                                             : workspace.value(name)[0]);
+              if (test) {
+                pnode->init_vector_tensor(1);
+                pnode->t[0]=scalar_type(1);
+              }
+              else pnode->init_scalar_tensor(workspace.value(name)[0]);
             } else {
               if (test) {
                 pnode->init_matrix_tensor(n,n);

Modified: trunk/getfem/src/getfem_models.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_models.cc?rev=4953&r1=4952&r2=4953&view=diff
==============================================================================
--- trunk/getfem/src/getfem_models.cc   (original)
+++ trunk/getfem/src/getfem_models.cc   Tue Apr 14 20:46:00 2015
@@ -238,8 +238,8 @@
     for (VAR_SET::iterator it = variables.begin(); it != variables.end();
          ++it) {
       if (it->second.is_fem_dofs && !(it->second.is_affine_dependent)
-          && (it->second.filter == VDESCRFILTER_CTERM
-              || it->second.filter == VDESCRFILTER_INFSUP)) {
+          && ((it->second.filter & VDESCRFILTER_CTERM)
+              || (it->second.filter & VDESCRFILTER_INFSUP))) {
         VAR_SET::iterator it2 = variables.find(it->second.filter_var);
         GMM_ASSERT1(it2 != variables.end(), "The primal variable of the "
                     "multiplier does not exist");
@@ -306,14 +306,15 @@
       }
       size_type s = 0;
       std::set<size_type> glob_columns;
-      std::vector<dal::bit_vector> mult_kept_dofs;
+      // std::vector<dal::bit_vector> mult_kept_dofs;
       for (size_type k = 0; k < mults.size(); ++k) {
         VAR_SET::iterator it = variables.find(mults[k]);
 
         // This step forces the recomputation of corresponding bricks.
         // A test to check if a modification is really necessary could
         // be done first ... (difficult to coordinate with other multipliers)
-        mult_kept_dofs.push_back(it->second.partial_mf->retrieve_kept_dofs());
+        
+        // 
mult_kept_dofs.push_back(it->second.partial_mf->retrieve_kept_dofs());
         dal::bit_vector alldof; alldof.add(0, it->second.mf->nb_dof());
         it->second.partial_mf->adapt(alldof);
         it->second.set_size(it->second.partial_mf->nb_dof());
@@ -326,7 +327,7 @@
           MM(it2->second.associated_mf().nb_dof(), it->second.mf->nb_dof());
         bool termadded = false;
 
-        if (it->second.filter == VDESCRFILTER_CTERM) {
+        if (it->second.filter & VDESCRFILTER_CTERM) {
 
           for (dal::bv_visitor ib(valid_bricks); !ib.finished(); ++ib) {
             const brick_description &brick = bricks[ib];
@@ -370,7 +371,7 @@
           if (!termadded)
             GMM_WARNING1("No term found to filter multiplier " << it->first
                          << ". Variable is cancelled");
-        } else if (it->second.filter == VDESCRFILTER_INFSUP) {
+        } else if (it->second.filter & VDESCRFILTER_INFSUP) {
           mesh_region rg(it->second.m_region);
           it->second.mim->linked_mesh().intersect_with_mpi_region(rg);
           asm_mass_matrix(MM, *(it->second.mim), it2->second.associated_mf(),
@@ -399,7 +400,9 @@
           for (std::set<size_type>::iterator itt = columns.begin();
                itt != columns.end(); ++itt)
             kept.add(*itt);
-          kept &= mult_kept_dofs[k];
+          if (it->second.filter & VDESCRFILTER_REGION)
+            kept &= it->second.mf->dof_on_region(it->second.m_region);
+          // kept &= mult_kept_dofs[k];
           it->second.partial_mf->adapt(kept);
           it->second.set_size(it->second.partial_mf->nb_dof());
           it->second.v_num = act_counter();
@@ -428,7 +431,9 @@
           for (std::set<size_type>::iterator itt = glob_columns.begin();
                itt != glob_columns.end(); ++itt)
             if (*itt >= s && *itt < s + nbdof) kept.add(*itt-s);
-          kept &= mult_kept_dofs[k];
+          if (it->second.filter & VDESCRFILTER_REGION)
+            kept &= it->second.mf->dof_on_region(it->second.m_region);
+          // kept &= mult_kept_dofs[k];
           it->second.partial_mf->adapt(kept);
           it->second.set_size(it->second.partial_mf->nb_dof());
           it->second.v_num = act_counter();
@@ -591,6 +596,18 @@
     check_name_validity(name);
     variables[name] = var_description(true, is_complex(), true, niter,
                                       VDESCRFILTER_CTERM, &mf, 0,
+                                      1, primal_name);
+    variables[name].set_size(mf.nb_dof());
+    act_size_to_be_done = true;
+    add_dependency(mf);
+  }
+
+  void model::add_multiplier(const std::string &name, const mesh_fem &mf,
+                             size_type region, const std::string &primal_name,
+                             size_type niter) {
+    check_name_validity(name);
+    variables[name] = var_description(true, is_complex(), true, niter,
+                                      VDESCRFILTER_REGION_CTERM, &mf, region,
                                       1, primal_name);
     variables[name].set_size(mf.nb_dof());
     act_size_to_be_done = true;

Modified: trunk/getfem/src/getfem_nonlinear_elasticity.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_nonlinear_elasticity.cc?rev=4953&r1=4952&r2=4953&view=diff
==============================================================================
--- trunk/getfem/src/getfem_nonlinear_elasticity.cc     (original)
+++ trunk/getfem/src/getfem_nonlinear_elasticity.cc     Tue Apr 14 20:46:00 2015
@@ -943,7 +943,7 @@
 
   //=========================================================================
   //
-  //  Nonlinear elasticity Brick
+  //  Nonlinear elasticity (old) Brick
   //
   //=========================================================================
 

Modified: trunk/getfem/src/getfem_partial_mesh_fem.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_partial_mesh_fem.cc?rev=4953&r1=4952&r2=4953&view=diff
==============================================================================
--- trunk/getfem/src/getfem_partial_mesh_fem.cc (original)
+++ trunk/getfem/src/getfem_partial_mesh_fem.cc Tue Apr 14 20:46:00 2015
@@ -78,20 +78,21 @@
     is_adapted = true; touch(); v_num = act_counter();
   }
 
-  dal::bit_vector partial_mesh_fem::retrieve_kept_dofs() const
-  {
-    base_vector full(nb_basic_dof());
-    for (size_type i = 0; i < full.size(); ++i) full[i] = i;
-    base_vector reduced(nb_dof());
-
-    if (R_.ncols() > 0) gmm::mult(R_, full, reduced);
-    else reduced = full;
-
-    dal::bit_vector kept_dofs;
-    for (size_type i = 0; i < reduced.size(); ++i) kept_dofs.add(reduced[i]);
-
-    return kept_dofs;
-  }
+  // invalid function for a mesh change.
+  // dal::bit_vector partial_mesh_fem::retrieve_kept_dofs() const
+  // {
+  //   base_vector full(nb_basic_dof());
+  //   for (size_type i = 0; i < full.size(); ++i) full[i] = i;
+  //   base_vector reduced(nb_dof());
+  // 
+  //   if (R_.ncols() > 0) gmm::mult(R_, full, reduced);
+  //   else reduced = full;
+  // 
+  //   dal::bit_vector kept_dofs;
+  //   for (size_type i=0; i < reduced.size(); ++i) kept_dofs.add(reduced[i]); 
+  // 
+  //   return kept_dofs;
+  // }
 
   void partial_mesh_fem::write_to_file(std::ostream &ost) const
   { context_check(); mf.context_check();




reply via email to

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