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 
48 
49 namespace Nektar
50 {
51 namespace LibUtilities
52 {
53 
54 ///////////////////////////////////////////////////////////////////////////////
55 // Euler
56 
58 {
59 public:
60  EulerTimeIntegrationScheme(std::string variant, unsigned int order,
61  std::vector<NekDouble> freeParams)
62  : TimeIntegrationSchemeGLM(variant, 1, freeParams)
63  {
64  boost::ignore_unused(order);
65 
66  ASSERTL1(variant == "Backward" || variant == "Forward",
67  "Euler Time integration scheme unknown variant: " + variant +
68  ". Must be 'Backward' or 'Forward'");
69 
72  new TimeIntegrationAlgorithmGLM(this));
73 
75  variant);
76  }
77 
79  {
80  }
81 
83  std::string variant, unsigned int order,
84  std::vector<NekDouble> freeParams)
85  {
86  boost::ignore_unused(order);
87 
90  variant, 1, freeParams);
91  return p;
92  }
93 
94  static std::string className;
95 
97  std::string variant)
98  {
99  double A = 0;
100 
101  if (variant == "Backward")
102  {
103  phase->m_schemeType = eDiagonallyImplicit;
104 
105  A = 1;
106  }
107  else if (variant == "Forward")
108  {
109  phase->m_schemeType = eExplicit;
110 
111  A = 0;
112  }
113 
114  phase->m_variant = variant;
115  phase->m_order = 1;
116  phase->m_name = variant + std::string("EulerOrder") +
117  std::to_string(phase->m_order);
118 
119  phase->m_numsteps = 1;
120  phase->m_numstages = 1;
121 
122  phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
123  phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
124 
125  phase->m_A[0] =
126  Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, A);
127  phase->m_B[0] =
128  Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 1.0);
129  phase->m_U =
130  Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
131  phase->m_V =
132  Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
133 
134  phase->m_numMultiStepValues = 1;
135  phase->m_numMultiStepImplicitDerivs = 0;
136  phase->m_numMultiStepDerivs = 0;
137  phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
138  phase->m_timeLevelOffset[0] = 0;
139 
140  phase->CheckAndVerify();
141  }
142 
143 protected:
144  LUE virtual std::string v_GetFullName() const override
145  {
146  return m_integration_phases[m_integration_phases.size() - 1]->m_name;
147  }
148 
149  LUE virtual std::string v_GetName() const override
150  {
151  return std::string("Euler");
152  }
153 
154  LUE virtual NekDouble v_GetTimeStability() const override
155  {
156  if (GetVariant() == "Backward")
157  {
158  return 1.0;
159  }
160  else
161  {
162  return 2.784;
163  }
164  }
165 
166 }; // end class EulerTimeIntegrator
167 
168 ////////////////////////////////////////////////////////////////////////////////
169 // Backwards compatibility
171 {
172 public:
173  BackwardEulerTimeIntegrationScheme(std::string variant, unsigned int order,
174  std::vector<NekDouble> freeParams)
175  : EulerTimeIntegrationScheme("Backward", 1, freeParams)
176  {
177  boost::ignore_unused(variant);
178  boost::ignore_unused(order);
179  }
180 
182  std::string variant, unsigned int order,
183  std::vector<NekDouble> freeParams)
184  {
185  boost::ignore_unused(variant);
186  boost::ignore_unused(order);
187 
190  "Backward", 1, freeParams);
191  return p;
192  }
193 
194  static std::string className;
195 
196 }; // end class BackwardEulerTimeIntegrationScheme
197 
199 {
200 public:
201  ForwardEulerTimeIntegrationScheme(std::string variant, unsigned int 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, unsigned int order,
211  std::vector<NekDouble> freeParams)
212  {
213  boost::ignore_unused(variant);
214  boost::ignore_unused(order);
215 
218  "Forward", 1, freeParams);
219  return p;
220  }
221 
222  static std::string className;
223 
224 }; // end class ForwardEulerTimeIntegrationScheme
225 
226 } // end namespace LibUtilities
227 } // end namespace Nektar
228 
229 #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, unsigned int order, std::vector< NekDouble > freeParams)
BackwardEulerTimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
EulerTimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
static LUE void SetupSchemeData(TimeIntegrationAlgorithmGLMSharedPtr &phase, std::string variant)
virtual LUE NekDouble v_GetTimeStability() const override
virtual LUE std::string v_GetFullName() const override
virtual LUE std::string v_GetName() const override
ForwardEulerTimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
static TimeIntegrationSchemeSharedPtr create(std::string variant, 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
@ 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