8 #if !defined(KRATOS_DAM_UP_SCHEME )
9 #define KRATOS_DAM_UP_SCHEME
25 template<
class TSparseSpace,
class TDenseSpace>
72 if(DISPLACEMENT.Key() == 0)
73 KRATOS_THROW_ERROR( std::invalid_argument,
"DISPLACEMENT has Key zero! (check if the application is correctly registered",
"" )
74 if(VELOCITY.Key() == 0)
75 KRATOS_THROW_ERROR( std::invalid_argument,
"VELOCITY has Key zero! (check if the application is correctly registered",
"" )
76 if(ACCELERATION.Key() == 0)
77 KRATOS_THROW_ERROR( std::invalid_argument,
"ACCELERATION has Key zero! (check if the application is correctly registered",
"" )
78 if(PRESSURE.Key() == 0)
79 KRATOS_THROW_ERROR( std::invalid_argument,
"PRESSURE has Key zero! (check if the application is correctly registered",
"" )
80 if(Dt_PRESSURE.Key() == 0)
81 KRATOS_THROW_ERROR( std::invalid_argument,
"Dt_PRESSURE has Key zero! (check if the application is correctly registered",
"" )
82 if(Dt2_PRESSURE.Key() == 0)
83 KRATOS_THROW_ERROR( std::invalid_argument,
"Dt2_PRESSURE has Key zero! (check if the application is correctly registered",
"" )
84 if ( VELOCITY_PRESSURE_COEFFICIENT.Key() == 0 )
85 KRATOS_THROW_ERROR( std::invalid_argument,
"VELOCITY_PRESSURE_COEFFICIENT has Key zero! (check if the application is correctly registered",
"" )
86 if ( ACCELERATION_PRESSURE_COEFFICIENT.Key() == 0 )
87 KRATOS_THROW_ERROR( std::invalid_argument,
"ACCELERATION_PRESSURE_COEFFICIENT has Key zero! (check if the application is correctly registered",
"" )
90 for(ModelPart::NodesContainerType::iterator it=r_model_part.
NodesBegin(); it!=r_model_part.
NodesEnd(); it++)
92 if(it->SolutionStepsDataHas(DISPLACEMENT) ==
false)
93 KRATOS_THROW_ERROR( std::logic_error,
"DISPLACEMENT variable is not allocated for node ", it->Id() )
94 if(it->SolutionStepsDataHas(VELOCITY) ==
false)
95 KRATOS_THROW_ERROR( std::logic_error,
"VELOCITY variable is not allocated for node ", it->Id() )
96 if(it->SolutionStepsDataHas(ACCELERATION) ==
false)
97 KRATOS_THROW_ERROR( std::logic_error,
"ACCELERATION variable is not allocated for node ", it->Id() )
98 if(it->SolutionStepsDataHas(PRESSURE) ==
false)
99 KRATOS_THROW_ERROR( std::logic_error,
"PRESSURE variable is not allocated for node ", it->Id() )
100 if(it->SolutionStepsDataHas(Dt_PRESSURE) ==
false)
101 KRATOS_THROW_ERROR( std::logic_error,
"Dt_PRESSURE variable is not allocated for node ", it->Id() )
102 if(it->SolutionStepsDataHas(Dt2_PRESSURE) ==
false)
103 KRATOS_THROW_ERROR( std::logic_error,
"Dt2_PRESSURE variable is not allocated for node ", it->Id() )
106 if(it->HasDofFor(DISPLACEMENT_X) ==
false)
107 KRATOS_THROW_ERROR( std::invalid_argument,
"missing DISPLACEMENT_X dof on node ",it->Id() )
108 if(it->HasDofFor(DISPLACEMENT_Y) ==
false)
109 KRATOS_THROW_ERROR( std::invalid_argument,
"missing DISPLACEMENT_Y dof on node ",it->Id() )
110 if(it->HasDofFor(DISPLACEMENT_Z) ==
false)
111 KRATOS_THROW_ERROR( std::invalid_argument,
"missing DISPLACEMENT_Z dof on node ",it->Id() )
112 if(it->HasDofFor(PRESSURE) ==
false)
118 KRATOS_THROW_ERROR( std::logic_error,
"insufficient buffer size. Buffer size should be greater than 2. Current size is", r_model_part.
GetBufferSize() )
122 KRATOS_THROW_ERROR( std::invalid_argument,
"Some of the scheme variables: beta or gamma has an invalid value ",
"" )
166 int NElems =
static_cast<int>(r_model_part.
Elements().size());
167 ModelPart::ElementsContainerType::iterator el_begin = r_model_part.
ElementsBegin();
169 #pragma omp parallel for
170 for(
int i = 0;
i < NElems;
i++)
172 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
176 int NCons =
static_cast<int>(r_model_part.
Conditions().size());
177 ModelPart::ConditionsContainerType::iterator con_begin = r_model_part.
ConditionsBegin();
179 #pragma omp parallel for
180 for(
int i = 0;
i < NCons;
i++)
182 ModelPart::ConditionsContainerType::iterator itCond = con_begin +
i;
203 double DeltaPressure;
205 const int NNodes =
static_cast<int>(r_model_part.
Nodes().size());
206 ModelPart::NodesContainerType::iterator node_begin = r_model_part.
NodesBegin();
208 #pragma omp parallel for private(DeltaDisplacement,DeltaPressure)
209 for(
int i = 0;
i < NNodes;
i++)
211 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
215 array_1d<double,3>& CurrentDisplacement = itNode->FastGetSolutionStepValue(DISPLACEMENT);
216 array_1d<double,3>& CurrentAcceleration = itNode->FastGetSolutionStepValue(ACCELERATION);
219 const array_1d<double,3>& PreviousDisplacement = itNode->FastGetSolutionStepValue(DISPLACEMENT, 1);
220 const array_1d<double,3>& PreviousAcceleration = itNode->FastGetSolutionStepValue(ACCELERATION, 1);
221 const array_1d<double,3>& PreviousVelocity = itNode->FastGetSolutionStepValue(VELOCITY, 1);
223 if (itNode -> IsFixed(ACCELERATION_X))
225 CurrentDisplacement[0] = PreviousDisplacement[0] +
mDeltaTime * PreviousVelocity[0] + std::pow(
mDeltaTime, 2) * ( ( 0.5 -
mBeta) * PreviousAcceleration[0] +
mBeta * CurrentAcceleration[0] );
227 else if (itNode -> IsFixed(VELOCITY_X))
229 CurrentDisplacement[0] = PreviousDisplacement[0] +
mDeltaTime*(
mBeta/
mGamma*(CurrentVelocity[0]-PreviousVelocity[0])+PreviousVelocity[0]);
231 else if (itNode -> IsFixed(DISPLACEMENT_X) ==
false)
233 CurrentDisplacement[0] = PreviousDisplacement[0] +
mDeltaTime * PreviousVelocity[0] + 0.5 * std::pow(
mDeltaTime, 2) * PreviousAcceleration[0];
236 if (itNode -> IsFixed(ACCELERATION_Y))
238 CurrentDisplacement[1] = PreviousDisplacement[1] +
mDeltaTime * PreviousVelocity[1] + std::pow(
mDeltaTime, 2) * ( ( 0.5 -
mBeta) * PreviousAcceleration[1] +
mBeta * CurrentAcceleration[1] );
240 else if (itNode -> IsFixed(VELOCITY_Y))
242 CurrentDisplacement[1] = PreviousDisplacement[1] +
mDeltaTime*(
mBeta/
mGamma*(CurrentVelocity[1]-PreviousVelocity[1])+PreviousVelocity[1]);
244 else if (itNode -> IsFixed(DISPLACEMENT_Y) ==
false)
246 CurrentDisplacement[1] = PreviousDisplacement[1] +
mDeltaTime * PreviousVelocity[1] + 0.5 * std::pow(
mDeltaTime, 2) * PreviousAcceleration[1];
250 if (itNode -> HasDofFor(DISPLACEMENT_Z))
252 if (itNode -> IsFixed(ACCELERATION_Z))
254 CurrentDisplacement[2] = PreviousDisplacement[2] +
mDeltaTime * PreviousVelocity[2] + std::pow(
mDeltaTime, 2) * ( ( 0.5 -
mBeta) * PreviousAcceleration[2] +
mBeta * CurrentAcceleration[2] );
256 else if (itNode -> IsFixed(VELOCITY_Z))
258 CurrentDisplacement[2] = PreviousDisplacement[2] +
mDeltaTime*(
mBeta/
mGamma*(CurrentVelocity[2]-PreviousVelocity[2])+PreviousVelocity[2]);
260 else if (itNode -> IsFixed(DISPLACEMENT_Z) ==
false)
262 CurrentDisplacement[2] = PreviousDisplacement[2] +
mDeltaTime * PreviousVelocity[2] + 0.5 * std::pow(
mDeltaTime, 2) * PreviousAcceleration[2];
266 noalias(DeltaDisplacement) = CurrentDisplacement - PreviousDisplacement;
273 double& CurrentDt2Pressure = itNode->FastGetSolutionStepValue(Dt2_PRESSURE);
274 double& CurrentDtPressure = itNode->FastGetSolutionStepValue(Dt_PRESSURE);
275 DeltaPressure = itNode->FastGetSolutionStepValue(PRESSURE) - itNode->FastGetSolutionStepValue(PRESSURE, 1);
276 const double& PreviousDt2Pressure = itNode->FastGetSolutionStepValue(Dt2_PRESSURE, 1);
277 const double& PreviousDtPressure = itNode->FastGetSolutionStepValue(Dt_PRESSURE, 1);
299 int NElems =
static_cast<int>(r_model_part.
Elements().size());
300 ModelPart::ElementsContainerType::iterator el_begin = r_model_part.
ElementsBegin();
302 #pragma omp parallel for
303 for(
int i = 0;
i < NElems;
i++)
305 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
306 itElem -> InitializeNonLinearIteration(CurrentProcessInfo);
309 int NCons =
static_cast<int>(r_model_part.
Conditions().size());
310 ModelPart::ConditionsContainerType::iterator con_begin = r_model_part.
ConditionsBegin();
312 #pragma omp parallel for
313 for(
int i = 0;
i < NCons;
i++)
315 ModelPart::ConditionsContainerType::iterator itCond = con_begin +
i;
316 itCond -> InitializeNonLinearIteration(CurrentProcessInfo);
334 int NElems =
static_cast<int>(r_model_part.
Elements().size());
335 ModelPart::ElementsContainerType::iterator el_begin = r_model_part.
ElementsBegin();
337 #pragma omp parallel for
338 for(
int i = 0;
i < NElems;
i++)
340 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
341 itElem -> FinalizeNonLinearIteration(CurrentProcessInfo);
344 int NCons =
static_cast<int>(r_model_part.
Conditions().size());
345 ModelPart::ConditionsContainerType::iterator con_begin = r_model_part.
ConditionsBegin();
347 #pragma omp parallel for
348 for(
int i = 0;
i < NCons;
i++)
350 ModelPart::ConditionsContainerType::iterator itCond = con_begin +
i;
351 itCond -> FinalizeNonLinearIteration(CurrentProcessInfo);
516 dof.GetSolutionStepValue() += TSparseSpace::GetValue(Dx, dof.EquationId());
552 double DeltaPressure;
554 const int NNodes =
static_cast<int>(r_model_part.
Nodes().size());
555 ModelPart::NodesContainerType::iterator node_begin = r_model_part.
NodesBegin();
557 #pragma omp parallel for private(DeltaDisplacement,DeltaPressure)
558 for(
int i = 0;
i < NNodes;
i++)
560 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
564 array_1d<double,3>& CurrentDisplacement = itNode->FastGetSolutionStepValue(DISPLACEMENT);
565 array_1d<double,3>& CurrentAcceleration = itNode->FastGetSolutionStepValue(ACCELERATION);
568 const array_1d<double,3>& PreviousDisplacement = itNode->FastGetSolutionStepValue(DISPLACEMENT, 1);
569 const array_1d<double,3>& PreviousAcceleration = itNode->FastGetSolutionStepValue(ACCELERATION, 1);
570 const array_1d<double,3>& PreviousVelocity = itNode->FastGetSolutionStepValue(VELOCITY, 1);
572 noalias(DeltaDisplacement) = CurrentDisplacement - PreviousDisplacement;
579 double& CurrentDt2Pressure = itNode->FastGetSolutionStepValue(Dt2_PRESSURE);
580 double& CurrentDtPressure = itNode->FastGetSolutionStepValue(Dt_PRESSURE);
581 DeltaPressure = itNode->FastGetSolutionStepValue(PRESSURE) - itNode->FastGetSolutionStepValue(PRESSURE, 1);
582 const double& PreviousDt2Pressure = itNode->FastGetSolutionStepValue(Dt2_PRESSURE, 1);
583 const double& PreviousDtPressure = itNode->FastGetSolutionStepValue(Dt_PRESSURE, 1);
Base class for all Conditions.
Definition: condition.h:59
virtual void CalculateLeftHandSide(MatrixType &rLeftHandSideMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:426
virtual void EquationIdVector(EquationIdVectorType &rResult, const ProcessInfo &rCurrentProcessInfo) const
Definition: condition.h:260
virtual void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:440
virtual void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:408
Definition: dam_UP_scheme.hpp:28
BaseType::DofsArrayType DofsArrayType
Definition: dam_UP_scheme.hpp:35
void Initialize(ModelPart &r_model_part) override
This is the place to initialize the Scheme.
Definition: dam_UP_scheme.hpp:131
void InitializeSolutionStep(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function called once at the beginning of each solution step.
Definition: dam_UP_scheme.hpp:152
void Calculate_RHS_Contribution(Condition &rCurrentCondition, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo)
Definition: dam_UP_scheme.hpp:438
BaseType::TSystemVectorType TSystemVectorType
Definition: dam_UP_scheme.hpp:37
void Calculate_LHS_Contribution(Element &rCurrentElement, LocalSystemMatrixType &LHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo)
Definition: dam_UP_scheme.hpp:458
std::vector< Matrix > mDampingMatrix
Definition: dam_UP_scheme.hpp:541
void FinalizeNonLinIteration(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Function to be called when it is needed to finalize an iteration. It is designed to be called at the ...
Definition: dam_UP_scheme.hpp:324
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: dam_UP_scheme.hpp:38
DamUPScheme(double beta, double gamma, double rayleigh_m, double rayleigh_k)
Constructor.
Definition: dam_UP_scheme.hpp:44
std::vector< Vector > mAccelerationVector
Definition: dam_UP_scheme.hpp:540
void Calculate_RHS_Contribution(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo)
Definition: dam_UP_scheme.hpp:411
virtual ~DamUPScheme()
Destructor.
Definition: dam_UP_scheme.hpp:63
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: dam_UP_scheme.hpp:34
void InitializeNonLinIteration(ModelPart &r_model_part, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
unction to be called when it is needed to initialize an iteration. It is designed to be called at the...
Definition: dam_UP_scheme.hpp:289
void Calculate_LHS_Contribution(Condition &rCurrentCondition, LocalSystemMatrixType &LHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo)
Definition: dam_UP_scheme.hpp:485
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: dam_UP_scheme.hpp:39
std::vector< Vector > mVelocityVector
Definition: dam_UP_scheme.hpp:542
double mGamma
Definition: dam_UP_scheme.hpp:534
double mDeltaTime
Definition: dam_UP_scheme.hpp:535
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: dam_UP_scheme.hpp:361
void AddDynamicsToRHS(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, LocalSystemMatrixType &M, LocalSystemMatrixType &C, const ProcessInfo &CurrentProcessInfo)
Definition: dam_UP_scheme.hpp:608
double mrayleigh_m
Definition: dam_UP_scheme.hpp:536
int Check(ModelPart &r_model_part) override
Definition: dam_UP_scheme.hpp:67
void UpdateVariablesDerivatives(ModelPart &r_model_part)
Definition: dam_UP_scheme.hpp:546
double mBeta
Member Variables.
Definition: dam_UP_scheme.hpp:533
void Predict(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Performing the prediction of the solution.
Definition: dam_UP_scheme.hpp:191
BaseType::TSystemMatrixType TSystemMatrixType
Definition: dam_UP_scheme.hpp:36
KRATOS_CLASS_POINTER_DEFINITION(DamUPScheme)
std::vector< Matrix > mMassMatrix
Definition: dam_UP_scheme.hpp:539
double mrayleigh_k
Definition: dam_UP_scheme.hpp:537
void CalculateSystemContributions(Condition &rCurrentCondition, LocalSystemMatrixType &LHS_Contribution, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &CurrentProcessInfo) override
Functions totally analogous to the precedent but applied to the "condition" objects.
Definition: dam_UP_scheme.hpp:391
void AddDynamicsToLHS(LocalSystemMatrixType &LHS_Contribution, LocalSystemMatrixType &M, LocalSystemMatrixType &C, const ProcessInfo &CurrentProcessInfo)
Definition: dam_UP_scheme.hpp:595
void Update(ModelPart &r_model_part, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Performing the update of the solution.
Definition: dam_UP_scheme.hpp:502
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 CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:570
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 GetSecondDerivativesVector(Vector &values, int Step=0) const
Definition: element.h:320
virtual void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:405
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
IndexType GetBufferSize() const
This method gets the suffer size of the model part database.
Definition: model_part.h:1876
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
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
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
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
virtual void EquationId(const Element &rElement, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo)
This method gets the eqaution id corresponding to the current element.
Definition: scheme.h:636
typename TSparseSpace::VectorType TSystemVectorType
Vector type definition.
Definition: scheme.h:74
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
bool mSchemeIsInitialized
Definition: scheme.h:755
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
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
int C
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:27
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
float gamma
Definition: generate_two_fluid_navier_stokes.py:131
int dof
Definition: ode_solve.py:393
A
Definition: sensitivityMatrix.py:70
integer i
Definition: TensorModule.f:17