Nektar++
TimeIntegrationScheme.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TimeIntegrationScheme.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 scheme base class,
32// this class is the parent class for the TimeIntegrationSchemeGLM,
33// TimeIntegrationSchemeFIT, TimeIntegrationSchemeGEM, and
34// TimeIntegrationSchemeSDC classes.
35//
36///////////////////////////////////////////////////////////////////////////////
37
38#ifndef NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME
39#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME
40
41#include <string>
42
43#include <boost/core/ignore_unused.hpp>
44
50
53
54#define LUE LIB_UTILITIES_EXPORT
55
56namespace Nektar
57{
58namespace LibUtilities
59{
60
61/// Datatype of the NekFactory used to instantiate classes derived from the
62/// EquationSystem class.
63typedef NekFactory<std::string, TimeIntegrationScheme, std::string, size_t,
64 std::vector<NekDouble>>
66
67// Allows a code to create a TimeIntegrator. Usually used like this:
68//
69// LibUtilities::TimeIntegrationSchemeSharedPtr timeIntegrationScheme =
70// LibUtilities::GetTimeIntegrationSchemeFactory().CreateInstance(
71// "IMEX", "dirk", 3, std::vector<size_t>{2,3} );
73
74/**
75 * @brief Base class for time integration schemes.
76 */
78{
79public:
80 // Access methods
81 LUE std::string GetFullName() const
82 {
83 return v_GetFullName();
84 }
85 LUE std::string GetName() const
86 {
87 return v_GetName();
88 }
89 LUE std::string GetVariant() const
90 {
91 return v_GetVariant();
92 }
93 LUE size_t GetOrder() const
94 {
95 return v_GetOrder();
96 }
97 LUE std::vector<NekDouble> GetFreeParams()
98 {
99 return v_GetFreeParams();
100 }
102 {
104 }
106 {
107 return v_GetTimeStability();
108 }
110 {
112 }
113
114 /**
115 * \brief Gets the solution vector of the ODE
116 */
118 {
119 return v_GetSolutionVector();
120 }
121
123 {
124 return v_UpdateSolutionVector();
125 }
126
127 /**
128 * \brief Sets the solution vector of the ODE
129 */
130 LUE void SetSolutionVector(const size_t Offset, const DoubleArray &y)
131 {
132 v_SetSolutionVector(Offset, y);
133 }
134
135 // The worker methods
136 /**
137 * \brief Explicit integration of an ODE.
138 *
139 * This function explicitely perfroms a single integration step of the ODE
140 * system:
141 * \f[
142 * \frac{d\boldsymbol{y}}{dt}=\boldsymbol{f}(t,\boldsymbol{y})
143 * \f]
144 *
145 * \param timestep The size of the timestep, i.e. \f$\Delta t\f$.
146 * \param f an object of the class FuncType, where FuncType should have a
147 * method FuncType::ODEforcing
148 * to evaluate the right hand side \f$f(t,\boldsymbol{y})\f$ of the
149 * ODE.
150 * \param y on input: the vectors \f$\boldsymbol{y}^{[n-1]}\f$ and
151 * \f$t^{[n-1]}\f$ (which corresponds to the
152 * solution at the old time level)
153 * \param y on output: the vectors \f$\boldsymbol{y}^{[n]}\f$ and
154 * \f$t^{[n]}\f$ (which corresponds to the
155 * solution at the old new level)
156 * \return The actual solution \f$\boldsymbol{y}^{n}\f$ at the new time
157 * level
158 * (which in fact is also embedded in the argument y).
159 */
161 const NekDouble time,
163 {
164 v_InitializeScheme(deltaT, y_0, time, op);
165 }
166
167 LUE ConstDoubleArray &TimeIntegrate(const size_t timestep,
168 const NekDouble delta_t)
169 {
170 return v_TimeIntegrate(timestep, delta_t);
171 }
172
173 LUE void print(std::ostream &os) const
174 {
175 v_print(os);
176 }
177 LUE void printFull(std::ostream &os) const
178 {
179 v_printFull(os);
180 }
181
182 // Friend classes
183 LUE friend std::ostream &operator<<(std::ostream &os,
184 const TimeIntegrationScheme &rhs);
185 LUE friend std::ostream &operator<<(
186 std::ostream &os, const TimeIntegrationSchemeSharedPtr &rhs);
187
188protected:
189 LUE virtual std::string v_GetFullName() const;
190 LUE virtual std::string v_GetName() const = 0;
191 LUE virtual std::string v_GetVariant() const = 0;
192 LUE virtual size_t v_GetOrder() const = 0;
193 LUE virtual std::vector<NekDouble> v_GetFreeParams() const = 0;
195 const = 0;
196 LUE virtual NekDouble v_GetTimeStability() const = 0;
197 LUE virtual size_t v_GetNumIntegrationPhases() const = 0;
198 LUE virtual const TripleArray &v_GetSolutionVector() const = 0;
200 LUE virtual void v_SetSolutionVector(const size_t Offset,
201 const DoubleArray &y) = 0;
203 const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time,
204 const TimeIntegrationSchemeOperators &op) = 0;
205 LUE virtual ConstDoubleArray &v_TimeIntegrate(const size_t timestep,
206 const NekDouble delta_t) = 0;
207 LUE virtual void v_print(std::ostream &os) const = 0;
208 LUE virtual void v_printFull(std::ostream &os) const = 0;
209
210 // These methods should never be used directly, only used by child classes.
211 LUE TimeIntegrationScheme(std::string variant, size_t order,
212 std::vector<NekDouble> freeParams)
213 {
214 boost::ignore_unused(variant, order, freeParams);
215 }
216
218
220 {
221 }
222
223}; // end class TimeIntegrationScheme
224
225LUE std::ostream &operator<<(std::ostream &os,
226 const TimeIntegrationScheme &rhs);
227LUE std::ostream &operator<<(std::ostream &os,
229
230} // end of namespace LibUtilities
231} // end of namespace Nektar
232
233#endif
#define LUE
Provides a generic Factory class.
Definition: NekFactory.hpp:105
Base class for time integration schemes.
virtual LUE std::string v_GetName() const =0
LUE TimeIntegrationSchemeType GetIntegrationSchemeType()
virtual LUE ConstDoubleArray & v_TimeIntegrate(const size_t timestep, const NekDouble delta_t)=0
virtual LUE std::vector< NekDouble > v_GetFreeParams() const =0
LUE void InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op)
Explicit integration of an ODE.
LUE const TripleArray & GetSolutionVector() const
Gets the solution vector of the ODE.
virtual LUE TimeIntegrationSchemeType v_GetIntegrationSchemeType() const =0
LUE TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
virtual LUE void v_print(std::ostream &os) const =0
virtual LUE std::string v_GetVariant() const =0
virtual LUE void v_printFull(std::ostream &os) const =0
LUE friend std::ostream & operator<<(std::ostream &os, const TimeIntegrationScheme &rhs)
virtual LUE size_t v_GetOrder() const =0
virtual LUE void v_InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op)=0
LUE void printFull(std::ostream &os) const
LUE ConstDoubleArray & TimeIntegrate(const size_t timestep, const NekDouble delta_t)
virtual LUE NekDouble v_GetTimeStability() const =0
LUE TimeIntegrationScheme(const TimeIntegrationScheme &in)=delete
LUE void SetSolutionVector(const size_t Offset, const DoubleArray &y)
Sets the solution vector of the ODE.
virtual LUE size_t v_GetNumIntegrationPhases() const =0
virtual LUE void v_SetSolutionVector(const size_t Offset, const DoubleArray &y)=0
virtual LUE TripleArray & v_UpdateSolutionVector()=0
virtual LUE const TripleArray & v_GetSolutionVector() const =0
LUE std::vector< NekDouble > GetFreeParams()
Binds a set of functions for use by time integration schemes.
TimeIntegrationSchemeFactory & GetTimeIntegrationSchemeFactory()
NekFactory< std::string, TimeIntegrationScheme, std::string, size_t, std::vector< NekDouble > > TimeIntegrationSchemeFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class.
std::ostream & operator<<(std::ostream &os, const BasisKey &rhs)
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble