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
48
51
52#define LUE LIB_UTILITIES_EXPORT
53
55{
56
57/// Datatype of the NekFactory used to instantiate classes derived from the
58/// EquationSystem class.
59typedef NekFactory<std::string, TimeIntegrationScheme, std::string, size_t,
60 std::vector<NekDouble>>
62
63// Allows a code to create a TimeIntegrator. Usually used like this:
64//
65// LibUtilities::TimeIntegrationSchemeSharedPtr timeIntegrationScheme =
66// LibUtilities::GetTimeIntegrationSchemeFactory().CreateInstance(
67// "IMEX", "dirk", 3, std::vector<size_t>{2,3} );
69
70/**
71 * @brief Base class for time integration schemes.
72 */
74{
75public:
76 // Access methods
77 LUE std::string GetFullName() const
78 {
79 return v_GetFullName();
80 }
81 LUE std::string GetName() const
82 {
83 return v_GetName();
84 }
85 LUE std::string GetVariant() const
86 {
87 return v_GetVariant();
88 }
89 LUE size_t GetOrder() const
90 {
91 return v_GetOrder();
92 }
93 LUE std::vector<NekDouble> GetFreeParams()
94 {
95 return v_GetFreeParams();
96 }
98 {
100 }
102 {
103 return v_GetTimeStability();
104 }
106 {
108 }
109
110 /**
111 * \brief Gets the solution vector of the ODE
112 */
114 {
115 return v_GetSolutionVector();
116 }
117
119 {
120 return v_UpdateSolutionVector();
121 }
122
123 /**
124 * \brief Sets the solution vector of the ODE
125 */
126 LUE void SetSolutionVector(const size_t Offset, const DoubleArray &y)
127 {
128 v_SetSolutionVector(Offset, y);
129 }
130
131 // The worker methods
132 /**
133 * \brief Explicit integration of an ODE.
134 *
135 * This function explicitely perfroms a single integration step of the ODE
136 * system:
137 * \f[
138 * \frac{d\boldsymbol{y}}{dt}=\boldsymbol{f}(t,\boldsymbol{y})
139 * \f]
140 *
141 * \param timestep The size of the timestep, i.e. \f$\Delta t\f$.
142 * \param f an object of the class FuncType, where FuncType should have a
143 * method FuncType::ODEforcing
144 * to evaluate the right hand side \f$f(t,\boldsymbol{y})\f$ of the
145 * ODE.
146 * \param y on input: the vectors \f$\boldsymbol{y}^{[n-1]}\f$ and
147 * \f$t^{[n-1]}\f$ (which corresponds to the
148 * solution at the old time level)
149 * \param y on output: the vectors \f$\boldsymbol{y}^{[n]}\f$ and
150 * \f$t^{[n]}\f$ (which corresponds to the
151 * solution at the old new level)
152 * \return The actual solution \f$\boldsymbol{y}^{n}\f$ at the new time
153 * level
154 * (which in fact is also embedded in the argument y).
155 */
157 const NekDouble time,
159 {
160 v_InitializeScheme(deltaT, y_0, time, op);
161 }
162
163 LUE ConstDoubleArray &TimeIntegrate(const size_t timestep,
164 const NekDouble delta_t)
165 {
166 return v_TimeIntegrate(timestep, delta_t);
167 }
168
169 LUE void print(std::ostream &os) const
170 {
171 v_print(os);
172 }
173 LUE void printFull(std::ostream &os) const
174 {
175 v_printFull(os);
176 }
177
178 // Friend classes
179 LUE friend std::ostream &operator<<(std::ostream &os,
180 const TimeIntegrationScheme &rhs);
181 LUE friend std::ostream &operator<<(
182 std::ostream &os, const TimeIntegrationSchemeSharedPtr &rhs);
183
184protected:
185 LUE virtual std::string v_GetFullName() const;
186 LUE virtual std::string v_GetName() const = 0;
187 LUE virtual std::string v_GetVariant() const = 0;
188 LUE virtual size_t v_GetOrder() const = 0;
189 LUE virtual std::vector<NekDouble> v_GetFreeParams() const = 0;
191 const = 0;
192 LUE virtual NekDouble v_GetTimeStability() const = 0;
193 LUE virtual size_t v_GetNumIntegrationPhases() const = 0;
194 LUE virtual const TripleArray &v_GetSolutionVector() const = 0;
196 LUE virtual void v_SetSolutionVector(const size_t Offset,
197 const DoubleArray &y) = 0;
199 const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time,
200 const TimeIntegrationSchemeOperators &op) = 0;
201 LUE virtual ConstDoubleArray &v_TimeIntegrate(const size_t timestep,
202 const NekDouble delta_t) = 0;
203 LUE virtual void v_print(std::ostream &os) const = 0;
204 LUE virtual void v_printFull(std::ostream &os) const = 0;
205
206 // These methods should never be used directly, only used by child classes.
207 LUE TimeIntegrationScheme(std::string variant, size_t order,
208 std::vector<NekDouble> freeParams);
209
211 virtual ~TimeIntegrationScheme() = default;
212
213}; // end class TimeIntegrationScheme
214
215LUE std::ostream &operator<<(std::ostream &os,
216 const TimeIntegrationScheme &rhs);
217LUE std::ostream &operator<<(std::ostream &os,
219
220} // namespace Nektar::LibUtilities
221
222#endif
#define LUE
Provides a generic Factory class.
Definition: NekFactory.hpp:104
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
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 TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
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
double NekDouble