MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
shell_face_pressure_load.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_shell_face_pressure_load_h__
21 #define __mast_shell_face_pressure_load_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 FEVarType,
32  typename PressureFieldType,
33  typename ContextType>
35 
36 public:
37 
38  using scalar_t = typename FEVarType::scalar_t;
39  using basis_scalar_t = typename FEVarType::fe_shape_deriv_t::scalar_t;
40  using vector_t = typename Eigen::Matrix<scalar_t, Eigen::Dynamic, 1>;
41  using matrix_t = typename Eigen::Matrix<scalar_t, Eigen::Dynamic, Eigen::Dynamic>;
42 
44  _pressure (nullptr),
45  _fe_var_data (nullptr),
46  _displ_index (-1)
47  { }
48 
49  virtual ~ShellFacePressureLoad() { }
50 
51  inline void set_pressure(const PressureFieldType& p) { _pressure = &p;}
52 
66  inline void set_fe_var_data(const FEVarType& fe,
67  const uint_t displ_index) {
68 
69  _fe_var_data = &fe;
70  _displ_index = displ_index;
71  }
72 
73  inline uint_t n_dofs() const {
74 
75  Assert0(_fe_var_data, "FE data not initialized.");
76 
77  return _fe_var_data->get_fe_shape_data().n_basis();
78  }
79 
80  inline void compute(ContextType& c,
81  vector_t& res,
82  matrix_t* jac = nullptr) const {
83 
84  Assert0(_fe_var_data, "FE data not initialized.");
85  Assert0(_pressure, "Pressure not initialized");
86 
87  const typename FEVarType::fe_shape_deriv_t
88  &fe = _fe_var_data->get_fe_shape_data();
89 
90  for (uint_t i=0; i<fe.n_q_points(); i++) {
91 
92  c.qp = i;
93  scalar_t p = _pressure->value(c);
94 
95  for (uint_t k=0; k<fe.n_basis(); k++)
96  res(k) -= fe.detJxW(i) * fe.phi(i, k) * p;
97  }
98  }
99 
100 
101  template <typename ScalarFieldType>
102  inline void derivative(ContextType& c,
103  const ScalarFieldType& f,
104  vector_t& res,
105  matrix_t* jac = nullptr) const {
106 
107  Assert0(_fe_var_data, "FE data not initialized.");
108  Assert0(_pressure, "Pressure not initialized");
109 
110  const typename FEVarType::fe_shape_deriv_t
111  &fe = _fe_var_data->get_fe_shape_data();
112 
113  for (uint_t i=0; i<fe.n_q_points(); i++) {
114 
115  c.qp = i;
116  scalar_t p = _pressure->derivative(c, f);
117 
118  for (uint_t k=0; k<fe.n_basis(); k++)
119  res(k) -= fe.detJxW(i) * fe.phi(i, k) * p;
120  }
121  }
122 
123 private:
124 
125  const PressureFieldType *_pressure;
126  const FEVarType *_fe_var_data;
128 };
129 
130 
131 } // namespace Elasticity
132 } // namespace Physics
133 } // namespace MAST
134 
135 
136 #endif // __mast_shell_face_pressure_load_h__
void set_fe_var_data(const FEVarType &fe, const uint_t displ_index)
This assumes that the face is oriented along the x-axis (+ve or -ve) for a 1D element and in the xy-p...
void compute(ContextType &c, vector_t &res, matrix_t *jac=nullptr) const
void derivative(ContextType &c, const ScalarFieldType &f, vector_t &res, matrix_t *jac=nullptr) const
typename Eigen::Matrix< scalar_t, Eigen::Dynamic, 1 > vector_t
typename Eigen::Matrix< scalar_t, Eigen::Dynamic, Eigen::Dynamic > matrix_t
#define Assert0(cond, msg)
Definition: exceptions.hpp:134
unsigned int uint_t
typename FEVarType::fe_shape_deriv_t::scalar_t basis_scalar_t