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 
49 namespace Nektar
50 {
51 namespace LibUtilities
52 {
53 
54 ///////////////////////////////////////////////////////////////////////////////
55 /// Class for fractional-in-time integration.
57 {
58 public:
59  /// Constructor
60  FractionalInTimeIntegrationScheme(std::string variant, unsigned int order,
61  std::vector<NekDouble> freeParams);
62 
63  /// Destructor
65  {
66  }
67 
68  /// Creator
70  std::string variant, unsigned int order,
71  std::vector<NekDouble> freeParams)
72  {
75  variant, order, freeParams);
76 
77  return p;
78  }
79 
80  static std::string className;
81 
82  // Access methods from the base class that are virtual
83  LUE virtual std::string GetName() const
84  {
85  return m_name;
86  }
87 
88  LUE virtual std::string GetVariant() const
89  {
90  return m_variant;
91  }
92 
93  LUE virtual unsigned int GetOrder() const
94  {
95  return m_order;
96  }
97 
98  LUE virtual std::vector<NekDouble> GetFreeParams() const
99  {
100  return m_freeParams;
101  }
102 
104  {
105  return m_schemeType;
106  }
107 
109  {
110  return 1.0;
111  }
112 
113  LUE unsigned int GetNumIntegrationPhases() const
114  {
115  return 1;
116  }
117 
118  /**
119  * \brief Gets the solution vector of the ODE
120  */
121  inline const TripleArray &GetSolutionVector() const
122  {
123  return m_u;
124  }
125 
126  /**
127  * \brief Sets the solution vector of the ODE
128  */
129  inline void SetSolutionVector(const int Offset, const DoubleArray &y)
130  {
131  m_u[Offset] = y;
132  }
133 
134  // The worker methods from the base class that are virtual
135  LUE virtual void InitializeScheme(const NekDouble deltaT,
136  ConstDoubleArray &y_0,
137  const NekDouble time,
139 
141  const int timestep, const NekDouble delta_t,
143 
144  LUE virtual void print(std::ostream &os) const;
145  LUE virtual void printFull(std::ostream &os) const;
146 
147  // Friend classes
148  LUE friend std::ostream &operator<<(
149  std::ostream &os, const FractionalInTimeIntegrationScheme &rhs);
150  LUE friend std::ostream &operator<<(
151  std::ostream &os,
153 
154 protected:
155  struct Instance
156  {
157  int base;
158 
159  int index; // Index of this instance
160  bool active; // Used to determine if active
161  int activecounter; // counter used to flip active bit
163 
164  // Major storage for auxilliary ODE solutions.
165  // Storage for values of y currently used to update u
167  std::pair<int, int> stage_ind; // Time-step counters indicating the
168  // interval ymain is associated with
169 
170  // Staging allocation
173  int stage_cbase; // This base is halved after the first cycle
175  int stage_fbase; // This base is halved after the first cycle
176 
177  // Ceiling stash allocation
178  int cstash_counter; // Counter used to determine
179  // when to stash
180  int cstash_base; // base for counter
182  std::pair<int, int> 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<int, int> csandbox_ind;
191 
192  // Floor stash
195  std::pair<int, int> fstash_ind;
196 
197  // Floor sandbox
202  std::pair<int, int> fsandbox_ind;
203 
204  // Talbot quadrature rule
207 
209 
213  };
214 
215  inline unsigned int modIncrement(const unsigned int counter,
216  const unsigned int base) const;
217 
218  inline unsigned int computeL(const unsigned int base,
219  const unsigned int m) const;
220 
221  inline unsigned int computeQML(const unsigned int base,
222  const unsigned int m);
223 
224  inline unsigned int computeTaus(const unsigned int base,
225  const unsigned int m);
226 
227  void talbotQuadrature(const unsigned int nQuadPts, const NekDouble mu,
228  const NekDouble nu, const NekDouble sigma,
229  ComplexSingleArray &lamb,
230  ComplexSingleArray &w) const;
231 
232  void integralClassInitialize(const unsigned int index,
233  Instance &instance) const;
234 
235  void updateStage(const unsigned int timeStep, Instance &instance);
236 
237  void finalIncrement(const unsigned int timeStep,
239 
240  void integralContribution(const unsigned int timeStep,
241  const unsigned int tauml,
242  const Instance &instance);
243 
244  void timeAdvance(const unsigned int timeStep,
246  Instance &instance, ComplexTripleArray &y);
247 
248  void advanceSandbox(const unsigned int timeStep,
250  Instance &instance);
251 
252  // Variables common to all schemes.
253  std::string m_name;
254  std::string m_variant;
255  unsigned int m_order{0};
256  std::vector<NekDouble> m_freeParams;
257 
259 
260  // Varaibles and methods specific to FIT integration schemes.
262  NekDouble m_T{0}; // Finial time
263  unsigned int m_maxTimeSteps; // Number of time steps.
264  NekDouble m_alpha{0.3}; // Value for exp integration.
265  unsigned int m_base{4}; // "Base" of the algorithm.
266  unsigned int m_nQuadPts{20}; // Number of Talbot quadrature rule points
270 
271  int m_nvars{0}; // Number of variables in the integration scheme.
272  int m_npoints{0}; // Number of points in the integration scheme.
273 
274  unsigned int m_Lmax{0}; // Maxium number of integral groups.
276 
277  // Demarcation integers
279  // Demarcation interval markers
281 
282  // Storage of the initial values.
284  // Storage of the next solution from the final increment.
286  // Storage for the integral contribution.
288  // Storage for the exponential factor in the integral contribution.
290 
291  // Storage of previous states and associated timesteps.
293 
294  // Storage for the stage derivative as the data will be re-used to
295  // update the solution.
297 
298  // J
300 
301  // Ahat array one for each order.
303 
304  // Mulitply the last Ahat array, transposed by J
306 
307 }; // end class FractionalInTimeIntegrator
308 
309 LUE std::ostream &operator<<(std::ostream &os,
311 LUE std::ostream &operator<<(
312  std::ostream &os, const FractionalInTimeIntegrationSchemeSharedPtr &rhs);
313 
314 } // end namespace LibUtilities
315 } // end namespace Nektar
316 
317 #endif
#define LUE
unsigned int modIncrement(const unsigned int counter, const unsigned int base) const
Method that increments the counter then performs mod calculation.
virtual LUE void print(std::ostream &os) const
Worker method to print details on the integration scheme.
void updateStage(const unsigned int timeStep, Instance &instance)
Method to rearrange of staging/stashing for current time.
void integralClassInitialize(const unsigned int index, Instance &instance) const
Method to initialize the integral class.
unsigned int computeQML(const unsigned int base, const unsigned int m)
Method to compute the demarcation integers q_{m, ell}.
virtual LUE TimeIntegrationSchemeType GetIntegrationSchemeType() const
unsigned int computeL(const unsigned int base, const unsigned int m) const
Method to compute the smallest integer L such that base < 2.
void timeAdvance(const unsigned int timeStep, const TimeIntegrationSchemeOperators &op, 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, unsigned int order, std::vector< NekDouble > freeParams)
Creator.
virtual LUE std::vector< NekDouble > GetFreeParams() const
virtual LUE void InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op)
Worker method to initialize the integration scheme.
virtual LUE ConstDoubleArray & TimeIntegrate(const int timestep, const NekDouble delta_t, const TimeIntegrationSchemeOperators &op)
Worker method that performs the time integration.
unsigned int computeTaus(const unsigned int base, const unsigned int m)
Method to compute the demarcation interval marker tau_{m, ell}.
void talbotQuadrature(const unsigned int nQuadPts, const NekDouble mu, const NekDouble nu, const NekDouble sigma, ComplexSingleArray &lamb, ComplexSingleArray &w) const
Method to compute the quadrature rule over Tablot contour.
void advanceSandbox(const unsigned int timeStep, const TimeIntegrationSchemeOperators &op, Instance &instance)
Method to update sandboxes to the current time.
FractionalInTimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
Constructor.
LUE friend std::ostream & operator<<(std::ostream &os, const FractionalInTimeIntegrationScheme &rhs)
void finalIncrement(const unsigned int timeStep, const TimeIntegrationSchemeOperators &op)
Method to approximate the integral.
void integralContribution(const unsigned int timeStep, const unsigned int tauml, const Instance &instance)
Method to get the integral contribution over [taus(i+1) taus(i)]. Stored in m_uInt.
const TripleArray & GetSolutionVector() const
Gets the solution vector of the ODE.
void SetSolutionVector(const int Offset, const DoubleArray &y)
Sets the solution vector of the ODE.
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
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble