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_step_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_STEP_METHOD_H_INCLUDED)
11 #define KRATOS_BOSSAK_STEP_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 BossakStepMethod : public NewmarkStepMethod<TVariableType,TValueType>
51  {
52  public:
53 
56 
59 
61  typedef typename BaseType::Pointer BasePointerType;
62 
64  typedef typename BaseType::NodeType NodeType;
65 
68 
71 
72 
74 
78 
79 
82 
84  BossakStepMethod(const TVariableType& rVariable) : DerivedType(rVariable) {}
85 
87  BossakStepMethod(const TVariableType& rVariable, const TVariableType& rFirstDerivative, const TVariableType& rSecondDerivative) : DerivedType(rVariable,rFirstDerivative,rSecondDerivative) {}
88 
90  BossakStepMethod(const TVariableType& rVariable, const TVariableType& rFirstDerivative, const TVariableType& rSecondDerivative, const TVariableType& rPrimaryVariable) : DerivedType(rVariable,rFirstDerivative,rSecondDerivative,rPrimaryVariable) {}
91 
94  :DerivedType(rOther)
95  ,mAlpha(rOther.mAlpha)
96  {
97  }
98 
101  {
102  return BasePointerType( new BossakStepMethod(*this) );
103  }
104 
106  ~BossakStepMethod() override{}
107 
111 
115 
116  //calculate parameters (to call it once with the original input parameters)
117  void CalculateParameters(ProcessInfo& rCurrentProcessInfo) override
118  {
119  KRATOS_TRY
120 
121  double beta = 0.25;
122  if (rCurrentProcessInfo.Has(NEWMARK_BETA))
123  {
124  beta = rCurrentProcessInfo[NEWMARK_BETA];
125  }
126  double gamma = 0.5;
127  if (rCurrentProcessInfo.Has(NEWMARK_GAMMA))
128  {
129  gamma = rCurrentProcessInfo[NEWMARK_GAMMA];
130  }
131 
132  mAlpha = -0.3;
133  if (rCurrentProcessInfo.Has(BOSSAK_ALPHA))
134  {
135  mAlpha = rCurrentProcessInfo[BOSSAK_ALPHA];
136  }
137 
138  if(mAlpha > 0.0 || mAlpha < -0.3)
139  {
140  KRATOS_ERROR << "Value not admissible for AlphaBossak. Admissible values should be between 0.0 and -0.3. Current value is " << mAlpha << std::endl;
141  }
142 
143  beta = (1.0 - mAlpha) * (1.0 - mAlpha) * beta;
144  gamma = gamma - mAlpha;
145 
146  rCurrentProcessInfo[NEWMARK_BETA] = beta;
147  rCurrentProcessInfo[NEWMARK_GAMMA] = gamma;
148  rCurrentProcessInfo[BOSSAK_ALPHA] = mAlpha;
149 
150  this->SetParameters(rCurrentProcessInfo);
151 
152  KRATOS_CATCH( "" )
153  }
154 
155  // set parameters (do not calculate parameters here, only read them)
156  void SetParameters(const ProcessInfo& rCurrentProcessInfo) override
157  {
158  KRATOS_TRY
159 
160  double delta_time = rCurrentProcessInfo[DELTA_TIME];
161 
162  if (delta_time < 1.0e-24)
163  {
164  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;
165  }
166 
167  double beta = 0.25;
168  if (rCurrentProcessInfo.Has(NEWMARK_BETA))
169  {
170  beta = rCurrentProcessInfo[NEWMARK_BETA];
171  }
172  double gamma = 0.5;
173  if (rCurrentProcessInfo.Has(NEWMARK_GAMMA))
174  {
175  gamma = rCurrentProcessInfo[NEWMARK_GAMMA];
176  }
177 
178  mAlpha = -0.3;
179  if (rCurrentProcessInfo.Has(BOSSAK_ALPHA))
180  {
181  mAlpha = rCurrentProcessInfo[BOSSAK_ALPHA];
182  }
183 
184  if(mAlpha > 0.0 || mAlpha < -0.3)
185  {
186  KRATOS_ERROR << "Value not admissible for AlphaBossak. Admissible values should be between 0.0 and -0.3. Current value is " << mAlpha << std::endl;
187  }
188 
190 
191  KRATOS_CATCH( "" )
192  }
193 
194 
195  // set parameters to process info
196  void SetProcessInfoParameters(ProcessInfo& rCurrentProcessInfo) override
197  {
198  KRATOS_TRY
199 
200  rCurrentProcessInfo[NEWMARK_BETA] = this->mNewmark.beta;
201  rCurrentProcessInfo[NEWMARK_GAMMA] = this->mNewmark.gamma;
202  rCurrentProcessInfo[BOSSAK_ALPHA] = this->mAlpha;
203 
204  KRATOS_CATCH( "" )
205  }
206 
207 
211 
215 
219 
220 
222  std::string Info() const override
223  {
224  std::stringstream buffer;
225  buffer << "BossakStepMethod";
226  return buffer.str();
227  }
228 
230  void PrintInfo(std::ostream& rOStream) const override
231  {
232  rOStream << "BossakStepMethod";
233  }
234 
236  void PrintData(std::ostream& rOStream) const override
237  {
238  rOStream << "BossakStepMethod Data";
239  }
240 
241 
245 
246 
248 
249  protected:
250 
253 
257 
258  double mAlpha;
259 
263 
267 
271 
272  double& GetSecondDerivativeKineticParameter(double& rParameter) override
273  {
274  rParameter = mAlpha;
275  return rParameter;
276  }
277 
278  double& GetSecondDerivativeInertialParameter(double& rParameter) override
279  {
280  rParameter = (1.0 - mAlpha) * this->mNewmark.c0;
281  return rParameter;
282  }
283 
287 
291 
293 
294  private:
295 
298 
302 
306 
310 
314 
318  friend class Serializer;
319 
320  void save(Serializer& rSerializer) const override
321  {
323  rSerializer.save("BossakAlpha", mAlpha);
324  };
325 
326  void load(Serializer& rSerializer) override
327  {
329  rSerializer.load("BossakAlpha", mAlpha);
330  };
331 
335 
339 
341 
342  }; // Class BossakStepMethod
343 
345 
348 
349 
353 
354  template<class TVariableType, class TValueType>
355  inline std::istream & operator >> (std::istream & rIStream, BossakStepMethod<TVariableType,TValueType>& rThis)
356  {
357  return rIStream;
358  }
359 
360  template<class TVariableType, class TValueType>
361  inline std::ostream & operator << (std::ostream & rOStream, const BossakStepMethod<TVariableType,TValueType>& rThis)
362  {
363  return rOStream << rThis.Info();
364  }
365 
367 
369 
370 } // namespace Kratos.
371 
372 #endif // KRATOS_BOSSAK_STEP_METHOD_H_INCLUDED defined
Short class definition.
Definition: bossak_step_method.hpp:51
BaseType::Pointer BasePointerType
BasePointerType.
Definition: bossak_step_method.hpp:61
BossakStepMethod(const TVariableType &rVariable, const TVariableType &rFirstDerivative, const TVariableType &rSecondDerivative)
Constructor.
Definition: bossak_step_method.hpp:87
double mAlpha
Definition: bossak_step_method.hpp:258
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: bossak_step_method.hpp:236
BossakStepMethod(const TVariableType &rVariable, const TVariableType &rFirstDerivative, const TVariableType &rSecondDerivative, const TVariableType &rPrimaryVariable)
Constructor.
Definition: bossak_step_method.hpp:90
BaseType::NodeType NodeType
NodeType.
Definition: bossak_step_method.hpp:64
KRATOS_CLASS_POINTER_DEFINITION(BossakStepMethod)
BossakStepMethod()
Default Constructor.
Definition: bossak_step_method.hpp:81
TimeIntegrationMethod< TVariableType, TValueType > BaseType
BaseType.
Definition: bossak_step_method.hpp:58
double & GetSecondDerivativeKineticParameter(double &rParameter) override
Definition: bossak_step_method.hpp:272
double & GetSecondDerivativeInertialParameter(double &rParameter) override
Definition: bossak_step_method.hpp:278
NewmarkStepMethod< TVariableType, TValueType > DerivedType
DerivedType.
Definition: bossak_step_method.hpp:70
BaseType::VariablePointer VariablePointer
KratosVariable or KratosVariableComponent.
Definition: bossak_step_method.hpp:67
std::string Info() const override
Turn back information as a string.
Definition: bossak_step_method.hpp:222
BossakStepMethod(BossakStepMethod &rOther)
Copy Constructor.
Definition: bossak_step_method.hpp:93
BossakStepMethod(const TVariableType &rVariable)
Constructor.
Definition: bossak_step_method.hpp:84
BasePointerType Clone() override
Clone.
Definition: bossak_step_method.hpp:100
void CalculateParameters(ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_step_method.hpp:117
void SetParameters(const ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_step_method.hpp:156
~BossakStepMethod() override
Destructor.
Definition: bossak_step_method.hpp:106
void SetProcessInfoParameters(ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_step_method.hpp:196
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: bossak_step_method.hpp:230
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
NewmarkParameters mNewmark
Definition: newmark_method.hpp:320
Short class definition.
Definition: newmark_step_method.hpp:51
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