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.
residual_based_pseudo_static_displacement_scheme.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: Vicente Mataix Ferrandiz
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
21 
22 namespace Kratos
23 {
38 
47 template<class TSparseSpace, class TDenseSpace >
49  : public ResidualBasedBossakDisplacementScheme<TSparseSpace,TDenseSpace>
50 {
51 public:
55 
57 
59 
60  typedef typename BaseType::TDataType TDataType;
61 
63 
65 
67 
69 
71 
73 
75 
77 
78  typedef typename BaseType::Pointer BaseTypePointer;
79 
81 
82  static constexpr double ZeroTolerance = std::numeric_limits<double>::epsilon();
83 
87 
92  : DerivedBaseType(0.0),
93  mpRayleighBeta(&NODAL_MAUX)
94  {
95  }
96 
102  : DerivedBaseType()
103  {
104  // Validate and assign defaults
105  ThisParameters = this->ValidateAndAssignParameters(ThisParameters, this->GetDefaultParameters());
106  this->AssignSettings(ThisParameters);
107  }
108 
112  explicit ResidualBasedPseudoStaticDisplacementScheme(const Variable<double>& RayleighBetaVariable)
113  :DerivedBaseType(0.0),
114  mpRayleighBeta(&RayleighBetaVariable)
115  {
116  }
117 
121  :DerivedBaseType(rOther),
122  mpRayleighBeta(rOther.mpRayleighBeta)
123  {
124  }
125 
130  {
132  }
133 
137  {
138  }
139 
143 
147 
152  typename BaseType::Pointer Create(Parameters ThisParameters) const override
153  {
154  return Kratos::make_shared<ClassType>(ThisParameters);
155  }
156 
166  void Update(
167  ModelPart& rModelPart,
168  DofsArrayType& rDofSet,
169  TSystemMatrixType& rA,
170  TSystemVectorType& rDx,
172  ) override
173  {
174  KRATOS_TRY;
175 
176  DerivedBaseType::mpDofUpdater->UpdateDofs(rDofSet, rDx);
177 
178  // Updating time derivatives (nodally for efficiency)
179  array_1d<double, 3 > delta_displacement;
180  block_for_each(rModelPart.Nodes(), delta_displacement, [&](Node& rNode, array_1d<double,3>& rDeltaDisplacementTLS){
181 
182  noalias(rDeltaDisplacementTLS) = rNode.FastGetSolutionStepValue(DISPLACEMENT) - rNode.FastGetSolutionStepValue(DISPLACEMENT, 1);
183 
184  array_1d<double, 3>& r_current_velocity = rNode.FastGetSolutionStepValue(VELOCITY);
185  const array_1d<double, 3>& r_previous_velocity = rNode.FastGetSolutionStepValue(VELOCITY, 1);
186 
187  noalias(r_current_velocity) = (this->mBossak.c1 * rDeltaDisplacementTLS - this->mBossak.c4 * r_previous_velocity);
188  });
189 
190  KRATOS_CATCH( "" );
191  }
192 
202  void Predict(
203  ModelPart& rModelPart,
204  DofsArrayType& rDofSet,
205  TSystemMatrixType& rA,
206  TSystemVectorType& rDx,
208  ) override
209  {
210  KRATOS_TRY;
211 
212  // Process info
213  const ProcessInfo& r_current_process_info = rModelPart.GetProcessInfo();
214 
215  // Delta time
216  const double delta_time = r_current_process_info[DELTA_TIME];
217 
218  // Updating time derivatives (nodally for efficiency)
219  const auto it_node_begin = rModelPart.Nodes().begin();
220 
221  // Auxiliar variables
222  const array_1d<double, 3> zero_array = ZeroVector(3);
223  array_1d<double, 3 > delta_displacement = zero_array;
224 
225  // Getting position
226  const int disppos_x = it_node_begin->HasDofFor(DISPLACEMENT_X) ? static_cast<int>(it_node_begin->GetDofPosition(DISPLACEMENT_X)) : -1;
227  const int velpos_x = it_node_begin->HasDofFor(VELOCITY_X) ? static_cast<int>(it_node_begin->GetDofPosition(VELOCITY_X)) : -1;
228  const int disppos_y = it_node_begin->HasDofFor(DISPLACEMENT_Y) ? static_cast<int>(it_node_begin->GetDofPosition(DISPLACEMENT_Y)) : -1;
229  const int velpos_y = it_node_begin->HasDofFor(VELOCITY_Y) ? static_cast<int>(it_node_begin->GetDofPosition(VELOCITY_Y)) : -1;
230  const int disppos_z = it_node_begin->HasDofFor(DISPLACEMENT_Z) ? static_cast<int>(it_node_begin->GetDofPosition(DISPLACEMENT_Z)) : -1;
231  const int velpos_z = it_node_begin->HasDofFor(VELOCITY_Z) ? static_cast<int>(it_node_begin->GetDofPosition(VELOCITY_Z)) : -1;
232 
233  block_for_each(rModelPart.Nodes(), delta_displacement, [&](Node& rNode, array_1d<double,3>& rDeltaDisplacementTLS){
234 
235  bool predicted_x = false;
236  bool predicted_y = false;
237  bool predicted_z = false;
238 
239  //Predicting: r_current_displacement = r_previous_displacement + r_previous_velocity * delta_time;
240  //ATTENTION::: the prediction is performed only on free nodes
241 
242  const array_1d<double, 3>& r_previous_velocity = rNode.FastGetSolutionStepValue(VELOCITY, 1);
243  const array_1d<double, 3>& r_previous_displacement = rNode.FastGetSolutionStepValue(DISPLACEMENT, 1);
244  array_1d<double, 3>& r_current_acceleration = rNode.FastGetSolutionStepValue(ACCELERATION);
245  array_1d<double, 3>& r_current_velocity = rNode.FastGetSolutionStepValue(VELOCITY);
246  array_1d<double, 3>& r_current_displacement = rNode.FastGetSolutionStepValue(DISPLACEMENT);
247 
248  if (velpos_x > -1) {
249  if (rNode.GetDof(VELOCITY_X, velpos_x).IsFixed()) {
250  rDeltaDisplacementTLS[0] = (r_current_velocity[0] + this->mBossak.c4 * r_previous_velocity[0])/this->mBossak.c1;
251  r_current_displacement[0] = r_previous_displacement[0] + rDeltaDisplacementTLS[0];
252  predicted_x = true;
253  }
254  }
255  if (disppos_x > -1 && !predicted_x) {
256  if (!rNode.GetDof(DISPLACEMENT_X, disppos_x).IsFixed() && !predicted_x) {
257  r_current_displacement[0] = r_previous_displacement[0] + delta_time * r_previous_velocity[0];
258  }
259  }
260 
261  if (velpos_y > -1) {
262  if (rNode.GetDof(VELOCITY_Y, velpos_y).IsFixed()) {
263  rDeltaDisplacementTLS[1] = (r_current_velocity[1] + this->mBossak.c4 * r_previous_velocity[1])/this->mBossak.c1;
264  r_current_displacement[1] = r_previous_displacement[1] + rDeltaDisplacementTLS[1];
265  predicted_y = true;
266  }
267  }
268  if (disppos_y > -1 && !predicted_y) {
269  if (!rNode.GetDof(DISPLACEMENT_Y, disppos_y).IsFixed() && !predicted_y) {
270  r_current_displacement[1] = r_previous_displacement[1] + delta_time * r_previous_velocity[1];
271  }
272  }
273 
274  if (velpos_z > -1) {
275  if (rNode.GetDof(VELOCITY_Z, velpos_z).IsFixed()) {
276  rDeltaDisplacementTLS[2] = (r_current_velocity[2] + this->mBossak.c4 * r_previous_velocity[2])/this->mBossak.c1;
277  r_current_displacement[2] = r_previous_displacement[2] + rDeltaDisplacementTLS[2];
278  predicted_z = true;
279  }
280  }
281  if (disppos_z > -1 && !predicted_z) {
282  if (!rNode.GetDof(DISPLACEMENT_Z, disppos_z).IsFixed() && !predicted_z) {
283  r_current_displacement[2] = r_previous_displacement[2] + delta_time * r_previous_velocity[2];
284  }
285  }
286 
287  // Updating time derivatives
288  noalias(r_current_acceleration) = zero_array;
289  noalias(r_current_velocity) = r_previous_velocity;
290  });
291 
292  KRATOS_CATCH( "" );
293  }
294 
300  {
301  Parameters default_parameters = Parameters(R"(
302  {
303  "name" : "pseudo_static_scheme",
304  "rayleigh_beta_variable" : "RAYLEIGH_BETA"
305  })");
306 
307  // Getting base class default parameters
308  const Parameters base_default_parameters = DerivedBaseType::GetDefaultParameters();
309  default_parameters.RecursivelyAddMissingParameters(base_default_parameters);
310  return default_parameters;
311  }
312 
317  static std::string Name()
318  {
319  return "pseudo_static_scheme";
320  }
321 
325 
329 
333 
335  std::string Info() const override
336  {
337  return "ResidualBasedPseudoStaticDisplacementScheme";
338  }
339 
341  void PrintInfo(std::ostream& rOStream) const override
342  {
343  rOStream << Info();
344  }
345 
347  void PrintData(std::ostream& rOStream) const override
348  {
349  rOStream << Info() << ". Considering the following damping variable " << *mpRayleighBeta;
350  }
351 
355 
356 protected:
360 
364 
368 
372 
381  LocalSystemMatrixType& rLHSContribution,
384  const ProcessInfo& rCurrentProcessInfo
385  ) override
386  {
387  // Adding damping contribution
388  if (rD.size1() != 0 && TDenseSpace::TwoNorm(rD) > ZeroTolerance) // if D matrix declared
389  noalias(rLHSContribution) += rD * this->mBossak.c1;
390  else if (rM.size1() != 0) {
391  const double beta = rCurrentProcessInfo[*mpRayleighBeta];
392  noalias(rLHSContribution) += rM * beta * this->mBossak.c1;
393  }
394  }
395 
405  Element& rElement,
406  LocalSystemVectorType& rRHSContribution,
409  const ProcessInfo& rCurrentProcessInfo
410  ) override
411  {
412  const std::size_t this_thread = OpenMPUtils::ThisThread();
413  const auto& r_const_elem_ref = rElement;
414  // Adding damping contribution
415  if (rD.size1() != 0 && TDenseSpace::TwoNorm(rD) > ZeroTolerance) {
416  r_const_elem_ref.GetFirstDerivativesVector(this->mVector.v[this_thread], 0);
417  noalias(rRHSContribution) -= prod(rD, this->mVector.v[this_thread]);
418  } else if (rM.size1() != 0) {
419  const double beta = rCurrentProcessInfo[*mpRayleighBeta];
420  r_const_elem_ref.GetFirstDerivativesVector(this->mVector.v[this_thread], 0);
421  noalias(rRHSContribution) -= beta * prod(rM, this->mVector.v[this_thread]);
422  }
423  }
424 
434  Condition& rCondition,
435  LocalSystemVectorType& rRHSContribution,
438  const ProcessInfo& rCurrentProcessInfo
439  ) override
440  {
441  const std::size_t this_thread = OpenMPUtils::ThisThread();
442  const auto& r_const_cond_ref = rCondition;
443  // Adding damping contribution
444  // Damping contribution
445  if (rD.size1() != 0 && TDenseSpace::TwoNorm(rD) > ZeroTolerance) {
446  r_const_cond_ref.GetFirstDerivativesVector(this->mVector.v[this_thread], 0);
447  noalias(rRHSContribution) -= prod(rD, this->mVector.v[this_thread]);
448  } else if (rM.size1() != 0) {
449  const double beta = rCurrentProcessInfo[*mpRayleighBeta];
450  r_const_cond_ref.GetFirstDerivativesVector(this->mVector.v[this_thread], 0);
451  noalias(rRHSContribution) -= beta * prod(rM, this->mVector.v[this_thread]);
452  }
453  }
454 
459  void AssignSettings(const Parameters ThisParameters) override
460  {
461  DerivedBaseType::AssignSettings(ThisParameters);
462  mpRayleighBeta = &KratosComponents<Variable<double>>::Get(ThisParameters["rayleigh_beta_variable"].GetString());
463  }
464 
468 
472 
477 private:
483 
484  const Variable<double>* mpRayleighBeta = nullptr;
485 
489 
493 
498 
502 
509 }; /* Class ResidualBasedPseudoStaticDisplacementScheme */
510 } /* namespace Kratos.*/
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
Base class for all Conditions.
Definition: condition.h:59
virtual void GetFirstDerivativesVector(Vector &values, int Step=0) const
Definition: condition.h:313
bool IsFixed() const
Definition: dof.h:376
Base class for all Elements.
Definition: element.h:60
virtual void GetFirstDerivativesVector(Vector &values, int Step=0) const
Definition: element.h:310
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
KratosComponents class encapsulates a lookup table for a family of classes in a generic way.
Definition: kratos_components.h:49
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
const DofType & GetDof(TVariableType const &rDofVariable, int pos) const
Get dof with a given position. If not found it is search.
Definition: node.h:649
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void RecursivelyAddMissingParameters(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing contain at least all parameters...
Definition: kratos_parameters.cpp:1457
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Bossak integration scheme (for linear and nonlinear dynamic problems) for displacements.
Definition: residual_based_bossak_displacement_scheme.hpp:43
TSparseSpace::DofUpdaterPointerType mpDofUpdater
Definition: residual_based_bossak_displacement_scheme.hpp:490
typename ImplicitBaseType::TSystemMatrixType TSystemMatrixType
Type for the system matrix within ImplicitBaseType.
Definition: residual_based_bossak_displacement_scheme.hpp:69
typename ImplicitBaseType::LocalSystemMatrixType LocalSystemMatrixType
Type for local system matrices within ImplicitBaseType.
Definition: residual_based_bossak_displacement_scheme.hpp:78
typename ImplicitBaseType::LocalSystemVectorType LocalSystemVectorType
Type for local system vectors within ImplicitBaseType.
Definition: residual_based_bossak_displacement_scheme.hpp:75
typename ImplicitBaseType::TSystemVectorType TSystemVectorType
Type for the system vector within ImplicitBaseType.
Definition: residual_based_bossak_displacement_scheme.hpp:72
typename ImplicitBaseType::DofsArrayType DofsArrayType
Array type for degrees of freedom within ImplicitBaseType.
Definition: residual_based_bossak_displacement_scheme.hpp:63
typename BaseType::Pointer BaseTypePointer
Pointer type for the BaseType.
Definition: residual_based_bossak_displacement_scheme.hpp:93
This is a pseudo-static scheme.
Definition: residual_based_pseudo_static_displacement_scheme.h:50
~ResidualBasedPseudoStaticDisplacementScheme() override
Definition: residual_based_pseudo_static_displacement_scheme.h:136
ResidualBasedPseudoStaticDisplacementScheme(Parameters ThisParameters)
Constructor. The pseudo static scheme (parameters)
Definition: residual_based_pseudo_static_displacement_scheme.h:101
void Update(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Performing the update of the solution.
Definition: residual_based_pseudo_static_displacement_scheme.h:166
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: residual_based_pseudo_static_displacement_scheme.h:56
static constexpr double ZeroTolerance
Definition: residual_based_pseudo_static_displacement_scheme.h:82
Element::DofsVectorType DofsVectorType
Definition: residual_based_pseudo_static_displacement_scheme.h:64
ResidualBasedPseudoStaticDisplacementScheme(const Variable< double > &RayleighBetaVariable)
Default constructor. The pseudo static scheme.
Definition: residual_based_pseudo_static_displacement_scheme.h:112
BaseType::TSystemVectorType TSystemVectorType
Definition: residual_based_pseudo_static_displacement_scheme.h:68
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: residual_based_pseudo_static_displacement_scheme.h:299
std::string Info() const override
Turn back information as a string.
Definition: residual_based_pseudo_static_displacement_scheme.h:335
BaseType::DofsArrayType DofsArrayType
Definition: residual_based_pseudo_static_displacement_scheme.h:62
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: residual_based_pseudo_static_displacement_scheme.h:347
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: residual_based_pseudo_static_displacement_scheme.h:76
KRATOS_CLASS_POINTER_DEFINITION(ResidualBasedPseudoStaticDisplacementScheme)
BaseType::Pointer BaseTypePointer
Definition: residual_based_pseudo_static_displacement_scheme.h:78
void AddDynamicsToRHS(Element &rElement, LocalSystemVectorType &rRHSContribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo) override
It adds the dynamic RHS contribution of the elements b - D*v.
Definition: residual_based_pseudo_static_displacement_scheme.h:404
void AddDynamicsToRHS(Condition &rCondition, LocalSystemVectorType &rRHSContribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo) override
It adds the dynamic RHS contribution of the condition b - M*a - D*v.
Definition: residual_based_pseudo_static_displacement_scheme.h:433
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residual_based_pseudo_static_displacement_scheme.h:72
ResidualBasedPseudoStaticDisplacementScheme()
Default constructor.
Definition: residual_based_pseudo_static_displacement_scheme.h:91
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: residual_based_pseudo_static_displacement_scheme.h:341
BaseType::TDataType TDataType
Definition: residual_based_pseudo_static_displacement_scheme.h:60
ResidualBasedPseudoStaticDisplacementScheme(ResidualBasedPseudoStaticDisplacementScheme &rOther)
Definition: residual_based_pseudo_static_displacement_scheme.h:120
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residual_based_pseudo_static_displacement_scheme.h:70
ResidualBasedPseudoStaticDisplacementScheme< TSparseSpace, TDenseSpace > ClassType
Definition: residual_based_pseudo_static_displacement_scheme.h:58
BaseType::TSystemMatrixType TSystemMatrixType
Definition: residual_based_pseudo_static_displacement_scheme.h:66
void AddDynamicsToLHS(LocalSystemMatrixType &rLHSContribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo) override
It adds the dynamic LHS contribution of the elements D*c1 + K.
Definition: residual_based_pseudo_static_displacement_scheme.h:380
BaseTypePointer Clone() override
Definition: residual_based_pseudo_static_displacement_scheme.h:129
BaseType::Pointer Create(Parameters ThisParameters) const override
Create method.
Definition: residual_based_pseudo_static_displacement_scheme.h:152
ModelPart::ElementsContainerType ElementsArrayType
Definition: residual_based_pseudo_static_displacement_scheme.h:74
ResidualBasedBossakDisplacementScheme< TSparseSpace, TDenseSpace > DerivedBaseType
Definition: residual_based_pseudo_static_displacement_scheme.h:80
void Predict(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Performing the prediction of the solution.
Definition: residual_based_pseudo_static_displacement_scheme.h:202
static std::string Name()
Returns the name of the class as used in the settings (snake_case format)
Definition: residual_based_pseudo_static_displacement_scheme.h:317
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: residual_based_pseudo_static_displacement_scheme.h:459
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
typename TSparseSpace::MatrixType TSystemMatrixType
Matrix type definition.
Definition: scheme.h:71
typename TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: scheme.h:74
typename TDenseSpace::VectorType LocalSystemVectorType
Local system vector type definition.
Definition: scheme.h:80
virtual Parameters ValidateAndAssignParameters(Parameters ThisParameters, const Parameters DefaultParameters) const
This method validate and assign default parameters.
Definition: scheme.h:773
typename TSparseSpace::DataType TDataType
Data type definition.
Definition: scheme.h:68
typename TDenseSpace::MatrixType LocalSystemMatrixType
Local system matrix type definition.
Definition: scheme.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
double TwoNorm(SparseSpaceType &dummy, SparseSpaceType::VectorType &x)
Definition: add_strategies_to_python.cpp:164
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
delta_time
Definition: generate_frictional_mortar_condition.py:130