MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
linear_elastic_strain_operator.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_linear_elastic_strain_operator_h__
21 #define __mast_linear_elastic_strain_operator_h__
22 
23 // MAST includes
25 #include <mast/base/exceptions.hpp>
27 
28 
29 namespace MAST {
30 namespace Physics {
31 namespace Elasticity {
32 namespace LinearContinuum {
33 
34 template <uint_t D> struct NStrainComponents { };
35 template <> struct NStrainComponents<1> { static const uint_t value = 1; };
36 template <> struct NStrainComponents<2> { static const uint_t value = 3; };
37 template <> struct NStrainComponents<3> { static const uint_t value = 6; };
38 
39 
40 template <typename NodalScalarType, typename VarScalarType, typename FEVarType, uint_t Dim>
41 inline
42 typename std::enable_if<Dim == 2, void>::type
43 strain(const FEVarType& fe_var,
44  const uint_t qp,
45  typename Eigen::Matrix<VarScalarType, 3, 1>& epsilon,
47 
48  epsilon.setZero();
49 
50  const typename FEVarType::fe_shape_deriv_t
51  &fe = fe_var.get_fe_shape_data();
52 
53  // make sure all matrices are the right size
54  Assert1(epsilon.size() == 3,
55  epsilon.size(),
56  "Strain vector for 2D continuum strain should be 3");
57  Assert1(Bmat.m() == 3,
58  Bmat.m(),
59  "Strain vector for 2D continuum strain should be 3");
60  Assert2(Bmat.n() == 2*fe.n_basis(),
61  Bmat.n(), 2*fe.n_basis(),
62  "Incompatible Operator size.");
63 
64 
65  // linear strain operator
66  Bmat.set_shape_function(0, 0, fe.dphi_dx(qp, 0)); // epsilon_xx = du/dx
67  Bmat.set_shape_function(2, 1, fe.dphi_dx(qp, 0)); // gamma_xy = dv/dx + ...
68 
69  // linear strain operator
70  Bmat.set_shape_function(1, 1, fe.dphi_dx(qp, 1)); // epsilon_yy = dv/dy
71  Bmat.set_shape_function(2, 0, fe.dphi_dx(qp, 1)); // gamma_xy = du/dy + ...
72 
73  epsilon(0) = fe_var.du_dx(qp, 0, 0); // du/dx
74  epsilon(1) = fe_var.du_dx(qp, 1, 1); // dv/dy
75  epsilon(2) = fe_var.du_dx(qp, 0, 1) + fe_var.du_dx(qp, 1, 0); // du/dy + dv/dx
76 }
77 
78 
79 
80 template <typename NodalScalarType, typename VarScalarType, typename FEVarType, uint_t Dim>
81 inline
82 typename std::enable_if<Dim == 3, void>::type
83 strain(const FEVarType& fe_var,
84  const uint_t qp,
85  typename Eigen::Matrix<VarScalarType, 6, 1>& epsilon,
87 
88  epsilon.setZero();
89 
90  const typename FEVarType::fe_shape_deriv_t
91  &fe = fe_var.get_fe_shape_data();
92 
93  // make sure all matrices are the right size
94  Assert1(epsilon.size() == 6,
95  epsilon.size(),
96  "Strain vector for 3D continuum strain should be 6");
97  Assert1(Bmat.m() == 6,
98  Bmat.m(),
99  "Strain vector for 3D continuum strain should be 6");
100  Assert2(Bmat.n() == 3*fe.n_basis(),
101  Bmat.n(), 3*fe.n_basis(),
102  "Incompatible Operator size.");
103 
104 
105  // linear strain operator
106  Bmat.set_shape_function(0, 0, fe.dphi_dx(qp, 0)); // epsilon_xx = du/dx
107  Bmat.set_shape_function(3, 1, fe.dphi_dx(qp, 0)); // gamma_xy = dv/dx + ...
108  Bmat.set_shape_function(5, 2, fe.dphi_dx(qp, 0)); // gamma_zx = dw/dx + ...
109 
110  // linear strain operator
111  Bmat.set_shape_function(1, 1, fe.dphi_dx(qp, 1)); // epsilon_yy = dv/dy
112  Bmat.set_shape_function(3, 0, fe.dphi_dx(qp, 1)); // gamma_xy = du/dy + ...
113  Bmat.set_shape_function(4, 2, fe.dphi_dx(qp, 1)); // gamma_yz = dw/dy + ...
114 
115  Bmat.set_shape_function(2, 2, fe.dphi_dx(qp, 2)); // epsilon_zz = dw/dz
116  Bmat.set_shape_function(4, 1, fe.dphi_dx(qp, 2)); // gamma_yz = dv/dz + ...
117  Bmat.set_shape_function(5, 0, fe.dphi_dx(qp, 2)); // gamma_zx = du/dz + ...
118 
119  epsilon(0) = fe_var.du_dx(qp, 0, 0); // du/dx
120  epsilon(1) = fe_var.du_dx(qp, 1, 1); // dv/dy
121  epsilon(2) = fe_var.du_dx(qp, 2, 2); // dv/dy
122  epsilon(3) = fe_var.du_dx(qp, 0, 1) + fe_var.du_dx(qp, 1, 0); // du/dy + dv/dx
123  epsilon(4) = fe_var.du_dx(qp, 1, 2) + fe_var.du_dx(qp, 2, 1); // dv/dz + dw/dy
124  epsilon(5) = fe_var.du_dx(qp, 0, 2) + fe_var.du_dx(qp, 2, 0); // du/dz + dw/dx
125 }
126 
127 } // namespace LinearContinuum
128 } // namespace Elasticity
129 } // namespace Physics
130 } // namespace MAST
131 
132 
133 #endif // __mast_linear_elastic_strain_operator_h__
#define Assert1(cond, v1, msg)
Definition: exceptions.hpp:143
std::enable_if< Dim< 3, ScalarType >::typesource_load_multiplier(const SourceLoadFieldType *f, const SectionAreaType *s, ContextType &c) { Assert0(f, "Invalid pointer");Assert0(s, "Invalid pointer");return f-> value(c) *s -> value(c)
std::enable_if< Dim==2, void >::type strain(const FEVarType &fe_var, const uint_t qp, typename Eigen::Matrix< VarScalarType, 3, 1 > &epsilon, MAST::Numerics::FEMOperatorMatrix< NodalScalarType > &Bmat)
void set_shape_function(uint_t interpolated_var, uint_t discrete_var, const VecType &shape_func)
sets the shape function values for the block corresponding to interpolated_var and discrete_var...
unsigned int uint_t
#define Assert2(cond, v1, v2, msg)
Definition: exceptions.hpp:152