Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
Nektar::LibUtilities::DIRKTimeIntegrationScheme Class Reference

#include <DIRKTimeIntegrationSchemes.h>

Inheritance diagram for Nektar::LibUtilities::DIRKTimeIntegrationScheme:
[legend]

Public Member Functions

 DIRKTimeIntegrationScheme (std::string variant, size_t order, std::vector< NekDouble > freeParams)
 
 ~DIRKTimeIntegrationScheme () override
 
- Public Member Functions inherited from Nektar::LibUtilities::TimeIntegrationSchemeGLM
LUE void InitializeSecondaryData (TimeIntegrationAlgorithmGLM *phase, NekDouble deltaT) const
 
- Public Member Functions inherited from Nektar::LibUtilities::TimeIntegrationScheme
LUE std::string GetFullName () const
 
LUE std::string GetName () const
 
LUE std::string GetVariant () const
 
LUE size_t GetOrder () const
 
LUE std::vector< NekDoubleGetFreeParams ()
 
LUE TimeIntegrationSchemeType GetIntegrationSchemeType ()
 
LUE NekDouble GetTimeStability () const
 
LUE size_t GetNumIntegrationPhases ()
 
LUE const TripleArrayGetSolutionVector () const
 Gets the solution vector of the ODE. More...
 
LUE TripleArrayUpdateSolutionVector ()
 
LUE void SetSolutionVector (const size_t Offset, const DoubleArray &y)
 Sets the solution vector of the ODE. More...
 
LUE void InitializeScheme (const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op)
 Explicit integration of an ODE. More...
 
LUE ConstDoubleArrayTimeIntegrate (const size_t timestep, const NekDouble delta_t)
 
LUE void print (std::ostream &os) const
 
LUE void printFull (std::ostream &os) const
 

Static Public Member Functions

static TimeIntegrationSchemeSharedPtr create (std::string variant, size_t order, std::vector< NekDouble > freeParams)
 
static LUE void SetupSchemeData (TimeIntegrationAlgorithmGLMSharedPtr &phase, size_t order)
 
static LUE void SetupSchemeDataESDIRK (TimeIntegrationAlgorithmGLMSharedPtr &phase, std::string variant, size_t order, std::vector< NekDouble > freeParams)
 

Static Public Attributes

static std::string className
 

Protected Member Functions

LUE std::string v_GetName () const override
 
LUE NekDouble v_GetTimeStability () const override
 
- Protected Member Functions inherited from Nektar::LibUtilities::TimeIntegrationSchemeGLM
LUE std::string v_GetVariant () const override
 
LUE size_t v_GetOrder () const override
 
LUE std::vector< NekDoublev_GetFreeParams () const override
 
LUE TimeIntegrationSchemeType v_GetIntegrationSchemeType () const override
 
LUE size_t v_GetNumIntegrationPhases () const override
 
LUE const TripleArrayv_GetSolutionVector () const override
 
LUE TripleArrayv_UpdateSolutionVector () override
 
LUE void v_SetSolutionVector (const size_t Offset, const DoubleArray &y) override
 
LUE void v_InitializeScheme (const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op) override
 Worker method to initialize the integration scheme. More...
 
LUE ConstDoubleArrayv_TimeIntegrate (const size_t timestep, const NekDouble delta_t) override
 Worker method that actually does the time integration. More...
 
virtual LUE void v_InitializeSecondaryData (TimeIntegrationAlgorithmGLM *phase, NekDouble deltaT) const
 
LUE void v_print (std::ostream &os) const override
 Worker method to print details on the integration scheme. More...
 
LUE void v_printFull (std::ostream &os) const override
 
LUE TimeIntegrationSchemeGLM (std::string variant, size_t order, std::vector< NekDouble > freeParams)
 
 ~TimeIntegrationSchemeGLM () override
 
- Protected Member Functions inherited from Nektar::LibUtilities::TimeIntegrationScheme
virtual LUE std::string v_GetFullName () const
 
virtual LUE std::string v_GetName () const =0
 
virtual LUE std::string v_GetVariant () const =0
 
virtual LUE size_t v_GetOrder () const =0
 
virtual LUE std::vector< NekDoublev_GetFreeParams () const =0
 
virtual LUE TimeIntegrationSchemeType v_GetIntegrationSchemeType () const =0
 
virtual LUE NekDouble v_GetTimeStability () const =0
 
virtual LUE size_t v_GetNumIntegrationPhases () const =0
 
virtual LUE const TripleArrayv_GetSolutionVector () const =0
 
virtual LUE TripleArrayv_UpdateSolutionVector ()=0
 
virtual LUE void v_SetSolutionVector (const size_t Offset, const DoubleArray &y)=0
 
virtual LUE void v_InitializeScheme (const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op)=0
 
virtual LUE ConstDoubleArrayv_TimeIntegrate (const size_t timestep, const NekDouble delta_t)=0
 
virtual LUE void v_print (std::ostream &os) const =0
 
virtual LUE void v_printFull (std::ostream &os) const =0
 
LUE TimeIntegrationScheme (std::string variant, size_t order, std::vector< NekDouble > freeParams)
 
LUE TimeIntegrationScheme (const TimeIntegrationScheme &in)=delete
 
virtual ~TimeIntegrationScheme ()=default
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::LibUtilities::TimeIntegrationSchemeGLM
TimeIntegrationAlgorithmGLMVector m_integration_phases
 
TimeIntegrationSolutionGLMSharedPtr m_solVector
 

Detailed Description

Definition at line 53 of file DIRKTimeIntegrationSchemes.h.

Constructor & Destructor Documentation

◆ DIRKTimeIntegrationScheme()

Nektar::LibUtilities::DIRKTimeIntegrationScheme::DIRKTimeIntegrationScheme ( std::string  variant,
size_t  order,
std::vector< NekDouble freeParams 
)
inline

Definition at line 56 of file DIRKTimeIntegrationSchemes.h.

58 : TimeIntegrationSchemeGLM(variant, order, freeParams)
59 {
60 // Currently up to 4th order is implemented.
61 ASSERTL0(1 <= order && order <= 4,
62 "Diagonally Implicit Runge Kutta integration scheme bad order "
63 "(1-4): " +
64 std::to_string(order));
65
68 new TimeIntegrationAlgorithmGLM(this));
69
70 ASSERTL1((variant == "" || variant == "ES5" || variant == "ES6"),
71 "DIRK Time integration scheme bad variant: " + variant +
72 ". "
73 "Must blank, 'ES5', or 'ES6'");
74
75 if ("" == variant)
76 {
78 order);
79 }
80 else
81 {
83 m_integration_phases[0], variant, order, freeParams);
84 }
85 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
static LUE void SetupSchemeDataESDIRK(TimeIntegrationAlgorithmGLMSharedPtr &phase, std::string variant, size_t order, std::vector< NekDouble > freeParams)
static LUE void SetupSchemeData(TimeIntegrationAlgorithmGLMSharedPtr &phase, size_t order)
TimeIntegrationAlgorithmGLMVector m_integration_phases
LUE TimeIntegrationSchemeGLM(std::string variant, size_t order, std::vector< NekDouble > freeParams)
std::shared_ptr< TimeIntegrationAlgorithmGLM > TimeIntegrationAlgorithmGLMSharedPtr
std::vector< TimeIntegrationAlgorithmGLMSharedPtr > TimeIntegrationAlgorithmGLMVector

References ASSERTL0, ASSERTL1, Nektar::LibUtilities::TimeIntegrationSchemeGLM::m_integration_phases, SetupSchemeData(), and SetupSchemeDataESDIRK().

◆ ~DIRKTimeIntegrationScheme()

Nektar::LibUtilities::DIRKTimeIntegrationScheme::~DIRKTimeIntegrationScheme ( )
inlineoverride

Definition at line 87 of file DIRKTimeIntegrationSchemes.h.

88 {
89 }

Member Function Documentation

◆ create()

static TimeIntegrationSchemeSharedPtr Nektar::LibUtilities::DIRKTimeIntegrationScheme::create ( std::string  variant,
size_t  order,
std::vector< NekDouble freeParams 
)
inlinestatic

Definition at line 91 of file DIRKTimeIntegrationSchemes.h.

93 {
96 variant, order, freeParams);
97 return p;
98 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.

◆ SetupSchemeData()

static LUE void Nektar::LibUtilities::DIRKTimeIntegrationScheme::SetupSchemeData ( TimeIntegrationAlgorithmGLMSharedPtr phase,
size_t  order 
)
inlinestatic

Definition at line 102 of file DIRKTimeIntegrationSchemes.h.

104 {
105 phase->m_schemeType = eDiagonallyImplicit;
106 phase->m_order = order;
107 phase->m_name =
108 std::string("DIRKOrder" + std::to_string(phase->m_order));
109
110 phase->m_numsteps = 1;
111 phase->m_numstages = phase->m_order;
112
113 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
114 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
115
116 phase->m_A[0] =
117 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
118 phase->m_B[0] =
119 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
120 phase->m_U =
121 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
122 phase->m_V =
123 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
124
125 switch (phase->m_order)
126 {
127 case 1:
128 {
129 // One-stage, 1st order, L-stable Diagonally Implicit
130 // Runge Kutta (backward Euler) method:
131
132 phase->m_A[0][0][0] = 1.0;
133
134 phase->m_B[0][0][0] = 1.0;
135 }
136 break;
137 case 2:
138 {
139 // Two-stage, 2nd order Diagonally Implicit Runge
140 // Kutta method. It is A-stable if and only if x ≥ 1/4
141 // and is L-stable if and only if x equals one of the
142 // roots of the polynomial x^2 - 2x + 1/2, i.e. if
143 // x = 1 ± sqrt(2)/2.
144 const NekDouble lambda = (2.0 - sqrt(2.0)) / 2.0;
145
146 phase->m_A[0][0][0] = lambda;
147 phase->m_A[0][1][0] = 1.0 - lambda;
148 phase->m_A[0][1][1] = lambda;
149
150 phase->m_B[0][0][0] = 1.0 - lambda;
151 phase->m_B[0][0][1] = lambda;
152 }
153 break;
154
155 case 3:
156 {
157 // Three-stage, 3rd order, L-stable Diagonally Implicit
158 // Runge Kutta method:
159 constexpr NekDouble lambda = 0.4358665215;
160
161 phase->m_A[0][0][0] = lambda;
162 phase->m_A[0][1][0] = 0.5 * (1.0 - lambda);
163 phase->m_A[0][2][0] =
164 0.25 * (-6.0 * lambda * lambda + 16.0 * lambda - 1.0);
165
166 phase->m_A[0][1][1] = lambda;
167
168 phase->m_A[0][2][1] =
169 0.25 * (6.0 * lambda * lambda - 20.0 * lambda + 5.0);
170 phase->m_A[0][2][2] = lambda;
171
172 phase->m_B[0][0][0] =
173 0.25 * (-6.0 * lambda * lambda + 16.0 * lambda - 1.0);
174 phase->m_B[0][0][1] =
175 0.25 * (6.0 * lambda * lambda - 20.0 * lambda + 5.0);
176 phase->m_B[0][0][2] = lambda;
177 }
178 break;
179 }
180
181 phase->m_numMultiStepValues = 1;
182 phase->m_numMultiStepImplicitDerivs = 0;
183 phase->m_numMultiStepExplicitDerivs = 0;
184 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
185 phase->m_timeLevelOffset[0] = 0;
186
187 phase->CheckAndVerify();
188 }
@ eDiagonallyImplicit
Diagonally implicit scheme (e.g. the DIRK schemes)
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294

References Nektar::LibUtilities::eDiagonallyImplicit, and tinysimd::sqrt().

Referenced by Nektar::LibUtilities::AdamsMoultonTimeIntegrationScheme::AdamsMoultonTimeIntegrationScheme(), Nektar::LibUtilities::BDFImplicitTimeIntegrationScheme::BDFImplicitTimeIntegrationScheme(), and DIRKTimeIntegrationScheme().

◆ SetupSchemeDataESDIRK()

static LUE void Nektar::LibUtilities::DIRKTimeIntegrationScheme::SetupSchemeDataESDIRK ( TimeIntegrationAlgorithmGLMSharedPtr phase,
std::string  variant,
size_t  order,
std::vector< NekDouble freeParams 
)
inlinestatic

Definition at line 190 of file DIRKTimeIntegrationSchemes.h.

193 {
194 phase->m_schemeType = eDiagonallyImplicit;
195 phase->m_order = order;
196 phase->m_name =
197 std::string("DIRKOrder" + std::to_string(phase->m_order) + variant);
198
199 phase->m_numsteps = 1;
200 char const &stage = variant.back();
201 phase->m_numstages = std::atoi(&stage);
202
203 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
204 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
205
206 phase->m_A[0] =
207 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
208 phase->m_B[0] =
209 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
210 phase->m_U =
211 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
212 phase->m_V =
213 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
214
215 const NekDouble ConstSqrt2 = sqrt(2.0);
216 switch (phase->m_order)
217 {
218 case 3:
219 {
220 // See: Kennedy, Christopher A., and Mark H. Carpenter.
221 // Diagonally implicit Runge-Kutta methods for ordinary
222 // differential equations. A review. No. NF1676L-19716. 2016.
223 ASSERTL0(5 == phase->m_numstages,
224 std::string("DIRKOrder3_ES" +
225 std::to_string(phase->m_numstages) +
226 " not defined"));
227
228 NekDouble lambda =
229 (freeParams.size()) ? freeParams[0] : 9.0 / 40.0;
230
231 phase->m_A[0][0][0] = 0.0;
232 phase->m_A[0][1][0] = lambda;
233 phase->m_A[0][2][0] = 9.0 * (1.0 + ConstSqrt2) / 80.0;
234 phase->m_A[0][3][0] =
235 (22.0 + 15.0 * ConstSqrt2) / (80.0 * (1.0 + ConstSqrt2));
236 phase->m_A[0][4][0] = (2398.0 + 1205.0 * ConstSqrt2) /
237 (2835.0 * (4.0 + 3.0 * ConstSqrt2));
238
239 phase->m_A[0][1][1] = phase->m_A[0][1][0];
240 phase->m_A[0][2][1] = phase->m_A[0][2][0];
241 phase->m_A[0][3][1] = phase->m_A[0][3][0];
242 phase->m_A[0][4][1] = phase->m_A[0][4][0];
243
244 phase->m_A[0][2][2] = lambda;
245 phase->m_A[0][3][2] = -7.0 / (40.0 * (1.0 + ConstSqrt2));
246 phase->m_A[0][4][2] = -2374.0 * (1.0 + 2.0 * ConstSqrt2) /
247 (2835.0 * (5.0 + 3.0 * ConstSqrt2));
248
249 phase->m_A[0][3][3] = lambda;
250 phase->m_A[0][4][3] = 5827.0 / 7560.0;
251
252 phase->m_A[0][4][4] = lambda;
253
254 phase->m_B[0][0][0] = phase->m_A[0][4][0];
255 phase->m_B[0][0][1] = phase->m_A[0][4][1];
256 phase->m_B[0][0][2] = phase->m_A[0][4][2];
257 phase->m_B[0][0][3] = phase->m_A[0][4][3];
258 phase->m_B[0][0][4] = phase->m_A[0][4][4];
259 }
260 break;
261
262 case 4:
263 {
264 // See: Kennedy, Christopher A., and Mark H. Carpenter.
265 // Diagonally implicit Runge-Kutta methods for ordinary
266 // differential equations. A review. No. NF1676L-19716. 2016.
267 ASSERTL0(6 == phase->m_numstages,
268 std::string("DIRKOrder4_ES" +
269 std::to_string(phase->m_numstages) +
270 " not defined"));
271
272 NekDouble lambda =
273 (freeParams.size()) ? freeParams[0] : 1.0 / 4.0;
274
275 phase->m_A[0][0][0] = 0.0;
276 phase->m_A[0][1][0] = lambda;
277 phase->m_A[0][2][0] = (1.0 - ConstSqrt2) / 8.0;
278 phase->m_A[0][3][0] = (5.0 - 7.0 * ConstSqrt2) / 64.0;
279 phase->m_A[0][4][0] =
280 (-13796.0 - 54539.0 * ConstSqrt2) / 125000.0;
281 phase->m_A[0][5][0] = (1181.0 - 987.0 * ConstSqrt2) / 13782.0;
282
283 phase->m_A[0][1][1] = phase->m_A[0][1][0];
284 phase->m_A[0][2][1] = phase->m_A[0][2][0];
285 phase->m_A[0][3][1] = phase->m_A[0][3][0];
286 phase->m_A[0][4][1] = phase->m_A[0][4][0];
287 phase->m_A[0][5][1] = phase->m_A[0][5][0];
288
289 phase->m_A[0][2][2] = lambda;
290 phase->m_A[0][3][2] = 7.0 * (1.0 + ConstSqrt2) / 32.0;
291 phase->m_A[0][4][2] =
292 (506605.0 + 132109.0 * ConstSqrt2) / 437500.0;
293 phase->m_A[0][5][2] =
294 47.0 * (-267.0 + 1783.0 * ConstSqrt2) / 273343.0;
295
296 phase->m_A[0][3][3] = lambda;
297 phase->m_A[0][4][3] =
298 166.0 * (-97.0 + 376.0 * ConstSqrt2) / 109375.0;
299 phase->m_A[0][5][3] =
300 -16.0 * (-22922.0 + 3525.0 * ConstSqrt2) / 571953.0;
301
302 phase->m_A[0][4][4] = lambda;
303 phase->m_A[0][5][4] =
304 -15625.0 * (97.0 + 376.0 * ConstSqrt2) / 90749876.0;
305
306 phase->m_A[0][5][5] = lambda;
307
308 phase->m_B[0][0][0] = phase->m_A[0][5][0];
309 phase->m_B[0][0][1] = phase->m_A[0][5][1];
310 phase->m_B[0][0][2] = phase->m_A[0][5][2];
311 phase->m_B[0][0][3] = phase->m_A[0][5][3];
312 phase->m_B[0][0][4] = phase->m_A[0][5][4];
313 phase->m_B[0][0][5] = phase->m_A[0][5][5];
314 }
315 break;
316 default:
317 {
318 ASSERTL0(false, std::string("ESDIRK of order" +
319 std::to_string(phase->m_order) +
320 " not defined"));
321 break;
322 }
323 }
324
325 phase->m_numMultiStepValues = 1;
326 phase->m_numMultiStepImplicitDerivs = 0;
327 phase->m_numMultiStepExplicitDerivs = 0;
328 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
329 phase->m_timeLevelOffset[0] = 0;
330
331 phase->CheckAndVerify();
332 }

References ASSERTL0, Nektar::LibUtilities::eDiagonallyImplicit, and tinysimd::sqrt().

Referenced by DIRKTimeIntegrationScheme().

◆ v_GetName()

LUE std::string Nektar::LibUtilities::DIRKTimeIntegrationScheme::v_GetName ( ) const
inlineoverrideprotectedvirtual

Implements Nektar::LibUtilities::TimeIntegrationScheme.

Definition at line 335 of file DIRKTimeIntegrationSchemes.h.

336 {
337 return std::string("DIRK");
338 }

◆ v_GetTimeStability()

LUE NekDouble Nektar::LibUtilities::DIRKTimeIntegrationScheme::v_GetTimeStability ( ) const
inlineoverrideprotectedvirtual

Implements Nektar::LibUtilities::TimeIntegrationScheme.

Definition at line 340 of file DIRKTimeIntegrationSchemes.h.

341 {
342 return 1.0;
343 }

Member Data Documentation

◆ className

std::string Nektar::LibUtilities::DIRKTimeIntegrationScheme::className
static

Definition at line 100 of file DIRKTimeIntegrationSchemes.h.