GRINS-0.6.0
elastic_membrane_constant_pressure.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 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
29 #include "grins_config.h"
30 #include "grins/assembly_context.h"
31 
32 // libMesh
33 #include "libmesh/getpot.h"
34 #include "libmesh/quadrature.h"
35 #include "libmesh/boundary_info.h"
36 #include "libmesh/fem_system.h"
37 
38 namespace GRINS
39 {
41  : ElasticMembraneBase(physics_name,input),
42  _pressure(0.0)
43  {
44  if( !input.have_variable("Physics/"+physics_name+"/pressure") )
45  {
46  std::cerr << "Error: Must input pressure for "+physics_name+"." << std::endl
47  << " Please set Physics/"+physics_name+"/pressure." << std::endl;
48  libmesh_error();
49  }
50 
51  this->set_parameter
52  (_pressure, input, "Physics/"+physics_name+"/pressure", _pressure );
53  }
54 
56  {
57  return;
58  }
59 
61  AssemblyContext& context,
62  CachedValues& /*cache*/ )
63  {
64  const unsigned int n_u_dofs = context.get_dof_indices(_disp_vars.u_var()).size();
65 
66  const std::vector<libMesh::Real> &JxW =
67  this->get_fe(context)->get_JxW();
68 
69  const std::vector<std::vector<libMesh::Real> >& u_phi =
70  this->get_fe(context)->get_phi();
71 
72  libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(_disp_vars.u_var());
73  libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(_disp_vars.v_var());
74  libMesh::DenseSubVector<libMesh::Number> &Fw = context.get_elem_residual(_disp_vars.w_var());
75 
76  libMesh::DenseSubMatrix<libMesh::Number>& Kuv = context.get_elem_jacobian(_disp_vars.u_var(),_disp_vars.v_var());
77  libMesh::DenseSubMatrix<libMesh::Number>& Kuw = context.get_elem_jacobian(_disp_vars.u_var(),_disp_vars.w_var());
78 
79  libMesh::DenseSubMatrix<libMesh::Number>& Kvu = context.get_elem_jacobian(_disp_vars.v_var(),_disp_vars.u_var());
80  libMesh::DenseSubMatrix<libMesh::Number>& Kvw = context.get_elem_jacobian(_disp_vars.v_var(),_disp_vars.w_var());
81 
82  libMesh::DenseSubMatrix<libMesh::Number>& Kwu = context.get_elem_jacobian(_disp_vars.w_var(),_disp_vars.u_var());
83  libMesh::DenseSubMatrix<libMesh::Number>& Kwv = context.get_elem_jacobian(_disp_vars.w_var(),_disp_vars.v_var());
84 
85  unsigned int n_qpoints = context.get_element_qrule().n_points();
86 
87  // All shape function gradients are w.r.t. master element coordinates
88  const std::vector<std::vector<libMesh::Real> >& dphi_dxi =
89  this->get_fe(context)->get_dphidxi();
90 
91  const std::vector<std::vector<libMesh::Real> >& dphi_deta =
92  this->get_fe(context)->get_dphideta();
93 
94  const libMesh::DenseSubVector<libMesh::Number>& u_coeffs = context.get_elem_solution( _disp_vars.u_var() );
95  const libMesh::DenseSubVector<libMesh::Number>& v_coeffs = context.get_elem_solution( _disp_vars.v_var() );
96  const libMesh::DenseSubVector<libMesh::Number>& w_coeffs = context.get_elem_solution( _disp_vars.w_var() );
97 
98  const std::vector<libMesh::RealGradient>& dxdxi = this->get_fe(context)->get_dxyzdxi();
99  const std::vector<libMesh::RealGradient>& dxdeta = this->get_fe(context)->get_dxyzdeta();
100 
101  for (unsigned int qp=0; qp != n_qpoints; qp++)
102  {
103  // sqrt(det(a_cov)), a_cov being the covariant metric tensor of undeformed body
104  libMesh::Real sqrt_a = sqrt( dxdxi[qp]*dxdxi[qp]*dxdeta[qp]*dxdeta[qp]
105  - dxdxi[qp]*dxdeta[qp]*dxdeta[qp]*dxdxi[qp] );
106 
107  // Gradients are w.r.t. master element coordinates
108  libMesh::Gradient grad_u, grad_v, grad_w;
109  for( unsigned int d = 0; d < n_u_dofs; d++ )
110  {
111  libMesh::RealGradient u_gradphi( dphi_dxi[d][qp], dphi_deta[d][qp] );
112  grad_u += u_coeffs(d)*u_gradphi;
113  grad_v += v_coeffs(d)*u_gradphi;
114  grad_w += w_coeffs(d)*u_gradphi;
115  }
116 
117  libMesh::RealGradient dudxi( grad_u(0), grad_v(0), grad_w(0) );
118  libMesh::RealGradient dudeta( grad_u(1), grad_v(1), grad_w(1) );
119 
120  libMesh::RealGradient A_1 = dxdxi[qp] + dudxi;
121  libMesh::RealGradient A_2 = dxdeta[qp] + dudeta;
122 
123  libMesh::RealGradient A_3 = A_1.cross(A_2);
124 
125  /* The formula here is actually
126  P*\sqrt{\frac{A}{a}}*A_3, where A_3 is a unit vector
127  But, |A_3| = \sqrt{A} so the normalizing part kills
128  the \sqrt{A} in the numerator, so we can leave it out
129  and *not* normalize A_3.
130  */
131  libMesh::RealGradient traction = _pressure/sqrt_a*A_3;
132 
133  libMesh::Real jac = JxW[qp];
134 
135  for (unsigned int i=0; i != n_u_dofs; i++)
136  {
137  Fu(i) += traction(0)*u_phi[i][qp]*jac;
138 
139  Fv(i) += traction(1)*u_phi[i][qp]*jac;
140 
141  Fw(i) += traction(2)*u_phi[i][qp]*jac;
142 
143  if( compute_jacobian )
144  {
145  for (unsigned int j=0; j != n_u_dofs; j++)
146  {
147  libMesh::RealGradient u_gradphi( dphi_dxi[j][qp], dphi_deta[j][qp] );
148 
149  const libMesh::Real dt0_dv = _pressure/sqrt_a*(u_gradphi(0)*A_2(2) - A_1(2)*u_gradphi(1));
150  const libMesh::Real dt0_dw = _pressure/sqrt_a*(A_1(1)*u_gradphi(1) - u_gradphi(0)*A_2(1));
151 
152  const libMesh::Real dt1_du = _pressure/sqrt_a*(A_1(2)*u_gradphi(1) - u_gradphi(0)*A_2(2));
153  const libMesh::Real dt1_dw = _pressure/sqrt_a*(u_gradphi(0)*A_2(0) - A_1(0)*u_gradphi(1));
154 
155  const libMesh::Real dt2_du = _pressure/sqrt_a*(u_gradphi(0)*A_2(1) - A_1(1)*u_gradphi(1));
156  const libMesh::Real dt2_dv = _pressure/sqrt_a*(A_1(0)*u_gradphi(1) - u_gradphi(0)*A_2(0));
157 
158  Kuv(i,j) += dt0_dv*u_phi[i][qp]*jac;
159  Kuw(i,j) += dt0_dw*u_phi[i][qp]*jac;
160 
161  Kvu(i,j) += dt1_du*u_phi[i][qp]*jac;
162  Kvw(i,j) += dt1_dw*u_phi[i][qp]*jac;
163 
164  Kwu(i,j) += dt2_du*u_phi[i][qp]*jac;
165  Kwv(i,j) += dt2_dv*u_phi[i][qp]*jac;
166  }
167  }
168  }
169  }
170 
171  return;
172  }
173 
174  void ElasticMembraneConstantPressure::reset_pressure( libMesh::Real pressure_in )
175  {
176  _pressure = pressure_in;
177  return;
178  }
179 
180 } // end namespace GRINS
virtual void set_parameter(libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
Each subclass can simultaneously read a parameter value from.
SolidMechanicsFEVariables _disp_vars
virtual void element_time_derivative(bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
Time dependent part(s) of physics for element interiors.
GRINS namespace.
std::string PhysicsName
const libMesh::FEGenericBase< libMesh::Real > * get_fe(const AssemblyContext &context)

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1