Nektar++
TimeIntegrationSchemeFIT.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TimeIntegrationSchemeFIT.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 FIT base class
32//
33///////////////////////////////////////////////////////////////////////////////
34
35// Note: The file is named TimeIntegrationSchemeFIT to parallel the
36// TimeIntegrationSchemeGLM file but the class is named
37// FractionalInTimeIntegrationScheme so keep with the factory naming
38// convention.
39
40#ifndef NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME_FIT
41#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME_FIT
42
43#define LUE LIB_UTILITIES_EXPORT
44
45#include <string>
46
48
50{
51
52///////////////////////////////////////////////////////////////////////////////
53/// Class for fractional-in-time integration.
55{
56public:
57 /// Constructor
58 FractionalInTimeIntegrationScheme(std::string variant, size_t order,
59 std::vector<NekDouble> freeParams);
60
61 /// Destructor
63 {
64 }
65
66 /// Creator
68 std::string variant, size_t order, std::vector<NekDouble> freeParams)
69 {
72 variant, order, freeParams);
73
74 return p;
75 }
76
77 static std::string className;
78
79 // Friend classes
80 LUE friend std::ostream &operator<<(
81 std::ostream &os, const FractionalInTimeIntegrationScheme &rhs);
82 LUE friend std::ostream &operator<<(
83 std::ostream &os,
85
86protected:
87 // Access methods from the base class that are virtual
88 LUE std::string v_GetName() const override
89 {
90 return m_name;
91 }
92
93 LUE std::string v_GetVariant() const override
94 {
95 return m_variant;
96 }
97
98 LUE size_t v_GetOrder() const override
99 {
100 return m_order;
101 }
102
103 LUE std::vector<NekDouble> v_GetFreeParams() const override
104 {
105 return m_freeParams;
106 }
107
109 {
110 return m_schemeType;
111 }
112
114 {
115 return 1.0;
116 }
117
118 LUE size_t v_GetNumIntegrationPhases() const override
119 {
120 return 1;
121 }
122
123 /**
124 * \brief Gets the solution vector of the ODE
125 */
126 const TripleArray &v_GetSolutionVector() const override
127 {
128 return m_u;
129 }
131 {
132 return m_u;
133 }
134
135 /**
136 * \brief Sets the solution vector of the ODE
137 */
138 void v_SetSolutionVector(const size_t Offset, const DoubleArray &y) override
139 {
140 m_u[Offset] = y;
141 }
142
143 // The worker methods from the base class that are virtual
145 const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time,
146 const TimeIntegrationSchemeOperators &op) override;
147
148 LUE ConstDoubleArray &v_TimeIntegrate(const size_t timestep,
149 const NekDouble delta_t) override;
150
151 LUE void v_print(std::ostream &os) const override;
152 LUE void v_printFull(std::ostream &os) const override;
153
154 struct Instance
155 {
156 size_t base;
157
158 size_t index; // Index of this instance
159 bool active; // Used to determine if active
160 size_t activecounter; // counter used to flip active bit
162
163 // Major storage for auxilliary ODE solutions.
164 // Storage for values of y currently used to update u
166 std::pair<size_t, size_t>
167 stage_ind; // Time-step counters indicating the
168 // interval ymain is associated with
169
170 // Staging allocation
173 size_t stage_cbase; // This base is halved after the first cycle
175 size_t stage_fbase; // This base is halved after the first cycle
176
177 // Ceiling stash allocation
178 size_t cstash_counter; // Counter used to determine
179 // when to stash
180 size_t cstash_base; // base for counter
182 std::pair<size_t, size_t> cstash_ind; // ind(1) is never used:
183 // it always matches main.ind(1)
184
185 // Ceiling sandbox allocation
186 bool csandbox_active; // Flag to determine when
187 // stash 2 is utilized
190 std::pair<size_t, size_t> csandbox_ind;
191
192 // Floor stash
195 std::pair<size_t, size_t> fstash_ind;
196
197 // Floor sandbox
202 std::pair<size_t, size_t> fsandbox_ind;
203
204 // Talbot quadrature rule
207
209
213 };
214
215 inline size_t modIncrement(const size_t counter, const size_t base) const;
216
217 inline size_t computeL(const size_t base, const size_t m) const;
218
219 inline size_t computeQML(const size_t base, const size_t m);
220
221 inline size_t computeTaus(const size_t base, const size_t m);
222
223 void talbotQuadrature(const size_t nQuadPts, const NekDouble mu,
224 const NekDouble nu, const NekDouble sigma,
225 ComplexSingleArray &lamb,
226 ComplexSingleArray &w) const;
227
228 void integralClassInitialize(const size_t index, Instance &instance) const;
229
230 void updateStage(const size_t timeStep, Instance &instance);
231
232 void finalIncrement(const size_t timeStep);
233
234 void integralContribution(const size_t timeStep, const size_t tauml,
235 const Instance &instance);
236
237 void timeAdvance(const size_t timeStep, Instance &instance,
239
240 void advanceSandbox(const size_t timeStep, Instance &instance);
241
242 // Variables common to all schemes.
243 std::string m_name;
244 std::string m_variant;
245 size_t m_order{0};
246 std::vector<NekDouble> m_freeParams;
247
250
251 // Varaibles and methods specific to FIT integration schemes.
253 NekDouble m_T{0}; // Finial time
254 size_t m_maxTimeSteps; // Number of time steps.
255 NekDouble m_alpha{0.3}; // Value for exp integration.
256 size_t m_base{4}; // "Base" of the algorithm.
257 size_t m_nQuadPts{20}; // Number of Talbot quadrature rule points
261
262 size_t m_nvars{0}; // Number of variables in the integration scheme.
263 size_t m_npoints{0}; // Number of points in the integration scheme.
264
265 size_t m_Lmax{0}; // Maxium number of integral groups.
267
268 // Demarcation integers
270 // Demarcation interval markers
272
273 // Storage of the initial values.
275 // Storage of the next solution from the final increment.
277 // Storage for the integral contribution.
279 // Storage for the exponential factor in the integral contribution.
281
282 // Storage of previous states and associated timesteps.
284
285 // Storage for the stage derivative as the data will be re-used to
286 // update the solution.
288
289 // J
291
292 // Ahat array one for each order.
294
295 // Multiply the last Ahat array, transposed by J
297
298}; // end class FractionalInTimeIntegrator
299
300LUE std::ostream &operator<<(std::ostream &os,
302LUE std::ostream &operator<<(
303 std::ostream &os, const FractionalInTimeIntegrationSchemeSharedPtr &rhs);
304
305} // namespace Nektar::LibUtilities
306
307#endif
#define LUE
size_t computeTaus(const size_t base, const size_t m)
Method to compute the demarcation interval marker tau_{m, ell}.
LUE void v_InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op) override
Worker method to initialize the integration scheme.
LUE TimeIntegrationSchemeType v_GetIntegrationSchemeType() const override
void timeAdvance(const size_t timeStep, Instance &instance, ComplexTripleArray &y)
Method to get the solution to y' = z*y + f(u), using an exponential integrator with implicit order (m...
static TimeIntegrationSchemeSharedPtr create(std::string variant, size_t order, std::vector< NekDouble > freeParams)
Creator.
const TripleArray & v_GetSolutionVector() const override
Gets the solution vector of the ODE.
void updateStage(const size_t timeStep, Instance &instance)
Method to rearrange of staging/stashing for current time.
void advanceSandbox(const size_t timeStep, Instance &instance)
Method to update sandboxes to the current time.
void integralClassInitialize(const size_t index, Instance &instance) const
Method to initialize the integral class.
LUE void v_print(std::ostream &os) const override
Worker method to print details on the integration scheme.
size_t modIncrement(const size_t counter, const size_t base) const
Method that increments the counter then performs mod calculation.
void v_SetSolutionVector(const size_t Offset, const DoubleArray &y) override
Sets the solution vector of the ODE.
void finalIncrement(const size_t timeStep)
Method to approximate the integral.
void integralContribution(const size_t timeStep, const size_t tauml, const Instance &instance)
Method to get the integral contribution over [taus(i+1) taus(i)]. Stored in m_uInt.
void talbotQuadrature(const size_t nQuadPts, const NekDouble mu, const NekDouble nu, const NekDouble sigma, ComplexSingleArray &lamb, ComplexSingleArray &w) const
Method to compute the quadrature rule over Tablot contour.
size_t computeL(const size_t base, const size_t m) const
Method to compute the smallest integer L such that base < 2.
LUE ConstDoubleArray & v_TimeIntegrate(const size_t timestep, const NekDouble delta_t) override
Worker method that performs the time integration.
FractionalInTimeIntegrationScheme(std::string variant, size_t order, std::vector< NekDouble > freeParams)
Constructor.
size_t computeQML(const size_t base, const size_t m)
Method to compute the demarcation integers q_{m, ell}.
LUE std::vector< NekDouble > v_GetFreeParams() const override
LUE friend std::ostream & operator<<(std::ostream &os, const FractionalInTimeIntegrationScheme &rhs)
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.
@ eFractionalInTime
Fractional in Time scheme.
std::shared_ptr< FractionalInTimeIntegrationScheme > FractionalInTimeIntegrationSchemeSharedPtr
std::ostream & operator<<(std::ostream &os, const BasisKey &rhs)
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
std::vector< double > w(NPUPPER)
double NekDouble