Nektar++
TimeIntegrationSchemeGEM.h
Go to the documentation of this file.
1//////////////////////////////////////////////////////////////////////////////polationMethod
2//
3// File: TimeIntegrationSchemeGEM.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 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// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Header file of time integration scheme GEM base class
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME_GEM
36#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME_GEM
37
38#define LUE LIB_UTILITIES_EXPORT
39
40#include <string>
41
44
46{
47
48///////////////////////////////////////////////////////////////////////////////
49/// Class for spectral deferred correction integration.
51{
52public:
53 TimeIntegrationSchemeGEM(std::string variant, size_t order,
54 std::vector<NekDouble> freeParams)
55 : TimeIntegrationScheme(variant, order, freeParams),
56 m_name("ExtrapolationMethod")
57 {
58 ASSERTL0(variant == "" || variant == "ExplicitEuler" ||
59 variant == "ImplicitEuler" || variant == "IMEXEuler" ||
60 variant == "ExplicitMidpoint" ||
61 variant == "ImplicitMidpoint",
62 "Extrapolation Time integration "
63 "scheme bad variant (ExplicitEuler, ImplicitEuler, "
64 "ExplicitMidpoint)")
65
66 if (variant == "IMEXEuler")
67 {
68 std::cerr << "WARNING: IMEX Euler extrapolation method has been "
69 "implemented but its use is not recommended as the "
70 "approach is affected by order-reduction problems."
71 << std::endl;
72 }
73
74 if (variant == "" || variant == "ExplicitEuler" ||
75 variant == "ImplicitEuler" || variant == "IMEXEuler")
76 {
77 ASSERTL0(order >= 1, "Extrapolation Time integration "
78 "scheme bad order numbers (>=1): " +
79 std::to_string(order));
80 }
81 else if (variant == "ExplicitMidpoint" || variant == "ImplicitMidpoint")
82 {
83 ASSERTL0(order >= 2, "Extrapolation Time integration "
84 "scheme bad order numbers (>=2): " +
85 std::to_string(order));
86
87 ASSERTL0(order % 2 == 0,
88 "Extrapolation Time integration "
89 "scheme bad order numbers (even number): " +
90 std::to_string(order));
91 }
92
93 m_variant = variant;
94 m_order = order;
95 m_freeParams = freeParams;
96 if (variant == "ExplicitEuler" || variant == "ExplicitMidpoint")
97 {
99 }
100 else if (variant == "ImplicitEuler" || variant == "ImplicitMidpoint")
101 {
103 }
104 else if (variant == "IMEXEuler")
105 {
107 }
108 }
109
110 /// Destructor
112 {
113 }
114
116 std::string variant, size_t order, std::vector<NekDouble> freeParams)
117 {
120 variant, order, freeParams);
121
122 return p;
123 }
124
125 static std::string className;
126
127protected:
128 LUE std::string v_GetName() const override;
129 LUE std::string v_GetVariant() const override;
130 LUE size_t v_GetOrder() const override;
131 LUE std::vector<NekDouble> v_GetFreeParams() const override;
133 LUE NekDouble v_GetTimeStability() const override;
134 LUE size_t v_GetNumIntegrationPhases() const override;
135 LUE const TripleArray &v_GetSolutionVector() const override;
137 LUE void v_SetSolutionVector(const size_t Offset,
138 const DoubleArray &y) override;
140 const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time,
141 const TimeIntegrationSchemeOperators &op) override;
142 LUE ConstDoubleArray &v_TimeIntegrate(const size_t timestep,
143 const NekDouble delta_t) override;
144 LUE void v_print(std::ostream &os) const override;
145 LUE void v_printFull(std::ostream &os) const override;
146
147 // Variables common to all schemes.
149 std::string m_name;
150 std::string m_variant;
151 std::vector<NekDouble> m_freeParams;
154
155 // Storage of previous states and associated timesteps.
156 TripleArray m_Y; /// Array containing the stage values
157 TripleArray m_T; /// Array containing the solution values
158 TripleArray m_T0; /// Array containing the solution values
159 DoubleArray m_F; /// Array corresponding to the stage Derivatives
160 DoubleArray m_F0; /// Array corresponding to the stage Derivatives
161
162 // GEM parameter
163 size_t m_order{0}; // Order of the integration scheme
164 size_t m_nvars{0}; // Number of variables in the integration scheme.
165 size_t m_npoints{0}; // Number of points in the integration scheme.
166 bool m_initialized{false};
167
168}; // end class TimeIntegrationSchemeGEM
169
170LUE std::ostream &operator<<(std::ostream &os,
171 const TimeIntegrationSchemeGEM &rhs);
172
173LUE std::ostream &operator<<(std::ostream &os,
175
176} // namespace Nektar::LibUtilities
177
178#endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
#define LUE
Class for spectral deferred correction integration.
LUE TimeIntegrationSchemeType v_GetIntegrationSchemeType() const override
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
LUE void v_printFull(std::ostream &os) const override
LUE void v_SetSolutionVector(const size_t Offset, const DoubleArray &y) override
LUE const TripleArray & v_GetSolutionVector() const override
LUE void v_print(std::ostream &os) const override
Worker method to print details on the integration scheme.
TimeIntegrationSchemeGEM(std::string variant, size_t order, std::vector< NekDouble > freeParams)
DoubleArray m_F
Array containing the solution values.
size_t m_order
Array corresponding to the stage Derivatives.
TripleArray m_T
Array containing the stage values.
DoubleArray m_F0
Array corresponding to the stage Derivatives.
TripleArray m_T0
Array containing the solution values.
LUE ConstDoubleArray & v_TimeIntegrate(const size_t timestep, const NekDouble delta_t) override
Worker method that performs the time integration.
LUE std::vector< NekDouble > v_GetFreeParams() const override
LUE void v_InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op) override
Worker method to initialize the integration scheme.
Base class for time integration schemes.
Binds a set of functions for use by time integration schemes.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
@ eImplicit
Fully implicit scheme.
@ eExplicit
Formally explicit scheme.
@ eIMEX
Implicit Explicit General Linear Method.
std::shared_ptr< TimeIntegrationSchemeGEM > TimeIntegrationSchemeGEMSharedPtr
std::ostream & operator<<(std::ostream &os, const BasisKey &rhs)
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
double NekDouble