29 #include "grins_config.h"
37 #include "libmesh/getpot.h"
38 #include "libmesh/quadrature.h"
39 #include "libmesh/boundary_info.h"
40 #include "libmesh/fem_system.h"
41 #include "libmesh/elem.h"
45 template<
typename StressStrainLaw>
47 bool is_compressible )
53 template<
typename StressStrainLaw>
59 if( input.have_variable(section) )
61 unsigned int n_vars = input.vector_variable_size(section);
63 for(
unsigned int v = 0; v < n_vars; v++ )
65 std::string name = input(section,
"DIE!",v);
67 if( name == std::string(
"stress") )
71 _stress_indices.resize(7);
87 else if( name == std::string(
"stress_zz" ) )
92 else if( name == std::string(
"strain") )
95 _strain_indices.resize(3);
106 <<
" Found " << name << std::endl
107 <<
" Acceptable values are: stress" << std::endl
108 <<
" strain" << std::endl;
115 template<
typename StressStrainLaw>
119 const unsigned int n_u_dofs = context.get_dof_indices(this->_disp_vars.u()).size();
121 const std::vector<libMesh::Real> &JxW =
122 this->get_fe(context)->get_JxW();
125 libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_disp_vars.u());
126 libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_disp_vars.v());
127 libMesh::DenseSubVector<libMesh::Number>* Fw = NULL;
129 libMesh::DenseSubMatrix<libMesh::Number>& Kuu = context.get_elem_jacobian(this->_disp_vars.u(),this->_disp_vars.u());
130 libMesh::DenseSubMatrix<libMesh::Number>& Kuv = context.get_elem_jacobian(this->_disp_vars.u(),this->_disp_vars.v());
132 libMesh::DenseSubMatrix<libMesh::Number>& Kvu = context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.u());
133 libMesh::DenseSubMatrix<libMesh::Number>& Kvv = context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.v());
135 libMesh::DenseSubMatrix<libMesh::Number>* Kuw = NULL;
136 libMesh::DenseSubMatrix<libMesh::Number>* Kvw = NULL;
138 libMesh::DenseSubMatrix<libMesh::Number>* Kwu = NULL;
139 libMesh::DenseSubMatrix<libMesh::Number>* Kwv = NULL;
140 libMesh::DenseSubMatrix<libMesh::Number>* Kww = NULL;
142 if( this->_disp_vars.dim() == 3 )
144 Fw = &context.get_elem_residual(this->_disp_vars.w());
146 Kuw = &context.get_elem_jacobian(this->_disp_vars.u(),this->_disp_vars.w());
147 Kvw = &context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.w());
148 Kwu = &context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.u());
149 Kwv = &context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.v());
150 Kww = &context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.w());
153 unsigned int n_qpoints = context.get_element_qrule().n_points();
156 const std::vector<std::vector<libMesh::Real> >& dphi_dxi =
157 this->get_fe(context)->get_dphidxi();
159 const std::vector<std::vector<libMesh::Real> >& dphi_deta =
160 this->get_fe(context)->get_dphideta();
162 const libMesh::DenseSubVector<libMesh::Number>& u_coeffs = context.get_elem_solution( this->_disp_vars.u() );
163 const libMesh::DenseSubVector<libMesh::Number>& v_coeffs = context.get_elem_solution( this->_disp_vars.v() );
164 const libMesh::DenseSubVector<libMesh::Number>* w_coeffs = NULL;
166 if( this->_disp_vars.dim() == 3 )
167 w_coeffs = &context.get_elem_solution( this->_disp_vars.w() );
170 const std::vector<libMesh::RealGradient>& dxdxi = this->get_fe(context)->get_dxyzdxi();
171 const std::vector<libMesh::RealGradient>& dxdeta = this->get_fe(context)->get_dxyzdeta();
173 for (
unsigned int qp=0; qp != n_qpoints; qp++)
176 libMesh::Gradient grad_u, grad_v, grad_w;
178 for(
unsigned int d = 0; d < n_u_dofs; d++ )
180 libMesh::RealGradient u_gradphi( dphi_dxi[d][qp], dphi_deta[d][qp] );
181 grad_u += u_coeffs(d)*u_gradphi;
182 grad_v += v_coeffs(d)*u_gradphi;
184 if( this->_disp_vars.dim() == 3 )
185 grad_w += (*w_coeffs)(d)*u_gradphi;
188 libMesh::RealGradient grad_x( dxdxi[qp](0), dxdeta[qp](0) );
189 libMesh::RealGradient grad_y( dxdxi[qp](1), dxdeta[qp](1) );
190 libMesh::RealGradient grad_z( dxdxi[qp](2), dxdeta[qp](2) );
193 libMesh::Real lambda_sq = 0;
195 this->compute_metric_tensors( qp, *(this->get_fe(context)), context,
196 grad_u, grad_v, grad_w,
197 a_cov, a_contra, A_cov, A_contra,
200 const unsigned int manifold_dim = 2;
205 this->_stress_strain_law.compute_stress_and_elasticity(manifold_dim,a_contra,a_cov,A_contra,A_cov,tau,C);
207 libMesh::Real jac = JxW[qp];
209 for (
unsigned int i=0; i != n_u_dofs; i++)
211 libMesh::RealGradient u_gradphi( dphi_dxi[i][qp], dphi_deta[i][qp] );
213 for(
unsigned int alpha = 0; alpha < manifold_dim; alpha++ )
215 for(
unsigned int beta = 0; beta < manifold_dim; beta++ )
217 libMesh::Real factor = 0.5*tau(alpha,beta)*this->_h0*jac;
219 Fu(i) += factor*( (grad_x(beta) + grad_u(beta))*u_gradphi(alpha) +
220 (grad_x(alpha) + grad_u(alpha))*u_gradphi(beta) );
222 Fv(i) += factor*( (grad_y(beta) + grad_v(beta))*u_gradphi(alpha) +
223 (grad_y(alpha) + grad_v(alpha))*u_gradphi(beta) );
225 if( this->_disp_vars.dim() == 3 )
226 (*Fw)(i) += factor*( (grad_z(beta) + grad_w(beta))*u_gradphi(alpha) +
227 (grad_z(alpha) + grad_w(alpha))*u_gradphi(beta) );
232 if( compute_jacobian )
234 for (
unsigned int i=0; i != n_u_dofs; i++)
236 libMesh::RealGradient u_gradphi_i( dphi_dxi[i][qp], dphi_deta[i][qp] );
238 for (
unsigned int j=0; j != n_u_dofs; j++)
240 libMesh::RealGradient u_gradphi_j( dphi_dxi[j][qp], dphi_deta[j][qp] );
242 for(
unsigned int alpha = 0; alpha < manifold_dim; alpha++ )
244 for(
unsigned int beta = 0; beta < manifold_dim; beta++ )
246 const libMesh::Real diag_term = 0.5*this->_h0*jac*tau(alpha,beta)*context.get_elem_solution_derivative()*
247 ( u_gradphi_j(beta)*u_gradphi_i(alpha) +
248 u_gradphi_j(alpha)*u_gradphi_i(beta) );
249 Kuu(i,j) += diag_term;
251 Kvv(i,j) += diag_term;
253 if( this->_disp_vars.dim() == 3 )
254 (*Kww)(i,j) += diag_term;
256 for(
unsigned int lambda = 0; lambda < manifold_dim; lambda++ )
258 for(
unsigned int mu = 0; mu < manifold_dim; mu++ )
260 const libMesh::Real dgamma_du = 0.5*( u_gradphi_j(lambda)*(grad_x(mu)+grad_u(mu)) +
261 (grad_x(lambda)+grad_u(lambda))*u_gradphi_j(mu) );
263 const libMesh::Real dgamma_dv = 0.5*( u_gradphi_j(lambda)*(grad_y(mu)+grad_v(mu)) +
264 (grad_y(lambda)+grad_v(lambda))*u_gradphi_j(mu) );
266 const libMesh::Real C1 = 0.5*this->_h0*jac*C(alpha,beta,lambda,mu)*context.get_elem_solution_derivative();
268 const libMesh::Real x_term = C1*( (grad_x(beta)+grad_u(beta))*u_gradphi_i(alpha) +
269 (grad_x(alpha)+grad_u(alpha))*u_gradphi_i(beta) );
271 const libMesh::Real y_term = C1*( (grad_y(beta)+grad_v(beta))*u_gradphi_i(alpha) +
272 (grad_y(alpha)+grad_v(alpha))*u_gradphi_i(beta) );
274 Kuu(i,j) += x_term*dgamma_du;
276 Kuv(i,j) += x_term*dgamma_dv;
278 Kvu(i,j) += y_term*dgamma_du;
280 Kvv(i,j) += y_term*dgamma_dv;
282 if( this->_disp_vars.dim() == 3 )
284 const libMesh::Real dgamma_dw = 0.5*( u_gradphi_j(lambda)*(grad_z(mu)+grad_w(mu)) +
285 (grad_z(lambda)+grad_w(lambda))*u_gradphi_j(mu) );
287 const libMesh::Real z_term = C1*( (grad_z(beta)+grad_w(beta))*u_gradphi_i(alpha) +
288 (grad_z(alpha)+grad_w(alpha))*u_gradphi_i(beta) );
290 (*Kuw)(i,j) += x_term*dgamma_dw;
292 (*Kvw)(i,j) += y_term*dgamma_dw;
294 (*Kwu)(i,j) += z_term*dgamma_du;
296 (*Kwv)(i,j) += z_term*dgamma_dv;
298 (*Kww)(i,j) += z_term*dgamma_dw;
311 template<
typename StressStrainLaw>
316 if( this->_is_compressible )
318 unsigned int n_qpoints = context.get_element_qrule().n_points();
320 const unsigned int n_u_dofs = context.get_dof_indices(this->_disp_vars.u()).size();
322 const std::vector<libMesh::Real> &JxW = context.get_element_fe(this->_lambda_sq_var)->get_JxW();
324 libMesh::DenseSubVector<libMesh::Number>& Fl = context.get_elem_residual(this->_lambda_sq_var);
326 const std::vector<std::vector<libMesh::Real> >& phi =
327 context.get_element_fe(this->_lambda_sq_var)->get_phi();
329 const unsigned int n_lambda_sq_dofs = context.get_dof_indices(this->_lambda_sq_var).size();
331 const libMesh::DenseSubVector<libMesh::Number>& u_coeffs = context.get_elem_solution( this->_disp_vars.u() );
332 const libMesh::DenseSubVector<libMesh::Number>& v_coeffs = context.get_elem_solution( this->_disp_vars.v() );
333 const libMesh::DenseSubVector<libMesh::Number>* w_coeffs = NULL;
335 if( this->_disp_vars.dim() == 3 )
336 w_coeffs = &context.get_elem_solution( this->_disp_vars.w() );
339 const std::vector<std::vector<libMesh::Real> >& dphi_dxi =
340 this->get_fe(context)->get_dphidxi();
342 const std::vector<std::vector<libMesh::Real> >& dphi_deta =
343 this->get_fe(context)->get_dphideta();
345 for (
unsigned int qp=0; qp != n_qpoints; qp++)
347 libMesh::Real jac = JxW[qp];
349 libMesh::Gradient grad_u, grad_v, grad_w;
350 for(
unsigned int d = 0; d < n_u_dofs; d++ )
352 libMesh::RealGradient u_gradphi( dphi_dxi[d][qp], dphi_deta[d][qp] );
353 grad_u += u_coeffs(d)*u_gradphi;
354 grad_v += v_coeffs(d)*u_gradphi;
356 if( this->_disp_vars.dim() == 3 )
357 grad_w += (*w_coeffs)(d)*u_gradphi;
361 libMesh::Real lambda_sq = 0;
363 this->compute_metric_tensors( qp, *(this->get_fe(context)), context,
364 grad_u, grad_v, grad_w,
365 a_cov, a_contra, A_cov, A_contra,
368 libMesh::Real stress_33 = this->_stress_strain_law.compute_33_stress( a_contra, a_cov, A_contra, A_cov );
370 for (
unsigned int i=0; i != n_lambda_sq_dofs; i++)
371 Fl(i) += stress_33*phi[i][qp]*jac;
373 if( compute_jacobian )
374 libmesh_not_implemented();
379 template<
typename StressStrainLaw>
382 const libMesh::Point& point,
383 libMesh::Real& value )
385 bool is_stress =
false;
386 if( !_stress_indices.empty() )
387 is_stress= ( _stress_indices[0] == quantity_index ||
388 _stress_indices[1] == quantity_index ||
389 _stress_indices[2] == quantity_index ||
390 _stress_indices[3] == quantity_index ||
391 _stress_indices[4] == quantity_index ||
392 _stress_indices[5] == quantity_index ||
393 _stress_indices[6] == quantity_index ||
394 _stress_zz_index == quantity_index );
396 bool is_strain =
false;
397 if( !_strain_indices.empty() )
398 is_strain = ( _strain_indices[0] == quantity_index ||
399 _strain_indices[1] == quantity_index ||
400 _strain_indices[2] == quantity_index );
402 if( is_stress || is_strain )
404 const unsigned int n_u_dofs = context.get_dof_indices(this->_disp_vars.u()).size();
406 const libMesh::DenseSubVector<libMesh::Number>& u_coeffs = context.get_elem_solution( this->_disp_vars.u() );
407 const libMesh::DenseSubVector<libMesh::Number>& v_coeffs = context.get_elem_solution( this->_disp_vars.v() );
408 const libMesh::DenseSubVector<libMesh::Number>* w_coeffs = NULL;
410 if( this->_disp_vars.dim() == 3 )
411 w_coeffs = &context.get_elem_solution( this->_disp_vars.w() );
414 libMesh::UniquePtr<libMesh::FEGenericBase<libMesh::Real> > fe_new =
415 this->build_new_fe( &context.get_elem(), this->get_fe(context),
418 const std::vector<std::vector<libMesh::Real> >& dphi_dxi =
419 fe_new->get_dphidxi();
421 const std::vector<std::vector<libMesh::Real> >& dphi_deta =
422 fe_new->get_dphideta();
425 const std::vector<libMesh::RealGradient>& dxdxi = fe_new->get_dxyzdxi();
426 const std::vector<libMesh::RealGradient>& dxdeta = fe_new->get_dxyzdeta();
429 libMesh::Gradient grad_u, grad_v, grad_w;
430 for(
unsigned int d = 0; d < n_u_dofs; d++ )
432 libMesh::RealGradient u_gradphi( dphi_dxi[d][0], dphi_deta[d][0] );
433 grad_u += u_coeffs(d)*u_gradphi;
434 grad_v += v_coeffs(d)*u_gradphi;
436 if( this->_disp_vars.dim() == 3 )
437 grad_w += (*w_coeffs)(d)*u_gradphi;
440 libMesh::RealGradient grad_x( dxdxi[0](0), dxdeta[0](0) );
441 libMesh::RealGradient grad_y( dxdxi[0](1), dxdeta[0](1) );
442 libMesh::RealGradient grad_z( dxdxi[0](2), dxdeta[0](2) );
445 libMesh::Real lambda_sq = 0;
448 this->compute_metric_tensors(0, *fe_new, context, grad_u, grad_v, grad_w,
449 a_cov, a_contra, A_cov, A_contra, lambda_sq );
454 if( _strain_indices[0] == quantity_index )
456 value = 0.5*(A_cov(0,0) - a_cov(0,0));
458 else if( _strain_indices[1] == quantity_index )
460 value = 0.5*(A_cov(0,1) - a_cov(0,1));
462 else if( _strain_indices[2] == quantity_index )
464 value = 0.5*(A_cov(1,1) - a_cov(1,1));
476 libMesh::Real det_a = a_cov(0,0)*a_cov(1,1) - a_cov(0,1)*a_cov(1,0);
477 libMesh::Real det_A = A_cov(0,0)*A_cov(1,1) - A_cov(0,1)*A_cov(1,0);
479 libMesh::Real I3 = lambda_sq*det_A/det_a;
482 this->_stress_strain_law.compute_stress(2,a_contra,a_cov,A_contra,A_cov,tau);
484 if( _stress_indices[0] == quantity_index )
487 value = tau(0,0)/std::sqrt(I3);
489 else if( _stress_indices[1] == quantity_index )
492 value = tau(0,1)/std::sqrt(I3);
494 else if( _stress_indices[2] == quantity_index )
497 value = tau(1,1)/std::sqrt(I3);
499 else if( _stress_indices[3] == quantity_index )
501 value = 0.5*(tau(0,0) + tau(1,1)) + std::sqrt(0.25*(tau(0,0)-tau(1,1))*(tau(0,0)-tau(1,1))
502 + tau(0,1)*tau(0,1) );
504 else if( _stress_indices[4] == quantity_index ||
505 _stress_indices[5] == quantity_index ||
506 _stress_indices[6] == quantity_index )
508 if(this->_is_compressible)
510 tau(2,2) = this->_stress_strain_law.compute_33_stress( a_contra, a_cov, A_contra, A_cov );
513 libMesh::Real stress_I1 = tau(0,0) + tau(1,1) + tau(2,2);
514 libMesh::Real stress_I2 = 0.5*(stress_I1*stress_I1 - (tau(0,0)*tau(0,0) + tau(1,1)*tau(1,1)
515 + tau(2,2)*tau(2,2) + tau(0,1)*tau(0,1)
516 + tau(1,0)*tau(1,0)) );
518 libMesh::Real stress_I3 = tau(2,2)*( tau(0,0)*tau(1,1) - tau(1,0)*tau(0,1) );
524 libMesh::Real C1 = (stress_I1*stress_I1 - 3*stress_I2);
527 libMesh::Real C2 = (2*stress_I1*stress_I1*stress_I1 - 9*stress_I1*stress_I2 + 27*stress_I3)/54;
529 libMesh::Real theta = std::acos( C2/(2*std::sqrt(C1*C1*C1)) )/3.0;
531 if( _stress_indices[4] == quantity_index )
533 value = (stress_I1 + 2.0*std::sqrt(C1)*std::cos(theta))/3.0;
536 if( _stress_indices[5] == quantity_index )
538 value = (stress_I1 + 2.0*std::sqrt(C1)*std::cos(theta+
Constants::two_pi/3.0))/3.0;
541 if( _stress_indices[6] == quantity_index )
543 value = (stress_I1 + 2.0*std::sqrt(C1)*std::cos(theta+2.0*
Constants::two_pi/3.0))/3.0;
546 else if( _stress_zz_index == quantity_index )
548 value = this->_stress_strain_law.compute_33_stress( a_contra, a_cov, A_contra, A_cov );
unsigned int register_quantity(std::string name)
Register quantity to be postprocessed.
GRINS::ICHandlingBase * _ic_handler
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context)
Time dependent part(s) of physics for element interiors.
Base class for reading and handling initial conditions for physics classes.
static PhysicsName elastic_membrane()
virtual void register_postprocessing_vars(const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
Register postprocessing variables for ElasticMembrane.
virtual void compute_postprocessed_quantity(unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
Compute the registered postprocessed quantities.
const libMesh::Real two_pi
virtual void element_constraint(bool compute_jacobian, AssemblyContext &context)
Constraint part(s) of physics for element interiors.