Plugins
skin_law_impl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015: G-CSC, Goethe University Frankfurt
3  * Author: Andreas Vogel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef SKIN_LAW_IMPL_H_
34 #define SKIN_LAW_IMPL_H_
35 
37 
38 #include "skin_law.h"
39 
40 #define PROFILE_HOOKE
41 #ifdef PROFILE_HOOKE
42  #define HOOKE_PROFILE_FUNC() PROFILE_FUNC_GROUP("Hooke")
43  #define HOOKE_PROFILE_BEGIN(name) PROFILE_BEGIN_GROUP(name, "Hooke")
44  #define HOOKE_PROFILE_END() PROFILE_END()
45 #else
46  #define HOOKE_PROFILE_FUNC()
47  #define HOOKE_PROFILE_BEGIN(name)
48  #define HOOKE_PROFILE_END()
49 #endif
50 
51 namespace ug{
52 namespace SmallStrainMechanics{
53 
54 template <typename TDomain>
55 void
57 init()
58 {
59  // dummy values
60  set_hooke_elasticity_tensor(-10000, -100000);
61 
62  // check, if ElasticityTensor is set
63  if (m_spElastTensorFunct.invalid())
64  UG_THROW("No elasticity tensor set in SkinMaterialLaw::init()!");
65 
66  base_type::m_bInit = true;
67 }
68 
69 template <typename TDomain>
70 inline
71 void
73 strainTensor(MathMatrix<dim,dim>& strainTens, const MathMatrix<dim, dim>& GradU)
74 {
75  for(size_t i = 0; i < (size_t) dim; ++i)
76  for(size_t j = 0; j < (size_t) dim; ++j)
77  strainTens[i][j] = 0.5 * (GradU[i][j] + GradU[j][i]);
78 }
79 
80 
81 template <typename TDomain>
82 void
84 stressTensor(MathMatrix<dim,dim>& stressTens, const size_t ip,
85  const MathVector<dim>& x, const MathMatrix<dim, dim>& GradU)
86 {
87  HOOKE_PROFILE_BEGIN(SkinMaterialLaw_stressTensor);
88 
89  const number y = x[1];
90  number _y = 1.0;
91 
92  if (0.9375 >= y && y > 0.8125) _y = 0.875;
93  else if (0.8125 >= y && y > 0.6875) _y = 0.75;
94  else if (0.6875 >= y && y > 0.5625) _y = 0.625;
95  else if (0.5625 >= y && y > 0.4375) _y = 0.5;
96  else if (0.4375 >= y && y > 0.3125) _y = 0.375;
97  else if (0.3125 >= y && y > 0.1875) _y = 0.25;
98  else if (0.1875 >= y && y > 0.0625) _y = 0.125;
99 
100  if(_y == 1.0) UG_THROW("Position not found: " << y);
101 
102  const number lambda_top = 1.0, lambda_bottom = 2.0;
103  const number mu_top = 0.1, mu_bottom = 0.2;
104 
105  const number mu = mu_bottom * (1.0 - _y) + mu_top * (_y);
106  const number lambda = lambda_bottom * (1.0 - _y) + lambda_top * (_y);
107 
108 
109 /*
110  const number lambda_top = 1.0, lambda_bottom = 2.0;
111  const number mu_top = 0.1, mu_bottom = 0.2;
112 
113  const number mu = mu_bottom * (1.0 - x[1]) + mu_top * (x[1]);
114  const number lambda = lambda_bottom * (1.0 - x[1]) + lambda_top * (x[1]);
115 */
116 
117  // get linearized strain tensor (eps) at ip
118  MathMatrix<dim, dim> strainTens;
119  strainTensor(strainTens, GradU);
120 
121  MatScale(stressTens, 2*mu, strainTens);
122 
123  const number trace = Trace(strainTens);
124  for (int d = 0; d < dim; ++d)
125  stressTens[d][d] += lambda * trace;
126 
127 }
128 
129 template <typename TDomain>
132 elasticityTensor(const size_t ip, const MathVector<dim>& x, const MathMatrix<dim, dim>& GradU)
133 {
134  const number y = x[1];
135  number _y = 1.0;
136 
137  if (0.9375 >= y && y > 0.8125) _y = 0.875;
138  else if (0.8125 >= y && y > 0.6875) _y = 0.75;
139  else if (0.6875 >= y && y > 0.5625) _y = 0.625;
140  else if (0.5625 >= y && y > 0.4375) _y = 0.5;
141  else if (0.4375 >= y && y > 0.3125) _y = 0.375;
142  else if (0.3125 >= y && y > 0.1875) _y = 0.25;
143  else if (0.1875 >= y && y > 0.0625) _y = 0.125;
144 
145  if(_y == 1.0) UG_THROW("Position not found: " << y);
146 
147  const number lambda_top = 1.0, lambda_bottom = 2.0;
148  const number mu_top = 0.1, mu_bottom = 0.2;
149 
150  const number mu = mu_bottom * (1.0 - _y) + mu_top * (_y);
151  const number lambda = lambda_bottom * (1.0 - _y) + lambda_top * (_y);
152 
153  set_hooke_elasticity_tensor(lambda, mu);
154 
155  return m_spElastTensorFunct;
156 }
157 
158 
159 template <typename TDomain>
160 void
163 {
164  if(dim != 2) UG_THROW("Plain Stress Tensor only for 2 dimensions" );
165 
166  MathTensor4<dim,dim,dim,dim> elastTensorFunct;
167 
168  // setze alle wWerte auf 0
169  for (size_t i = 0; i < (size_t) dim; ++i)
170  for (size_t j = 0; j < (size_t) dim; ++j)
171  for (size_t k = 0; k < (size_t) dim; ++k)
172  for (size_t l = 0; l < (size_t) dim; ++l)
173  elastTensorFunct[i][j][k][l] = 0.0;
174 
175  // Tensor mit Werte fuellen
176  // i j k l
177  elastTensorFunct[0][0][0][0] = E/(1-nu*nu); // C11
178  elastTensorFunct[1][1][1][1] = E/(1-nu*nu); // C22
179 
180  elastTensorFunct[0][0][1][1] =
181  elastTensorFunct[1][1][0][0] = (E*nu)/(1-nu*nu); // = C12 = C21
182 
183  elastTensorFunct[0][1][0][1] =
184  elastTensorFunct[1][0][0][1] =
185  elastTensorFunct[0][1][1][0] =
186  elastTensorFunct[1][0][1][0] = E*(1-nu)/(1-nu*nu); // C33
187 
188  // remembering the elasticity tensor
189  SmartPtr<MathTensor4<dim,dim,dim,dim> > spElastTens(new MathTensor4<dim,dim,dim,dim>(elastTensorFunct));
190  m_spElastTensorFunct = spElastTens;
191 
192  std::stringstream ss;
193  ss << "Hooke Elasticity Isotropic (PLAIN STRESS): \n";
194  ss << " young modulus (Elastizitaetsmodul): " << E << "\n";
195  ss << " poisson ratio (Querkontraktionszahl) v: " << nu << "\n";
196  ss << " Elasticity Tensor = " << elastTensorFunct << "\n";
197  m_materialConfiguration = ss.str();
198 }
199 
200 template <typename TDomain>
201 void
204 {
205  if(dim != 2) UG_THROW("Plain Strain Tensor only for 2 dimensions" );
206 
207  set_hooke_elasticity_tensor_E_nu(E, nu);
208 }
209 
210 
211 template <typename TDomain>
212 void
215 {
216  number lambda = (E*nu) / ((1+nu)*(1-2*nu));
217  number mu = E/(2*(1+nu));
218  set_hooke_elasticity_tensor(lambda, mu);
219 }
220 
221 template <typename TDomain>
222 void
224 set_hooke_elasticity_tensor(const number lambda, const number mu)
225 {
226  // sets the 'Hooke'-elasticity tensor for isotropic materials
227  // in 2D this tensor formulation corresponds to the
228  // plane strain assumption for Hookes`s law
229 
230  MathTensor4<dim,dim,dim,dim> elastTensorFunct;
231 
232  // filling the constant elasticity tensor
233  for (size_t i = 0; i < (size_t) dim; ++i)
234  for (size_t j = 0; j < (size_t) dim; ++j)
235  for (size_t k = 0; k < (size_t) dim; ++k)
236  for (size_t l = 0; l < (size_t) dim; ++l)
237  {
238  elastTensorFunct[i][j][k][l] = 0.0;
239 
240  if ((i == j) && (k == l))
241  elastTensorFunct[i][j][k][l] += lambda;
242 
243  if ((i == k) && (j == l))
244  elastTensorFunct[i][j][k][l] += mu;
245 
246  if ((i == l) && (j == k))
247  elastTensorFunct[i][j][k][l] += mu;
248 
249  } //end (l)
250 
251  // remembering the elasticity tensor
252  SmartPtr<MathTensor4<dim,dim,dim,dim> > spElastTens(new MathTensor4<dim,dim,dim,dim>(elastTensorFunct));
253  m_spElastTensorFunct = spElastTens;
254 
255  number E = mu * (3.0 * lambda + 2.0 * mu)/(lambda + mu);
256  number v = 0.5 * lambda/(lambda + mu);
257  number kappa = lambda + 2.0/3.0 * mu;
258 
259  std::stringstream ss;
260  ss << "Hooke Elasticity Isotropic: \n";
261  ss << " Lame`s first constant lambda: " << lambda << "\n";
262  ss << " Lame`s second constant mue (sometimes 'G', shear modulus) (Schubmodul): " << mu << "\n";
263  ss << " This setting equals: \n";
264  ss << " young modulus (Elastizitaetsmodul): " << E << "\n";
265  ss << " poisson ratio (Querkontraktionszahl) v: " << v << "\n";
266  ss << " bulk modulus (Kompressionsmodul): " << kappa << "\n";
267  ss << " Elasticity Tensor = " << elastTensorFunct << "\n";
268  m_materialConfiguration = ss.str();
269 }
270 
271 }// end of namespace SmallStrainMechanics
272 }// end of namespace ug
273 
274 #endif /* SKIN_LAW_IMPL_H_ */
static const int dim
MathMatrix< 1, 1, T >::value_type Trace(const MathMatrix< 1, 1, T > &m)
void MatScale(matrix_t &mOut, typename matrix_t::value_type s, const matrix_t &m)
void init()
Definition: skin_law_impl.h:57
void strainTensor(MathMatrix< dim, dim > &strainTens, const MathMatrix< dim, dim > &GradU)
Definition: skin_law_impl.h:73
void set_hooke_elasticity_tensor(const number lambda, const number mu)
Definition: skin_law_impl.h:224
virtual SmartPtr< MathTensor4< dim, dim, dim, dim > > elasticityTensor()
computes the elasticity tensor; commonly denoted by C
Definition: skin_law.h:113
void set_hooke_elasticity_tensor_plain_strain_E_nu(const number E, const number nu)
Definition: skin_law_impl.h:203
void set_hooke_elasticity_tensor_plain_stress_E_nu(const number E, const number nu)
Definition: skin_law_impl.h:162
void set_hooke_elasticity_tensor_E_nu(const number E, const number nu)
Definition: skin_law_impl.h:214
void stressTensor(MathMatrix< dim, dim > &stressTens, const size_t ip, const MathMatrix< dim, dim > &GradU)
computes the cauchy stress tensor sigma at an integration point 'ip'
Definition: skin_law.h:105
#define UG_THROW(msg)
double number
#define HOOKE_PROFILE_BEGIN(name)
Definition: skin_law_impl.h:43