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
47
49
50namespace Nektar
51{
52namespace LibUtilities
53{
54
55///////////////////////////////////////////////////////////////////////////////
56// BDF Implicit Order N
57
59{
60public:
61 BDFImplicitTimeIntegrationScheme(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 "BDFImplicit 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)
81 m_integration_phases[order - 2], order - 1);
82
83 // Last phase
85 m_integration_phases[order - 1], order);
86
87 // Initial phases
88 switch (order)
89 {
90 case 1:
91 // No intial phase.
92 break;
93
94 case 2:
95 // Intial phase set above
96 break;
97
98 case 3:
99 // Order 2
102 break;
103
104 case 4:
105 // Order 3
108 // Order 3
111 break;
112
113 default:
114 ASSERTL1(false,
115 "BDFImplicit Time integration scheme bad order: " +
116 std::to_string(order));
117 }
118 }
119
121 {
122 }
123
125 std::string variant, size_t order, std::vector<NekDouble> freeParams)
126 {
129 variant, order, freeParams);
130
131 return p;
132 }
133
134 static std::string className;
135
137 size_t order)
138 {
139 constexpr NekDouble ABcoefficients[5] = {0.,
140 1., // 1st Order
141 2. / 3., // 2nd Order
142 6. / 11., // 3rd Order
143 12. / 25.}; // 4th Order
144
145 // clang-format off
146 constexpr NekDouble UVcoefficients[5][4] =
147 { { 0., 0., 0., 0. },
148 // 1st Order
149 { 1., 0., 0., 0. },
150 // 2nd Order
151 { 4./ 3., -1./ 3., 0., 0. },
152 // 3rd Order
153 { 18./11., -9./11., 2./11., 0. },
154 // 4th Order
155 { 48./25., -36./25., 16./25., -3./25. } };
156 // clang-format on
157
158 phase->m_schemeType = eDiagonallyImplicit;
159 phase->m_order = order;
160 phase->m_name =
161 std::string("BDFImplicitOrder" + std::to_string(phase->m_order));
162
163 phase->m_numsteps = phase->m_order;
164 phase->m_numstages = 1;
165
166 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
167 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
168
169 phase->m_A[0] =
170 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
171 phase->m_B[0] =
172 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
173 phase->m_U =
174 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
175 phase->m_V =
176 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
177
178 // Coefficients
179
180 // A/B Coefficient for first row first column
181 phase->m_A[0][0][0] = ABcoefficients[phase->m_order];
182 phase->m_B[0][0][0] = ABcoefficients[phase->m_order];
183
184 // U/V Coefficients for first row additional columns
185 for (size_t n = 0; n < phase->m_order; ++n)
186 {
187 phase->m_U[0][n] = UVcoefficients[phase->m_order][n];
188 phase->m_V[0][n] = UVcoefficients[phase->m_order][n];
189 }
190
191 // V evaluation value shuffling row n column n-1
192 for (size_t n = 1; n < phase->m_order; ++n)
193 {
194 phase->m_V[n][n - 1] = 1.0;
195 }
196
197 phase->m_numMultiStepValues = phase->m_order;
198 phase->m_numMultiStepImplicitDerivs = 0;
199 phase->m_numMultiStepExplicitDerivs = 0;
200 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
201 for (size_t n = 0; n < phase->m_order; ++n)
202 {
203 phase->m_timeLevelOffset[n] = n;
204 }
205
206 phase->CheckAndVerify();
207 }
208
209protected:
210 LUE virtual std::string v_GetName() const override
211 {
212 return std::string("BDFImplicit");
213 }
214
215 LUE virtual NekDouble v_GetTimeStability() const override
216 {
217 return 1.0;
218 }
219
220}; // end class BDFImplicitTimeIntegrator
221
222////////////////////////////////////////////////////////////////////////////////
223// Backwards compatibility
226{
227public:
228 BDFImplicitOrder1TimeIntegrationScheme(std::string variant, size_t order,
229 std::vector<NekDouble> freeParams)
230 : BDFImplicitTimeIntegrationScheme("", 1, freeParams)
231 {
232 boost::ignore_unused(variant);
233 boost::ignore_unused(order);
234 }
235
237 std::string variant, size_t order, std::vector<NekDouble> freeParams)
238 {
239 boost::ignore_unused(variant);
240 boost::ignore_unused(order);
241
244 "", 1, freeParams);
245 return p;
246 }
247
248 static std::string className;
249
250protected:
252
253}; // end class BDFImplicitOrder1TimeIntegrationScheme
254
257{
258public:
259 BDFImplicitOrder2TimeIntegrationScheme(std::string variant, size_t order,
260 std::vector<NekDouble> freeParams)
261 : BDFImplicitTimeIntegrationScheme("", 2, freeParams)
262 {
263 boost::ignore_unused(variant);
264 boost::ignore_unused(order);
265 }
266
268 std::string variant, size_t order, std::vector<NekDouble> freeParams)
269 {
270 boost::ignore_unused(variant);
271 boost::ignore_unused(order);
272
275 "", 2, freeParams);
276 return p;
277 }
278
279 static std::string className;
280
281protected:
283
284}; // end class BDFImplicitOrder2TimeIntegrationScheme
285
288{
289public:
290 BDFImplicitOrder3TimeIntegrationScheme(std::string variant, size_t order,
291 std::vector<NekDouble> freeParams)
292 : BDFImplicitTimeIntegrationScheme("", 3, freeParams)
293 {
294 boost::ignore_unused(variant);
295 boost::ignore_unused(order);
296 }
297
299 std::string variant, size_t order, std::vector<NekDouble> freeParams)
300 {
301 boost::ignore_unused(variant);
302 boost::ignore_unused(order);
303
306 "", 3, freeParams);
307 return p;
308 }
309
310 static std::string className;
311
312protected:
314
315}; // end class BDFImplicitOrder3TimeIntegrationScheme
316
319{
320public:
321 BDFImplicitOrder4TimeIntegrationScheme(std::string variant, size_t order,
322 std::vector<NekDouble> freeParams)
323 : BDFImplicitTimeIntegrationScheme("", 4, freeParams)
324 {
325 boost::ignore_unused(variant);
326 boost::ignore_unused(order);
327 }
328
330 std::string variant, size_t order, std::vector<NekDouble> freeParams)
331 {
332 boost::ignore_unused(variant);
333 boost::ignore_unused(order);
334
337 "", 4, freeParams);
338 return p;
339 }
340
341 static std::string className;
342
343protected:
345
346}; // end class BDFImplicitOrder4TimeIntegrationScheme
347
348} // end namespace LibUtilities
349} // end namespace Nektar
350
351#endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
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
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble