20 #ifndef __mast_linear_continuum_von_mises_stress_h__ 21 #define __mast_linear_continuum_von_mises_stress_h__ 28 namespace Elasticity {
29 namespace LinearContinuum {
32 template <
typename ScalarType, u
int_t Dim>
37 template <
typename ScalarType, u
int_t Dim>
39 MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
44 template <
typename ScalarType, u
int_t Dim,
typename VecType>
46 typename std::enable_if<Dim==2, ScalarType>::type
49 Assert1(stress.size() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
51 "Incorrect stress vector dimension");
54 pow(0.5 * (pow(stress(0)-stress(1),2) +
57 3.0 * (pow(stress(2), 2)), 0.5);
62 template <
typename ScalarType, u
int_t Dim,
typename VecType>
64 typename std::enable_if<Dim==3, ScalarType>::type
67 Assert1(stress.size() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
69 "Incorrect stress vector dimension");
72 pow(0.5 * (pow(stress(0)-stress(1),2) +
73 pow(stress(1)-stress(2),2) +
74 pow(stress(2)-stress(0),2)) +
75 3.0 * (pow(stress(3), 2) +
77 pow(stress(5), 2)), 0.5);
82 template <
typename ScalarType, u
int_t Dim,
typename Vec1Type,
typename Vec2Type>
84 typename std::enable_if<Dim==2, ScalarType>::type
86 const Vec2Type& dstress_dp) {
88 Assert1(stress.size() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
90 "Incorrect stress vector dimension");
91 Assert1(dstress_dp.size() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
93 "Incorrect stress vector dimension");
97 0.5 * (pow(stress(0)-stress(1),2) +
100 3.0 * (pow(stress(2), 2)),
107 (((dstress_dp(0) - dstress_dp(1)) * (stress(0) - stress(1)) +
108 (dstress_dp(1)) * (stress(1)) +
109 (dstress_dp(0)) * (stress(0))) +
110 6.0 * (dstress_dp(2) * stress(2))) * 0.5 * pow(p, -0.5);
118 template <
typename ScalarType, u
int_t Dim,
typename Vec1Type,
typename Vec2Type>
120 typename std::enable_if<Dim==3, ScalarType>::type
122 const Vec2Type& dstress_dp) {
124 Assert1(stress.size() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
126 "Incorrect stress vector dimension");
127 Assert1(dstress_dp.size() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
129 "Incorrect stress vector dimension");
133 0.5 * (pow(stress(0)-stress(1),2) +
134 pow(stress(1)-stress(2),2) +
135 pow(stress(2)-stress(0),2)) +
136 3.0 * (pow(stress(3), 2) +
145 (((dstress_dp(0) - dstress_dp(1)) * (stress(0) - stress(1)) +
146 (dstress_dp(1) - dstress_dp(2)) * (stress(1) - stress(2)) +
147 (dstress_dp(2) - dstress_dp(0)) * (stress(2) - stress(0))) +
148 6.0 * (dstress_dp(3) * stress(3)+
149 dstress_dp(4) * stress(4)+
150 dstress_dp(5) * stress(5))) * 0.5 * pow(p, -0.5);
157 template <
typename ScalarType,
162 typename std::enable_if<Dim==2, void>::type
164 const AdjMatType &dstress_dX,
165 Eigen::Matrix<ScalarType, Eigen::Dynamic, 1> &vm_adjoint) {
167 Assert1(stress.size() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
169 "Incorrect stress vector dimension");
170 Assert1(dstress_dX.rows() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
172 "Incorrect stress adjoint matrix rows");
173 Assert2(vm_adjoint.size() == dstress_dX.cols(),
174 vm_adjoint.size(), dstress_dX.cols(),
175 "Incorrect von Mises adjoint vector dimension");
179 0.5 * (pow(stress(0)-stress(1),2) +
182 3.0 * (pow(stress(2), 2));
189 (((dstress_dX.row(0) - dstress_dX.row(1)) * (stress(0) - stress(1)) +
190 dstress_dX.row(1) * stress(1) +
191 dstress_dX.row(0) * stress(0)) +
192 6.0 * dstress_dX.row(2) * stress(2)) * 0.5 * pow(p, -0.5);
197 template <
typename ScalarType,
202 typename std::enable_if<Dim==3, void>::type
204 const AdjMatType &dstress_dX,
205 Eigen::Matrix<ScalarType, Eigen::Dynamic, 1> &vm_adjoint) {
207 Assert1(stress.size() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
209 "Incorrect stress vector dimension");
210 Assert1(dstress_dX.rows() == MAST::Physics::Elasticity::LinearContinuum::NStrainComponents<Dim>::value,
212 "Incorrect stress adjoint matrix rows");
213 Assert2(vm_adjoint.size() == dstress_dX.cols(),
214 vm_adjoint.size(), dstress_dX.cols(),
215 "Incorrect von Mises adjoint vector dimension");
219 0.5 * (pow(stress(0)-stress(1),2) +
220 pow(stress(1)-stress(2),2) +
221 pow(stress(2)-stress(0),2)) +
222 3.0 * (pow(stress(3), 2) +
231 (((dstress_dX.row(0) - dstress_dX.row(1)) * (stress(0) - stress(1)) +
232 (dstress_dX.row(1) - dstress_dX.row(2)) * (stress(1) - stress(2)) +
233 (dstress_dX.row(2) - dstress_dX.row(0)) * (stress(2) - stress(0))) +
234 6.0 * (dstress_dX.row(3) * stress(3)+
235 dstress_dX.row(4) * stress(4)+
236 dstress_dX.row(5) * stress(5))) * 0.5 * pow(p, -0.5);
245 #endif // __mast_linear_continuum_von_mises_stress_h__ Eigen::Matrix< ScalarType, MAST::Physics::Elasticity::LinearContinuum::NStrainComponents< Dim >::value, Eigen::Dynamic > stress_adjoint_mat_t
#define Assert1(cond, v1, msg)
std::enable_if< Dim==2, ScalarType >::type vonMises_stress(const VecType &stress)
std::enable_if< Dim==2, ScalarType >::type vonMises_stress_derivative(const Vec1Type &stress, const Vec2Type &dstress_dp)
#define Assert2(cond, v1, v2, msg)
Eigen::Matrix< ScalarType, MAST::Physics::Elasticity::LinearContinuum::NStrainComponents< Dim >::value, 1 > stress_vec_t
std::enable_if< Dim==2, void >::type vonMises_stress_dX(const VecType &stress, const AdjMatType &dstress_dX, Eigen::Matrix< ScalarType, Eigen::Dynamic, 1 > &vm_adjoint)