Nektar++
EulerTimeIntegrationSchemes.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: EulerTimeIntegrationSchemes.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 basic Euler 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_EULER_TIME_INTEGRATION_SCHEME
42#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_EULER_TIME_INTEGRATION_SCHEME
43
44#define LUE LIB_UTILITIES_EXPORT
45
47
49{
50
51///////////////////////////////////////////////////////////////////////////////
52// Euler
53
55{
56public:
57 EulerTimeIntegrationScheme(std::string variant, size_t order,
58 std::vector<NekDouble> freeParams)
59 : TimeIntegrationSchemeGLM(variant, 1, freeParams)
60 {
61 boost::ignore_unused(variant, order);
62
63 ASSERTL1(variant == "Backward" || variant == "Forward",
64 "Euler Time integration scheme unknown variant: " + variant +
65 ". Must be 'Backward' or 'Forward'");
66
70
72 variant);
73 }
74
76 {
77 }
78
80 std::string variant, [[maybe_unused]] size_t order,
81 std::vector<NekDouble> freeParams)
82 {
85 variant, 1, freeParams);
86 return p;
87 }
88
89 static std::string className;
90
92 std::string variant)
93 {
94 double A = 0;
95
96 if (variant == "Backward")
97 {
98 phase->m_schemeType = eDiagonallyImplicit;
99
100 A = 1;
101 }
102 else if (variant == "Forward")
103 {
104 phase->m_schemeType = eExplicit;
105
106 A = 0;
107 }
108
109 phase->m_variant = variant;
110 phase->m_order = 1;
111 phase->m_name = variant + std::string("EulerOrder") +
112 std::to_string(phase->m_order);
113
114 phase->m_numsteps = 1;
115 phase->m_numstages = 1;
116
117 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
118 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
119
120 phase->m_A[0] =
121 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, A);
122 phase->m_B[0] =
123 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 1.0);
124 phase->m_U =
125 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
126 phase->m_V =
127 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
128
129 phase->m_numMultiStepValues = 1;
130 phase->m_numMultiStepImplicitDerivs = 0;
131 phase->m_numMultiStepExplicitDerivs = 0;
132 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
133 phase->m_timeLevelOffset[0] = 0;
134
135 phase->CheckAndVerify();
136 }
137
138protected:
139 LUE std::string v_GetFullName() const override
140 {
141 return m_integration_phases.back()->m_name;
142 }
143
144 LUE std::string v_GetName() const override
145 {
146 return std::string("Euler");
147 }
148
150 {
151 if (GetVariant() == "Backward")
152 {
153 return 1.0;
154 }
155 else
156 {
157 return 2.0;
158 }
159 }
160
161}; // end class EulerTimeIntegrator
162
163////////////////////////////////////////////////////////////////////////////////
164// Backwards compatibility
166{
167public:
168 BackwardEulerTimeIntegrationScheme(std::string variant, size_t order,
169 std::vector<NekDouble> freeParams)
170 : EulerTimeIntegrationScheme("Backward", 1, freeParams)
171 {
172 boost::ignore_unused(variant, order);
173 }
174
176 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
177 std::vector<NekDouble> freeParams)
178 {
181 "Backward", 1, freeParams);
182 return p;
183 }
184
185 static std::string className;
186
187protected:
189
190}; // end class BackwardEulerTimeIntegrationScheme
191
193{
194public:
195 ForwardEulerTimeIntegrationScheme(std::string variant, size_t order,
196 std::vector<NekDouble> freeParams)
197 : EulerTimeIntegrationScheme("Forward", 1, freeParams)
198 {
199 boost::ignore_unused(variant, order);
200 }
201
203 [[maybe_unused]] std::string variant, [[maybe_unused]] size_t order,
204 std::vector<NekDouble> freeParams)
205 {
208 "Forward", 1, freeParams);
209 return p;
210 }
211
212 static std::string className;
213
214protected:
216
217}; // end class ForwardEulerTimeIntegrationScheme
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....
Definition: ErrorUtil.hpp:242
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
BackwardEulerTimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static LUE void SetupSchemeData(TimeIntegrationAlgorithmGLMSharedPtr &phase, std::string variant)
EulerTimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
ForwardEulerTimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t 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
@ eExplicit
Formally explicit scheme.
@ eDiagonallyImplicit
Diagonally implicit scheme (e.g. the DIRK schemes)
std::vector< TimeIntegrationAlgorithmGLMSharedPtr > TimeIntegrationAlgorithmGLMVector
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
double NekDouble