Nektar++
BDFImplicitTimeIntegrationSchemes.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: BDFImplicitTimeIntegrationSchemes.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 BDF Implicit based time integration
33// 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_BDF_TIME_INTEGRATION_SCHEME
42#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_BDF_TIME_INTEGRATION_SCHEME
43
44#define LUE LIB_UTILITIES_EXPORT
45
46#include <boost/core/ignore_unused.hpp>
47
50
52{
53
54///////////////////////////////////////////////////////////////////////////////
55// BDF Implicit Order N
56
58{
59public:
60 BDFImplicitTimeIntegrationScheme(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 "BDFImplicit 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 phase.
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 "BDFImplicit 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 constexpr NekDouble ABcoefficients[5] = {0.,
141 1., // 1st Order
142 2. / 3., // 2nd Order
143 6. / 11., // 3rd Order
144 12. / 25.}; // 4th Order
145
146 // clang-format off
147 constexpr NekDouble UVcoefficients[5][4] =
148 { { 0., 0., 0., 0. },
149 // 1st Order
150 { 1., 0., 0., 0. },
151 // 2nd Order
152 { 4./ 3., -1./ 3., 0., 0. },
153 // 3rd Order
154 { 18./11., -9./11., 2./11., 0. },
155 // 4th Order
156 { 48./25., -36./25., 16./25., -3./25. } };
157 // clang-format on
158
159 phase->m_schemeType = eDiagonallyImplicit;
160 phase->m_order = order;
161 phase->m_name =
162 std::string("BDFImplicitOrder" + std::to_string(phase->m_order));
163
164 phase->m_numsteps = phase->m_order;
165 phase->m_numstages = 1;
166
167 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
168 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
169
170 phase->m_A[0] =
171 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
172 phase->m_B[0] =
173 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
174 phase->m_U =
175 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
176 phase->m_V =
177 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
178
179 // Coefficients
180
181 // A/B Coefficient for first row first column
182 phase->m_A[0][0][0] = ABcoefficients[phase->m_order];
183 phase->m_B[0][0][0] = ABcoefficients[phase->m_order];
184
185 // U/V Coefficients for first row additional columns
186 for (size_t n = 0; n < phase->m_order; ++n)
187 {
188 phase->m_U[0][n] = UVcoefficients[phase->m_order][n];
189 phase->m_V[0][n] = UVcoefficients[phase->m_order][n];
190 }
191
192 // V evaluation value shuffling row n column n-1
193 for (size_t n = 1; n < phase->m_order; ++n)
194 {
195 phase->m_V[n][n - 1] = 1.0;
196 }
197
198 phase->m_numMultiStepValues = phase->m_order;
199 phase->m_numMultiStepImplicitDerivs = 0;
200 phase->m_numMultiStepExplicitDerivs = 0;
201 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
202 for (size_t n = 0; n < phase->m_order; ++n)
203 {
204 phase->m_timeLevelOffset[n] = n;
205 }
206
207 phase->CheckAndVerify();
208 }
209
210protected:
211 LUE std::string v_GetName() const override
212 {
213 return std::string("BDFImplicit");
214 }
215
217 {
218 return 1.0;
219 }
220
221}; // end class BDFImplicitTimeIntegrator
222
223////////////////////////////////////////////////////////////////////////////////
224// Backwards compatibility
227{
228public:
229 BDFImplicitOrder1TimeIntegrationScheme(std::string variant, size_t order,
230 std::vector<NekDouble> freeParams)
231 : BDFImplicitTimeIntegrationScheme("", 1, freeParams)
232 {
233 boost::ignore_unused(variant, order);
234 }
235
237 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
238 std::vector<NekDouble> freeParams)
239 {
242 "", 1, freeParams);
243 return p;
244 }
245
246 static std::string className;
247
248protected:
250
251}; // end class BDFImplicitOrder1TimeIntegrationScheme
252
255{
256public:
257 BDFImplicitOrder2TimeIntegrationScheme(std::string variant, size_t order,
258 std::vector<NekDouble> freeParams)
259 : BDFImplicitTimeIntegrationScheme("", 2, freeParams)
260 {
261 boost::ignore_unused(variant, order);
262 }
263
265 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
266 std::vector<NekDouble> freeParams)
267 {
270 "", 2, freeParams);
271 return p;
272 }
273
274 static std::string className;
275
276protected:
278
279}; // end class BDFImplicitOrder2TimeIntegrationScheme
280
283{
284public:
285 BDFImplicitOrder3TimeIntegrationScheme(std::string variant, size_t order,
286 std::vector<NekDouble> freeParams)
287 : BDFImplicitTimeIntegrationScheme("", 3, freeParams)
288 {
289 boost::ignore_unused(variant, order);
290 }
291
293 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
294 std::vector<NekDouble> freeParams)
295 {
298 "", 3, freeParams);
299 return p;
300 }
301
302 static std::string className;
303
304protected:
306
307}; // end class BDFImplicitOrder3TimeIntegrationScheme
308
311{
312public:
313 BDFImplicitOrder4TimeIntegrationScheme(std::string variant, size_t order,
314 std::vector<NekDouble> freeParams)
315 : BDFImplicitTimeIntegrationScheme("", 4, freeParams)
316 {
317 boost::ignore_unused(variant, order);
318 }
319
321 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
322 std::vector<NekDouble> freeParams)
323 {
326 "", 4, freeParams);
327 return p;
328 }
329
330 static std::string className;
331
332protected:
334
335}; // end class BDFImplicitOrder4TimeIntegrationScheme
336
337} // namespace Nektar::LibUtilities
338
339#endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
BDFImplicitOrder1TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
BDFImplicitOrder2TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
BDFImplicitOrder3TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
BDFImplicitOrder4TimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
BDFImplicitTimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
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 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