GRINS-0.8.0
elastic_membrane_base.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 // This class
27 
28 // GRINS
30 
31 // libMesh
32 #include "libmesh/getpot.h"
33 #include "libmesh/quadrature.h"
34 #include "libmesh/fem_system.h"
35 #include "libmesh/elem.h"
36 
37 namespace GRINS
38 {
39  template<typename StressStrainLaw>
41  const GetPot& input,
42  bool is_compressible )
43  : ElasticMembraneAbstract(physics_name,input),
44  _stress_strain_law(input,MaterialsParsing::material_name(input,PhysicsNaming::elastic_membrane())),
45  _is_compressible(is_compressible),
46  _h0(0.0)
47  {
49  "Physics/"+physics_name+"/h0",
50  "MembraneThickness",
52  (*this),
53  _h0 );
54 
55  MaterialsParsing::read_density( physics_name,
56  input,
57  (*this),
58  _rho );
59 
60  if( this->_disp_vars.dim() < 2 )
61  libmesh_error_msg("ERROR: ElasticMembraneBase subclasses only valid for two or three dimensions! Make sure you have at least two components in your Displacement type variable.");
62  }
63 
64  template<typename StressStrainLaw>
65  void ElasticMembraneBase<StressStrainLaw>::init_variables( libMesh::FEMSystem* system )
66  {
67  // First call base class
69 
70  // Now build lambda_sq variable if we need it
71  if(_is_compressible)
72  {
74  _lambda_sq_var = system->add_variable( "lambda_sq", GRINSEnums::FIRST, GRINSEnums::LAGRANGE);
75  }
76  }
77 
78  template<typename StressStrainLaw>
80  AssemblyContext& context,
81  InteriorFuncType interior_solution,
82  VarDerivType get_solution_deriv,
83  libMesh::Real mu )
84  {
85  const unsigned int n_u_dofs = context.get_dof_indices(_disp_vars.u()).size();
86 
87  const std::vector<libMesh::Real> &JxW =
88  this->get_fe(context)->get_JxW();
89 
90  const std::vector<std::vector<libMesh::Real> >& u_phi =
91  this->get_fe(context)->get_phi();
92 
93  // Residuals that we're populating
94  libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(_disp_vars.u());
95  libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(_disp_vars.v());
96  libMesh::DenseSubVector<libMesh::Number>* Fw = NULL;
97 
98  libMesh::DenseSubMatrix<libMesh::Number>& Kuu = context.get_elem_jacobian(_disp_vars.u(),_disp_vars.u());
99  libMesh::DenseSubMatrix<libMesh::Number>& Kvv = context.get_elem_jacobian(_disp_vars.v(),_disp_vars.v());
100  libMesh::DenseSubMatrix<libMesh::Number>* Kww = NULL;
101 
102  if( this->_disp_vars.dim() == 3 )
103  {
104  Fw = &context.get_elem_residual(this->_disp_vars.w());
105 
106  Kww = &context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.w());
107  }
108 
109  unsigned int n_qpoints = context.get_element_qrule().n_points();
110 
111  for (unsigned int qp=0; qp != n_qpoints; qp++)
112  {
113  libMesh::Real jac = JxW[qp];
114 
115  libMesh::Real u_ddot, v_ddot;
116  (context.*interior_solution)( _disp_vars.u(), qp, u_ddot );
117  (context.*interior_solution)( _disp_vars.v(), qp, v_ddot );
118 
119  libMesh::Real w_ddot = 0.0;
120  if( this->_disp_vars.dim() == 3 )
121  (context.*interior_solution)( _disp_vars.w(), qp, w_ddot );
122 
123  for (unsigned int i=0; i != n_u_dofs; i++)
124  {
125  Fu(i) += mu*this->_rho*_h0*u_ddot*u_phi[i][qp]*jac;
126  Fv(i) += mu*this->_rho*_h0*v_ddot*u_phi[i][qp]*jac;
127 
128  if( this->_disp_vars.dim() == 3 )
129  (*Fw)(i) += mu*this->_rho*_h0*w_ddot*u_phi[i][qp]*jac;
130 
131  if( compute_jacobian )
132  {
133  for (unsigned int j=0; j != n_u_dofs; j++)
134  {
135  libMesh::Real jac_term = this->_rho*_h0*u_phi[i][qp]*u_phi[j][qp]*jac;
136  jac_term *= mu*(context.*get_solution_deriv)();
137 
138  Kuu(i,j) += jac_term;
139  Kvv(i,j) += jac_term;
140 
141  if( this->_disp_vars.dim() == 3 )
142  (*Kww)(i,j) += jac_term;
143  }
144  }
145  }
146  }
147  }
148 
149  template<typename StressStrainLaw>
151  const libMesh::FEBase& elem,
152  const AssemblyContext& context,
153  const libMesh::Gradient& grad_u,
154  const libMesh::Gradient& grad_v,
155  const libMesh::Gradient& grad_w,
160  libMesh::Real& lambda_sq )
161  {
162  const std::vector<libMesh::RealGradient>& dxdxi = elem.get_dxyzdxi();
163  const std::vector<libMesh::RealGradient>& dxdeta = elem.get_dxyzdeta();
164 
165  const std::vector<libMesh::Real>& dxidx = elem.get_dxidx();
166  const std::vector<libMesh::Real>& dxidy = elem.get_dxidy();
167  const std::vector<libMesh::Real>& dxidz = elem.get_dxidz();
168 
169  const std::vector<libMesh::Real>& detadx = elem.get_detadx();
170  const std::vector<libMesh::Real>& detady = elem.get_detady();
171  const std::vector<libMesh::Real>& detadz = elem.get_detadz();
172 
173  libMesh::RealGradient dxi( dxidx[qp], dxidy[qp], dxidz[qp] );
174  libMesh::RealGradient deta( detadx[qp], detady[qp], detadz[qp] );
175 
176  libMesh::RealGradient dudxi( grad_u(0), grad_v(0), grad_w(0) );
177  libMesh::RealGradient dudeta( grad_u(1), grad_v(1), grad_w(1) );
178 
179  // Covariant metric tensor of reference configuration
180  a_cov.zero();
181  a_cov(0,0) = dxdxi[qp]*dxdxi[qp];
182  a_cov(0,1) = dxdxi[qp]*dxdeta[qp];
183  a_cov(1,0) = dxdeta[qp]*dxdxi[qp];
184  a_cov(1,1) = dxdeta[qp]*dxdeta[qp];
185 
186  libMesh::Real det_a = a_cov(0,0)*a_cov(1,1) - a_cov(0,1)*a_cov(1,0);
187 
188  // Covariant metric tensor of current configuration
189  A_cov.zero();
190  A_cov(0,0) = (dxdxi[qp] + dudxi)*(dxdxi[qp] + dudxi);
191  A_cov(0,1) = (dxdxi[qp] + dudxi)*(dxdeta[qp] + dudeta);
192  A_cov(1,0) = (dxdeta[qp] + dudeta)*(dxdxi[qp] + dudxi);
193  A_cov(1,1) = (dxdeta[qp] + dudeta)*(dxdeta[qp] + dudeta);
194 
195  // Contravariant metric tensor of reference configuration
196  a_contra.zero();
197  a_contra(0,0) = dxi*dxi;
198  a_contra(0,1) = dxi*deta;
199  a_contra(1,0) = deta*dxi;
200  a_contra(1,1) = deta*deta;
201 
202  // Contravariant metric tensor in current configuration is A_cov^{-1}
203  libMesh::Real det_A = A_cov(0,0)*A_cov(1,1) - A_cov(0,1)*A_cov(1,0);
204 
205  A_contra.zero();
206  A_contra(0,0) = A_cov(1,1)/det_A;
207  A_contra(0,1) = -A_cov(0,1)/det_A;
208  A_contra(1,0) = -A_cov(1,0)/det_A;
209  A_contra(1,1) = A_cov(0,0)/det_A;
210 
211  a_cov(2,2) = 1.0;
212  a_contra(2,2) = 1.0;
213 
214 
215  // If the material is compressible, then lambda_sq is an independent variable
216  if( _is_compressible )
217  {
218  lambda_sq = context.interior_value(this->_lambda_sq_var, qp);
219  }
220  else
221  {
222  // If the material is incompressible, lambda^2 is known
223  lambda_sq = det_a/det_A;
224  }
225 
226  A_cov(2,2) = lambda_sq;
227  A_contra(2,2) = 1.0/lambda_sq;
228  }
229 
230 } // end namespace GRINS
void mass_residual_impl(bool compute_jacobian, AssemblyContext &context, InteriorFuncType interior_solution, VarDerivType get_solution_deriv, libMesh::Real mu=1.0)
Implementation of mass_residual.
void compute_metric_tensors(unsigned int qp, const libMesh::FEBase &elem, const AssemblyContext &context, const libMesh::Gradient &grad_u, const libMesh::Gradient &grad_v, const libMesh::Gradient &grad_w, libMesh::TensorValue< libMesh::Real > &a_cov, libMesh::TensorValue< libMesh::Real > &a_contra, libMesh::TensorValue< libMesh::Real > &A_cov, libMesh::TensorValue< libMesh::Real > &A_contra, libMesh::Real &lambda_sq)
libMesh::Real _rho
Membrane density.
static void read_density(const std::string &core_physics_name, const GetPot &input, ParameterUser &params, libMesh::Real &rho)
Helper function to reading density from input.
GRINS namespace.
static PhysicsName elastic_membrane()
Helper functions for parsing material properties.
std::string PhysicsName
virtual void init_variables(libMesh::FEMSystem *)
Initialize variables for this physics.
Definition: physics.h:115
static void read_property(const GetPot &input, const std::string &old_option, const std::string &property, const std::string &core_physics, ParameterUser &param_user, libMesh::Real &value)
Helper function for parsing/maintaing backward compatibility.
unsigned int dim() const
Number of components.
libMesh::Real _h0
Membrane thickness.
virtual void init_variables(libMesh::FEMSystem *system)
Initialize variables for this physics.

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1