GRINS-0.7.0
elastic_cable_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-2016 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  : ElasticCableAbstract(physics_name,input),
44  _stress_strain_law(input,MaterialsParsing::material_name(input,PhysicsNaming::elastic_cable())),
45  _is_compressible(is_compressible)
46  {}
47 
48  template<typename StressStrainLaw>
50  AssemblyContext& context,
51  InteriorFuncType interior_solution,
52  VarDerivType get_solution_deriv,
53  libMesh::Real mu )
54  {
55  const unsigned int n_u_dofs = context.get_dof_indices(this->_disp_vars.u()).size();
56 
57  const std::vector<libMesh::Real> &JxW =
58  this->get_fe(context)->get_JxW();
59 
60  const std::vector<std::vector<libMesh::Real> >& u_phi =
61  this->get_fe(context)->get_phi();
62 
63  // Residuals that we're populating
64  libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_disp_vars.u());
65  libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_disp_vars.v());
66  libMesh::DenseSubVector<libMesh::Number> &Fw = context.get_elem_residual(this->_disp_vars.w());
67 
68  libMesh::DenseSubMatrix<libMesh::Number>& Kuu = context.get_elem_jacobian(this->_disp_vars.u(),this->_disp_vars.u());
69  libMesh::DenseSubMatrix<libMesh::Number>& Kvv = context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.v());
70  libMesh::DenseSubMatrix<libMesh::Number>& Kww = context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.w());
71 
72  unsigned int n_qpoints = context.get_element_qrule().n_points();
73 
74  for (unsigned int qp=0; qp != n_qpoints; qp++)
75  {
76  libMesh::Real jac = JxW[qp];
77 
78  libMesh::Real u_ddot, v_ddot, w_ddot;
79  (context.*interior_solution)( this->_disp_vars.u(), qp, u_ddot );
80  (context.*interior_solution)( this->_disp_vars.v(), qp, v_ddot );
81  (context.*interior_solution)( this->_disp_vars.w(), qp, w_ddot );
82 
83  for (unsigned int i=0; i != n_u_dofs; i++)
84  {
85  libMesh::Real value = this->_rho*this->_A*u_phi[i][qp]*jac*mu;
86  Fu(i) += value*u_ddot;
87  Fv(i) += value*v_ddot;
88  Fw(i) += value*w_ddot;
89 
90  if( compute_jacobian )
91  {
92  for (unsigned int j=0; j != n_u_dofs; j++)
93  {
94  libMesh::Real jac_term = mu*this->_rho*this->_A*u_phi[i][qp]*u_phi[j][qp]*jac;
95  jac_term *= (context.*get_solution_deriv)();
96 
97  Kuu(i,j) += jac_term;
98  Kvv(i,j) += jac_term;
99  Kww(i,j) += jac_term;
100  }
101  }
102  }
103  }
104  }
105 
106  template<typename StressStrainLaw>
108  const libMesh::FEBase& elem,
109  const AssemblyContext& /*context*/,
110  const libMesh::Gradient& grad_u,
111  const libMesh::Gradient& grad_v,
112  const libMesh::Gradient& grad_w,
117  libMesh::Real& lambda_sq )
118  {
119  const std::vector<libMesh::RealGradient>& dxdxi = elem.get_dxyzdxi();
120 
121  const std::vector<libMesh::Real>& dxidx = elem.get_dxidx();
122  const std::vector<libMesh::Real>& dxidy = elem.get_dxidy();
123  const std::vector<libMesh::Real>& dxidz = elem.get_dxidz();
124 
125  libMesh::RealGradient dxi( dxidx[qp], dxidy[qp], dxidz[qp] );
126 
127  libMesh::RealGradient dudxi( grad_u(0), grad_v(0), grad_w(0) );
128 
129  // Covariant metric tensor of reference configuration
130  a_cov.zero();
131  a_cov(0,0) = dxdxi[qp]*dxdxi[qp];
132  a_cov(1,1) = 1.0;
133  a_cov(2,2) = 1.0;
134 
135  // Covariant metric tensor of current configuration
136  A_cov.zero();
137  A_cov(0,0) = (dxdxi[qp] + dudxi)*(dxdxi[qp] + dudxi);
138 
139  // Contravariant metric tensor of reference configuration
140  a_contra.zero();
141  a_contra(0,0) = 1/a_cov(0,0);
142  a_contra(1,1) = 1.0;
143  a_contra(2,2) = 1.0;
144 
145  // Contravariant metric tensor in current configuration is A_cov^{-1}
146  A_contra.zero();
147  A_contra(0,0) = 1/A_cov(0,0);
148 
149  // If the material is compressible, then lambda_sq is an independent variable
150  if( _is_compressible )
151  {
152  libmesh_not_implemented();
153  //lambda_sq = context.interior_value(this->_lambda_sq_var, qp);
154  }
155  else
156  {
157  // If the material is incompressible, lambda^2 is known
158  lambda_sq = a_cov(0,0)/A_cov(0,0);//det_a/det_A;
159  }
160 
161  //Update the covariant and contravariant tensors of current configuration
162  A_cov(1,1) = lambda_sq;
163  A_cov(2,2) = lambda_sq;
164  A_contra(1,1) = 1.0/lambda_sq;
165  A_contra(2,2) = 1.0/lambda_sq;
166  }
167 
168 } // end namespace GRINS
GRINS namespace.
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.
std::string PhysicsName

Generated on Thu Jun 2 2016 21:52:27 for GRINS-0.7.0 by  doxygen 1.8.10