linear_elasticity/elasticity_tensor.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 // Header file for objects representing the fourth-rank elasticity tensor
27 // for linear elasticity problems
28 
29 // Include guards to prevent multiple inclusion of the header
30 #ifndef OOMPH_ELASTICITY_TENSOR_HEADER
31 #define OOMPH_ELASTICITY_TENSOR_HEADER
32 
33 // Config header generated by autoconfig
34 #ifdef HAVE_CONFIG_H
35 #include <oomph-lib-config.h>
36 #endif
37 
38 #include "../generic/oomph_utilities.h"
39 
40 namespace oomph
41 {
42  //=====================================================================
53  //=====================================================================
55  {
56  protected:
59  static const unsigned Index[3][3][3][3];
60 
63  virtual inline double independent_component(const unsigned& i) const
64  {
65  return 0.0;
66  }
67 
72  void range_check(const unsigned& i,
73  const unsigned& j,
74  const unsigned& k,
75  const unsigned& l) const
76  {
77  if ((i > 2) || (j > 2) || (k > 2) || (l > 2))
78  {
79  std::ostringstream error_message;
80  if (i > 2)
81  {
82  error_message << "Range Error : Index 1 " << i
83  << " is not in the range (0,2)";
84  }
85  if (j > 2)
86  {
87  error_message << "Range Error : Index 2 " << j
88  << " is not in the range (0,2)";
89  }
90 
91  if (k > 2)
92  {
93  error_message << "Range Error : Index 2 " << k
94  << " is not in the range (0,2)";
95  }
96 
97  if (l > 2)
98  {
99  error_message << "Range Error : Index 4 " << l
100  << " is not in the range (0,2)";
101  }
102 
103  // Throw the error
104  throw OomphLibError(error_message.str(),
107  }
108  }
109 
112 
113  public:
115  virtual ~ElasticityTensor() {}
116 
117  public:
120  double operator()(const unsigned& i,
121  const unsigned& j,
122  const unsigned& k,
123  const unsigned& l) const
124  {
125  // Range check
126 #ifdef PARANOID
127  range_check(i, j, k, l);
128 #endif
129  return independent_component(Index[i][j][k][l]);
130  }
131 
134  virtual void set_value(const unsigned& i,
135  const unsigned& j,
136  const unsigned& k,
137  const unsigned& l,
138  const double& value)
139  {
140  std::stringstream error_stream;
141  error_stream << "Broken base implementation.\n"
142  << "Must be overloaded for specific storage schemes.\n";
143  throw OomphLibError(error_stream.str().c_str(),
146  }
147  };
148 
149 
150  //===================================================================
158  //===================================================================
160  {
161  // Storage for the independent components of the elasticity tensor
162  double C[4];
163 
164  // Translation scheme between the 21 independent components of the general
165  // elasticity tensor and the isotropic case
166  static const unsigned StaticIndex[21];
167 
168  public:
174  IsotropicElasticityTensor(const double& nu, const double& E)
175  : ElasticityTensor()
176  {
177  // Set the three indepdent components
178  C[0] = 0.0;
179  double lambda = E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu));
180  double mu = E / (2.0 * (1.0 + nu));
181  this->set_lame_coefficients(lambda, mu);
182  }
183 
188  {
189  // Set the three indepdent components
190  C[0] = 0.0;
191 
192  // reference value
193  double E = 1.0;
194  double lambda = E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu));
195  double mu = E / (2.0 * (1.0 + nu));
196  this->set_lame_coefficients(lambda, mu);
197  }
198 
203  {
204  // Set the three independent componens
205  C[0] = 0.0;
206  this->set_lame_coefficients(lame[0], lame[1]);
207  }
208 
214  void update_constitutive_parameters(const double& nu, const double& E = 1.0)
215  {
216  // Set the three indepdent components
217  C[0] = 0.0;
218  double lambda = E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu));
219  double mu = E / (2.0 * (1.0 + nu));
220  this->set_lame_coefficients(lambda, mu);
221  }
222 
223 
225  inline double independent_component(const unsigned& i) const
226  {
227  return C[StaticIndex[i]];
228  }
229 
230 
231  private:
232  // Set the values of the lame coefficients
233  void set_lame_coefficients(const double& lambda, const double& mu)
234  {
235  C[1] = lambda + 2.0 * mu;
236  C[2] = lambda;
237  C[3] = mu;
238  }
239  };
240 
241 
242  //========================================================================
245  //===================================================================
247  {
248  // Storage for the independent components of the elasticity tensor
249  double C[21];
250 
251  public:
254  {
255  // Initialise all independent components to zero
256  for (unsigned i = 0; i < 21; i++)
257  {
258  C[i] = 0.0;
259  }
260  }
261 
263  inline double independent_component(const unsigned& i) const
264  {
265  return C[i];
266  }
267 
269  void set_value(const unsigned& i,
270  const unsigned& j,
271  const unsigned& k,
272  const unsigned& l,
273  const double& value)
274  {
275  C[this->Index[i][j][k][l]] = value;
276  }
277  };
278 
279 
280 } // namespace oomph
281 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
cout<< "The eigenvalues of A are:"<< endl<< ces.eigenvalues()<< endl;cout<< "The matrix of eigenvectors, V, is:"<< endl<< ces.eigenvectors()<< endl<< endl;complex< float > lambda
Definition: ComplexEigenSolver_compute.cpp:9
Definition: linear_elasticity/elasticity_tensor.h:55
virtual ~ElasticityTensor()
Empty virtual Destructor.
Definition: linear_elasticity/elasticity_tensor.h:115
double operator()(const unsigned &i, const unsigned &j, const unsigned &k, const unsigned &l) const
Definition: linear_elasticity/elasticity_tensor.h:120
static const unsigned Index[3][3][3][3]
Definition: linear_elasticity/elasticity_tensor.h:59
virtual double independent_component(const unsigned &i) const
Definition: linear_elasticity/elasticity_tensor.h:63
ElasticityTensor()
Empty Constructor.
Definition: linear_elasticity/elasticity_tensor.h:111
virtual void set_value(const unsigned &i, const unsigned &j, const unsigned &k, const unsigned &l, const double &value)
Definition: linear_elasticity/elasticity_tensor.h:134
void range_check(const unsigned &i, const unsigned &j, const unsigned &k, const unsigned &l) const
Definition: linear_elasticity/elasticity_tensor.h:72
Definition: linear_elasticity/elasticity_tensor.h:247
double independent_component(const unsigned &i) const
Overload the independent coefficient function.
Definition: linear_elasticity/elasticity_tensor.h:263
GeneralElasticityTensor()
Empy Constructor.
Definition: linear_elasticity/elasticity_tensor.h:253
void set_value(const unsigned &i, const unsigned &j, const unsigned &k, const unsigned &l, const double &value)
Allow the values to be set.
Definition: linear_elasticity/elasticity_tensor.h:269
Definition: linear_elasticity/elasticity_tensor.h:160
IsotropicElasticityTensor(const double &nu, const double &E)
Definition: linear_elasticity/elasticity_tensor.h:174
IsotropicElasticityTensor(const Vector< double > &lame)
Definition: linear_elasticity/elasticity_tensor.h:202
void set_lame_coefficients(const double &lambda, const double &mu)
Definition: linear_elasticity/elasticity_tensor.h:233
IsotropicElasticityTensor(const double &nu)
Definition: linear_elasticity/elasticity_tensor.h:187
double independent_component(const unsigned &i) const
Overload the independent coefficient function.
Definition: linear_elasticity/elasticity_tensor.h:225
void update_constitutive_parameters(const double &nu, const double &E=1.0)
Definition: linear_elasticity/elasticity_tensor.h:214
static const unsigned StaticIndex[21]
Translation scheme for the isotropic elasticity tensor.
Definition: linear_elasticity/elasticity_tensor.h:166
Definition: matrices.h:74
Definition: oomph_definitions.h:222
char char char int int * k
Definition: level2_impl.h:374
squared absolute value
Definition: GlobalFunctions.h:87
std::complex< double > mu
Definition: time_harmonic_fourier_decomposed_linear_elasticity/cylinder/cylinder.cc:52
double E
Elastic modulus.
Definition: TwenteMeshGluing.cpp:68
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2