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.
newmark_quasistatic_damped_U_Pw_scheme.hpp
Go to the documentation of this file.
1 // KRATOS___
2 // // ) )
3 // // ___ ___
4 // // ____ //___) ) // ) )
5 // // / / // // / /
6 // ((____/ / ((____ ((___/ / MECHANICS
7 //
8 // License: geo_mechanics_application/license.txt
9 //
10 // Main authors: Ignasi de Pouplana,
11 // Vahid Galavi
12 //
13 
14 #pragma once
15 
16 // Application includes
19 
20 namespace Kratos
21 {
22 
23 template <class TSparseSpace, class TDenseSpace>
24 class NewmarkQuasistaticDampedUPwScheme : public NewmarkQuasistaticUPwScheme<TSparseSpace, TDenseSpace>
25 {
26 public:
28 
32 
33  NewmarkQuasistaticDampedUPwScheme(double beta, double gamma, double theta)
34  : NewmarkQuasistaticUPwScheme<TSparseSpace, TDenseSpace>(beta, gamma, theta)
35  {
36  // Allocate auxiliary memory
38  mDampingMatrix.resize(num_threads);
39  mVelocityVector.resize(num_threads);
40  }
41 
42  void CalculateSystemContributions(Element& rCurrentElement,
43  LocalSystemMatrixType& LHS_Contribution,
44  LocalSystemVectorType& RHS_Contribution,
46  const ProcessInfo& CurrentProcessInfo) override
47  {
49 
50  int thread = OpenMPUtils::ThisThread();
51 
52  rCurrentElement.CalculateLocalSystem(LHS_Contribution, RHS_Contribution, CurrentProcessInfo);
53 
54  rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], CurrentProcessInfo);
55 
56  this->AddDampingToLHS(LHS_Contribution, mDampingMatrix[thread], CurrentProcessInfo);
57 
58  this->AddDampingToRHS(rCurrentElement, RHS_Contribution, mDampingMatrix[thread], CurrentProcessInfo);
59 
60  rCurrentElement.EquationIdVector(EquationId, CurrentProcessInfo);
61 
62  KRATOS_CATCH("")
63  }
64 
65  void CalculateRHSContribution(Element& rCurrentElement,
66  LocalSystemVectorType& RHS_Contribution,
68  const ProcessInfo& CurrentProcessInfo) override
69  {
71 
72  int thread = OpenMPUtils::ThisThread();
73 
74  rCurrentElement.CalculateRightHandSide(RHS_Contribution, CurrentProcessInfo);
75 
76  rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], CurrentProcessInfo);
77 
78  this->AddDampingToRHS(rCurrentElement, RHS_Contribution, mDampingMatrix[thread], CurrentProcessInfo);
79 
80  rCurrentElement.EquationIdVector(EquationId, CurrentProcessInfo);
81 
82  KRATOS_CATCH("")
83  }
84 
85  void CalculateLHSContribution(Element& rCurrentElement,
86  LocalSystemMatrixType& LHS_Contribution,
88  const ProcessInfo& CurrentProcessInfo) override
89  {
91 
92  int thread = OpenMPUtils::ThisThread();
93 
94  rCurrentElement.CalculateLeftHandSide(LHS_Contribution, CurrentProcessInfo);
95 
96  rCurrentElement.CalculateDampingMatrix(mDampingMatrix[thread], CurrentProcessInfo);
97 
98  this->AddDampingToLHS(LHS_Contribution, mDampingMatrix[thread], CurrentProcessInfo);
99 
100  rCurrentElement.EquationIdVector(EquationId, CurrentProcessInfo);
101 
102  KRATOS_CATCH("")
103  }
104 
105 protected:
106  void AddDampingToLHS(LocalSystemMatrixType& LHS_Contribution, LocalSystemMatrixType& C, const ProcessInfo& CurrentProcessInfo)
107  {
108  // adding damping contribution
109  if (C.size1() != 0)
110  noalias(LHS_Contribution) += (this->GetGamma() / (this->GetBeta() * this->GetDeltaTime())) * C;
111  }
112 
113  void AddDampingToRHS(Element& rCurrentElement,
114  LocalSystemVectorType& RHS_Contribution,
116  const ProcessInfo& CurrentProcessInfo)
117  {
118  int thread = OpenMPUtils::ThisThread();
119 
120  // adding damping contribution
121  if (C.size1() != 0) {
122  rCurrentElement.GetFirstDerivativesVector(mVelocityVector[thread], 0);
123  noalias(RHS_Contribution) -= prod(C, mVelocityVector[thread]);
124  }
125  }
126 
127 private:
128  std::vector<Matrix> mDampingMatrix;
129  std::vector<Vector> mVelocityVector;
130 }; // Class NewmarkQuasistaticDampedUPwScheme
131 
132 } // namespace Kratos
Base class for all Elements.
Definition: element.h:60
virtual void GetFirstDerivativesVector(Vector &values, int Step=0) const
Definition: element.h:310
virtual void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:423
virtual void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:437
virtual void CalculateDampingMatrix(MatrixType &rDampingMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:583
virtual void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const
Definition: element.h:258
virtual void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:405
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
double GetGamma() const
Definition: generalized_newmark_scheme.hpp:96
double GetBeta() const
Definition: generalized_newmark_scheme.hpp:94
void EquationId(const Element &rElement, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This method gets the eqaution id corresponding to the current element.
Definition: geomechanics_time_integration_scheme.hpp:96
double GetDeltaTime() const
Definition: geomechanics_time_integration_scheme.hpp:331
Definition: newmark_quasistatic_damped_U_Pw_scheme.hpp:25
void AddDampingToRHS(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, LocalSystemMatrixType &C, const ProcessInfo &CurrentProcessInfo)
Definition: newmark_quasistatic_damped_U_Pw_scheme.hpp:113
void AddDampingToLHS(LocalSystemMatrixType &LHS_Contribution, LocalSystemMatrixType &C, const ProcessInfo &CurrentProcessInfo)
Definition: newmark_quasistatic_damped_U_Pw_scheme.hpp:106
KRATOS_CLASS_POINTER_DEFINITION(NewmarkQuasistaticDampedUPwScheme)
void CalculateSystemContributions(Element &rCurrentElement, LocalSystemMatrixType &LHS_Contribution, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
This function is designed to be called in the builder and solver to introduce the selected time integ...
Definition: newmark_quasistatic_damped_U_Pw_scheme.hpp:42
NewmarkQuasistaticDampedUPwScheme(double beta, double gamma, double theta)
Definition: newmark_quasistatic_damped_U_Pw_scheme.hpp:33
void CalculateLHSContribution(Element &rCurrentElement, LocalSystemMatrixType &LHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
This function is designed to calculate just the LHS contribution.
Definition: newmark_quasistatic_damped_U_Pw_scheme.hpp:85
void CalculateRHSContribution(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: newmark_quasistatic_damped_U_Pw_scheme.hpp:65
Definition: newmark_quasistatic_U_Pw_scheme.hpp:27
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
typename TDenseSpace::VectorType LocalSystemVectorType
Local system vector type definition.
Definition: scheme.h:80
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
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
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
int C
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:27
float gamma
Definition: generate_two_fluid_navier_stokes.py:131
def num_threads
Definition: script.py:75