Nektar++
TimeIntegrationSchemeOperators.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: TimeIntegrationOperators.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Header file of time integration operators class
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME_OPERATORS
36 #define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME_OPERATORS
37 
38 #include <string>
39 
40 #include <boost/core/ignore_unused.hpp>
41 
47 
48 ///////////////////////////////////////////////////////////////////////////////
49 
50 #define LUE LIB_UTILITIES_EXPORT
51 
52 namespace Nektar
53 {
54 namespace LibUtilities
55 {
56 
57 class TimeIntegrationSchemeOperators;
58 
59 typedef std::shared_ptr<TimeIntegrationSchemeOperators>
61 
62 /**
63  * @brief Binds a set of functions for use by time integration schemes.
64  */
66 {
67 public:
70 
71  typedef std::function<void(InArrayType &, OutArrayType &, const NekDouble)>
73  typedef std::function<void(InArrayType &, OutArrayType &, const NekDouble,
74  const NekDouble)>
76 
79 
82 
84  {
85  }
86 
87  template <typename FuncPointerT, typename ObjectPointerT>
88  void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
89  {
90  m_functors1[0] =
91  std::bind(func, obj, std::placeholders::_1, std::placeholders::_2,
92  std::placeholders::_3);
93  }
94 
95  template <typename FuncPointerT, typename ObjectPointerT>
96  void DefineOdeExplicitRhs(FuncPointerT func, ObjectPointerT obj)
97  {
98  m_functors1[1] =
99  std::bind(func, obj, std::placeholders::_1, std::placeholders::_2,
100  std::placeholders::_3);
101  }
102 
103  template <typename FuncPointerT, typename ObjectPointerT>
104  void DefineOdeImplicitRhs(FuncPointerT func, ObjectPointerT obj)
105  {
106  m_functors1[2] =
107  std::bind(func, obj, std::placeholders::_1, std::placeholders::_2,
108  std::placeholders::_3);
109  }
110 
111  template <typename FuncPointerT, typename ObjectPointerT>
112  void DefineProjection(FuncPointerT func, ObjectPointerT obj)
113  {
114  m_functors1[3] =
115  std::bind(func, obj, std::placeholders::_1, std::placeholders::_2,
116  std::placeholders::_3);
117  }
118 
119  template <typename FuncPointerT, typename ObjectPointerT>
120  void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
121  {
122  m_functors2[0] =
123  std::bind(func, obj, std::placeholders::_1, std::placeholders::_2,
124  std::placeholders::_3, std::placeholders::_4);
125  }
126 
127  inline void DoOdeRhs(InArrayType &inarray, OutArrayType &outarray,
128  const NekDouble time) const
129  {
130  ASSERTL1(m_functors1[0], "OdeRhs should be defined for this time "
131  "integration scheme");
132  m_functors1[0](inarray, outarray, time);
133  }
134 
135  inline void DoOdeExplicitRhs(InArrayType &inarray, OutArrayType &outarray,
136  const NekDouble time) const
137  {
138  ASSERTL1(m_functors1[1], "OdeExplicitRhs should be defined for this "
139  "time integration scheme");
140  m_functors1[1](inarray, outarray, time);
141  }
142 
143  inline void DoOdeImplicitRhs(InArrayType &inarray, OutArrayType &outarray,
144  const NekDouble time) const
145  {
146  ASSERTL1(m_functors1[2], "OdeImplictRhs should be defined for this "
147  "time integration scheme");
148  m_functors1[2](inarray, outarray, time);
149  }
150 
151  inline void DoProjection(InArrayType &inarray, OutArrayType &outarray,
152  const NekDouble time) const
153  {
154  ASSERTL1(m_functors1[3], "Projection operation should be defined for "
155  "this time integration scheme");
156  m_functors1[3](inarray, outarray, time);
157  }
158 
159  inline void DoImplicitSolve(InArrayType &inarray, OutArrayType &outarray,
160  const NekDouble time,
161  const NekDouble lambda) const
162  {
163  ASSERTL1(m_functors2[0], "ImplicitSolve should be defined for this "
164  "time integration scheme");
165  m_functors2[0](inarray, outarray, time, lambda);
166  }
167 
168 protected:
171 
172 private:
173 };
174 
175 } // namespace LibUtilities
176 } // namespace Nektar
177 
178 #endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
Binds a set of functions for use by time integration schemes.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
void DefineOdeExplicitRhs(FuncPointerT func, ObjectPointerT obj)
void DoImplicitSolve(InArrayType &inarray, OutArrayType &outarray, const NekDouble time, const NekDouble lambda) const
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
void DoProjection(InArrayType &inarray, OutArrayType &outarray, const NekDouble time) const
void DoOdeExplicitRhs(InArrayType &inarray, OutArrayType &outarray, const NekDouble time) const
const Array< OneD, const Array< OneD, NekDouble > > InArrayType
void DoOdeRhs(InArrayType &inarray, OutArrayType &outarray, const NekDouble time) const
void DefineOdeImplicitRhs(FuncPointerT func, ObjectPointerT obj)
std::function< void(InArrayType &, OutArrayType &, const NekDouble, const NekDouble)> FunctorType2
std::function< void(InArrayType &, OutArrayType &, const NekDouble)> FunctorType1
void DoOdeImplicitRhs(InArrayType &inarray, OutArrayType &outarray, const NekDouble time) const
std::shared_ptr< TimeIntegrationSchemeOperators > TimeIntegrationSchemeOperatorsSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble