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], 3, std::vector<NekDouble>{3, 4});
105  m_integration_phases[1], 3, std::vector<NekDouble>{3, 4});
106  break;
107 
108  case 4:
110  m_integration_phases[0], 3, std::vector<NekDouble>{2, 3});
112  m_integration_phases[1], 3, std::vector<NekDouble>{2, 3});
113  break;
114 
115  default:
116  ASSERTL1(false,
117  "BDFImplicit Time integration scheme bad order: " +
118  std::to_string(order));
119  }
120  }
121 
123  {
124  }
125 
127  std::string variant, unsigned int order,
128  std::vector<NekDouble> freeParams)
129  {
132  variant, order, freeParams);
133 
134  return p;
135  }
136 
137  static std::string className;
138 
139  LUE virtual std::string GetName() const
140  {
141  return std::string("BDFImplicit");
142  }
143 
145  {
146  return 1.0;
147  }
148 
150  unsigned int order)
151  {
152  const NekDouble ABcoefficients[5] = {0.,
153  1., // 1st Order
154  2. / 3., // 2nd Order
155  6. / 11., // 3rd Order
156  12. / 25.}; // 4th Order
157 
158  // The 3rd and 4th order tableaus have not been validated!!!!!
159 
160  // clang-format off
161  const NekDouble UVcoefficients[5][4] =
162  { { 0., 0., 0., 0. },
163  // 1st Order
164  { 1., 0., 0., 0. },
165  // 2nd Order
166  { 4./ 3., -1./ 3., 0., 0. },
167  // 3rd Order
168  { 18./11., -9./11., 2./11., 0. },
169  // 4th Order
170  { 48./25., -36./25., 16./25., -3./25. } };
171  // clang-format on
172 
173  phase->m_schemeType = eDiagonallyImplicit;
174  phase->m_order = order;
175  phase->m_name =
176  std::string("BDFImplicitOrder" + std::to_string(phase->m_order));
177 
178  phase->m_numsteps = phase->m_order;
179  phase->m_numstages = 1;
180 
181  phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
182  phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
183 
184  phase->m_A[0] =
185  Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
186  phase->m_B[0] =
187  Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
188  phase->m_U =
189  Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
190  phase->m_V =
191  Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
192 
193  // Coefficients
194 
195  // When multiple steps are taken A/B[0][0] and U/V[0][1...s]
196  // must be weighted so the time contribution is correct.
197 
198  // A/B Coefficient for first row first column
199  phase->m_A[0][0][0] = ABcoefficients[phase->m_order];
200  phase->m_B[0][0][0] = ABcoefficients[phase->m_order];
201 
202  // U/V Coefficients for first row additional columns
203  for (int n = 0; n < phase->m_order; ++n)
204  {
205  phase->m_U[0][n] = UVcoefficients[phase->m_order][n];
206  phase->m_V[0][n] = UVcoefficients[phase->m_order][n];
207  }
208 
209  // V evaluation value shuffling row n column n-1
210  for (int n = 1; n < phase->m_order; ++n)
211  {
212  phase->m_V[n][n - 1] = 1.0;
213  }
214 
215  phase->m_numMultiStepValues = phase->m_order;
216  phase->m_numMultiStepDerivs = 0;
217  phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
218 
219  // For order >= 1 values are needed.
220  for (int n = 0; n < phase->m_order; ++n)
221  {
222  phase->m_timeLevelOffset[n] = n;
223  }
224 
225  phase->CheckAndVerify();
226  }
227 
228 }; // end class BDFImplicitTimeIntegrator
229 
230 ////////////////////////////////////////////////////////////////////////////////
231 // Backwards compatibility
234 {
235 public:
237  unsigned int order,
238  std::vector<NekDouble> freeParams)
239  : BDFImplicitTimeIntegrationScheme("", 1, freeParams)
240  {
241  boost::ignore_unused(variant);
242  boost::ignore_unused(order);
243  }
244 
246  std::string variant, unsigned int order,
247  std::vector<NekDouble> freeParams)
248  {
249  boost::ignore_unused(variant);
250  boost::ignore_unused(order);
251 
254  "", 1, freeParams);
255  return p;
256  }
257 
258  static std::string className;
259 
260 }; // end class BDFImplicitOrder1TimeIntegrationScheme
261 
264 {
265 public:
267  unsigned int order,
268  std::vector<NekDouble> freeParams)
269  : BDFImplicitTimeIntegrationScheme("", 2, freeParams)
270  {
271  boost::ignore_unused(variant);
272  boost::ignore_unused(order);
273  }
274 
276  std::string variant, unsigned int order,
277  std::vector<NekDouble> freeParams)
278  {
279  boost::ignore_unused(variant);
280  boost::ignore_unused(order);
281 
284  "", 2, freeParams);
285  return p;
286  }
287 
288  static std::string className;
289 
290 }; // end class BDFImplicitOrder2TimeIntegrationScheme
291 
292 } // end namespace LibUtilities
293 } // end namespace Nektar
294 
295 #endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
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)
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, std::vector< NekDouble > freeParams)
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:1
double NekDouble