Nektar++
Loading...
Searching...
No Matches
AdamsMoultonTimeIntegrationSchemes.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: AdamsMoultonTimeIntegrationSchemes.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 Adams Moulton based time
33// integration 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_AM_TIME_INTEGRATION_SCHEME
42#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_AM_TIME_INTEGRATION_SCHEME
43
44#define LUE LIB_UTILITIES_EXPORT
45
48
50{
51
52///////////////////////////////////////////////////////////////////////////////
53// Adams Moulton Order N
54
56{
57public:
58 AdamsMoultonTimeIntegrationScheme(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 "AdamsMoulton 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 phases.
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 "AdamsMoulton 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 // clang-format off
137 constexpr NekDouble coefficients[5][4] =
138 { { 0., 0., 0., 0. },
139 // 1st Order
140 { 1., 0., 0., 0. },
141 // 2nd Order
142 { 1./ 2., 1./ 2., 0., 0. },
143 // 3rd Order
144 { 5./12., 8./12., -1./12., 0. },
145 // 4th Order
146 { 9./24., 19./24., -5./24., 1./24. } };
147 // clang-format on
148
149 phase->m_schemeType = eDiagonallyImplicit;
150 phase->m_order = order;
151 phase->m_name =
152 std::string("AdamsMoultonOrder" + std::to_string(phase->m_order));
153
154 phase->m_numsteps = phase->m_order;
155 phase->m_numstages = 1;
156
157 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
158 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
159
160 phase->m_A[0] =
161 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
162 phase->m_B[0] =
163 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
164 phase->m_U =
165 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
166 phase->m_V =
167 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
168
169 // Coefficients
170
171 // A/B Coefficient for first row first column
172 phase->m_A[0][0][0] = coefficients[phase->m_order][0];
173 phase->m_B[0][0][0] = coefficients[phase->m_order][0];
174
175 // B evaluation value shuffling second row first column
176 if (phase->m_order > 1)
177 {
178 phase->m_B[0][1][0] = 1.0;
179 }
180
181 // U/V Coefficient for first row first column
182 phase->m_U[0][0] = 1.0;
183 phase->m_V[0][0] = 1.0;
184
185 // U/V Coefficients for first row additional columns
186 for (size_t n = 1; n < phase->m_order; ++n)
187 {
188 phase->m_U[0][n] = coefficients[phase->m_order][n];
189 phase->m_V[0][n] = coefficients[phase->m_order][n];
190 }
191
192 // V evaluation value shuffling row n column n-1
193 for (size_t n = 2; n < phase->m_order; ++n)
194 {
195 phase->m_V[n][n - 1] = 1.0;
196 }
197
198 phase->m_numMultiStepValues = 1;
199 phase->m_numMultiStepImplicitDerivs = phase->m_order - 1;
200 phase->m_numMultiStepExplicitDerivs = 0;
201 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
202 phase->m_timeLevelOffset[0] = 0;
203
204 // For order > 1 derivatives are needed.
205 for (size_t n = 1; n < phase->m_order; ++n)
206 {
207 phase->m_timeLevelOffset[n] = n - 1;
208 }
209
210 phase->CheckAndVerify();
211 }
212
213protected:
214 LUE std::string v_GetName() const override
215 {
216 return std::string("AdamsMoulton");
217 }
218
220 {
221 return 1.0;
222 }
223
224}; // end class AdamsMoultonTimeIntegrationScheme
225
226} // namespace Nektar::LibUtilities
227
228#endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
AdamsMoultonTimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static LUE void SetupSchemeData(TimeIntegrationAlgorithmGLMSharedPtr &phase, size_t order)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
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