GRINS-0.8.0
hookes_law_1d.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
26 #include "grins/hookes_law_1d.h"
27 
28 // GRINS
30 #include "grins/common.h"
32 
33 // libMesh
34 #include "libmesh/getpot.h"
35 #include "libmesh/tensor_value.h"
36 
37 namespace GRINS
38 {
39  HookesLaw1D::HookesLaw1D(const GetPot& input)
41  ParameterUser("HookesLaw1D"),
42  _E(0.0),
43  _nu(0.0)
44  {
45  // Warning about this constructor being deprecated
46  {
47  std::string warning = "WARNING: Use of this constructor is DEPRECATED.\n";
48  warning += " Please update to use constructor with input material name.\n";
49  grins_warning(warning);
50  }
51 
52  this->read_input_options(input);
53 
54  return;
55  }
56 
57  HookesLaw1D::HookesLaw1D(const GetPot& input, const std::string& material)
59  ParameterUser("HookesLaw1D"),
60  _E(0.0),
61  _nu(0.0)
62  {
64  "Materials/"+material+"/StressStrainLaw/HookesLaw/lambda",
65  "Physics/HookesLaw/lambda");
67  "Materials/"+material+"/StressStrainLaw/HookesLaw/mu",
68  "Physics/HookesLaw/mu");
70  "Materials/"+material+"/StressStrainLaw/HookesLaw/E",
71  "Physics/HookesLaw/E");
73  "Materials/"+material+"/StressStrainLaw/HookesLaw/nu",
74  "Physics/HookesLaw/nu");
75 
76  // Parse the new version
77  if( input.have_variable("Materials/"+material+"/StressStrainLaw/HookesLaw/lambda") &&
78  input.have_variable("Materials/"+material+"/StressStrainLaw/HookesLaw/mu") )
79  {
80  // FIXME - we'll need a special accessor to give parameter
81  // access to these
82  libMesh::Real lambda = input("Physics/HookesLaw/lambda", 0.0);
83  libMesh::Real mu = input("Physics/HookesLaw/mu", 0.0);
84  _E = mu*(3*lambda + 2*mu)/(lambda+mu);
85  _nu = lambda/(2*(lambda+mu));
86  }
87  else if( input.have_variable("Materials/"+material+"/StressStrainLaw/HookesLaw/E") &&
88  input.have_variable("Materials/"+material+"/StressStrainLaw/HookesLaw/nu") )
89  {
90  this->set_parameter
91  (_E, input, "Materials/"+material+"/StressStrainLaw/HookesLaw/E", 0.0);
92  this->set_parameter
93  (_nu, input, "Materials/"+material+"/StressStrainLaw/HookesLaw/nu", 0.0);
94  }
95  // Parse the old version
96  else if( input.have_variable("Physics/HookesLaw/lambda") &&
97  input.have_variable("Physics/HookesLaw/mu") )
98  {
99  MaterialsParsing::dep_input_warning( "Physics/HookesLaw/lambda",
100  "StressStrainLaw/HookesLaw/lambda" );
101  MaterialsParsing::dep_input_warning( "Physics/HookesLaw/mu",
102  "StressStrainLaw/HookesLaw/mu" );
103 
105  libMesh::Real lambda = input("Physics/HookesLaw/lambda", 0.0);
106  libMesh::Real mu = input("Physics/HookesLaw/mu", 0.0);
107  _E = mu*(3*lambda + 2*mu)/(lambda+mu);
108  _nu = lambda/(2*(lambda+mu));
109  }
110  else if( input.have_variable("Physics/HookesLaw/E") &&
111  input.have_variable("Physics/HookesLaw/nu") )
112  {
113  MaterialsParsing::dep_input_warning( "Physics/HookesLaw/E",
114  "StressStrainLaw/HookesLaw/E" );
115  MaterialsParsing::dep_input_warning( "Physics/HookesLaw/nu",
116  "StressStrainLaw/HookesLaw/nu" );
117 
118  this->set_parameter(_E, input, "Physics/HookesLaw/E", 0.0);
119  this->set_parameter(_nu, input, "Physics/HookesLaw/nu", 0.0);
120  }
121  else
122  {
123  libmesh_error_msg("ERROR: Could not find consistent HookesLaw input!");
124  }
125 
126  // mu should be positive
127  if( _E <= 0.0 )
128  libmesh_error_msg("ERROR: Detected non-positive Young's modulus!");
129 
130  // Technically, Poisson's ratio can be negative, but it's weird. Let's warn about it.
131  if( _nu < 0.0 )
132  {
133  std::string warning = "WARNING: Detected non-positive Poisson's ratio";
134  grins_warning(warning);
135  }
136  }
137 
139  {
140  return;
141  }
142 
143  void HookesLaw1D::read_input_options(const GetPot& input)
144  {
145  // We'd better have either Lam\'{e} constants or E and nu
146  if( ( !input.have_variable("Physics/HookesLaw/lambda") ||
147  !input.have_variable("Physics/HookesLaw/mu") ) &&
148  ( !input.have_variable("Physics/HookesLaw/E") ||
149  !input.have_variable("Physics/HookesLaw/nu") ) )
150  {
151  std::cerr << "Error: Must specify either Lame constants lambda and mu or" << std::endl
152  << " Young's modulus and Poisson's ratio." << std::endl;
153  libmesh_error();
154  }
155 
156  if( input.have_variable("Physics/HookesLaw/lambda") &&
157  input.have_variable("Physics/HookesLaw/mu") )
158  {
159  // FIXME - we'll need a special accessor to give parameter
160  // access to these
161  libMesh::Real lambda = input("Physics/HookesLaw/lambda", 0.0);
162  libMesh::Real mu = input("Physics/HookesLaw/mu", 0.0);
163  _E = mu*(3*lambda + 2*mu)/(lambda+mu);
164  _nu = lambda/(2*(lambda+mu));
165  }
166  else
167  {
168  if( input.have_variable("Physics/HookesLaw/E") )
169  this->set_parameter
170  (_E, input, "Physics/HookesLaw/E", 0.0);
171 
172  if( input.have_variable("Physics/HookesLaw/nu") )
173  this->set_parameter
174  (_nu, input, "Physics/HookesLaw/nu", 0.0);
175  }
176  }
177 
178  void HookesLaw1D::compute_stress_imp( unsigned int /*dim*/,
179  const libMesh::TensorValue<libMesh::Real>& g_contra,
181  const libMesh::TensorValue<libMesh::Real>& /*G_contra*/,
184  {
185  stress.zero();
186 
187  libMesh::Real strain = 0.5*(G_cov(0,0) - g_cov(0,0));
188 
189  stress(0,0) = (this->_E)*g_contra(0,0)*g_contra(0,0)*strain;
190 
191  return;
192  }
193 
195  const libMesh::TensorValue<libMesh::Real>& g_contra,
197  const libMesh::TensorValue<libMesh::Real>& G_contra,
200  ElasticityTensor& C)
201  {
202  this->compute_stress_imp(dim,g_contra,g_cov,G_contra,G_cov,stress);
203 
204  C(0,0,0,0) = this->_E*g_contra(0,0)*g_contra(0,0);
205 
206  return;
207  }
208 
210  const libMesh::TensorValue<libMesh::Real>& /*g_cov*/,
211  const libMesh::TensorValue<libMesh::Real>& /*G_contra*/,
212  const libMesh::TensorValue<libMesh::Real>& /*G_cov*/ )
213  {
214  libmesh_not_implemented();
215 
216  return 0.0;
217  }
218 
219 } // 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.
libMesh::Real _E
Lam\'{e} constant.
Definition: hookes_law_1d.h:85
libMesh::Real _nu
Lam\'{e} constant.
Definition: hookes_law_1d.h:88
#define grins_warning(message)
Definition: common.h:34
GRINS namespace.
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)
Hooke's law specialized for one-dimensional problems.
Definition: hookes_law_1d.h:43
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)
virtual ~HookesLaw1D()
ParameterUser base class. Utility methods for subclasses.
void read_input_options(const GetPot &input)
Parse properties from input.
static void dep_input_warning(const std::string &old_option, const std::string &property)
Helper function for parsing/maintaing backward compatibility.
static void duplicate_input_test(const GetPot &input, const std::string &option1, const std::string &option2)
Helper function for parsing/maintaing backward compatibility.
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)

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1