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.
bossak_method.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosSolidMechanicsApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: November 2017 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_BOSSAK_METHOD_H_INCLUDED)
11 #define KRATOS_BOSSAK_METHOD_H_INCLUDED
12 
13 // System includes
14 
15 // External includes
16 
17 // Project includes
19 
20 namespace Kratos
21 {
24 
27 
31 
35 
39 
43 
44 
46 
49  template<class TVariableType, class TValueType>
50  class BossakMethod : public NewmarkMethod<TVariableType,TValueType>
51  {
52  protected:
53 
54 
55  public:
56 
59 
62 
64  typedef typename BaseType::Pointer BasePointerType;
65 
67  typedef typename BaseType::NodeType NodeType;
68 
71 
74 
75 
77 
81 
82 
85 
87  BossakMethod(const TVariableType& rVariable) : DerivedType(rVariable) {}
88 
90  BossakMethod(const TVariableType& rVariable, const TVariableType& rFirstDerivative, const TVariableType& rSecondDerivative) : DerivedType(rVariable,rFirstDerivative,rSecondDerivative) {}
91 
93  BossakMethod(const TVariableType& rVariable, const TVariableType& rFirstDerivative, const TVariableType& rSecondDerivative, const TVariableType& rPrimaryVariable) : DerivedType(rVariable,rFirstDerivative,rSecondDerivative,rPrimaryVariable) {}
94 
97  :DerivedType(rOther)
98  ,mAlpha(rOther.mAlpha)
99  {
100  }
101 
104  {
105  return BasePointerType( new BossakMethod(*this) );
106  }
107 
109  ~BossakMethod() override{}
110 
114 
118 
119  //calculate parameters (to call it once with the original input parameters)
120  void CalculateParameters(ProcessInfo& rCurrentProcessInfo) override
121  {
122  KRATOS_TRY
123 
124  double beta = 0.25;
125  if (rCurrentProcessInfo.Has(NEWMARK_BETA))
126  {
127  beta = rCurrentProcessInfo[NEWMARK_BETA];
128  }
129  double gamma = 0.5;
130  if (rCurrentProcessInfo.Has(NEWMARK_GAMMA))
131  {
132  gamma = rCurrentProcessInfo[NEWMARK_GAMMA];
133  }
134 
135  mAlpha = -0.3;
136  if (rCurrentProcessInfo.Has(BOSSAK_ALPHA))
137  {
138  mAlpha = rCurrentProcessInfo[BOSSAK_ALPHA];
139  }
140 
141  if(mAlpha > 0.0 || mAlpha < -0.3)
142  {
143  KRATOS_ERROR << "Value not admissible for AlphaBossak. Admissible values should be between 0.0 and -0.3. Current value is " << mAlpha << std::endl;
144  }
145 
146  beta = (1.0 - mAlpha) * (1.0 - mAlpha) * beta;
147  gamma = gamma - mAlpha;
148 
149  rCurrentProcessInfo[NEWMARK_BETA] = beta;
150  rCurrentProcessInfo[NEWMARK_GAMMA] = gamma;
151  rCurrentProcessInfo[BOSSAK_ALPHA] = mAlpha;
152 
153  this->SetParameters(rCurrentProcessInfo);
154 
155  KRATOS_CATCH( "" )
156  }
157 
158 
159  // set parameters (do not calculate parameters here, only read them)
160  void SetParameters(const ProcessInfo& rCurrentProcessInfo) override
161  {
162  KRATOS_TRY
163 
164  const double& delta_time = rCurrentProcessInfo[DELTA_TIME];
165 
166  if (delta_time < 1.0e-24)
167  {
168  KRATOS_ERROR << " ERROR: detected delta_time = 0 in the Solution Method DELTA_TIME. PLEASE : check if the time step is created correctly for the current model part " << std::endl;
169  }
170 
171  double beta = 0.25;
172  if (rCurrentProcessInfo.Has(NEWMARK_BETA))
173  {
174  beta = rCurrentProcessInfo[NEWMARK_BETA];
175  }
176  double gamma = 0.5;
177  if (rCurrentProcessInfo.Has(NEWMARK_GAMMA))
178  {
179  gamma = rCurrentProcessInfo[NEWMARK_GAMMA];
180  }
181 
182  mAlpha = -0.3;
183  if (rCurrentProcessInfo.Has(BOSSAK_ALPHA))
184  {
185  mAlpha = rCurrentProcessInfo[BOSSAK_ALPHA];
186  }
187 
188  if(mAlpha > 0.0 || mAlpha < -0.3)
189  {
190  KRATOS_ERROR << "Value not admissible for AlphaBossak. Admissible values should be between 0.0 and -0.3. Current value is " << mAlpha << std::endl;
191  }
192 
194 
195  KRATOS_CATCH( "" )
196  }
197 
198  // set parameters to process info
199  void SetProcessInfoParameters(ProcessInfo& rCurrentProcessInfo) override
200  {
201  KRATOS_TRY
202 
203  rCurrentProcessInfo[NEWMARK_BETA] = this->mNewmark.beta;
204  rCurrentProcessInfo[NEWMARK_GAMMA] = this->mNewmark.gamma;
205  rCurrentProcessInfo[BOSSAK_ALPHA] = this->mAlpha;
206 
207  KRATOS_CATCH( "" )
208  }
209 
210  double& GetSecondDerivativeKineticParameter(double& rParameter) override
211  {
212  rParameter = mAlpha;
213  return rParameter;
214  }
215 
216  double& GetSecondDerivativeInertialParameter(double& rParameter) override
217  {
218  rParameter = (1.0 - mAlpha) * this->mNewmark.c0;
219  return rParameter;
220  }
221 
225 
229 
233 
234 
236  std::string Info() const override
237  {
238  std::stringstream buffer;
239  buffer << "BossakMethod";
240  return buffer.str();
241  }
242 
244  void PrintInfo(std::ostream& rOStream) const override
245  {
246  rOStream << "BossakMethod";
247  }
248 
250  void PrintData(std::ostream& rOStream) const override
251  {
252  rOStream << "BossakMethod Data";
253  }
254 
255 
259 
260 
262 
263  protected:
264 
267 
271 
272  double mAlpha;
273 
277 
281 
285 
289 
293 
295 
296  private:
297 
300 
304 
308 
312 
316 
320  friend class Serializer;
321 
322  void save(Serializer& rSerializer) const override
323  {
325  rSerializer.save("BossakAlpha", mAlpha);
326  };
327 
328  void load(Serializer& rSerializer) override
329  {
331  rSerializer.load("BossakAlpha", mAlpha);
332  };
333 
337 
341 
343 
344  }; // Class BossakMethod
345 
347 
350 
351 
355 
356  template<class TVariableType, class TValueType>
357  inline std::istream & operator >> (std::istream & rIStream, BossakMethod<TVariableType,TValueType>& rThis)
358  {
359  return rIStream;
360  }
361 
362  template<class TVariableType, class TValueType>
363  inline std::ostream & operator << (std::ostream & rOStream, const BossakMethod<TVariableType,TValueType>& rThis)
364  {
365  return rOStream << rThis.Info();
366  }
367 
369 
371 
372 } // namespace Kratos.
373 
374 #endif // KRATOS_BOSSAK_METHOD_H_INCLUDED defined
Short class definition.
Definition: bossak_method.hpp:51
NewmarkMethod< TVariableType, TValueType > DerivedType
DerivedType.
Definition: bossak_method.hpp:73
double & GetSecondDerivativeKineticParameter(double &rParameter) override
Definition: bossak_method.hpp:210
BossakMethod()
Default Constructor.
Definition: bossak_method.hpp:84
void SetParameters(const ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_method.hpp:160
void CalculateParameters(ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_method.hpp:120
BossakMethod(const TVariableType &rVariable, const TVariableType &rFirstDerivative, const TVariableType &rSecondDerivative, const TVariableType &rPrimaryVariable)
Constructor.
Definition: bossak_method.hpp:93
BaseType::Pointer BasePointerType
BasePointerType.
Definition: bossak_method.hpp:64
BaseType::VariablePointer VariablePointer
KratosVariable or KratosVariableComponent.
Definition: bossak_method.hpp:70
BaseType::NodeType NodeType
NodeType.
Definition: bossak_method.hpp:67
BossakMethod(const TVariableType &rVariable, const TVariableType &rFirstDerivative, const TVariableType &rSecondDerivative)
Constructor.
Definition: bossak_method.hpp:90
double mAlpha
Definition: bossak_method.hpp:272
BasePointerType Clone() override
Clone.
Definition: bossak_method.hpp:103
~BossakMethod() override
Destructor.
Definition: bossak_method.hpp:109
BossakMethod(BossakMethod &rOther)
Copy Constructor.
Definition: bossak_method.hpp:96
std::string Info() const override
Turn back information as a string.
Definition: bossak_method.hpp:236
void SetProcessInfoParameters(ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_method.hpp:199
KRATOS_CLASS_POINTER_DEFINITION(BossakMethod)
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: bossak_method.hpp:244
double & GetSecondDerivativeInertialParameter(double &rParameter) override
Definition: bossak_method.hpp:216
BossakMethod(const TVariableType &rVariable)
Constructor.
Definition: bossak_method.hpp:87
TimeIntegrationMethod< TVariableType, TValueType > BaseType
BaseType.
Definition: bossak_method.hpp:61
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: bossak_method.hpp:250
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
Short class definition.
Definition: newmark_method.hpp:51
NewmarkParameters mNewmark
Definition: newmark_method.hpp:320
This class defines the node.
Definition: node.h:65
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
void load(std::string const &rTag, TDataType &rObject)
Definition: serializer.h:207
void save(std::string const &rTag, std::array< TDataType, TDataSize > const &rObject)
Definition: serializer.h:545
Short class definition.
Definition: time_integration_method.hpp:55
const TVariableType * VariablePointer
KratosVariable or KratosVariableComponent.
Definition: time_integration_method.hpp:65
#define KRATOS_SERIALIZE_SAVE_BASE_CLASS(Serializer, BaseType)
Definition: define.h:812
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_SERIALIZE_LOAD_BASE_CLASS(Serializer, BaseType)
Definition: define.h:815
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
delta_time
Definition: generate_frictional_mortar_condition.py:130
float gamma
Definition: generate_two_fluid_navier_stokes.py:131
def load(f)
Definition: ode_solve.py:307
double beta
Definition: newmark_method.hpp:56
double gamma
Definition: newmark_method.hpp:57
double c0
Definition: newmark_method.hpp:62
void SetParameters(const double &rbeta, const double &rgamma, const double &rdelta_time)
Definition: newmark_method.hpp:69