GRINS-0.8.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-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  : 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 = NULL;
66  libMesh::DenseSubVector<libMesh::Number> * Fw = NULL;
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 = NULL;
70  libMesh::DenseSubMatrix<libMesh::Number> * Kww = NULL;
71 
72  if( this->_disp_vars.dim() >= 2 )
73  {
74  Fv = &context.get_elem_residual(this->_disp_vars.v());
75  Kvv = &context.get_elem_jacobian(this->_disp_vars.v(),this->_disp_vars.v());
76  }
77 
78  if( this->_disp_vars.dim() == 3 )
79  {
80  Fw = &context.get_elem_residual(this->_disp_vars.w());
81  Kww = &context.get_elem_jacobian(this->_disp_vars.w(),this->_disp_vars.w());
82  }
83 
84  unsigned int n_qpoints = context.get_element_qrule().n_points();
85 
86  for (unsigned int qp=0; qp != n_qpoints; qp++)
87  {
88  libMesh::Real jac = JxW[qp];
89 
90  libMesh::Real u_ddot, v_ddot, w_ddot;
91  (context.*interior_solution)( this->_disp_vars.u(), qp, u_ddot );
92 
93  if( this->_disp_vars.dim() >= 2 )
94  (context.*interior_solution)( this->_disp_vars.v(), qp, v_ddot );
95 
96  if( this->_disp_vars.dim() == 3 )
97  (context.*interior_solution)( this->_disp_vars.w(), qp, w_ddot );
98 
99  for (unsigned int i=0; i != n_u_dofs; i++)
100  {
101  libMesh::Real value = this->_rho*this->_A*u_phi[i][qp]*jac*mu;
102  Fu(i) += value*u_ddot;
103 
104  if( this->_disp_vars.dim() >= 2 )
105  (*Fv)(i) += value*v_ddot;
106 
107  if( this->_disp_vars.dim() == 3 )
108  (*Fw)(i) += value*w_ddot;
109 
110  if( compute_jacobian )
111  {
112  for (unsigned int j=0; j != n_u_dofs; j++)
113  {
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)();
116 
117  Kuu(i,j) += jac_term;
118 
119  if( this->_disp_vars.dim() >= 2 )
120  (*Kvv)(i,j) += jac_term;
121 
122  if( this->_disp_vars.dim() == 3 )
123  (*Kww)(i,j) += jac_term;
124  }
125  }
126  }
127  }
128  }
129 
130  template<typename StressStrainLaw>
132  const libMesh::FEBase& elem,
133  const AssemblyContext& /*context*/,
134  const libMesh::Gradient& grad_u,
135  const libMesh::Gradient& grad_v,
136  const libMesh::Gradient& grad_w,
141  libMesh::Real& lambda_sq )
142  {
143  const std::vector<libMesh::RealGradient>& dxdxi = elem.get_dxyzdxi();
144 
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();
148 
149  libMesh::RealGradient dxi( dxidx[qp], dxidy[qp], dxidz[qp] );
150 
151  libMesh::RealGradient dudxi( grad_u(0), grad_v(0), grad_w(0) );
152 
153  // Covariant metric tensor of reference configuration
154  a_cov.zero();
155  a_cov(0,0) = dxdxi[qp]*dxdxi[qp];
156  a_cov(1,1) = 1.0;
157  a_cov(2,2) = 1.0;
158 
159  // Covariant metric tensor of current configuration
160  A_cov.zero();
161  A_cov(0,0) = (dxdxi[qp] + dudxi)*(dxdxi[qp] + dudxi);
162 
163  // Contravariant metric tensor of reference configuration
164  a_contra.zero();
165  a_contra(0,0) = 1/a_cov(0,0);
166  a_contra(1,1) = 1.0;
167  a_contra(2,2) = 1.0;
168 
169  // Contravariant metric tensor in current configuration is A_cov^{-1}
170  A_contra.zero();
171  A_contra(0,0) = 1/A_cov(0,0);
172 
173  // If the material is compressible, then lambda_sq is an independent variable
174  if( _is_compressible )
175  {
176  libmesh_not_implemented();
177  //lambda_sq = context.interior_value(this->_lambda_sq_var, qp);
178  }
179  else
180  {
181  // If the material is incompressible, lambda^2 is known
182  lambda_sq = a_cov(0,0)/A_cov(0,0);//det_a/det_A;
183  }
184 
185  //Update the covariant and contravariant tensors of current configuration
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;
190  }
191 
192 } // 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 Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1