getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] r5425 - in /trunk/getfem: doc/sphinx/source/userdoc/ in


From: Yves . Renard
Subject: [Getfem-commits] r5425 - in /trunk/getfem: doc/sphinx/source/userdoc/ interface/src/ src/ src/getfem/
Date: Tue, 18 Oct 2016 19:29:25 -0000

Author: renard
Date: Tue Oct 18 21:29:24 2016
New Revision: 5425

URL: http://svn.gna.org/viewcvs/getfem?rev=5425&view=rev
Log:
interface for the assembly assignments

Modified:
    trunk/getfem/doc/sphinx/source/userdoc/gasm_high.rst
    trunk/getfem/interface/src/gf_model_set.cc
    trunk/getfem/src/getfem/getfem_generic_assembly.h
    trunk/getfem/src/getfem/getfem_models.h
    trunk/getfem/src/getfem_generic_assembly.cc
    trunk/getfem/src/getfem_models.cc

Modified: trunk/getfem/doc/sphinx/source/userdoc/gasm_high.rst
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/doc/sphinx/source/userdoc/gasm_high.rst?rev=5425&r1=5424&r2=5425&view=diff
==============================================================================
--- trunk/getfem/doc/sphinx/source/userdoc/gasm_high.rst        (original)
+++ trunk/getfem/doc/sphinx/source/userdoc/gasm_high.rst        Tue Oct 18 
21:29:24 2016
@@ -787,3 +787,32 @@
 
 The value ``Xfem_plus(u)`` is the value of ``u`` on the side where the 
corresponding level-set function is positive and ``Xfem_minus(u)`` the value of 
``u`` on the side where the level-set function is negative.
   
+Storage of sub-expressions in a getfem::im_data object during assembly
+----------------------------------------------------------------------
+
+It is possible to store in a vector depending on a getfem::im_data object a 
part of an assembly computation, for instance to use this compuation in another 
assembly. This is an alternative to the interpolation functions which allows 
not to compute twice the same expression.
+
+The method to add such an assignment in the assembly is the following for a 
model or a ga_workspace::
+
+  model.add_assembly_assignments(dataname, expr, region = size_type(-1),
+                                order = 1, before = false);
+
+  workspace.add_assignment_expression(dataname, expr,
+            region = mesh_region::all_convexes(), order = 1, before = false)
+
+It adds expression `expr` to be evaluated at assembly time and being
+assigned to the data `dataname` which has to be of im_data type.
+`order` represents the order of assembly where this assignement has to be
+done (potential(0), weak form(1) or tangent system(2) or at each
+order(-1)). The default value is 1 which means at each order.
+If before = 1, the the assignement is perfromed before the computation
+of the other assembly terms, such that the data can be used in the
+remaining of the assembly as an intermediary result (be careful that it is
+still considered as a data, no derivation of the expression is performed).
+If before = 0 (default), the assignement is done after the assembly terms.
+
+Additionally, In a model, the method::
+  
+  model.clear_assembly_assignments()
+
+allows to cancel all the assembly assignments previously added.

Modified: trunk/getfem/interface/src/gf_model_set.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/gf_model_set.cc?rev=5425&r1=5424&r2=5425&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_model_set.cc  (original)
+++ trunk/getfem/interface/src/gf_model_set.cc  Tue Oct 18 21:29:24 2016
@@ -566,6 +566,43 @@
        out.pop().from_integer(int(ind));
        );
 
+    /address@hidden ('add assembly assignment', @str dataname, @str 
expression[, @int region[, @int order[, @int before]]])
+      Adds expression `expr` to be evaluated at assembly time and being
+      assigned to the data `dataname` which has to be of im_data type.
+      This allows for instance to store a sub-expression of an assembly
+      computation to be used on an other assembly. It can be used for instance
+      to store the plastic strain in plasticity models.
+      `order` represents the order of assembly where this assignement has to be
+      done (potential(0), weak form(1) or tangent system(2) or at each
+      order(-1)). The default value is 1.
+      If before = 1, the the assignement is perfromed before the computation
+      of the other assembly terms, such that the data can be used in the
+      remaining of the assembly as an intermediary result (be careful that it 
is
+      still considered as a data, no derivation of the expression is performed
+      for the tangent system).
+      If before = 0 (default), the assignement is done after the assembly 
terms.
+      @*/
+    sub_command
+      ("add assembly assignment", 2, 5, 0, 0,
+       std::string dataname = in.pop().to_string();
+       std::string expr = in.pop().to_string();
+       size_type region = size_type(-1);
+       if (in.remaining()) region = in.pop().to_integer();
+       size_type order = 1;
+       if (in.remaining()) order = in.pop().to_integer();
+       bool before = false;
+       if (in.remaining()) before = (in.pop().to_integer() != 0);
+       
+       md->add_assembly_assignments(dataname, expr, region, order, before);
+       );
+
+    /address@hidden ('clear assembly assignment')
+      Delete all added assembly assignments
+      @*/
+    sub_command
+      ("clear assembly assignment", 0, 0, 0, 0,
+       md->clear_assembly_assignments();
+       );
 
     /address@hidden ind = ('add Laplacian brick', @tmim mim, @str varname[, 
@int region])
     Add a Laplacian term to the model relatively to the variable `varname`

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=5425&r1=5424&r2=5425&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_generic_assembly.h   (original)
+++ trunk/getfem/src/getfem/getfem_generic_assembly.h   Tue Oct 18 21:29:24 2016
@@ -269,9 +269,9 @@
     (const std::string &expr, const mesh_im &mim,
      const mesh_region &rg = mesh_region::all_convexes());
     void add_assignment_expression
-    (const std::string &varname, const std::string &expr,
+    (const std::string &dataname, const std::string &expr,
      const mesh_region &rg_ = mesh_region::all_convexes(),
-     size_type order = size_type(-1), bool before = false);
+     size_type order = 1, bool before = false);
 
     /** Delete all previously added expressions. */
     void clear_expressions();

Modified: trunk/getfem/src/getfem/getfem_models.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_models.h?rev=5425&r1=5424&r2=5425&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_models.h     (original)
+++ trunk/getfem/src/getfem/getfem_models.h     Tue Oct 18 21:29:24 2016
@@ -303,8 +303,7 @@
                          BUILD_ALL = 3,
                          BUILD_ON_DATA_CHANGE = 4,
                          BUILD_WITH_COMPLETE_RHS = 8,
-                         BUILD_COMPLETE_RHS = 9,
-    };
+                         BUILD_COMPLETE_RHS = 9, };
 
   protected:
 
@@ -390,6 +389,18 @@
                size_type region_) : expr(expr_), mim(mim_), region(region_) {}
     };
 
+    // Structure for assignment in assembly
+    struct assignement_desc {
+      std::string varname;
+      std::string expr;
+      size_type region;
+      bool before;
+      size_type order;
+    };
+
+    std::list<assignement_desc> assignments;
+
+    
     mutable std::list<gen_expr> generic_expressions;
 
     // Groups of variables for interpolation on different meshes
@@ -462,6 +473,13 @@
       return (variable_groups.find(group_name))->second;
     }
 
+    void clear_assembly_assignments(void) { assignments.clear(); }
+    void add_assembly_assignments(const std::string &dataname,
+                                 const std::string &expr,
+                                 size_type rg = size_type(-1),
+                                 size_type order = 1,
+                                 bool before = false);
+
     void add_Neumann_term(pNeumann_elem_term p,
                           const std::string &varname,
                           size_type brick_num) const

Modified: trunk/getfem/src/getfem_generic_assembly.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_generic_assembly.cc?rev=5425&r1=5424&r2=5425&view=diff
==============================================================================
--- trunk/getfem/src/getfem_generic_assembly.cc (original)
+++ trunk/getfem/src/getfem_generic_assembly.cc Tue Oct 18 21:29:24 2016
@@ -11957,7 +11957,7 @@
       bgeot::pgeotrans_precomp pgp = 0;
       bool first_gp = true;
       for (getfem::mr_visitor v(rg, m); !v.finished(); ++v) {
-        if (mim.convex_index().is_in(v.cv())) {
+       if (mim.convex_index().is_in(v.cv())) {
           // cout << "proceed with element " << v.cv() << endl;
           if (v.cv() != old_cv) {
             pgt = m.trans_of_convex(v.cv());

Modified: trunk/getfem/src/getfem_models.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_models.cc?rev=5425&r1=5424&r2=5425&view=diff
==============================================================================
--- trunk/getfem/src/getfem_models.cc   (original)
+++ trunk/getfem/src/getfem_models.cc   Tue Oct 18 21:29:24 2016
@@ -2090,7 +2090,17 @@
     variable_groups[group_name] = nl;
   }
 
-
+  void model::add_assembly_assignments(const std::string &varname,
+                                      const std::string &expr, size_type rg,
+                                      size_type order, bool before) {
+    GMM_ASSERT1(order < 3 || order == size_type(-1), "Bad order value");
+    const im_data *imd = pim_data_of_variable(varname);
+    GMM_ASSERT1(imd != 0, "Only applicable to im_data");
+    assignement_desc as;
+    as.varname = varname; as.expr = expr; as.region = rg; as.order = order;
+    as.before = before;
+    assignments.push_back(as);
+  }
 
 
 
@@ -2795,6 +2805,10 @@
 
             ga_workspace workspace(*this);
 
+           for (const auto &ad : assignments)
+             workspace.add_assignment_expression
+               (ad.varname, ad.expr, ad.region, ad.order, ad.before);
+
             for (const auto &ge : generic_expressions)
              workspace.add_expression(ge.expr, ge.mim, ge.region);
 




reply via email to

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