KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
time_discretization.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Philipp Bucher
11 // Ruben Zorrilla
12 //
13 
14 #if !defined( KRATOS_TIME_DISCRETIZATION_H_INCLUDED )
15 #define KRATOS_TIME_DISCRETIZATION_H_INCLUDED
16 
17 // System includes
18 #include <vector>
19 
20 // External includes
21 
22 // Project includes
23 
24 namespace Kratos {
25 
26 class ProcessInfo; // forward-declaring to not having to include it here
27 
28 namespace TimeDiscretization {
29 
30 class KRATOS_API(KRATOS_CORE) BDF
31 {
32 public:
33 
35 
41  BDF(const unsigned int TimeOrder) : mTimeOrder(TimeOrder)
42  {
43  this->SetAuxBDFPointer(TimeOrder, mpAuxBDF);
44  };
45 
50  virtual ~BDF() = default;
51 
58  virtual std::vector<double> ComputeBDFCoefficients(double DeltaTime) const;
59 
67  virtual std::vector<double> ComputeBDFCoefficients(double DeltaTime, double PreviousDeltaTime) const;
68 
76  virtual std::vector<double> ComputeBDFCoefficients(const ProcessInfo& rProcessInfo) const;
77 
85  void ComputeAndSaveBDFCoefficients(ProcessInfo &rProcessInfo) const;
86 
92  std::size_t GetTimeOrder() const;
93 
94 protected:
95 
100  BDF(){};
101 
102 private:
103 
104  const std::size_t mTimeOrder = 0; // Time order of the auxiliary BDF class
105  Kratos::unique_ptr<BDF> mpAuxBDF = nullptr; // Pointer to an auxiliary BDF class with order
106 
114  static void SetAuxBDFPointer(
115  const std::size_t TimeOrder,
116  Kratos::unique_ptr<BDF> &rpAuxBDF);
117 };
118 
119 class KRATOS_API(KRATOS_CORE) BDF1 : public BDF
120 {
121 public:
122  std::vector<double> ComputeBDFCoefficients(double DeltaTime) const override;
123  std::vector<double> ComputeBDFCoefficients(const ProcessInfo& rProcessInfo) const override;
124 };
125 
126 class KRATOS_API(KRATOS_CORE) BDF2 : public BDF
127 {
128 public:
129  std::vector<double> ComputeBDFCoefficients(double DeltaTime, double PreviousDeltaTime) const override;
130  std::vector<double> ComputeBDFCoefficients(const ProcessInfo& rProcessInfo) const override;
131 };
132 
133 class KRATOS_API(KRATOS_CORE) BDF3 : public BDF
134 {
135 public:
136  std::vector<double> ComputeBDFCoefficients(double DeltaTime) const override;
137  std::vector<double> ComputeBDFCoefficients(const ProcessInfo& rProcessInfo) const override;
138 };
139 
140 class KRATOS_API(KRATOS_CORE) BDF4 : public BDF
141 {
142 public:
143  std::vector<double> ComputeBDFCoefficients(double DeltaTime) const override;
144  std::vector<double> ComputeBDFCoefficients(const ProcessInfo& rProcessInfo) const override;
145 };
146 
147 class KRATOS_API(KRATOS_CORE) BDF5 : public BDF
148 {
149 public:
150  std::vector<double> ComputeBDFCoefficients(double DeltaTime) const override;
151  std::vector<double> ComputeBDFCoefficients(const ProcessInfo& rProcessInfo) const override;
152 };
153 
154 class KRATOS_API(KRATOS_CORE) BDF6 : public BDF
155 {
156 public:
157  std::vector<double> ComputeBDFCoefficients(double DeltaTime) const override;
158  std::vector<double> ComputeBDFCoefficients(const ProcessInfo& rProcessInfo) const override;
159 };
160 
161 class Newmark
162 {
163 public:
164  Newmark() = default;
165 
166  explicit Newmark(const double NewmarkBeta,
167  const double NewmarkGamma)
168  : mNewmarkBeta(NewmarkBeta),
169  mNewmarkGamma(NewmarkGamma) {}
170 
171  double GetBeta() const { return mNewmarkBeta; }
172  double GetGamma() const { return mNewmarkGamma; }
173 
174 private:
175  double mNewmarkBeta=0.25;
176  double mNewmarkGamma=0.5;
177 };
178 
179 class Bossak
180 {
181 public:
182  Bossak() = default;
183 
184  explicit Bossak(const double AlphaM)
185  : mAlphaM(AlphaM) {}
186 
187  explicit Bossak(const double AlphaM,
188  const double NewmarkBeta,
189  const double NewmarkGamma)
190  : mAlphaM(AlphaM),
191  mNewmarkBeta(NewmarkBeta),
192  mNewmarkGamma(NewmarkGamma) {}
193 
194  double GetAlphaM() const { return mAlphaM; }
195  double GetBeta() const { return mNewmarkBeta * (1-mAlphaM) * (1-mAlphaM); }
196  double GetGamma() const { return mNewmarkGamma - mAlphaM; }
197 
198 private:
199  double mAlphaM=-0.3;
200  double mNewmarkBeta=0.25;
201  double mNewmarkGamma=0.5;
202 };
203 
205 {
206 public:
207  GeneralizedAlpha() = default;
208 
209  explicit GeneralizedAlpha(const double AlphaM,
210  const double AlphaF)
211  : mAlphaM(AlphaM),
212  mAlphaF(AlphaF) {}
213 
214  explicit GeneralizedAlpha(const double AlphaM,
215  const double AlphaF,
216  const double NewmarkBeta,
217  const double NewmarkGamma)
218  : mAlphaM(AlphaM),
219  mAlphaF(AlphaF),
220  mNewmarkBeta(NewmarkBeta),
221  mNewmarkGamma(NewmarkGamma) {}
222 
223  double GetAlphaM() const { return mAlphaM; }
224  double GetAlphaF() const { return mAlphaF; }
225  double GetBeta() const { return mNewmarkBeta * (1-mAlphaM+mAlphaF) * (1-mAlphaM+mAlphaF); }
226  double GetGamma() const { return mNewmarkGamma - mAlphaM + mAlphaF; }
227 
228 private:
229  double mAlphaM=-0.3;
230  double mAlphaF=0.0;
231  double mNewmarkBeta=0.25;
232  double mNewmarkGamma=0.5;
233 };
234 
235 inline std::size_t GetMinimumBufferSize(const BDF& rTimeDiscr) { return (rTimeDiscr.GetTimeOrder() + 1); }
236 inline std::size_t GetMinimumBufferSize(const BDF1& rTimeDiscr) { return 2;}
237 inline std::size_t GetMinimumBufferSize(const BDF2& rTimeDiscr) { return 3;}
238 inline std::size_t GetMinimumBufferSize(const BDF3& rTimeDiscr) { return 4;}
239 inline std::size_t GetMinimumBufferSize(const BDF4& rTimeDiscr) { return 5;}
240 inline std::size_t GetMinimumBufferSize(const BDF5& rTimeDiscr) { return 6;}
241 inline std::size_t GetMinimumBufferSize(const BDF6& rTimeDiscr) { return 7;}
242 
243 inline std::size_t GetMinimumBufferSize(const Newmark& rTimeDiscr) { return 2;}
244 inline std::size_t GetMinimumBufferSize(const Bossak& rTimeDiscr) { return 2;}
245 inline std::size_t GetMinimumBufferSize(const GeneralizedAlpha& rTimeDiscr) { return 2;}
246 
247 } // namespace TimeDiscretization.
248 } // namespace Kratos.
249 
250 #endif // KRATOS_TIME_DISCRETIZATION_H_INCLUDED defined
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Definition: time_discretization.h:120
Definition: time_discretization.h:127
Definition: time_discretization.h:134
Definition: time_discretization.h:141
Definition: time_discretization.h:148
Definition: time_discretization.h:155
Definition: time_discretization.h:31
BDF(const unsigned int TimeOrder)
Construct a new BDF object Constructor with time order.
Definition: time_discretization.h:41
BDF()
Construct a new BDF object Auxiliary constructor for derived classes.
Definition: time_discretization.h:100
virtual ~BDF()=default
Destroy the BDF object Destructor of the BDF class.
std::size_t GetTimeOrder() const
Get the Time Order object Auxiliary method to get the order of the BDF scheme.
Definition: time_discretization.cpp:101
Definition: time_discretization.h:180
double GetBeta() const
Definition: time_discretization.h:195
Bossak(const double AlphaM)
Definition: time_discretization.h:184
Bossak(const double AlphaM, const double NewmarkBeta, const double NewmarkGamma)
Definition: time_discretization.h:187
double GetGamma() const
Definition: time_discretization.h:196
double GetAlphaM() const
Definition: time_discretization.h:194
Definition: time_discretization.h:205
double GetBeta() const
Definition: time_discretization.h:225
double GetAlphaF() const
Definition: time_discretization.h:224
GeneralizedAlpha(const double AlphaM, const double AlphaF, const double NewmarkBeta, const double NewmarkGamma)
Definition: time_discretization.h:214
double GetGamma() const
Definition: time_discretization.h:226
GeneralizedAlpha(const double AlphaM, const double AlphaF)
Definition: time_discretization.h:209
double GetAlphaM() const
Definition: time_discretization.h:223
Definition: time_discretization.h:162
Newmark(const double NewmarkBeta, const double NewmarkGamma)
Definition: time_discretization.h:166
double GetGamma() const
Definition: time_discretization.h:172
double GetBeta() const
Definition: time_discretization.h:171
std::size_t GetMinimumBufferSize(const BDF &rTimeDiscr)
Definition: time_discretization.h:235
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33
ProcessInfo
Definition: edgebased_PureConvection.py:116