MAST3
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
scalar_field_wrapper.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_scalar_field_wrapper_h__
21 #define __mast_scalar_field_wrapper_h__
22 
23 
24 namespace MAST {
25 namespace FEBasis {
26 
27 template <typename ScalarType, typename FEVarType>
29 
30 public:
31 
33  _fe (nullptr),
34  _fe_derivative (nullptr),
35  _comp (0),
37  {}
38 
39  virtual ~ScalarFieldWrapper() { }
40 
41  inline void
42  set_fe_object_and_component(const FEVarType& fe, uint_t comp) {
43 
44  _fe = &fe;
45  _comp = comp;
46  }
47 
48  inline void
50  uint_t comp) {
51 
52  _fe_derivative = &fe;
53  _comp_derivative = comp;
54  }
55 
56  template <typename ContextType>
57  inline ScalarType value(const ContextType& c) const {
58 
59  Assert0(_fe, "Object not initialized");
60  return _fe->u(c.qp, _comp);
61  }
62 
63  template <typename ContextType, typename ScalarFieldType>
64  inline ScalarType derivative(const ContextType &c,
65  const ScalarFieldType &f) const {
66 
67  Assert0(_fe_derivative, "Object not initialized");
68  return _fe_derivative->u(c.qp, _comp_derivative);
69  }
70 
71 
72 private:
73 
74  const FEVarType * _fe;
75  const FEVarType * _fe_derivative;
76 
79 
80 };
81 
82 } // namespace FEBasis
83 } // namespace MAST
84 
85 #endif // __mast_scalar_field_wrapper_h__
ScalarType derivative(const ContextType &c, const ScalarFieldType &f) const
void set_derivative_fe_object_and_component(const FEVarType &fe, uint_t comp)
ScalarType value(const ContextType &c) const
#define Assert0(cond, msg)
Definition: exceptions.hpp:134
unsigned int uint_t
void set_fe_object_and_component(const FEVarType &fe, uint_t comp)