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 
96  LUE virtual std::string GetFullName() const
97  {
98  return m_integration_phases[m_integration_phases.size() - 1]->m_name;
99  }
100 
101  LUE virtual std::string GetName() const
102  {
103  return std::string("Euler");
104  }
105 
107  {
108  if (GetVariant() == "Backward")
109  {
110  return 1.0;
111  }
112  else
113  {
114  return 2.784;
115  }
116  }
117 
119  std::string variant)
120  {
121  double A = 0;
122 
123  if (variant == "Backward")
124  {
125  phase->m_schemeType = eDiagonallyImplicit;
126 
127  A = 1;
128  }
129  else if (variant == "Forward")
130  {
131  phase->m_schemeType = eExplicit;
132 
133  A = 0;
134  }
135 
136  phase->m_variant = variant;
137  phase->m_order = 1;
138  phase->m_name = variant + std::string("EulerOrder") +
139  std::to_string(phase->m_order);
140 
141  phase->m_numsteps = 1;
142  phase->m_numstages = 1;
143 
144  phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
145  phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
146 
147  phase->m_A[0] =
148  Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, A);
149  phase->m_B[0] =
150  Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 1.0);
151  phase->m_U =
152  Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
153  phase->m_V =
154  Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
155 
156  phase->m_numMultiStepValues = 1;
157  phase->m_numMultiStepDerivs = 0;
158  phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
159  phase->m_timeLevelOffset[0] = 0;
160 
161  phase->CheckAndVerify();
162  }
163 
164 }; // end class EulerTimeIntegrator
165 
166 ////////////////////////////////////////////////////////////////////////////////
167 // Backwards compatibility
169 {
170 public:
171  BackwardEulerTimeIntegrationScheme(std::string variant, unsigned int 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, unsigned int order,
181  std::vector<NekDouble> freeParams)
182  {
183  boost::ignore_unused(variant);
184  boost::ignore_unused(order);
185 
188  "Backward", 1, freeParams);
189  return p;
190  }
191 
192  static std::string className;
193 
194 }; // end class BackwardEulerTimeIntegrationScheme
195 
197 {
198 public:
199  ForwardEulerTimeIntegrationScheme(std::string variant, unsigned int order,
200  std::vector<NekDouble> freeParams)
201  : EulerTimeIntegrationScheme("Forward", 1, freeParams)
202  {
203  boost::ignore_unused(variant);
204  boost::ignore_unused(order);
205  }
206 
208  std::string variant, unsigned int order,
209  std::vector<NekDouble> freeParams)
210  {
211  boost::ignore_unused(variant);
212  boost::ignore_unused(order);
213 
216  "Forward", 1, freeParams);
217  return p;
218  }
219 
220  static std::string className;
221 
222 }; // end class ForwardEulerTimeIntegrationScheme
223 
224 } // end namespace LibUtilities
225 } // end namespace Nektar
226 
227 #endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
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)
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:1
double NekDouble