MAST
timoshenko_bending_operator.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2019 Manav Bhatia
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 
21 // MAST includes
26 #include "mesh/fe_base.h"
27 #include "mesh/geom_elem.h"
28 #include "base/nonlinear_system.h"
29 #include "base/assembly_base.h"
31 
32 
35 MAST::BendingOperator1D(elem),
36 _shear_quadrature_reduction(2)
37 { }
38 
39 
41 
42 
43 void
46  const unsigned int qp,
47  MAST::FEMOperatorMatrix& Bmat_bend_v,
48  MAST::FEMOperatorMatrix& Bmat_bend_w) {
49 
50  this->initialize_bending_strain_operator_for_yz(fe, qp, 1., 1.,
51  Bmat_bend_v,
52  Bmat_bend_w);
53 }
54 
55 
56 
57 
58 void
61  const unsigned int qp,
62  const Real y,
63  const Real z,
64  MAST::FEMOperatorMatrix& Bmat_bend_v,
65  MAST::FEMOperatorMatrix& Bmat_bend_w) {
66 
67  const std::vector<std::vector<libMesh::RealVectorValue> >& dphi = fe.get_dphi();
68  const std::vector<std::vector<Real> >& phi = fe.get_phi();
69 
70  const unsigned int n_phi = (unsigned int)phi.size();
71 
72  RealVectorX phi_vec = RealVectorX::Zero(n_phi);
73 
74  for ( unsigned int i_nd=0; i_nd<n_phi; i_nd++ )
75  phi_vec(i_nd) = dphi[i_nd][qp](0); // dphi/dx
76  phi_vec *= -y;
77  Bmat_bend_v.set_shape_function(0, 5, phi_vec); // v-bending: thetaz
78 
79  for ( unsigned int i_nd=0; i_nd<n_phi; i_nd++ )
80  phi_vec(i_nd) = dphi[i_nd][qp](0); // dphi/dx
81  phi_vec *= z;
82  Bmat_bend_w.set_shape_function(0, 4, phi_vec); // w-bending : thetay
83 }
84 
85 
86 
87 void
90  RealVectorX& local_f,
91  RealMatrixX& local_jac) {
92 
94 
95  // make an fe and quadrature object for the requested order for integrating
96  // transverse shear
97 
98  std::unique_ptr<MAST::FEBase>
99  fe(_elem.init_fe(true, false, -_shear_quadrature_reduction));
100 
101 
102  const std::vector<std::vector<libMesh::RealVectorValue> >& dphi = fe->get_dphi();
103  const std::vector<std::vector<Real> >& phi = fe->get_phi();
104  const std::vector<Real>& JxW = fe->get_JxW();
105  const std::vector<libMesh::Point>& xyz = fe->get_xyz();
106 
107  const unsigned int n_phi = (unsigned int)phi.size(), n2 = 6*n_phi;
108  RealVectorX phi_vec = RealVectorX::Zero(n_phi);
109 
111  vec_n2 = RealVectorX::Zero(n2),
112  vec_2 = RealVectorX::Zero(2);
114  material_trans_shear_mat,
115  mat_n2n2 = RealMatrixX::Zero(n2,n2),
116  mat_2n2 = RealMatrixX::Zero(2,n2);
117 
118 
120  Bmat_trans_v,
121  Bmat_trans_w;
122  Bmat_trans_v.reinit(2, 6, n_phi); // one shear stress for v-bending
123  Bmat_trans_w.reinit(2, 6, n_phi); // one shear stress for w-bending
124 
125  std::unique_ptr<MAST::FieldFunction<RealMatrixX>>
126  mat_stiff = property.transverse_shear_stiffness_matrix(_structural_elem);
127 
128  for (unsigned int qp=0; qp<JxW.size(); qp++) {
129 
130  (*mat_stiff)(xyz[qp],
131  _structural_elem.system().time,
132  material_trans_shear_mat);
133 
135  dphi,
136  JxW,
137  qp,
138  material_trans_shear_mat,
139  Bmat_trans_v,
140  Bmat_trans_w,
141  phi_vec,
142  vec_n2,
143  vec_2,
144  mat_n2n2,
145  mat_2n2,
146  request_jacobian,
147  local_f,
148  local_jac);
149  }
150 }
151 
152 
153 
154 void
157  bool request_jacobian,
158  RealVectorX& local_f,
159  RealMatrixX& local_jac) {
160 
162 
163  // make an fe and quadrature object for the requested order for integrating
164  // transverse shear
165 
166  std::unique_ptr<MAST::FEBase>
167  fe(_elem.init_fe(true, false, -_shear_quadrature_reduction));
168 
169 
170  const std::vector<std::vector<libMesh::RealVectorValue> >& dphi = fe->get_dphi();
171  const std::vector<std::vector<Real> >& phi = fe->get_phi();
172  const std::vector<Real>& JxW = fe->get_JxW();
173  const std::vector<libMesh::Point>& xyz = fe->get_xyz();
174 
175  const unsigned int n_phi = (unsigned int)phi.size(), n2 = 6*n_phi;
176  RealVectorX phi_vec = RealVectorX::Zero(n_phi);
177 
179  vec_n2 = RealVectorX::Zero(n2),
180  vec_2 = RealVectorX::Zero(2);
182  material_trans_shear_mat,
183  mat_n2n2 = RealMatrixX::Zero(n2,n2),
184  mat_2n2 = RealMatrixX::Zero(2,n2);
185 
186 
188  Bmat_trans_v,
189  Bmat_trans_w;
190  Bmat_trans_v.reinit(2, 6, n_phi); // one shear stress for v-bending
191  Bmat_trans_w.reinit(2, 6, n_phi); // one shear stress for w-bending
192 
193  std::unique_ptr<MAST::FieldFunction<RealMatrixX > >
194  mat_stiff = property.transverse_shear_stiffness_matrix(_structural_elem);
195 
196  for (unsigned int qp=0; qp<JxW.size(); qp++) {
197 
198  mat_stiff->derivative(p,
199  xyz[qp],
200  _structural_elem.system().time,
201  material_trans_shear_mat);
202 
204  dphi,
205  JxW,
206  qp,
207  material_trans_shear_mat,
208  Bmat_trans_v,
209  Bmat_trans_w,
210  phi_vec,
211  vec_n2,
212  vec_2,
213  mat_n2n2,
214  mat_2n2,
215  request_jacobian,
216  local_f,
217  local_jac);
218  }
219 }
220 
221 
222 
223 
224 void
226 _transverse_shear_operations(const std::vector<std::vector<Real> >& phi,
227  const std::vector<std::vector<libMesh::RealVectorValue> >& dphi,
228  const std::vector<Real>& JxW,
229  const unsigned int qp,
230  const RealMatrixX& material,
231  FEMOperatorMatrix& Bmat_v,
232  FEMOperatorMatrix& Bmat_w,
233  RealVectorX& phi_vec,
234  RealVectorX& vec_n2,
235  RealVectorX& vec_2,
236  RealMatrixX& mat_n2n2,
237  RealMatrixX& mat_2n2,
238  bool request_jacobian,
239  RealVectorX& local_f,
240  RealMatrixX& local_jac) {
241 
242  // initialize the strain operator
243  for ( unsigned int i_nd=0; i_nd<phi.size(); i_nd++ )
244  phi_vec(i_nd) = dphi[i_nd][qp](0); // dphi/dx
245  Bmat_v.set_shape_function(0, 1, phi_vec); // gamma-xy: v
246  Bmat_w.set_shape_function(0, 2, phi_vec); // gamma-xz : w
247 
248  for ( unsigned int i_nd=0; i_nd<phi.size(); i_nd++ )
249  phi_vec(i_nd) = phi[i_nd][qp]; // phi
250  Bmat_w.set_shape_function(0, 4, phi_vec); // gamma-xz: thetay
251  phi_vec *= -1.0;
252  Bmat_v.set_shape_function(0, 5, phi_vec); // gamma-xy : thetaz
253 
254 
255  // now add the transverse shear component
257  vec_2 = material * vec_2;
258  Bmat_v.vector_mult_transpose(vec_n2, vec_2);
259  local_f += JxW[qp] * vec_n2;
260 
262  vec_2 = material * vec_2;
263  Bmat_w.vector_mult_transpose(vec_n2, vec_2);
264  local_f += JxW[qp] * vec_n2;
265 
266  if (request_jacobian) {
267 
268  // now add the transverse shear component
269  Bmat_v.left_multiply(mat_2n2, material);
270  Bmat_v.right_multiply_transpose(mat_n2n2, mat_2n2);
271  local_jac += JxW[qp] * mat_n2n2;
272 
273  Bmat_w.left_multiply(mat_2n2, material);
274  Bmat_w.right_multiply_transpose(mat_n2n2, mat_2n2);
275  local_jac += JxW[qp] * mat_n2n2;
276  }
277 }
278 
279 
void vector_mult_transpose(T &res, const T &v) const
res = v^T * [this]
TimoshenkoBendingOperator(MAST::StructuralElementBase &elem)
MAST::NonlinearSystem & system()
Definition: elem_base.cpp:45
void reinit(unsigned int n_interpolated_vars, unsigned int n_discrete_vars, unsigned int n_discrete_dofs_per_var)
this initializes the operator for number of rows and variables, assuming that all variables has the s...
const RealVectorX & local_solution(bool if_sens=false) const
void set_shape_function(unsigned int interpolated_var, unsigned int discrete_var, const RealVectorX &shape_func)
sets the shape function values for the block corresponding to interpolated_var and discrete_var...
MAST::StructuralElementBase & _structural_elem
structural element associated with this
libMesh::Real Real
unsigned int _shear_quadrature_reduction
reduction in quadrature for shear energy
void _transverse_shear_operations(const std::vector< std::vector< Real > > &phi, const std::vector< std::vector< libMesh::RealVectorValue > > &dphi, const std::vector< Real > &JxW, const unsigned int qp, const RealMatrixX &material, FEMOperatorMatrix &Bmat_v, FEMOperatorMatrix &Bmat_w, RealVectorX &phi_vec, RealVectorX &vec_n2, RealVectorX &vec_2, RealMatrixX &mat_n2n2, RealMatrixX &mat_2n2, bool request_jacobian, RealVectorX &local_f, RealMatrixX &local_jac)
const MAST::ElementPropertyCardBase & elem_property()
returns a constant reference to the finite element object
Matrix< Real, Dynamic, Dynamic > RealMatrixX
void vector_mult(T &res, const T &v) const
res = [this] * v
virtual void calculate_transverse_shear_residual(bool request_jacobian, RealVectorX &local_f, RealMatrixX &local_jac)
calculate the transverse shear component for the element
Bending strain operator for 1D element.
Matrix< Real, Dynamic, 1 > RealVectorX
virtual void calculate_transverse_shear_residual_sensitivity(const MAST::FunctionBase &p, bool request_jacobian, RealVectorX &local_f, RealMatrixX &local_jac)
calculate the transverse shear component for the element
virtual const std::vector< std::vector< libMesh::RealVectorValue > > & get_dphi() const
Definition: fe_base.cpp:255
void right_multiply_transpose(T &r, const T &m) const
[R] = [this]^T * [M]
virtual void initialize_bending_strain_operator(const MAST::FEBase &fe, const unsigned int qp, MAST::FEMOperatorMatrix &Bmat_v, MAST::FEMOperatorMatrix &Bmat_w)
initialze the bending strain operator for Timoshenko beam element, withouth the y,z-location.
void left_multiply(T &r, const T &m) const
[R] = [M] * [this]
virtual const std::vector< std::vector< Real > > & get_phi() const
Definition: fe_base.cpp:247
const MAST::GeomElem & _elem
element for which bending operator is created
virtual std::unique_ptr< MAST::FEBase > init_fe(bool init_grads, bool init_second_order_derivative, int extra_quadrature_order=0) const
initializes the finite element shape function and quadrature object with the order of quadrature rule...
Definition: geom_elem.cpp:142
virtual void initialize_bending_strain_operator_for_yz(const MAST::FEBase &fe, const unsigned int qp, const Real y, const Real z, MAST::FEMOperatorMatrix &Bmat_bend_v, MAST::FEMOperatorMatrix &Bmat_bend_w)
initializes the bending strain operator for the specified quadrature point and y,z-location.