getfem-commits
[Top][All Lists]
Advanced

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

[Getfem-commits] r5266 - in /trunk/getfem: interface/src/ src/ src/getfe


From: Yves . Renard
Subject: [Getfem-commits] r5266 - in /trunk/getfem: interface/src/ src/ src/getfem/
Date: Tue, 29 Mar 2016 13:32:33 -0000

Author: renard
Date: Tue Mar 29 15:32:32 2016
New Revision: 5266

URL: http://svn.gna.org/viewcvs/getfem?rev=5266&view=rev
Log:
Adding a basic contact brick for two deformable bodies

Modified:
    trunk/getfem/interface/src/gf_model_set.cc
    trunk/getfem/src/getfem/getfem_contact_and_friction_nodal.h
    trunk/getfem/src/getfem_contact_and_friction_nodal.cc

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=5266&r1=5265&r2=5266&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_model_set.cc  (original)
+++ trunk/getfem/interface/src/gf_model_set.cc  Tue Mar 29 15:32:32 2016
@@ -2356,6 +2356,78 @@
         );
 
 
+     /address@hidden ind = ('add basic contact brick two deformable bodies', 
@str varname_u1, @str varname_u2, @str multname_n, @str dataname_r, @tspmat 
BN1, @tspmat BN2[, @str dataname_gap[, @str dataname_alpha[, @int 
augmented_version]]])
+       
+     Add a frictionless contact condition to the model between two deformable
+      bodies. If U1, U2 are the vector
+      of degrees of freedom on which the unilateral constraint is applied,
+      the matrices `BN1` and `BN2` have to be such that this condition
+      is defined by
+      $B_{N1} U_1 B_{N2} U_2 + \le gap$. The constraint is prescribed thank
+      to a multiplier
+      `multname_n` whose dimension should be equal to the number of lines of
+      `BN`. The augmentation parameter `r` should be chosen in a range of
+      acceptabe values (see Getfem user documentation). `dataname_gap` is an
+      optional parameter representing the initial gap. It can be a single value
+      or a vector of value. `dataname_alpha` is an optional homogenization
+      parameter for the augmentation parameter
+      (see Getfem user documentation). The parameter `aug_version` indicates
+      the augmentation strategy : 1 for the non-symmetric Alart-Curnier
+      augmented Lagrangian, 2 for the symmetric one, 3 for the unsymmetric
+      method with augmented multiplier. @*/
+     sub_command
+       ("add basic contact brick two deformable bodies", 6, 9, 0, 1,
+
+        std::string varname_u1 = in.pop().to_string();
+        std::string varname_u2 = in.pop().to_string();
+        std::string multname_n = in.pop().to_string();
+        std::string dataname_r = in.pop().to_string();
+       
+        std::shared_ptr<gsparse> BN1 = in.pop().to_sparse();
+        std::shared_ptr<gsparse> BN2 =  in.pop().to_sparse();
+        if (BN1->is_complex()) THROW_BADARG("Complex matrix not allowed");
+        if (BN2->is_complex()) THROW_BADARG("Complex matrix not allowed");
+
+        std::string dataname_gap;
+        if (in.remaining()) dataname_gap = in.pop().to_string();
+        std::string dataname_alpha;
+        if (in.remaining()) dataname_alpha = in.pop().to_string();
+        int augmented_version = 1;
+        if (in.remaining()) augmented_version = in.pop().to_integer(1,4);
+
+        getfem::CONTACT_B_MATRIX BBN1; getfem::CONTACT_B_MATRIX BBN2;
+        if (BN1->storage()==gsparse::CSCMAT) {
+          gmm::resize(BBN1, gmm::mat_nrows(BN1->real_csc()),
+                      gmm::mat_ncols(BN1->real_csc()));
+          gmm::copy(BN1->real_csc(), BBN1);
+        }
+        else if (BN1->storage()==gsparse::WSCMAT) {
+          gmm::resize(BBN1, gmm::mat_nrows(BN1->real_wsc()),
+                      gmm::mat_ncols(BN1->real_wsc()));
+          gmm::copy(BN1->real_wsc(), BBN1);
+        }
+        else THROW_BADARG("Matrix BN1 should be a sparse matrix");
+
+        if (BN2->storage()==gsparse::CSCMAT) {
+          gmm::resize(BBN2, gmm::mat_nrows(BN2->real_csc()),
+                      gmm::mat_ncols(BN2->real_csc()));
+          gmm::copy(BN2->real_csc(), BBN2);
+        }
+        else if (BN2->storage()==gsparse::WSCMAT) {
+          gmm::resize(BBN2, gmm::mat_nrows(BN2->real_wsc()),
+                      gmm::mat_ncols(BN2->real_wsc()));
+          gmm::copy(BN2->real_wsc(), BBN2);
+        }
+        else THROW_BADARG("Matrix BN2 should be a sparse matrix");
+
+        size_type ind;
+       ind = getfem::add_basic_contact_brick_two_deformable_bodies
+       (*md, varname_u1, varname_u2, multname_n, dataname_r, BBN1, BBN2,
+        dataname_gap, dataname_alpha, augmented_version);
+
+        out.pop().from_integer(int(ind + config::base_index()));
+        );
+
     /address@hidden ('contact brick set BN', @int indbrick, @tspmat BN)
     Can be used to set the BN matrix of a basic contact/friction brick. @*/
      sub_command

Modified: trunk/getfem/src/getfem/getfem_contact_and_friction_nodal.h
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_contact_and_friction_nodal.h?rev=5266&r1=5265&r2=5266&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_contact_and_friction_nodal.h (original)
+++ trunk/getfem/src/getfem/getfem_contact_and_friction_nodal.h Tue Mar 29 
15:32:32 2016
@@ -64,6 +64,32 @@
    const std::string &dataname_r, CONTACT_B_MATRIX &BN,
    std::string dataname_gap = "", std::string dataname_alpha = "",
    int aug_version=1, bool Hughes_stabilized=false);
+  
+  /** Add a frictionless contact condition to the model between two deformable
+      bodies. If U1, U2 are the vector
+      of degrees of freedom on which the unilateral constraint is applied,
+      the matrices `BN1` and `BN2` have to be such that this condition
+      is defined by
+      $B_{N1} U_1 B_{N2} U_2 + \le gap$. The constraint is prescribed thank
+      to a multiplier
+      `multname_n` whose dimension should be equal to the number of lines of
+      `BN`. The augmentation parameter `r` should be chosen in a range of
+      acceptabe values (see Getfem user documentation). `dataname_gap` is an
+      optional parameter representing the initial gap. It can be a single value
+      or a vector of value. `dataname_alpha` is an optional homogenization
+      parameter for the augmentation parameter
+      (see Getfem user documentation). The parameter `aug_version` indicates
+      the augmentation strategy : 1 for the non-symmetric Alart-Curnier
+      augmented Lagrangian, 2 for the symmetric one, 3 for the unsymmetric
+      method with augmented multiplier.
+  */
+  size_type add_basic_contact_brick_two_deformable_bodies
+  (model &md, const std::string &varname_u1, const std::string &varname_u2,
+   const std::string &multname_n,
+   const std::string &dataname_r, CONTACT_B_MATRIX &BN1, CONTACT_B_MATRIX &BN2,
+   std::string dataname_gap = "", std::string dataname_alpha = "",
+   int aug_version=1, bool Hughes_stabilized=false);
+  
 
 
   /** Add a contact with friction condition to the model. If U is the vector
@@ -100,6 +126,8 @@
    std::string dataname_gap="", std::string dataname_alpha="",
    int aug_version=1, bool Tresca_version=false, const std::string 
dataname_threshold="",
    std::string dataname_gamma="", std::string dataname_wt="", bool 
Hughes_stabilized=false);
+
+
 
   /** Can be used to change the matrix BN of a basic contact/friction brick
    */

Modified: trunk/getfem/src/getfem_contact_and_friction_nodal.cc
URL: 
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem_contact_and_friction_nodal.cc?rev=5266&r1=5265&r2=5266&view=diff
==============================================================================
--- trunk/getfem/src/getfem_contact_and_friction_nodal.cc       (original)
+++ trunk/getfem/src/getfem_contact_and_friction_nodal.cc       Tue Mar 29 
15:32:32 2016
@@ -1203,6 +1203,12 @@
       is_init = false;
     }
 
+    void set_BN2(CONTACT_B_MATRIX &BN2_) {
+      gmm::resize(BN2, gmm::mat_nrows(BN2_), gmm::mat_ncols(BN2_));
+      gmm::copy(BN2_, BN2);
+      is_init = false;
+    }
+
     void set_DN(CONTACT_B_MATRIX &DN_) {
       gmm::resize(DN, gmm::mat_nrows(DN_), gmm::mat_ncols(DN_));
       gmm::copy(DN_, DN);
@@ -1320,6 +1326,55 @@
     dl.push_back(dataname_alpha);
 
     model::varnamelist vl(1, varname_u);
+    vl.push_back(multname_n);
+
+    return md.add_brick(pbr, vl, dl, tl, model::mimlist(), size_type(-1));
+  }
+
+  //=========================================================================
+  //  Add a frictionless contact condition with BN, r, alpha given for
+  //  two deformable bodies
+  //=========================================================================
+
+  size_type add_basic_contact_brick_two_deformable_bodies
+  (model &md, const std::string &varname_u1, const std::string &varname_u2,
+   const std::string &multname_n,
+   const std::string &dataname_r, CONTACT_B_MATRIX &BN1, CONTACT_B_MATRIX &BN2,
+   std::string dataname_gap, std::string dataname_alpha,
+   int aug_version, bool Hughes_stabilized) {
+
+    auto pbr_ = std::make_shared<Coulomb_friction_brick>
+      (aug_version, true, true, false, Hughes_stabilized);
+    pbrick pbr(pbr_);
+    pbr_->set_BN1(BN1);
+    pbr_->set_BN2(BN2);
+
+    model::termlist tl;
+    tl.push_back(model::term_description(varname_u1, varname_u1, false));
+    tl.push_back(model::term_description(varname_u2, varname_u2, false));
+    tl.push_back(model::term_description(varname_u1, multname_n, false));
+    tl.push_back(model::term_description(multname_n, varname_u1, false));
+    tl.push_back(model::term_description(varname_u2, multname_n, false));
+    tl.push_back(model::term_description(multname_n, varname_u2, false));
+    tl.push_back(model::term_description(multname_n, multname_n, false));
+    model::varnamelist dl(1, dataname_r);
+
+    if (dataname_gap.size() == 0) {
+      dataname_gap = md.new_name("contact_gap_on_" + varname_u1);
+      md.add_initialized_fixed_size_data
+        (dataname_gap, model_real_plain_vector(1, scalar_type(0)));
+    }
+    dl.push_back(dataname_gap);
+
+    if (dataname_alpha.size() == 0) {
+      dataname_alpha = md.new_name("contact_parameter_alpha_on_"+ multname_n);
+      md.add_initialized_fixed_size_data
+        (dataname_alpha, model_real_plain_vector(1, scalar_type(1)));
+    }
+    dl.push_back(dataname_alpha);
+
+    model::varnamelist vl(1, varname_u1);
+    vl.push_back(varname_u2);
     vl.push_back(multname_n);
 
     return md.add_brick(pbr, vl, dl, tl, model::mimlist(), size_type(-1));




reply via email to

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