GRINS-0.6.0
hookes_law.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
26 #include "grins/hookes_law.h"
27 
28 // libMesh
29 #include "libmesh/getpot.h"
30 #include "libmesh/tensor_value.h"
31 
32 namespace GRINS
33 {
34  HookesLaw::HookesLaw(const GetPot& input)
36  ParameterUser("HookesLaw"),
37  _C(),
38  _lambda(0.0),
39  _mu(0.0)
40  {
41  this->read_input_options(input);
42 
43  return;
44  }
45 
47  {
48  return;
49  }
50 
51  void HookesLaw::read_input_options(const GetPot& input)
52  {
53  // We'd better have either Lam\'{e} constants or E and nu
54  if( ( !input.have_variable("Physics/HookesLaw/lambda") ||
55  !input.have_variable("Physics/HookesLaw/mu") ) &&
56  ( !input.have_variable("Physics/HookesLaw/E") ||
57  !input.have_variable("Physics/HookesLaw/nu") ) )
58  {
59  std::cerr << "Error: Must specify either Lame constants lambda and mu or" << std::endl
60  << " Young's modulus and Poisson's ratio." << std::endl;
61  libmesh_error();
62  }
63 
64  if( input.have_variable("Physics/HookesLaw/lambda") )
65  this->set_parameter
66  (_lambda, input, "Physics/HookesLaw/lambda", 0.0);
67 
68  if( input.have_variable("Physics/HookesLaw/mu") )
69  this->set_parameter
70  (_mu, input, "Physics/HookesLaw/mu", 0.0);
71 
72  if( input.have_variable("Physics/HookesLaw/E") &&
73  input.have_variable("Physics/HookesLaw/nu") )
74  {
75  // FIXME - we'll need a special accessor to give parameter
76  // access to these
77  libMesh::Real E = input("Physics/HookesLaw/E", 0.0);
78  libMesh::Real nu = input("Physics/HookesLaw/nu", 0.0);
79  _lambda = nu*E/( (1+nu)*(1-2*nu) );
80  _mu = E/(2*(1+nu));
81  }
82 
83  return;
84  }
85 
86  void HookesLaw::compute_stress_imp( unsigned int dim,
89  const libMesh::TensorValue<libMesh::Real>& /*G_contra*/,
92  {
93  stress.zero();
94 
95  for( unsigned int i = 0; i < dim; i++ )
96  {
97  for( unsigned int j = 0; j < dim; j++ )
98  {
99  for( unsigned int k = 0; k < dim; k++ )
100  {
101  for( unsigned int l = 0; l < dim; l++ )
102  {
103  libMesh::Real strain_kl = 0.5*(G_cov(k,l) - g_cov(k,l));
104 
105  _C(i,j,k,l) = _lambda*g_contra(i,j)*g_contra(k,l) +
106  _mu*(g_contra(i,k)*g_contra(j,l) + g_contra(i,l)*g_contra(j,k));
107 
108  stress(i,j) += _C(i,j,k,l)*strain_kl;
109  }
110  }
111  }
112  }
113 
114  return;
115  }
116 
118  const libMesh::TensorValue<libMesh::Real>& g_contra,
120  const libMesh::TensorValue<libMesh::Real>& G_contra,
123  ElasticityTensor& C)
124  {
125  this->compute_stress_imp(dim,g_contra,g_cov,G_contra,G_cov,stress);
126 
127  C = _C;
128 
129  return;
130  }
131 
134  const libMesh::TensorValue<libMesh::Real>& /*G_contra*/,
136  {
137  libMesh::Real sigma_33 = 0.0;
138 
139  for( unsigned int k = 0; k < 3; k++ )
140  {
141  for( unsigned int l = 0; l < 3; l++ )
142  {
143  libMesh::Real strain_kl = 0.5*(G_cov(k,l) - g_cov(k,l));
144 
145  libMesh::Real C = _lambda*g_contra(2,2)*g_contra(k,l) +
146  _mu*(g_contra(2,k)*g_contra(2,l) + g_contra(2,l)*g_contra(2,k));
147 
148  sigma_33 += C*strain_kl;
149  }
150  }
151 
152  return sigma_33;
153  }
154 
155 } // 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.
void compute_stress_imp(unsigned int dim, const libMesh::TensorValue< libMesh::Real > &g_contra, const libMesh::TensorValue< libMesh::Real > &g_cov, const libMesh::TensorValue< libMesh::Real > &G_contra, const libMesh::TensorValue< libMesh::Real > &G_cov, libMesh::TensorValue< libMesh::Real > &stress)
Definition: hookes_law.C:86
void read_input_options(const GetPot &input)
Parse properties from input.
Definition: hookes_law.C:51
virtual ~HookesLaw()
Definition: hookes_law.C:46
void compute_stress_and_elasticity_imp(unsigned int dim, const libMesh::TensorValue< libMesh::Real > &g_contra, const libMesh::TensorValue< libMesh::Real > &g_cov, const libMesh::TensorValue< libMesh::Real > &G_contra, const libMesh::TensorValue< libMesh::Real > &G_cov, libMesh::TensorValue< libMesh::Real > &stress, ElasticityTensor &C)
Definition: hookes_law.C:117
Elasticity tensor for Hooke's law.
Definition: hookes_law.h:46
GRINS namespace.
ParameterUser base class. Utility methods for subclasses.
libMesh::Real _mu
Lam\'{e} constant.
Definition: hookes_law.h:90
libMesh::Real compute_33_stress_imp(const libMesh::TensorValue< libMesh::Real > &g_contra, const libMesh::TensorValue< libMesh::Real > &g_cov, const libMesh::TensorValue< libMesh::Real > &G_contra, const libMesh::TensorValue< libMesh::Real > &G_cov)
Definition: hookes_law.C:132
libMesh::Real _lambda
Lam\'{e} constant.
Definition: hookes_law.h:87
ElasticityTensor _C
Definition: hookes_law.h:84

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