MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
green_lagrange_strain.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_green_lagrange_strain_operator_h__
21 #define __mast_green_lagrange_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 
33 
34 template <typename NodalScalarType, typename VarScalarType, typename FEVarType, uint_t Dim>
35 inline
36 typename std::enable_if<Dim == 2, void>::type
37 green_lagrange_strain_operator(const FEVarType& fe_var,
38  const uint_t qp,
39  typename Eigen::Matrix<VarScalarType, 2, 2>& E,
40  typename Eigen::Matrix<VarScalarType, 2, 2>& F,
41  typename Eigen::Matrix<VarScalarType, 3, 1>& epsilon,
42  typename Eigen::Matrix<VarScalarType, 3, 2>& mat_x,
43  typename Eigen::Matrix<VarScalarType, 3, 2>& mat_y,
49 
50 
51  epsilon.setZero();
52  mat_x.setZero();
53  mat_y.setZero();
54 
55  const typename FEVarType::fe_shape_data_type
56  &fe = fe_var.get_fe_shape_object();
57 
58  // make sure all matrices are the right size
59  Assert1(epsilon.size() == 3,
60  epsilon.size(),
61  "Strain vector for 2D continuum strain should be 3.");
62  Assert1(mat_x.rows() == 3,
63  mat_x.rows(),
64  "Incompatible matrix size.");
65  Assert1(mat_x.cols() == 2,
66  mat_x.cols(),
67  "Incompatible matrix size.");
68  Assert1(mat_y.rows() == 3,
69  mat_y.rows(),
70  "Incompatible matrix size.");
71  Assert1(mat_y.cols() == 2,
72  mat_y.cols(),
73  "Incompatible matrix size.");
74 
75  Assert1(Bmat_lin.m() == 3,
76  Bmat_lin.m(),
77  "Strain vector for 2D continuum strain should be 3");
78  Assert2(Bmat_lin.n() == 2*fe.n_basis(),
79  Bmat_lin.n(), 2*fe.n_basis(),
80  "Incompatible Operator size.");
81  Assert1(Bmat_nl_x.m() == 2,
82  Bmat_nl_x.m(),
83  "Incompatible matrix size.");
84  Assert2(Bmat_nl_x.n() == 2*fe.n_basis(),
85  Bmat_nl_x.n(), 2*fe.n_basis(),
86  "Incompatible matrix size.");
87  Assert1(Bmat_nl_y.m() == 2,
88  Bmat_nl_y.m(),
89  "Incompatible matrix size.");
90  Assert2(Bmat_nl_y.n() == 2*fe.n_basis(),
91  Bmat_nl_y.n(), 2*fe.n_basis(),
92  "Incompatible matrix size.");
93  Assert1(F.cols() == 2,
94  F.cols(),
95  "Incompatible matrix size.");
96  Assert1(F.rows() == 2,
97  F.rows(),
98  "Incompatible matrix size.");
99  Assert1(E.cols() == 2,
100  E.cols(),
101  "Incompatible matrix size.");
102  Assert1(E.rows() == 2,
103  E.rows(),
104  "Incompatible matrix size.");
105 
106 
107  // now set the shape function values
108  Bmat_lin.set_shape_function(0, 0, fe.dphi_dx(qp, 0)); // epsilon_xx = du/dx
109  Bmat_lin.set_shape_function(2, 1, fe.dphi_dx(qp, 0)); // gamma_xy = dv/dx + ...
110 
111  // nonlinear strain operator in x
112  Bmat_nl_x.set_shape_function(0, 0, fe.dphi_dx(qp, 0)); // du/dx
113  Bmat_nl_x.set_shape_function(1, 1, fe.dphi_dx(qp, 0)); // dv/dx
114 
115  // nonlinear strain operator in u
116  Bmat_nl_u.set_shape_function(0, 0, fe.dphi_dx(qp, 0)); // du/dx
117  Bmat_nl_v.set_shape_function(0, 1, fe.dphi_dx(qp, 0)); // dv/dx
118 
119  // dN/dy
120  Bmat_lin.set_shape_function(1, 1, fe.dphi_dx(qp, 1)); // epsilon_yy = dv/dy
121  Bmat_lin.set_shape_function(2, 0, fe.dphi_dx(qp, 1)); // gamma_xy = du/dy + ...
122 
123  // nonlinear strain operator in y
124  Bmat_nl_y.set_shape_function(0, 0, fe.dphi_dx(qp, 1)); // du/dy
125  Bmat_nl_y.set_shape_function(1, 1, fe.dphi_dx(qp, 1)); // dv/dy
126 
127  // nonlinear strain operator in v
128  Bmat_nl_u.set_shape_function(1, 0, fe.dphi_dx(qp, 1)); // du/dy
129  Bmat_nl_v.set_shape_function(1, 1, fe.dphi_dx(qp, 1)); // dv/dy
130 
131  // prepare the deformation gradient matrix
132  F.row(0) = fe_var.du_dx(qp, 0);
133  F.row(1) = fe_var.du_dx(qp, 1);
134 
135  // this calculates the Green-Lagrange strain in the reference config
136  E = 0.5*(F + F.transpose() + F.transpose() * F);
137 
138  // now, add this to the strain vector
139  epsilon(0) = E(0,0);
140  epsilon(1) = E(1,1);
141  epsilon(2) = E(0,1) + E(1,0);
142 
143  // now initialize the matrices with strain components
144  // that multiply the Bmat_nl terms
145  mat_x(0, 0) = fe_var.du_dx(qp, 0, 0);
146  mat_x(0, 1) = fe_var.du_dx(qp, 1, 0);
147  mat_x(2, 0) = fe_var.du_dx(qp, 0, 1);
148  mat_x(2, 1) = fe_var.du_dx(qp, 1, 1);
149 
150  mat_y(1, 0) = fe_var.du_dx(qp, 0, 1);
151  mat_y(1, 1) = fe_var.du_dx(qp, 1, 1);
152  mat_y(2, 0) = fe_var.du_dx(qp, 0, 0);
153  mat_y(2, 1) = fe_var.du_dx(qp, 1, 0);
154 }
155 
156 } // namespace Elasticity
157 } // namespace Physics
158 } // namespace MAST
159 
160 
161 #endif // __mast_green_lagrange_strain_operator_h__
#define Assert1(cond, v1, msg)
Definition: exceptions.hpp:143
std::enable_if< Dim==2, void >::type green_lagrange_strain_operator(const FEVarType &fe_var, const uint_t qp, typename Eigen::Matrix< VarScalarType, 2, 2 > &E, typename Eigen::Matrix< VarScalarType, 2, 2 > &F, typename Eigen::Matrix< VarScalarType, 3, 1 > &epsilon, typename Eigen::Matrix< VarScalarType, 3, 2 > &mat_x, typename Eigen::Matrix< VarScalarType, 3, 2 > &mat_y, MAST::Numerics::FEMOperatorMatrix< NodalScalarType > &Bmat_lin, MAST::Numerics::FEMOperatorMatrix< NodalScalarType > &Bmat_nl_x, MAST::Numerics::FEMOperatorMatrix< NodalScalarType > &Bmat_nl_y, MAST::Numerics::FEMOperatorMatrix< NodalScalarType > &Bmat_nl_u, MAST::Numerics::FEMOperatorMatrix< NodalScalarType > &Bmat_nl_v)
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