Nektar++
Loading...
Searching...
No Matches
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
52///////////////////////////////////////////////////////////////////////////////
53// BDF Implicit Order N
54
56{
57public:
58 BDFImplicitTimeIntegrationScheme(std::string variant, size_t order,
59 std::vector<NekDouble> freeParams)
60 : TimeIntegrationSchemeGLM(variant, order, freeParams)
61 {
62 // Currently up to 4th order is implemented.
63 ASSERTL1(1 <= order && order <= 4,
64 "BDFImplicit Time integration scheme bad order (1-4): " +
65 std::to_string(order));
66
68
69 for (size_t n = 0; n < order; ++n)
70 {
73 }
74
75 // Next to last phase
76 if (order > 1)
77 {
79 m_integration_phases[order - 2], order - 1);
80 }
81
82 // Last phase
84 m_integration_phases[order - 1], order);
85
86 // Initial phases
87 switch (order)
88 {
89 case 1:
90 // No intial phase.
91 break;
92
93 case 2:
94 // Intial phase set above
95 break;
96
97 case 3:
98 // Order 2
101 break;
102
103 case 4:
104 // Order 3
107 // Order 3
110 break;
111
112 default:
113 ASSERTL1(false,
114 "BDFImplicit Time integration scheme bad order: " +
115 std::to_string(order));
116 }
117 }
118
120
122 std::string variant, size_t order, std::vector<NekDouble> freeParams)
123 {
126 variant, order, freeParams);
127
128 return p;
129 }
130
131 static std::string className;
132
134 size_t order)
135 {
136 constexpr NekDouble ABcoefficients[5] = {0.,
137 1., // 1st Order
138 2. / 3., // 2nd Order
139 6. / 11., // 3rd Order
140 12. / 25.}; // 4th Order
141
142 // clang-format off
143 constexpr NekDouble UVcoefficients[5][4] =
144 { { 0., 0., 0., 0. },
145 // 1st Order
146 { 1., 0., 0., 0. },
147 // 2nd Order
148 { 4./ 3., -1./ 3., 0., 0. },
149 // 3rd Order
150 { 18./11., -9./11., 2./11., 0. },
151 // 4th Order
152 { 48./25., -36./25., 16./25., -3./25. } };
153 // clang-format on
154
155 phase->m_schemeType = eDiagonallyImplicit;
156 phase->m_order = order;
157 phase->m_name =
158 std::string("BDFImplicitOrder" + std::to_string(phase->m_order));
159
160 phase->m_numsteps = phase->m_order;
161 phase->m_numstages = 1;
162
163 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
164 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
165
166 phase->m_A[0] =
167 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
168 phase->m_B[0] =
169 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
170 phase->m_U =
171 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
172 phase->m_V =
173 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
174
175 // Coefficients
176
177 // A/B Coefficient for first row first column
178 phase->m_A[0][0][0] = ABcoefficients[phase->m_order];
179 phase->m_B[0][0][0] = ABcoefficients[phase->m_order];
180
181 // U/V Coefficients for first row additional columns
182 for (size_t n = 0; n < phase->m_order; ++n)
183 {
184 phase->m_U[0][n] = UVcoefficients[phase->m_order][n];
185 phase->m_V[0][n] = UVcoefficients[phase->m_order][n];
186 }
187
188 // V evaluation value shuffling row n column n-1
189 for (size_t n = 1; n < phase->m_order; ++n)
190 {
191 phase->m_V[n][n - 1] = 1.0;
192 }
193
194 phase->m_numMultiStepValues = phase->m_order;
195 phase->m_numMultiStepImplicitDerivs = 0;
196 phase->m_numMultiStepExplicitDerivs = 0;
197 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
198 for (size_t n = 0; n < phase->m_order; ++n)
199 {
200 phase->m_timeLevelOffset[n] = n;
201 }
202
203 phase->CheckAndVerify();
204 }
205
206protected:
207 LUE std::string v_GetName() const override
208 {
209 return std::string("BDFImplicit");
210 }
211
213 {
214 return 1.0;
215 }
216
217}; // end class BDFImplicitTimeIntegrator
218
219} // namespace Nektar::LibUtilities
220
221#endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
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.
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