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.
simo_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_SIMO_STEP_METHOD_H_INCLUDED)
11 #define KRATOS_SIMO_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 SimoStepMethod : public BossakStepMethod<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  SimoStepMethod(const TVariableType& rVariable) : DerivedType(rVariable) {}
85 
87  SimoStepMethod(const TVariableType& rVariable, const TVariableType& rFirstDerivative, const TVariableType& rSecondDerivative) : DerivedType(rVariable,rFirstDerivative,rSecondDerivative) {}
88 
90  SimoStepMethod(const TVariableType& rVariable, const TVariableType& rFirstDerivative, const TVariableType& rSecondDerivative, const TVariableType& rPrimaryVariable) : DerivedType(rVariable,rFirstDerivative,rSecondDerivative,rPrimaryVariable) {}
91 
94 
97  {
98  return BasePointerType( new SimoStepMethod(*this) );
99  }
100 
102  ~SimoStepMethod() override{}
103 
107 
111 
115 
119 
123 
124 
126  std::string Info() const override
127  {
128  std::stringstream buffer;
129  buffer << "SimoStepMethod";
130  return buffer.str();
131  }
132 
134  void PrintInfo(std::ostream& rOStream) const override
135  {
136  rOStream << "SimoStepMethod";
137  }
138 
140  void PrintData(std::ostream& rOStream) const override
141  {
142  rOStream << "SimoStepMethod Data";
143  }
144 
145 
149 
150 
152 
153  protected:
154 
157 
161 
162 
166 
170 
171  void AssignFromVariable(NodeType& rNode) override
172  {
173  KRATOS_TRY
174 
175  KRATOS_CATCH( "" )
176  }
177 
178  void AssignFromFirstDerivative(NodeType& rNode) override
179  {
180  KRATOS_TRY
181 
182  // predict variable from first derivative
183  TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
184  const TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
185 
186  const TValueType& CurrentFirstDerivative = rNode.FastGetSolutionStepValue(*this->mpFirstDerivative, 0);
187 
188  CurrentVariable = PreviousVariable + (CurrentFirstDerivative) * (1.0/this->mNewmark.c1);
189 
190  TValueType& CurrentSecondDerivative = rNode.FastGetSolutionStepValue(*this->mpSecondDerivative, 0);
191  CurrentSecondDerivative -= CurrentSecondDerivative;
192 
193 
194  KRATOS_CATCH( "" )
195  }
196 
197  void AssignFromSecondDerivative(NodeType& rNode) override
198  {
199  KRATOS_TRY
200 
201  // predict variable from second derivative
202  TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
203  const TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
204 
205  const TValueType& CurrentFirstDerivative = rNode.FastGetSolutionStepValue(*this->mpFirstDerivative, 0);
206 
207  const TValueType& CurrentSecondDerivative = rNode.FastGetSolutionStepValue(*this->mpSecondDerivative, 0);
208 
209 
210  CurrentVariable = PreviousVariable + CurrentFirstDerivative * (1.0/this->mNewmark.c1) + CurrentSecondDerivative * (1.0/this->mNewmark.c0);
211 
212  KRATOS_CATCH( "" )
213  }
214 
215  void PredictVariable(NodeType& rNode) override
216  {
217  KRATOS_TRY
218 
219  // const TValueType& CurrentStepVariable = rNode.FastGetSolutionStepValue(*this->mpStepVariable, 0);
220  // TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
221 
222  // CurrentVariable += CurrentStepVariable;
223 
224  KRATOS_CATCH( "" )
225  }
226 
227  void PredictFirstDerivative(NodeType& rNode) override
228  {
229  KRATOS_TRY
230 
231  const TValueType& CurrentStepVariable = rNode.FastGetSolutionStepValue(*this->mpStepVariable, 0);
232  TValueType& CurrentFirstDerivative = rNode.FastGetSolutionStepValue(*this->mpFirstDerivative, 0);
233 
234  CurrentFirstDerivative = this->mNewmark.c1 * (CurrentStepVariable);
235 
236  KRATOS_CATCH( "" )
237  }
238 
239  void PredictSecondDerivative(NodeType& rNode) override
240  {
241  KRATOS_TRY
242 
243  TValueType& CurrentSecondDerivative = rNode.FastGetSolutionStepValue(*this->mpSecondDerivative, 0);
244 
245  const TValueType& CurrentFirstDerivative = rNode.FastGetSolutionStepValue(*this->mpFirstDerivative, 0);
246  const TValueType& PreviousFirstDerivative = rNode.FastGetSolutionStepValue(*this->mpFirstDerivative, 1);
247 
248  CurrentSecondDerivative = (this->mNewmark.c0/this->mNewmark.c1) * (CurrentFirstDerivative-PreviousFirstDerivative);
249 
250  KRATOS_CATCH( "" )
251  }
252 
253 
254  void UpdateStepVariable(NodeType& rNode) override
255  {
256  KRATOS_TRY
257 
258  // predict step variable from previous and current values
259  TValueType& CurrentStepVariable = rNode.FastGetSolutionStepValue(*this->mpStepVariable, 0);
260 
261  const TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
262  const TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
263 
264  CurrentStepVariable += CurrentVariable-PreviousVariable;
265 
266  KRATOS_CATCH( "" )
267  }
268 
269 
270  void UpdateVariable(NodeType& rNode) override
271  {
272  KRATOS_TRY
273 
274  const TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
275  TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
276 
277  // update variable previous iteration instead of previous step
278  PreviousVariable = CurrentVariable;
279 
280  KRATOS_CATCH( "" )
281  }
282 
283  void UpdateFirstDerivative(NodeType& rNode) override
284  {
285  KRATOS_TRY
286 
287  const TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
288  TValueType& CurrentFirstDerivative = rNode.FastGetSolutionStepValue(*this->mpFirstDerivative, 0);
289 
290  const TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
291 
292  CurrentFirstDerivative += this->mNewmark.c1 * (CurrentVariable-PreviousVariable);
293 
294  KRATOS_CATCH( "" )
295  }
296 
297  void UpdateSecondDerivative(NodeType& rNode) override
298  {
299  KRATOS_TRY
300 
301  const TValueType& CurrentVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 0);
302  TValueType& CurrentSecondDerivative = rNode.FastGetSolutionStepValue(*this->mpSecondDerivative, 0);
303 
304  const TValueType& PreviousVariable = rNode.FastGetSolutionStepValue(*this->mpVariable, 1);
305 
306  CurrentSecondDerivative += this->mNewmark.c0 * (CurrentVariable-PreviousVariable);
307 
308  KRATOS_CATCH( "" )
309  }
310 
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  };
357 
358  void load(Serializer& rSerializer) override
359  {
361  };
362 
366 
370 
372 
373  }; // Class SimoStepMethod
374 
376 
379 
380 
384 
385  template<class TVariableType, class TValueType>
386  inline std::istream & operator >> (std::istream & rIStream, SimoStepMethod<TVariableType,TValueType>& rThis)
387  {
388  return rIStream;
389  }
390 
391  template<class TVariableType, class TValueType>
392  inline std::ostream & operator << (std::ostream & rOStream, const SimoStepMethod<TVariableType,TValueType>& rThis)
393  {
394  return rOStream << rThis.Info();
395  }
396 
398 
400 
401 } // namespace Kratos.
402 
403 #endif // KRATOS_SIMO_STEP_METHOD_H_INCLUDED defined
Short class definition.
Definition: bossak_step_method.hpp:51
BaseType::Pointer BasePointerType
BasePointerType.
Definition: bossak_step_method.hpp:61
NewmarkParameters mNewmark
Definition: newmark_method.hpp:320
Short class definition.
Definition: newmark_step_method.hpp:51
VariablePointer mpStepVariable
Definition: newmark_step_method.hpp:213
This class defines the node.
Definition: node.h:65
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
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: simo_step_method.hpp:51
SimoStepMethod(const TVariableType &rVariable)
Constructor.
Definition: simo_step_method.hpp:84
SimoStepMethod(const TVariableType &rVariable, const TVariableType &rFirstDerivative, const TVariableType &rSecondDerivative, const TVariableType &rPrimaryVariable)
Constructor.
Definition: simo_step_method.hpp:90
BasePointerType Clone() override
Clone.
Definition: simo_step_method.hpp:96
void AssignFromSecondDerivative(NodeType &rNode) override
Definition: simo_step_method.hpp:197
~SimoStepMethod() override
Destructor.
Definition: simo_step_method.hpp:102
BossakStepMethod< TVariableType, TValueType > DerivedType
DerivedType.
Definition: simo_step_method.hpp:70
BaseType::Pointer BasePointerType
BasePointerType.
Definition: simo_step_method.hpp:61
TimeIntegrationMethod< TVariableType, TValueType > BaseType
BaseType.
Definition: simo_step_method.hpp:58
SimoStepMethod(SimoStepMethod &rOther)
Copy Constructor.
Definition: simo_step_method.hpp:93
void AssignFromFirstDerivative(NodeType &rNode) override
Definition: simo_step_method.hpp:178
SimoStepMethod(const TVariableType &rVariable, const TVariableType &rFirstDerivative, const TVariableType &rSecondDerivative)
Constructor.
Definition: simo_step_method.hpp:87
KRATOS_CLASS_POINTER_DEFINITION(SimoStepMethod)
void AssignFromVariable(NodeType &rNode) override
Definition: simo_step_method.hpp:171
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: simo_step_method.hpp:134
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: simo_step_method.hpp:140
BaseType::NodeType NodeType
NodeType.
Definition: simo_step_method.hpp:64
void UpdateStepVariable(NodeType &rNode) override
Definition: simo_step_method.hpp:254
void PredictVariable(NodeType &rNode) override
Definition: simo_step_method.hpp:215
void PredictFirstDerivative(NodeType &rNode) override
Definition: simo_step_method.hpp:227
SimoStepMethod()
Default Constructor.
Definition: simo_step_method.hpp:81
std::string Info() const override
Turn back information as a string.
Definition: simo_step_method.hpp:126
void PredictSecondDerivative(NodeType &rNode) override
Definition: simo_step_method.hpp:239
void UpdateVariable(NodeType &rNode) override
Definition: simo_step_method.hpp:270
BaseType::VariablePointer VariablePointer
KratosVariable or KratosVariableComponent.
Definition: simo_step_method.hpp:67
void UpdateSecondDerivative(NodeType &rNode) override
Definition: simo_step_method.hpp:297
void UpdateFirstDerivative(NodeType &rNode) override
Definition: simo_step_method.hpp:283
Short class definition.
Definition: time_integration_method.hpp:55
VariablePointer mpVariable
Definition: time_integration_method.hpp:405
const TVariableType * VariablePointer
KratosVariable or KratosVariableComponent.
Definition: time_integration_method.hpp:65
VariablePointer mpFirstDerivative
Definition: time_integration_method.hpp:407
VariablePointer mpSecondDerivative
Definition: time_integration_method.hpp:409
#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
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
double c1
Definition: newmark_method.hpp:63
double c0
Definition: newmark_method.hpp:62