MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
isotropic_stiffness.hpp
Go to the documentation of this file.
1 /*
2 * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3 * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #ifndef __mast_isotropic_material_stiffness_h__
21 #define __mast_isotropic_material_stiffness_h__
22 
23 // MAST includes
25 #include <mast/base/exceptions.hpp>
26 
27 namespace MAST {
28 namespace Physics {
29 namespace Elasticity {
30 
31 template <typename ScalarType>
32 inline ScalarType
33 shear_modulus(ScalarType E, ScalarType nu) { return E/2./(1.+nu);}
34 
35 template <typename ScalarType>
36 inline ScalarType
37 shear_modulus_derivative(ScalarType E, ScalarType nu,
38  ScalarType dE, ScalarType dnu)
39 { return dE/2./(1.+nu) - E/2./pow(1.+nu,2) * dnu;}
40 
41 
42 template <typename ScalarType, uint_t Dim, typename ModulusType, typename PoissonType, typename ContextType>
44 
45 template <typename ScalarType, typename ModulusType, typename PoissonType, typename ContextType>
46 class IsotropicMaterialStiffness<ScalarType, 2, ModulusType, PoissonType, ContextType> {
47 public:
48 
49  using E_scalar_t = typename ModulusType::scalar_t;
50  using nu_scalar_t = typename PoissonType::scalar_t;
52  using value_t = typename Eigen::Matrix<scalar_t, 3, 3>;
53 
55  _E (nullptr),
56  _nu (nullptr) { }
57 
59 
60  inline void set_modulus_and_nu(const ModulusType& E, const PoissonType& nu) {
61 
62  _E = &E;
63  _nu = &nu;
64  }
65 
66 
67  inline const ModulusType& get_E() const {return *_E;}
68 
69  inline const PoissonType& get_nu() const {return *_nu;}
70 
71  inline scalar_t G(ContextType& c) const {
72 
73  return shear_modulus<scalar_t>(_E->value(c), _nu->value(c));
74  }
75 
76  template <typename ScalarFieldType>
77  inline scalar_t G_derivative(ContextType& c, const ScalarFieldType& f) const {
78 
79  return shear_modulus_derivative<scalar_t>(_E->value(c),
80  _nu->value(c),
81  _E->derivative(c, f),
82  _nu->derivative(c, f));
83  }
84 
85  inline void value(ContextType& c, value_t& m) const {
86 
87  Assert0(_E && _nu, "Material values not provided");
88 
89  const E_scalar_t
90  E = _E->value(c);
91  const nu_scalar_t
92  nu = _nu->value(c);
93 
94  m.setZero();
95 
96  m(0, 0) = m(1, 1) = E/(1.-nu*nu);
97  m(0, 1) = m(1, 0) = E*nu/(1.-nu*nu);
98  m(2, 2) = shear_modulus(E, nu);
99  }
100 
101 
102  template <typename ScalarFieldType>
103  inline void derivative(ContextType& c,
104  const ScalarFieldType& f,
105  value_t& m) const {
106 
107  Assert0(_E && _nu, "Material values not provided");
108 
109  const E_scalar_t
110  E = _E->value(c),
111  dEdp = _E->derivative(c, f);
112 
113  const nu_scalar_t
114  nu = _nu->value(c),
115  dnudp = _nu->derivative(c, f);
116 
117  m.setZero();
118 
119  m(0, 0) = m(1, 1) =
120  1./(1.-nu*nu) * dEdp + 2. * E/pow(1.-nu*nu,2) * nu * dnudp;
121 
122  m(0, 1) = m(1, 0) =
123  nu/(1.-nu*nu) * dEdp + (E/(1.-nu*nu) + 2. * E*nu/pow(1.-nu*nu,2) * nu) * dnudp;
124 
125  m(2, 2) = shear_modulus_derivative(E, nu, dEdp, dnudp);
126  }
127 
128 private:
129 
130  const ModulusType* _E;
131  const PoissonType* _nu;
132 };
133 
134 
135 
136 template <typename ScalarType, typename ModulusType, typename PoissonType, typename ContextType>
137 class IsotropicMaterialStiffness<ScalarType, 3, ModulusType, PoissonType, ContextType> {
138 public:
139 
140  using E_scalar_t = typename ModulusType::scalar_t;
141  using nu_scalar_t = typename PoissonType::scalar_t;
143  using value_t = typename Eigen::Matrix<scalar_t, 6, 6>;
144 
146  _E (nullptr),
147  _nu (nullptr) { }
148 
150 
151  inline void set_modulus_and_nu(const ModulusType& E, const PoissonType& nu) {
152 
153  _E = &E;
154  _nu = &nu;
155  }
156 
157  inline void value(const ContextType& c, value_t& m) const {
158 
159  Assert0(_E && _nu, "Material values not provided");
160 
161  const E_scalar_t
162  E = _E->value(c);
163  const nu_scalar_t
164  nu = _nu->value(c);
165 
166  m.setZero();
167 
168  m(0, 0) = m(1, 1) = m(2, 2) = E*(1.-nu)/(1.-nu-2.*nu*nu);
169  m(0, 1) = m(0, 2) = m(1, 0) = m(1, 2) = m(2, 0) = m(2, 1) = E*nu/(1.-nu-2.*nu*nu);
170  m(3, 3) = m(4, 4) = m(5, 5) = shear_modulus(E, nu);
171  }
172 
173 
174  template <typename ScalarFieldType>
175  inline void derivative(const ContextType& c,
176  const ScalarFieldType& f,
177  value_t& m) const {
178 
179  Assert0(_E && _nu, "Material values not provided");
180 
181  const E_scalar_t
182  E = _E->value(c),
183  dEdp = _E->derivative(c, f);
184 
185  const nu_scalar_t
186  nu = _nu->value(c),
187  dnudp = _nu->derivative(c, f);
188 
189  m.setZero();
190 
191  m(0, 0) = m(1, 1) = m(2, 2) =
192  (1.-nu)/(1.-nu-2.*nu*nu) * dEdp +
193  (-E/(1.-nu-2.*nu*nu) + E*(1.-nu)/pow(1.-nu-2.*nu*nu,2)*(1.+4.*nu)) * dnudp ;
194 
195  m(0, 1) = m(0, 2) = m(1, 0) = m(1, 2) = m(2, 0) = m(2, 1) =
196  nu/(1.-nu-2.*nu*nu) * dEdp +
197  (E/(1.-nu-2.*nu*nu) + E*nu/pow(1.-nu-2.*nu*nu,2)*(1.+4.*nu)) * dnudp;
198 
199  m(3, 3) = m(4, 4) = m(5, 5) = shear_modulus_derivative(E, nu, dEdp, dnudp);
200  }
201 
202 private:
203 
204  const ModulusType* _E;
205  const PoissonType* _nu;
206 };
207 
208 
209 } // namespace Elasticity
210 } // namespace Physics
211 } // namespace MAST
212 
213 
214 #endif // __mast_isotropic_material_stiffness_h__
ScalarType shear_modulus(ScalarType E, ScalarType nu)
#define Assert0(cond, msg)
Definition: exceptions.hpp:134
typename MAST::DeducedScalarType< typename MAST::DeducedScalarType< E_scalar_t, nu_scalar_t >::type, ScalarType >::type scalar_t
typename MAST::DeducedScalarType< typename MAST::DeducedScalarType< E_scalar_t, nu_scalar_t >::type, ScalarType >::type scalar_t
ScalarType shear_modulus_derivative(ScalarType E, ScalarType nu, ScalarType dE, ScalarType dnu)