Nektar++
TimeIntegrationScheme.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: TimeIntegrationScheme.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 base class,
32 // this class is the parent class for the TimeIntegrationSchemeGLM and
33 // TimeIntegrationSchemeFIT classes.
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
37 #ifndef NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME
38 #define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SCHEME
39 
40 #include <string>
41 
42 #include <boost/core/ignore_unused.hpp>
43 
49 
52 
53 #define LUE LIB_UTILITIES_EXPORT
54 
55 namespace Nektar
56 {
57 namespace LibUtilities
58 {
59 
60 /// Datatype of the NekFactory used to instantiate classes derived from the
61 /// EquationSystem class.
62 typedef NekFactory<std::string,
63  TimeIntegrationScheme, std::string, unsigned int,
64  std::vector<NekDouble> > TimeIntegrationSchemeFactory;
65 
66 // Allows a code to create a TimeIntegrator. Usually used like this:
67 //
68 // LibUtilities::TimeIntegrationSchemeSharedPtr timeIntegrationScheme =
69 // LibUtilities::GetTimeIntegrationSchemeFactory().CreateInstance(
70 // "IMEX", "dirk", 3, std::vector<unsigned int>{2,3} );
72 
73 /**
74  * @brief Base class for time integration schemes.
75  */
77 {
78 public:
79  // Access methods
80  LUE virtual std::string GetFullName () const;
81  LUE virtual std::string GetName () const = 0;
82  LUE virtual std::string GetVariant () const = 0;
83  LUE virtual unsigned int GetOrder () const = 0;
84  LUE virtual std::vector< NekDouble > GetFreeParams() const = 0;
85 
87 
88  LUE virtual NekDouble GetTimeStability() const = 0;
89 
90  LUE virtual unsigned int GetNumIntegrationPhases() const = 0;
91 
92  /**
93  * \brief Gets the solution vector of the ODE
94  */
95  virtual const TripleArray &GetSolutionVector() const = 0;
96 
97  /**
98  * \brief Sets the solution vector of the ODE
99  */
100  virtual void SetSolutionVector(const int Offset, const DoubleArray &y) = 0;
101 
102  // The worker methods
103  /**
104  * \brief Explicit integration of an ODE.
105  *
106  * This function explicitely perfroms a single integration step of the ODE
107  * system:
108  * \f[
109  * \frac{d\boldsymbol{y}}{dt}=\boldsymbol{f}(t,\boldsymbol{y})
110  * \f]
111  *
112  * \param timestep The size of the timestep, i.e. \f$\Delta t\f$.
113  * \param f an object of the class FuncType, where FuncType should have a
114  * method FuncType::ODEforcing
115  * to evaluate the right hand side \f$f(t,\boldsymbol{y})\f$ of the
116  * ODE.
117  * \param y on input: the vectors \f$\boldsymbol{y}^{[n-1]}\f$ and
118  * \f$t^{[n-1]}\f$ (which corresponds to the
119  * solution at the old time level)
120  * \param y on output: the vectors \f$\boldsymbol{y}^{[n]}\f$ and
121  * \f$t^{[n]}\f$ (which corresponds to the
122  * solution at the old new level)
123  * \return The actual solution \f$\boldsymbol{y}^{n}\f$ at the new time
124  * level
125  * (which in fact is also embedded in the argument y).
126  */
127  LUE virtual void InitializeScheme(
128  const NekDouble deltaT, ConstDoubleArray &y_0,
129  const NekDouble time, const TimeIntegrationSchemeOperators &op) = 0;
130 
132  const int timestep, const NekDouble delta_t,
133  const TimeIntegrationSchemeOperators &op) = 0;
134 
135  LUE virtual void print(std::ostream &os) const = 0;
136  LUE virtual void printFull(std::ostream &os) const = 0;
137 
138  // Friend classes
139  LUE friend std::ostream &operator<<(std::ostream &os,
140  const TimeIntegrationScheme &rhs);
141  LUE friend std::ostream &operator<<(std::ostream &os,
142  const TimeIntegrationSchemeSharedPtr &rhs);
143 
144 protected:
145  // These methods should never be used directly, only used by child classes.
146  LUE TimeIntegrationScheme(std::string variant, unsigned int order,
147  std::vector<NekDouble> freeParams)
148  {
149  boost::ignore_unused(variant, order, freeParams);
150  }
151 
153  {
154  boost::ignore_unused(in);
155 
156  NEKERROR(ErrorUtil::efatal, "Copy Constructor for the "
157  "TimeIntegrationScheme class should not be "
158  "called");
159  }
160 
162  {
163  }
164 
165 }; // end class TimeIntegrationScheme
166 
167 LUE std::ostream &operator<<(std::ostream &os,
168  const TimeIntegrationScheme &rhs);
169 
170 LUE std::ostream &operator<<(std::ostream &os,
171  const TimeIntegrationSchemeSharedPtr &rhs);
172 
173 } // end of namespace LibUtilities
174 } // end of namespace Nektar
175 
176 #endif
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209
#define LUE
Provides a generic Factory class.
Definition: NekFactory.hpp:105
Base class for time integration schemes.
virtual void SetSolutionVector(const int Offset, const DoubleArray &y)=0
Sets the solution vector of the ODE.
LUE TimeIntegrationScheme(const TimeIntegrationScheme &in)
virtual LUE TimeIntegrationSchemeType GetIntegrationSchemeType() const =0
virtual LUE std::string GetName() const =0
virtual LUE void InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op)=0
Explicit integration of an ODE.
virtual LUE std::vector< NekDouble > GetFreeParams() const =0
virtual const TripleArray & GetSolutionVector() const =0
Gets the solution vector of the ODE.
LUE friend std::ostream & operator<<(std::ostream &os, const TimeIntegrationScheme &rhs)
virtual LUE unsigned int GetOrder() const =0
virtual LUE void printFull(std::ostream &os) const =0
virtual LUE NekDouble GetTimeStability() const =0
virtual LUE ConstDoubleArray & TimeIntegrate(const int timestep, const NekDouble delta_t, const TimeIntegrationSchemeOperators &op)=0
LUE TimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
virtual LUE void print(std::ostream &os) const =0
virtual LUE std::string GetVariant() const =0
virtual LUE unsigned int GetNumIntegrationPhases() const =0
Binds a set of functions for use by time integration schemes.
NekFactory< std::string, TimeIntegrationScheme, std::string, unsigned int, std::vector< NekDouble > > TimeIntegrationSchemeFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class.
TimeIntegrationSchemeFactory & GetTimeIntegrationSchemeFactory()
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