Nektar++
AdamsMoultonTimeIntegrationSchemes.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: AdamsMoultonTimeIntegrationSchemes.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2018 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// License for the specific language governing rights and limitations under
14// Permission is hereby granted, free of charge, to any person obtaining a
15// copy of this software and associated documentation files (the "Software"),
16// to deal in the Software without restriction, including without limitation
17// the rights to use, copy, modify, merge, publish, distribute, sublicense,
18// and/or sell copies of the Software, and to permit persons to whom the
19// Software is furnished to do so, subject to the following conditions:
20//
21// The above copyright notice and this permission notice shall be included
22// in all copies or substantial portions of the Software.
23//
24// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30// DEALINGS IN THE SOFTWARE.
31//
32// Description: Combined header file for all Adams Moulton based time
33// integration schemes.
34//
35///////////////////////////////////////////////////////////////////////////////
36
37// Note : If adding a new integrator be sure to register the
38// integrator with the Time Integration Scheme Facatory in
39// SchemeInitializor.cpp.
40
41#ifndef NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_AM_TIME_INTEGRATION_SCHEME
42#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_AM_TIME_INTEGRATION_SCHEME
43
44#define LUE LIB_UTILITIES_EXPORT
45
47
49
50namespace Nektar
51{
52namespace LibUtilities
53{
54
55///////////////////////////////////////////////////////////////////////////////
56// Adams Moulton Order N
57
59{
60public:
61 AdamsMoultonTimeIntegrationScheme(std::string variant, size_t order,
62 std::vector<NekDouble> freeParams)
63 : TimeIntegrationSchemeGLM(variant, order, freeParams)
64 {
65 // Currently up to 4th order is implemented.
66 ASSERTL1(1 <= order && order <= 4,
67 "AdamsMoulton Time integration scheme bad order (1-4): " +
68 std::to_string(order));
69
71
72 for (size_t n = 0; n < order; ++n)
73 {
76 }
77
78 // Next to last phase
79 if (order > 1)
80 {
82 m_integration_phases[order - 2], order - 1);
83 }
84
85 // Last phase
87 m_integration_phases[order - 1], order);
88
89 // Initial phases
90 switch (order)
91 {
92 case 1:
93 // No intial phases.
94 break;
95
96 case 2:
97 // Intial phase set above
98 break;
99
100 case 3:
101 // Order 2
104 break;
105
106 case 4:
107 // Order 3
110 // Order 3
113 break;
114
115 default:
116 ASSERTL1(false,
117 "AdamsMoulton Time integration scheme bad order: " +
118 std::to_string(order));
119 }
120 }
121
123 {
124 }
125
127 std::string variant, size_t order, std::vector<NekDouble> freeParams)
128 {
131 variant, order, freeParams);
132
133 return p;
134 }
135
136 static std::string className;
137
139 size_t order)
140 {
141 // clang-format off
142 constexpr NekDouble coefficients[5][4] =
143 { { 0., 0., 0., 0. },
144 // 1st Order
145 { 1., 0., 0., 0. },
146 // 2nd Order
147 { 1./ 2., 1./ 2., 0., 0. },
148 // 3rd Order
149 { 5./12., 8./12., -1./12., 0. },
150 // 4th Order
151 { 9./24., 19./24., -5./24., 1./24. } };
152 // clang-format on
153
154 phase->m_schemeType = eDiagonallyImplicit;
155 phase->m_order = order;
156 phase->m_name =
157 std::string("AdamsMoultonOrder" + std::to_string(phase->m_order));
158
159 phase->m_numsteps = phase->m_order;
160 phase->m_numstages = 1;
161
162 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
163 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
164
165 phase->m_A[0] =
166 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
167 phase->m_B[0] =
168 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
169 phase->m_U =
170 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
171 phase->m_V =
172 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
173
174 // Coefficients
175
176 // A/B Coefficient for first row first column
177 phase->m_A[0][0][0] = coefficients[phase->m_order][0];
178 phase->m_B[0][0][0] = coefficients[phase->m_order][0];
179
180 // B evaluation value shuffling second row first column
181 if (phase->m_order > 1)
182 {
183 phase->m_B[0][1][0] = 1.0;
184 }
185
186 // U/V Coefficient for first row first column
187 phase->m_U[0][0] = 1.0;
188 phase->m_V[0][0] = 1.0;
189
190 // U/V Coefficients for first row additional columns
191 for (size_t n = 1; n < phase->m_order; ++n)
192 {
193 phase->m_U[0][n] = coefficients[phase->m_order][n];
194 phase->m_V[0][n] = coefficients[phase->m_order][n];
195 }
196
197 // V evaluation value shuffling row n column n-1
198 for (size_t n = 2; n < phase->m_order; ++n)
199 {
200 phase->m_V[n][n - 1] = 1.0;
201 }
202
203 phase->m_numMultiStepValues = 1;
204 phase->m_numMultiStepImplicitDerivs = phase->m_order - 1;
205 phase->m_numMultiStepExplicitDerivs = 0;
206 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
207 phase->m_timeLevelOffset[0] = 0;
208
209 // For order > 1 derivatives are needed.
210 for (size_t n = 1; n < phase->m_order; ++n)
211 {
212 phase->m_timeLevelOffset[n] = n - 1;
213 }
214
215 phase->CheckAndVerify();
216 }
217
218protected:
219 LUE virtual std::string v_GetName() const override
220 {
221 return std::string("AdamsMoulton");
222 }
223
224 LUE virtual NekDouble v_GetTimeStability() const override
225 {
226 return 1.0;
227 }
228
229}; // end class AdamsMoultonTimeIntegrationScheme
230
231////////////////////////////////////////////////////////////////////////////////
232// Backwards compatibility
235{
236public:
237 AdamsMoultonOrder1TimeIntegrationScheme(std::string variant, size_t order,
238 std::vector<NekDouble> freeParams)
239 : AdamsMoultonTimeIntegrationScheme("", 1, freeParams)
240 {
241 boost::ignore_unused(variant);
242 boost::ignore_unused(order);
243 }
244
246 std::string variant, size_t order, std::vector<NekDouble> freeParams)
247 {
248 boost::ignore_unused(variant);
249 boost::ignore_unused(order);
250
253 "", 1, freeParams);
254
255 return p;
256 }
257
258 static std::string className;
259
260protected:
262
263}; // end class AdamsMoultonOrder1TimeIntegrationScheme
264
267{
268public:
269 AdamsMoultonOrder2TimeIntegrationScheme(std::string variant, size_t order,
270 std::vector<NekDouble> freeParams)
271 : AdamsMoultonTimeIntegrationScheme("", 2, freeParams)
272 {
273 boost::ignore_unused(variant);
274 boost::ignore_unused(order);
275 }
276
278 std::string variant, size_t order, std::vector<NekDouble> freeParams)
279 {
280 boost::ignore_unused(variant);
281 boost::ignore_unused(order);
282
285 "", 2, freeParams);
286
287 return p;
288 }
289
290 static std::string className;
291
292protected:
294
295}; // end class AdamsMoultonOrder2TimeIntegrationScheme
296
299{
300public:
301 AdamsMoultonOrder3TimeIntegrationScheme(std::string variant, size_t order,
302 std::vector<NekDouble> freeParams)
303 : AdamsMoultonTimeIntegrationScheme("", 3, freeParams)
304 {
305 boost::ignore_unused(variant);
306 boost::ignore_unused(order);
307 }
308
310 std::string variant, size_t order, std::vector<NekDouble> freeParams)
311 {
312 boost::ignore_unused(variant);
313 boost::ignore_unused(order);
314
317 "", 3, freeParams);
318
319 return p;
320 }
321
322 static std::string className;
323
324protected:
326
327}; // end class AdamsMoultonOrder3TimeIntegrationScheme
328
331{
332public:
333 AdamsMoultonOrder4TimeIntegrationScheme(std::string variant, size_t order,
334 std::vector<NekDouble> freeParams)
335 : AdamsMoultonTimeIntegrationScheme("", 4, freeParams)
336 {
337 boost::ignore_unused(variant);
338 boost::ignore_unused(order);
339 }
340
342 std::string variant, size_t order, std::vector<NekDouble> freeParams)
343 {
344 boost::ignore_unused(variant);
345 boost::ignore_unused(order);
346
349 "", 4, freeParams);
350
351 return p;
352 }
353
354 static std::string className;
355
356protected:
358
359}; // end class AdamsMoultonOrder4TimeIntegrationScheme
360
361} // end namespace LibUtilities
362} // end namespace Nektar
363
364#endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
AdamsMoultonOrder1TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
AdamsMoultonOrder2TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
AdamsMoultonOrder3TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
AdamsMoultonOrder4TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
AdamsMoultonTimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static LUE void SetupSchemeData(TimeIntegrationAlgorithmGLMSharedPtr &phase, size_t order)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static LUE void SetupSchemeData(TimeIntegrationAlgorithmGLMSharedPtr &phase, size_t order)
Base class for GLM time integration schemes.
TimeIntegrationAlgorithmGLMVector m_integration_phases
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< TimeIntegrationAlgorithmGLM > TimeIntegrationAlgorithmGLMSharedPtr
@ eDiagonallyImplicit
Diagonally implicit scheme (e.g. the DIRK schemes)
std::vector< TimeIntegrationAlgorithmGLMSharedPtr > TimeIntegrationAlgorithmGLMVector
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble