20 template <
class TSparseSpace,
class TDenseSpace>
25 const std::vector<SecondOrderVectorVariable>& rSecondOrderVectorVariables,
26 std::optional<double> theta,
27 std::optional<double> beta,
28 std::optional<double>
gamma)
30 rSecondOrderVectorVariables),
35 KRATOS_ERROR_IF(!rFirstOrderScalarVariables.empty() && !mTheta.has_value())
36 <<
"Theta must be set when first order scalar variables are used\n";
37 KRATOS_ERROR_IF(!rSecondOrderVectorVariables.empty() && !mBeta.has_value())
38 <<
"Beta must be set when second order vector variables are used\n";
39 KRATOS_ERROR_IF(!rSecondOrderVectorVariables.empty() && !mGamma.has_value())
40 <<
"Gamma must be set when second order vector variables are used\n";
43 <<
"Theta must be larger than zero, but got " << mTheta.value() <<
"\n";
45 <<
"Beta must be larger than zero, but got " << mBeta.value() <<
"\n";
47 <<
"Gamma must be larger than zero, but got " << mGamma.value() <<
"\n";
52 rFirstOrderScalarVariables, {}, theta, std::nullopt, std::nullopt)
63 UpdateVectorSecondTimeDerivative(rNode);
64 UpdateVectorFirstTimeDerivative(rNode);
66 for (const auto& r_first_order_scalar_variable : this->GetFirstOrderScalarVariables()) {
67 UpdateScalarTimeDerivative(rNode, r_first_order_scalar_variable.instance,
68 r_first_order_scalar_variable.first_time_derivative);
81 for (
const auto& r_first_order_scalar_variable : this->GetFirstOrderScalarVariables()) {
82 rModelPart.
GetProcessInfo()[r_first_order_scalar_variable.delta_time_coefficient] =
83 1.0 / (GetTheta() * this->GetDeltaTime());
86 if (!this->GetSecondOrderVectorVariables().empty()) {
88 GetGamma() / (GetBeta() * this->GetDeltaTime());
94 double GetBeta()
const {
return mBeta.value(); }
96 double GetGamma()
const {
return mGamma.value(); }
98 double GetTheta()
const {
return mTheta.value(); }
103 const auto delta_variable =
108 (delta_variable - (1.0 - GetTheta()) * this->GetDeltaTime() * previous_dt_variable) /
109 (GetTheta() * this->GetDeltaTime());
112 void UpdateVectorFirstTimeDerivative(Node& rNode)
const
114 for (
const auto& r_second_order_vector_variable : this->GetSecondOrderVectorVariables()) {
115 if (!rNode.SolutionStepsDataHas(r_second_order_vector_variable.instance))
continue;
117 noalias(rNode.FastGetSolutionStepValue(r_second_order_vector_variable.first_time_derivative, 0)) =
118 rNode.FastGetSolutionStepValue(r_second_order_vector_variable.first_time_derivative, 1) +
119 (1.0 - GetGamma()) * this->GetDeltaTime() *
120 rNode.FastGetSolutionStepValue(r_second_order_vector_variable.second_time_derivative, 1) +
121 GetGamma() * this->GetDeltaTime() *
122 rNode.FastGetSolutionStepValue(r_second_order_vector_variable.second_time_derivative, 0);
126 void UpdateVectorSecondTimeDerivative(Node& rNode)
const
128 for (
const auto& r_second_order_vector_variable : this->GetSecondOrderVectorVariables()) {
129 if (!rNode.SolutionStepsDataHas(r_second_order_vector_variable.instance))
continue;
131 noalias(rNode.FastGetSolutionStepValue(r_second_order_vector_variable.second_time_derivative, 0)) =
132 ((rNode.FastGetSolutionStepValue(r_second_order_vector_variable.instance, 0) -
133 rNode.FastGetSolutionStepValue(r_second_order_vector_variable.instance, 1)) -
134 this->GetDeltaTime() * rNode.FastGetSolutionStepValue(
135 r_second_order_vector_variable.first_time_derivative, 1) -
136 (0.5 - GetBeta()) * this->GetDeltaTime() * this->GetDeltaTime() *
137 rNode.FastGetSolutionStepValue(r_second_order_vector_variable.second_time_derivative, 1)) /
138 (GetBeta() * this->GetDeltaTime() * this->GetDeltaTime());
142 std::optional<double> mTheta;
143 std::optional<double> mBeta;
144 std::optional<double> mGamma;
Definition: generalized_newmark_scheme.hpp:22
double GetTheta() const
Definition: generalized_newmark_scheme.hpp:98
double GetGamma() const
Definition: generalized_newmark_scheme.hpp:96
void SetTimeFactors(ModelPart &rModelPart) override
Definition: generalized_newmark_scheme.hpp:75
void UpdateVariablesDerivatives(ModelPart &rModelPart) override
Definition: generalized_newmark_scheme.hpp:57
GeneralizedNewmarkScheme(const std::vector< FirstOrderScalarVariable > &rFirstOrderScalarVariables, const std::vector< SecondOrderVectorVariable > &rSecondOrderVectorVariables, std::optional< double > theta, std::optional< double > beta, std::optional< double > gamma)
Definition: generalized_newmark_scheme.hpp:24
GeneralizedNewmarkScheme(const std::vector< FirstOrderScalarVariable > &rFirstOrderScalarVariables, double theta)
Definition: generalized_newmark_scheme.hpp:50
double GetBeta() const
Definition: generalized_newmark_scheme.hpp:94
Definition: geomechanics_time_integration_scheme.hpp:50
virtual void SetTimeFactors(ModelPart &rModelPart)
Definition: geomechanics_time_integration_scheme.hpp:324
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
TVariableType::Type & FastGetSolutionStepValue(const TVariableType &rThisVariable)
Definition: node.h:435
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
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
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
float gamma
Definition: generate_two_fluid_navier_stokes.py:131