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
46#include <boost/core/ignore_unused.hpp>
47
50
52{
53
54///////////////////////////////////////////////////////////////////////////////
55// Adams Moulton Order N
56
58{
59public:
60 AdamsMoultonTimeIntegrationScheme(std::string variant, size_t order,
61 std::vector<NekDouble> freeParams)
62 : TimeIntegrationSchemeGLM(variant, order, freeParams)
63 {
64 // Currently up to 4th order is implemented.
65 ASSERTL1(1 <= order && order <= 4,
66 "AdamsMoulton Time integration scheme bad order (1-4): " +
67 std::to_string(order));
68
70
71 for (size_t n = 0; n < order; ++n)
72 {
75 }
76
77 // Next to last phase
78 if (order > 1)
79 {
81 m_integration_phases[order - 2], order - 1);
82 }
83
84 // Last phase
86 m_integration_phases[order - 1], order);
87
88 // Initial phases
89 switch (order)
90 {
91 case 1:
92 // No intial phases.
93 break;
94
95 case 2:
96 // Intial phase set above
97 break;
98
99 case 3:
100 // Order 2
103 break;
104
105 case 4:
106 // Order 3
109 // Order 3
112 break;
113
114 default:
115 ASSERTL1(false,
116 "AdamsMoulton Time integration scheme bad order: " +
117 std::to_string(order));
118 }
119 }
120
122 {
123 }
124
126 std::string variant, size_t order, std::vector<NekDouble> freeParams)
127 {
130 variant, order, freeParams);
131
132 return p;
133 }
134
135 static std::string className;
136
138 size_t order)
139 {
140 // clang-format off
141 constexpr NekDouble coefficients[5][4] =
142 { { 0., 0., 0., 0. },
143 // 1st Order
144 { 1., 0., 0., 0. },
145 // 2nd Order
146 { 1./ 2., 1./ 2., 0., 0. },
147 // 3rd Order
148 { 5./12., 8./12., -1./12., 0. },
149 // 4th Order
150 { 9./24., 19./24., -5./24., 1./24. } };
151 // clang-format on
152
153 phase->m_schemeType = eDiagonallyImplicit;
154 phase->m_order = order;
155 phase->m_name =
156 std::string("AdamsMoultonOrder" + std::to_string(phase->m_order));
157
158 phase->m_numsteps = phase->m_order;
159 phase->m_numstages = 1;
160
161 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
162 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
163
164 phase->m_A[0] =
165 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
166 phase->m_B[0] =
167 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
168 phase->m_U =
169 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
170 phase->m_V =
171 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
172
173 // Coefficients
174
175 // A/B Coefficient for first row first column
176 phase->m_A[0][0][0] = coefficients[phase->m_order][0];
177 phase->m_B[0][0][0] = coefficients[phase->m_order][0];
178
179 // B evaluation value shuffling second row first column
180 if (phase->m_order > 1)
181 {
182 phase->m_B[0][1][0] = 1.0;
183 }
184
185 // U/V Coefficient for first row first column
186 phase->m_U[0][0] = 1.0;
187 phase->m_V[0][0] = 1.0;
188
189 // U/V Coefficients for first row additional columns
190 for (size_t n = 1; n < phase->m_order; ++n)
191 {
192 phase->m_U[0][n] = coefficients[phase->m_order][n];
193 phase->m_V[0][n] = coefficients[phase->m_order][n];
194 }
195
196 // V evaluation value shuffling row n column n-1
197 for (size_t n = 2; n < phase->m_order; ++n)
198 {
199 phase->m_V[n][n - 1] = 1.0;
200 }
201
202 phase->m_numMultiStepValues = 1;
203 phase->m_numMultiStepImplicitDerivs = phase->m_order - 1;
204 phase->m_numMultiStepExplicitDerivs = 0;
205 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
206 phase->m_timeLevelOffset[0] = 0;
207
208 // For order > 1 derivatives are needed.
209 for (size_t n = 1; n < phase->m_order; ++n)
210 {
211 phase->m_timeLevelOffset[n] = n - 1;
212 }
213
214 phase->CheckAndVerify();
215 }
216
217protected:
218 LUE std::string v_GetName() const override
219 {
220 return std::string("AdamsMoulton");
221 }
222
224 {
225 return 1.0;
226 }
227
228}; // end class AdamsMoultonTimeIntegrationScheme
229
230////////////////////////////////////////////////////////////////////////////////
231// Backwards compatibility
234{
235public:
236 AdamsMoultonOrder1TimeIntegrationScheme(std::string variant, size_t order,
237 std::vector<NekDouble> freeParams)
238 : AdamsMoultonTimeIntegrationScheme("", 1, freeParams)
239 {
240 boost::ignore_unused(variant, order);
241 }
242
244 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
245 std::vector<NekDouble> freeParams)
246 {
249 "", 1, freeParams);
250
251 return p;
252 }
253
254 static std::string className;
255
256protected:
258
259}; // end class AdamsMoultonOrder1TimeIntegrationScheme
260
263{
264public:
265 AdamsMoultonOrder2TimeIntegrationScheme(std::string variant, size_t order,
266 std::vector<NekDouble> freeParams)
267 : AdamsMoultonTimeIntegrationScheme("", 2, freeParams)
268 {
269 boost::ignore_unused(variant, order);
270 }
271
273 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
274 std::vector<NekDouble> freeParams)
275 {
278 "", 2, freeParams);
279
280 return p;
281 }
282
283 static std::string className;
284
285protected:
287
288}; // end class AdamsMoultonOrder2TimeIntegrationScheme
289
292{
293public:
294 AdamsMoultonOrder3TimeIntegrationScheme(std::string variant, size_t order,
295 std::vector<NekDouble> freeParams)
296 : AdamsMoultonTimeIntegrationScheme("", 3, freeParams)
297 {
298 boost::ignore_unused(variant, order);
299 }
300
302 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
303 std::vector<NekDouble> freeParams)
304 {
307 "", 3, freeParams);
308
309 return p;
310 }
311
312 static std::string className;
313
314protected:
316
317}; // end class AdamsMoultonOrder3TimeIntegrationScheme
318
321{
322public:
323 AdamsMoultonOrder4TimeIntegrationScheme(std::string variant, size_t order,
324 std::vector<NekDouble> freeParams)
325 : AdamsMoultonTimeIntegrationScheme("", 4, freeParams)
326 {
327 boost::ignore_unused(variant, order);
328 }
329
331 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
332 std::vector<NekDouble> freeParams)
333 {
336 "", 4, freeParams);
337
338 return p;
339 }
340
341 static std::string className;
342
343protected:
345
346}; // end class AdamsMoultonOrder4TimeIntegrationScheme
347
348} // namespace Nektar::LibUtilities
349
350#endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
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
double NekDouble