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.
static_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_STATIC_STEP_METHOD_H_INCLUDED)
11 #define KRATOS_STATIC_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 KRATOS_API(SOLID_MECHANICS_APPLICATION) StaticStepMethod : public StaticMethod<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  {
83  mpStepVariable = nullptr;
84  }
85 
87  StaticStepMethod(const TVariableType& rVariable) : DerivedType(rVariable)
88  {
89  mpStepVariable = nullptr;
90  }
91 
93  StaticStepMethod(const TVariableType& rVariable, const TVariableType& rFirstDerivative, const TVariableType& rSecondDerivative) : DerivedType(rVariable,rFirstDerivative,rSecondDerivative)
94  {
95  mpStepVariable = nullptr;
96  }
97 
99  StaticStepMethod(const TVariableType& rVariable, const TVariableType& rFirstDerivative, const TVariableType& rSecondDerivative, const TVariableType& rPrimaryVariable) : DerivedType(rVariable,rFirstDerivative,rSecondDerivative,rPrimaryVariable)
100  {
101  mpStepVariable = nullptr;
102  }
103 
106  :DerivedType(rOther)
107  ,mpStepVariable(rOther.mpStepVariable)
108  {
109  }
110 
113  {
114  return BasePointerType( new StaticStepMethod(*this) );
115  }
116 
118  ~StaticStepMethod() override{}
119 
123 
127 
128  // has step variable
129  bool HasStepVariable() override
130  {
131  return true;
132  }
133 
134  // set step variable (step variable)
135  void SetStepVariable(const TVariableType& rStepVariable) override
136  {
137  mpStepVariable = &rStepVariable;
138  }
139 
140  // Assign
141  void Assign(NodeType& rNode) override
142  {
143  KRATOS_TRY
144 
145  this->PredictStepVariable(rNode);
146  this->PredictVariable(rNode);
147 
148  KRATOS_CATCH( "" )
149  }
150 
151  // predict
152  void Predict(NodeType& rNode) override
153  {
154  KRATOS_TRY
155 
156  this->PredictStepVariable(rNode);
157  this->PredictVariable(rNode);
158 
159  KRATOS_CATCH( "" )
160  }
161 
162  // update
163  void Update(NodeType& rNode) override
164  {
165  KRATOS_TRY
166 
167  this->UpdateStepVariable(rNode);
168  this->UpdateVariable(rNode);
169 
170  KRATOS_CATCH( "" )
171  }
172 
177  int Check( const ProcessInfo& rCurrentProcessInfo ) override
178  {
179  KRATOS_TRY
180 
181  // Perform base integration method checks
182  int ErrorCode = 0;
183  ErrorCode = BaseType::Check(rCurrentProcessInfo);
184 
185 
186  if( this->mpStepVariable == nullptr ){
187  KRATOS_ERROR << " time integration method Step Variable not set " <<std::endl;
188  }
189 
190  return ErrorCode;
191 
192  KRATOS_CATCH("")
193  }
194 
198 
202 
206 
207 
209  std::string Info() const override
210  {
211  std::stringstream buffer;
212  buffer << "StaticStepMethod";
213  return buffer.str();
214  }
215 
217  void PrintInfo(std::ostream& rOStream) const override
218  {
219  rOStream << "StaticStepMethod";
220  }
221 
223  void PrintData(std::ostream& rOStream) const override
224  {
225  rOStream << "StaticStepMethod Data";
226  }
227 
228 
232 
233 
235 
236  protected:
237 
240 
244 
245  // method variables
247 
251 
255 
256  void PredictVariable(NodeType& rNode) override
257  {
258  KRATOS_TRY
259 
260  const TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
261  TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
262 
263  // update variable previous iteration instead of previous step
264  PreviousVariable = CurrentVariable;
265 
266  KRATOS_CATCH( "" )
267  }
268 
269  virtual void PredictStepVariable(NodeType& rNode)
270  {
271  KRATOS_TRY
272 
273  // predict step variable from previous and current values
274  TValueType& CurrentStepVariable = rNode.FastGetSolutionStepValue(*this->mpStepVariable, 0);
275 
276  const TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
277  const TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
278 
279  CurrentStepVariable = CurrentVariable-PreviousVariable;
280 
281  KRATOS_CATCH( "" )
282  }
283 
284 
285  virtual void UpdateStepVariable(NodeType& rNode)
286  {
287  KRATOS_TRY
288 
289  // predict step variable from previous and current values
290  TValueType& CurrentStepVariable = rNode.FastGetSolutionStepValue(*this->mpStepVariable, 0);
291 
292  const TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
293  const TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
294 
295  CurrentStepVariable += CurrentVariable-PreviousVariable;
296 
297  KRATOS_CATCH( "" )
298  }
299 
300  void UpdateVariable(NodeType& rNode) override
301  {
302  KRATOS_TRY
303 
304  const TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
305  TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
306 
307  // update variable previous iteration instead of previous step
308  PreviousVariable = CurrentVariable;
309 
310  KRATOS_CATCH( "" )
311  }
312 
316 
320 
324 
326 
327  private:
328 
331 
335 
339 
343 
347 
351  friend class Serializer;
352 
353  void save(Serializer& rSerializer) const override
354  {
356  // rSerializer.save("StepVariable", mpStepVariable);
357  };
358 
359  void load(Serializer& rSerializer) override
360  {
361  KRATOS_SERIALIZE_LOAD_BASE_CLASS( rSerializer, BaseType )
362  // rSerializer.load("StepVariable", mpStepVariable);
363  };
364 
368 
372 
374 
375  }; // Class StaticStepMethod
376 
378 
381 
382 
386 
387  template<class TVariableType, class TValueType>
388  inline std::istream & operator >> (std::istream & rIStream, StaticStepMethod<TVariableType,TValueType>& rThis)
389  {
390  return rIStream;
391  }
392 
393  template<class TVariableType, class TValueType>
394  inline std::ostream & operator << (std::ostream & rOStream, const StaticStepMethod<TVariableType,TValueType>& rThis)
395  {
396  return rOStream << rThis.Info();
397  }
398 
400 
402 
403 } // namespace Kratos.
404 
405 #endif // KRATOS_STATIC_STEP_METHOD_H_INCLUDED defined
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
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
Short class definition.
Definition: static_method.hpp:51
BaseType::VariablePointer VariablePointer
KratosVariable or KratosVariableComponent.
Definition: static_method.hpp:67
BaseType::Pointer BasePointerType
BasePointerType.
Definition: static_method.hpp:61
Short class definition.
Definition: static_step_method.hpp:51
void Assign(NodeType &rNode) override
Definition: static_step_method.hpp:141
StaticStepMethod(StaticStepMethod &rOther)
Copy Constructor.
Definition: static_step_method.hpp:105
KRATOS_CLASS_POINTER_DEFINITION(StaticStepMethod)
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: static_step_method.hpp:217
StaticStepMethod(const TVariableType &rVariable)
Constructor.
Definition: static_step_method.hpp:87
~StaticStepMethod() override
Destructor.
Definition: static_step_method.hpp:118
VariablePointer mpStepVariable
Definition: static_step_method.hpp:246
void SetStepVariable(const TVariableType &rStepVariable) override
Definition: static_step_method.hpp:135
TimeIntegrationMethod< TVariableType, TValueType > BaseType
BaseType.
Definition: static_step_method.hpp:58
BaseType::NodeType NodeType
NodeType.
Definition: static_step_method.hpp:64
StaticStepMethod(const TVariableType &rVariable, const TVariableType &rFirstDerivative, const TVariableType &rSecondDerivative)
Constructor.
Definition: static_step_method.hpp:93
bool HasStepVariable() override
Definition: static_step_method.hpp:129
std::string Info() const override
Turn back information as a string.
Definition: static_step_method.hpp:209
BasePointerType Clone() override
Clone.
Definition: static_step_method.hpp:112
BaseType::Pointer BasePointerType
BasePointerType.
Definition: static_step_method.hpp:61
void PredictVariable(NodeType &rNode) override
Definition: static_step_method.hpp:256
void Update(NodeType &rNode) override
Definition: static_step_method.hpp:163
StaticStepMethod()
Default Constructor.
Definition: static_step_method.hpp:81
void UpdateVariable(NodeType &rNode) override
Definition: static_step_method.hpp:300
void Predict(NodeType &rNode) override
Definition: static_step_method.hpp:152
BaseType::VariablePointer VariablePointer
KratosVariable or KratosVariableComponent.
Definition: static_step_method.hpp:67
virtual void UpdateStepVariable(NodeType &rNode)
Definition: static_step_method.hpp:285
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: static_step_method.hpp:223
StaticMethod< TVariableType, TValueType > DerivedType
DerivedType.
Definition: static_step_method.hpp:70
int Check(const ProcessInfo &rCurrentProcessInfo) override
This function is designed to be called once to perform all the checks needed.
Definition: static_step_method.hpp:177
StaticStepMethod(const TVariableType &rVariable, const TVariableType &rFirstDerivative, const TVariableType &rSecondDerivative, const TVariableType &rPrimaryVariable)
Constructor.
Definition: static_step_method.hpp:99
virtual void PredictStepVariable(NodeType &rNode)
Definition: static_step_method.hpp:269
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
def load(f)
Definition: ode_solve.py:307