32 #include "libmesh/getpot.h"
33 #include "libmesh/quadrature.h"
34 #include "libmesh/fem_system.h"
35 #include "libmesh/elem.h"
39 template<
typename StressStrainLaw>
42 bool is_compressible )
45 _is_compressible(is_compressible),
49 "Physics/"+physics_name+
"/h0",
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.");
64 template<
typename StressStrainLaw>
74 _lambda_sq_var = system->add_variable(
"lambda_sq", GRINSEnums::FIRST, GRINSEnums::LAGRANGE);
78 template<
typename StressStrainLaw>
81 InteriorFuncType interior_solution,
82 VarDerivType get_solution_deriv,
85 const unsigned int n_u_dofs = context.get_dof_indices(_disp_vars.u()).size();
87 const std::vector<libMesh::Real> &JxW =
88 this->get_fe(context)->get_JxW();
90 const std::vector<std::vector<libMesh::Real> >& u_phi =
91 this->get_fe(context)->get_phi();
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;
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;
102 if( this->_disp_vars.dim() == 3 )
104 Fw = &context.get_elem_residual(this->_disp_vars.w());
106 Kww = &context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.w());
109 unsigned int n_qpoints = context.get_element_qrule().n_points();
111 for (
unsigned int qp=0; qp != n_qpoints; qp++)
113 libMesh::Real jac = JxW[qp];
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 );
119 libMesh::Real w_ddot = 0.0;
120 if( this->_disp_vars.dim() == 3 )
121 (context.*interior_solution)( _disp_vars.w(), qp, w_ddot );
123 for (
unsigned int i=0; i != n_u_dofs; i++)
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;
128 if( this->_disp_vars.dim() == 3 )
129 (*Fw)(i) += mu*this->_rho*_h0*w_ddot*u_phi[i][qp]*jac;
131 if( compute_jacobian )
133 for (
unsigned int j=0; j != n_u_dofs; j++)
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)();
138 Kuu(i,j) += jac_term;
139 Kvv(i,j) += jac_term;
141 if( this->_disp_vars.dim() == 3 )
142 (*Kww)(i,j) += jac_term;
149 template<
typename StressStrainLaw>
151 const libMesh::FEBase& elem,
153 const libMesh::Gradient& grad_u,
154 const libMesh::Gradient& grad_v,
155 const libMesh::Gradient& grad_w,
160 libMesh::Real& lambda_sq )
162 const std::vector<libMesh::RealGradient>& dxdxi = elem.get_dxyzdxi();
163 const std::vector<libMesh::RealGradient>& dxdeta = elem.get_dxyzdeta();
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();
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();
173 libMesh::RealGradient dxi( dxidx[qp], dxidy[qp], dxidz[qp] );
174 libMesh::RealGradient deta( detadx[qp], detady[qp], detadz[qp] );
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) );
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];
186 libMesh::Real det_a = a_cov(0,0)*a_cov(1,1) - a_cov(0,1)*a_cov(1,0);
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);
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;
203 libMesh::Real det_A = A_cov(0,0)*A_cov(1,1) - A_cov(0,1)*A_cov(1,0);
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;
216 if( _is_compressible )
218 lambda_sq = context.interior_value(this->_lambda_sq_var, qp);
223 lambda_sq = det_a/det_A;
226 A_cov(2,2) = lambda_sq;
227 A_contra(2,2) = 1.0/lambda_sq;
DisplacementVariable & _disp_vars
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 ¶ms, libMesh::Real &rho)
Helper function to reading density from input.
static PhysicsName elastic_membrane()
Helper functions for parsing material properties.
virtual void init_variables(libMesh::FEMSystem *)
Initialize variables for this physics.
static void read_property(const GetPot &input, const std::string &old_option, const std::string &property, const std::string &core_physics, ParameterUser ¶m_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.