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
48namespace Nektar
49{
50namespace LibUtilities
51{
52
53///////////////////////////////////////////////////////////////////////////////
54// Euler
55
57{
58public:
59 EulerTimeIntegrationScheme(std::string variant, size_t order,
60 std::vector<NekDouble> freeParams)
61 : TimeIntegrationSchemeGLM(variant, 1, freeParams)
62 {
63 boost::ignore_unused(order);
64
65 ASSERTL1(variant == "Backward" || variant == "Forward",
66 "Euler Time integration scheme unknown variant: " + variant +
67 ". Must be 'Backward' or 'Forward'");
68
72
74 variant);
75 }
76
78 {
79 }
80
82 std::string variant, size_t order, std::vector<NekDouble> freeParams)
83 {
84 boost::ignore_unused(order);
85
88 variant, 1, freeParams);
89 return p;
90 }
91
92 static std::string className;
93
95 std::string variant)
96 {
97 double A = 0;
98
99 if (variant == "Backward")
100 {
101 phase->m_schemeType = eDiagonallyImplicit;
102
103 A = 1;
104 }
105 else if (variant == "Forward")
106 {
107 phase->m_schemeType = eExplicit;
108
109 A = 0;
110 }
111
112 phase->m_variant = variant;
113 phase->m_order = 1;
114 phase->m_name = variant + std::string("EulerOrder") +
115 std::to_string(phase->m_order);
116
117 phase->m_numsteps = 1;
118 phase->m_numstages = 1;
119
120 phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
121 phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
122
123 phase->m_A[0] =
124 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, A);
125 phase->m_B[0] =
126 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 1.0);
127 phase->m_U =
128 Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
129 phase->m_V =
130 Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
131
132 phase->m_numMultiStepValues = 1;
133 phase->m_numMultiStepImplicitDerivs = 0;
134 phase->m_numMultiStepExplicitDerivs = 0;
135 phase->m_timeLevelOffset = Array<OneD, size_t>(phase->m_numsteps);
136 phase->m_timeLevelOffset[0] = 0;
137
138 phase->CheckAndVerify();
139 }
140
141protected:
142 LUE virtual std::string v_GetFullName() const override
143 {
144 return m_integration_phases.back()->m_name;
145 }
146
147 LUE virtual std::string v_GetName() const override
148 {
149 return std::string("Euler");
150 }
151
152 LUE virtual NekDouble v_GetTimeStability() const override
153 {
154 if (GetVariant() == "Backward")
155 {
156 return 1.0;
157 }
158 else
159 {
160 return 2.0;
161 }
162 }
163
164}; // end class EulerTimeIntegrator
165
166////////////////////////////////////////////////////////////////////////////////
167// Backwards compatibility
169{
170public:
171 BackwardEulerTimeIntegrationScheme(std::string variant, size_t order,
172 std::vector<NekDouble> freeParams)
173 : EulerTimeIntegrationScheme("Backward", 1, freeParams)
174 {
175 boost::ignore_unused(variant);
176 boost::ignore_unused(order);
177 }
178
180 std::string variant, size_t order, std::vector<NekDouble> freeParams)
181 {
182 boost::ignore_unused(variant);
183 boost::ignore_unused(order);
184
187 "Backward", 1, freeParams);
188 return p;
189 }
190
191 static std::string className;
192
193protected:
195
196}; // end class BackwardEulerTimeIntegrationScheme
197
199{
200public:
201 ForwardEulerTimeIntegrationScheme(std::string variant, size_t order,
202 std::vector<NekDouble> freeParams)
203 : EulerTimeIntegrationScheme("Forward", 1, freeParams)
204 {
205 boost::ignore_unused(variant);
206 boost::ignore_unused(order);
207 }
208
210 std::string variant, size_t order, std::vector<NekDouble> freeParams)
211 {
212 boost::ignore_unused(variant);
213 boost::ignore_unused(order);
214
217 "Forward", 1, freeParams);
218 return p;
219 }
220
221 static std::string className;
222
223protected:
225
226}; // end class ForwardEulerTimeIntegrationScheme
227
228} // end namespace LibUtilities
229} // end namespace Nektar
230
231#endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
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)
virtual LUE NekDouble v_GetTimeStability() const override
EulerTimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
virtual LUE std::string v_GetFullName() const override
virtual LUE std::string v_GetName() const override
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
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble