MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
fe_side_data.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_libmesh_fe_side_data_h__
21 #define __mast_libmesh_fe_side_data_h__
22 
23 // MAST includes
25 #include <mast/fe/libmesh/fe.hpp>
26 
27 
28 namespace MAST {
29 namespace FEBasis {
30 namespace libMeshWrapper {
31 
32 template <uint_t Dim,
33  typename FEBasisType,
34  typename FEDerivativeType>
35 class FESideData {
36 
37 public:
38 
39  // libMesh quadrature and fe types are implemented for real variables only
41  using fe_basis_t = FEBasisType;
42  using fe_shape_deriv_t = FEDerivativeType;
43  using scalar_t = typename FEDerivativeType::scalar_t;
44  static_assert(std::is_same<FEBasisType, MAST::FEBasis::libMeshWrapper::FEBasis<real_t, Dim>>::value,
45  "FEBasisType should be libMeshWrapper::FEBasis.");
47  "Different FEBasisType than that used for instantiation of FEDerivativeType.");
49  "basis_scalar_t for provided FEDerivativeType must be real_t.");
50 
52  _initialized (false),
53  _q (nullptr),
54  _fe_basis (nullptr),
55  _fe_deriv (nullptr)
56  { }
57 
58  virtual ~FESideData() {
59 
60  if (_q) delete _q;
61  if (_fe_basis) delete _fe_basis;
62  if (_fe_deriv) delete _fe_deriv;
63  }
64 
65 
66  inline void init (libMesh::Order q_order,
67  libMesh::QuadratureType q_type,
68  libMesh::Order fe_order,
69  libMesh::FEFamily fe_type) {
70 
71  Assert0(!_initialized, "Object already initialized");
72 
73  _q = new quadrature_t(q_type, q_order);
74  _fe_basis = new fe_basis_t(libMesh::FEType(fe_order, fe_type));
75  _fe_deriv = new FEDerivativeType;
76 
77  _fe_deriv->set_fe_basis(*_fe_basis);
78 
79  _initialized = true;
80  }
81 
82  inline quadrature_t& quadrature() { return *_q;}
83  inline const quadrature_t& quadrature() const { return *_q;}
84 
85  inline fe_basis_t& fe_basis() { return *_fe_basis;}
86  inline const fe_basis_t& fe_basis() const { return *_fe_basis;}
87 
88  inline FEDerivativeType& fe_derivative() { return *_fe_deriv;}
89  inline const FEDerivativeType& fe_derivative() const { return *_fe_deriv;}
90 
91  template <typename ContextType>
92  inline void reinit_for_side(const ContextType& c, uint_t s) {
93 
94  _fe_basis->reinit_for_side(*c.elem, *_q, s);
95  _fe_deriv->reinit_for_side(c, s);
96  }
97 
98 private:
99 
103  FEDerivativeType *_fe_deriv;
104 };
105 
106 } // namespace libMeshWrapper
107 } // namespace FEBasis
108 } // namespace MAST
109 
110 #endif // __mast_libmesh_fe_side_data_h__
void init(libMesh::Order q_order, libMesh::QuadratureType q_type, libMesh::Order fe_order, libMesh::FEFamily fe_type)
const quadrature_t & quadrature() const
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)
void reinit_for_side(const ContextType &c, uint_t s)
typename FEDerivativeType::scalar_t scalar_t
#define Assert0(cond, msg)
Definition: exceptions.hpp:134
typename MAST::Quadrature::libMeshWrapper::Quadrature< real_t, Dim-1 > quadrature_t
unsigned int uint_t
const FEDerivativeType & fe_derivative() const
const fe_basis_t & fe_basis() const
double real_t