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 
48 
50 
51 namespace Nektar
52 {
53 namespace LibUtilities
54 {
55 
56 ///////////////////////////////////////////////////////////////////////////////
57 // BDF Implicit Order N
58 
60 {
61 public:
62  BDFImplicitTimeIntegrationScheme(std::string variant, unsigned int order,
63  std::vector<NekDouble> freeParams)
64  : TimeIntegrationSchemeGLM(variant, order, freeParams)
65  {
66  // Currently up to 4th order is implemented.
67 
68  // Methods with order > 6 are not zero-stable.
69  ASSERTL1(1 <= order && order <= 4,
70  "BDFImplicit Time integration scheme bad order (1-4): " +
71  std::to_string(order));
72 
74 
75  for (unsigned int n = 0; n < order; ++n)
76  {
78  new TimeIntegrationAlgorithmGLM(this));
79  }
80 
81  // Next to last phase
82  if (order > 1)
84  m_integration_phases[order - 2], order - 1);
85 
86  // Last phase
88  m_integration_phases[order - 1], order);
89 
90  // Initial phases
91  switch (order)
92  {
93  case 1:
94  // No intial phase.
95  break;
96 
97  case 2:
98  // Intial phase set above
99  break;
100 
101  case 3:
103  m_integration_phases[0], 2);
104  break;
105 
106  case 4:
108  m_integration_phases[0], 3);
110  m_integration_phases[1], 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, unsigned int order,
126  std::vector<NekDouble> freeParams)
127  {
130  variant, order, freeParams);
131 
132  return p;
133  }
134 
135  static std::string className;
136 
138  unsigned int order)
139  {
140  const 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  const 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  // When multiple steps are taken A/B[0][0] and U/V[0][1...s]
182  // must be weighted so the time contribution is correct.
183 
184  // A/B Coefficient for first row first column
185  phase->m_A[0][0][0] = ABcoefficients[phase->m_order];
186  phase->m_B[0][0][0] = ABcoefficients[phase->m_order];
187 
188  // U/V Coefficients for first row additional columns
189  for (int n = 0; n < phase->m_order; ++n)
190  {
191  phase->m_U[0][n] = UVcoefficients[phase->m_order][n];
192  phase->m_V[0][n] = UVcoefficients[phase->m_order][n];
193  }
194 
195  // V evaluation value shuffling row n column n-1
196  for (int n = 1; n < phase->m_order; ++n)
197  {
198  phase->m_V[n][n - 1] = 1.0;
199  }
200 
201  phase->m_numMultiStepValues = phase->m_order;
202  phase->m_numMultiStepImplicitDerivs = 0;
203  phase->m_numMultiStepDerivs = 0;
204  phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
205 
206  // For order >= 1 values are needed.
207  for (int n = 0; n < phase->m_order; ++n)
208  {
209  phase->m_timeLevelOffset[n] = n;
210  }
211 
212  phase->CheckAndVerify();
213  }
214 
215 protected:
216  LUE virtual std::string v_GetName() const override
217  {
218  return std::string("BDFImplicit");
219  }
220 
221  LUE virtual NekDouble v_GetTimeStability() const override
222  {
223  return 1.0;
224  }
225 
226 }; // end class BDFImplicitTimeIntegrator
227 
228 ////////////////////////////////////////////////////////////////////////////////
229 // Backwards compatibility
232 {
233 public:
235  unsigned int order,
236  std::vector<NekDouble> freeParams)
237  : BDFImplicitTimeIntegrationScheme("", 1, freeParams)
238  {
239  boost::ignore_unused(variant);
240  boost::ignore_unused(order);
241  }
242 
244  std::string variant, unsigned int order,
245  std::vector<NekDouble> freeParams)
246  {
247  boost::ignore_unused(variant);
248  boost::ignore_unused(order);
249 
252  "", 1, freeParams);
253  return p;
254  }
255 
256  static std::string className;
257 
258 }; // end class BDFImplicitOrder1TimeIntegrationScheme
259 
262 {
263 public:
265  unsigned int order,
266  std::vector<NekDouble> freeParams)
267  : BDFImplicitTimeIntegrationScheme("", 2, freeParams)
268  {
269  boost::ignore_unused(variant);
270  boost::ignore_unused(order);
271  }
272 
274  std::string variant, unsigned int order,
275  std::vector<NekDouble> freeParams)
276  {
277  boost::ignore_unused(variant);
278  boost::ignore_unused(order);
279 
282  "", 2, freeParams);
283  return p;
284  }
285 
286  static std::string className;
287 
288 }; // end class BDFImplicitOrder2TimeIntegrationScheme
289 
292 {
293 public:
295  unsigned int order,
296  std::vector<NekDouble> freeParams)
297  : BDFImplicitTimeIntegrationScheme("", 3, freeParams)
298  {
299  boost::ignore_unused(variant);
300  boost::ignore_unused(order);
301  }
302 
304  std::string variant, unsigned int order,
305  std::vector<NekDouble> freeParams)
306  {
307  boost::ignore_unused(variant);
308  boost::ignore_unused(order);
309 
312  "", 3, freeParams);
313  return p;
314  }
315 
316  static std::string className;
317 
318 }; // end class BDFImplicitOrder3TimeIntegrationScheme
319 
322 {
323 public:
325  unsigned int order,
326  std::vector<NekDouble> freeParams)
327  : BDFImplicitTimeIntegrationScheme("", 4, freeParams)
328  {
329  boost::ignore_unused(variant);
330  boost::ignore_unused(order);
331  }
332 
334  std::string variant, unsigned int order,
335  std::vector<NekDouble> freeParams)
336  {
337  boost::ignore_unused(variant);
338  boost::ignore_unused(order);
339 
342  "", 4, freeParams);
343  return p;
344  }
345 
346  static std::string className;
347 
348 }; // end class BDFImplicitOrder4TimeIntegrationScheme
349 
350 } // end namespace LibUtilities
351 } // end namespace Nektar
352 
353 #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, unsigned int order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
BDFImplicitOrder2TimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
BDFImplicitOrder3TimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
BDFImplicitOrder4TimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
BDFImplicitTimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
static LUE void SetupSchemeData(TimeIntegrationAlgorithmGLMSharedPtr &phase, unsigned int order)
static TimeIntegrationSchemeSharedPtr create(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
static LUE void SetupSchemeData(TimeIntegrationAlgorithmGLMSharedPtr &phase, unsigned int 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