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>
45 _is_compressible(is_compressible)
48 template<
typename StressStrainLaw>
51 InteriorFuncType interior_solution,
52 VarDerivType get_solution_deriv,
55 const unsigned int n_u_dofs = context.get_dof_indices(this->_disp_vars.u()).size();
57 const std::vector<libMesh::Real> &JxW =
58 this->get_fe(context)->get_JxW();
60 const std::vector<std::vector<libMesh::Real> >& u_phi =
61 this->get_fe(context)->get_phi();
64 libMesh::DenseSubVector<libMesh::Number> & Fu = context.get_elem_residual(this->_disp_vars.u());
65 libMesh::DenseSubVector<libMesh::Number> * Fv = NULL;
66 libMesh::DenseSubVector<libMesh::Number> * Fw = NULL;
68 libMesh::DenseSubMatrix<libMesh::Number> & Kuu = context.get_elem_jacobian(this->_disp_vars.u(),this->_disp_vars.u());
69 libMesh::DenseSubMatrix<libMesh::Number> * Kvv = NULL;
70 libMesh::DenseSubMatrix<libMesh::Number> * Kww = NULL;
72 if( this->_disp_vars.dim() >= 2 )
74 Fv = &context.get_elem_residual(this->_disp_vars.v());
75 Kvv = &context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.v());
78 if( this->_disp_vars.dim() == 3 )
80 Fw = &context.get_elem_residual(this->_disp_vars.w());
81 Kww = &context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.w());
84 unsigned int n_qpoints = context.get_element_qrule().n_points();
86 for (
unsigned int qp=0; qp != n_qpoints; qp++)
88 libMesh::Real jac = JxW[qp];
90 libMesh::Real u_ddot, v_ddot, w_ddot;
91 (context.*interior_solution)( this->_disp_vars.u(), qp, u_ddot );
93 if( this->_disp_vars.dim() >= 2 )
94 (context.*interior_solution)( this->_disp_vars.v(), qp, v_ddot );
96 if( this->_disp_vars.dim() == 3 )
97 (context.*interior_solution)( this->_disp_vars.w(), qp, w_ddot );
99 for (
unsigned int i=0; i != n_u_dofs; i++)
101 libMesh::Real value = this->_rho*this->_A*u_phi[i][qp]*jac*mu;
102 Fu(i) += value*u_ddot;
104 if( this->_disp_vars.dim() >= 2 )
105 (*Fv)(i) += value*v_ddot;
107 if( this->_disp_vars.dim() == 3 )
108 (*Fw)(i) += value*w_ddot;
110 if( compute_jacobian )
112 for (
unsigned int j=0; j != n_u_dofs; j++)
114 libMesh::Real jac_term = mu*this->_rho*this->_A*u_phi[i][qp]*u_phi[j][qp]*jac;
115 jac_term *= (context.*get_solution_deriv)();
117 Kuu(i,j) += jac_term;
119 if( this->_disp_vars.dim() >= 2 )
120 (*Kvv)(i,j) += jac_term;
122 if( this->_disp_vars.dim() == 3 )
123 (*Kww)(i,j) += jac_term;
130 template<
typename StressStrainLaw>
132 const libMesh::FEBase& elem,
134 const libMesh::Gradient& grad_u,
135 const libMesh::Gradient& grad_v,
136 const libMesh::Gradient& grad_w,
141 libMesh::Real& lambda_sq )
143 const std::vector<libMesh::RealGradient>& dxdxi = elem.get_dxyzdxi();
145 const std::vector<libMesh::Real>& dxidx = elem.get_dxidx();
146 const std::vector<libMesh::Real>& dxidy = elem.get_dxidy();
147 const std::vector<libMesh::Real>& dxidz = elem.get_dxidz();
149 libMesh::RealGradient dxi( dxidx[qp], dxidy[qp], dxidz[qp] );
151 libMesh::RealGradient dudxi( grad_u(0), grad_v(0), grad_w(0) );
155 a_cov(0,0) = dxdxi[qp]*dxdxi[qp];
161 A_cov(0,0) = (dxdxi[qp] + dudxi)*(dxdxi[qp] + dudxi);
165 a_contra(0,0) = 1/a_cov(0,0);
171 A_contra(0,0) = 1/A_cov(0,0);
174 if( _is_compressible )
176 libmesh_not_implemented();
182 lambda_sq = a_cov(0,0)/A_cov(0,0);
186 A_cov(1,1) = lambda_sq;
187 A_cov(2,2) = lambda_sq;
188 A_contra(1,1) = 1.0/lambda_sq;
189 A_contra(2,2) = 1.0/lambda_sq;
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)
Helper functions for parsing material properties.
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.