14 #if !defined(KRATOS_BOSSAK_SCALAR_TRANSPORT_SCHEME_H_INCLUDED)
15 #define KRATOS_BOSSAK_SCALAR_TRANSPORT_SCHEME_H_INCLUDED
46 template <
class TSparseSpace,
class TDenseSpace>
77 const double AlphaBossak,
78 const double RelaxationFactor,
81 mAlphaBossak(AlphaBossak),
82 mrScalarVariable(rScalarVariable)
85 const int num_threads = OpenMPUtils::GetNumThreads();
89 mSecondDerivativeValuesVectorOld.resize(
num_threads);
112 <<
"detected delta_time = 0 in the Bossak Scheme ... "
113 "check if the time step is created correctly for "
114 "the current model part.";
116 BossakRelaxationScalarScheme::CalculateBossakConstants(
135 this->UpdateScalarRateVariables(rModelPart);
147 << mrScalarVariable.
Name() <<
" not in nodal solution step variable list of "
148 << rModelPart.
Name() <<
".\n";
151 << rModelPart.
Name() <<
".\n";
154 << rModelPart.
Name() <<
".\n";
167 CalculateDynamicSystem<Element>(rElement, rLHS_Contribution, rRHS_Contribution,
168 rEquationIdVector, rCurrentProcessInfo);
177 CalculateDynamicRHS<Element>(rElement, rRHS_Contribution,
178 rEquationIdVector, rCurrentProcessInfo);
188 CalculateDynamicSystem<Condition>(rCondition, rLHS_Contribution, rRHS_Contribution,
189 rEquationIdVector, rCurrentProcessInfo);
198 CalculateDynamicRHS<Condition>(rCondition, rRHS_Contribution,
199 rEquationIdVector, rCurrentProcessInfo);
207 std::string
Info()
const override
209 std::stringstream msg;
210 msg <<
"Using generic residual based bossak scalar transport scheme "
212 <<
" Scalar variable : " << mrScalarVariable.
Name() <<
"\n"
214 <<
" Relaxed scalar rate variable: "
227 struct BossakConstants {
235 std::vector<LocalSystemVectorType> mSecondDerivativeValuesVectorOld;
236 std::vector<LocalSystemVectorType> mSecondDerivativeValuesVector;
237 std::vector<LocalSystemMatrixType> mMassMatrix;
238 std::vector<LocalSystemMatrixType> mDampingMatrix;
240 const double mAlphaBossak;
242 const Variable<double>& mrScalarVariable;
244 BossakConstants mBossak;
257 static void CalculateBossakConstants(
258 BossakConstants& rBossakConstants,
260 const double DeltaTime)
262 TimeDiscretization::Bossak bossak(
Alpha, 0.25, 0.5);
263 rBossakConstants.Alpha = bossak.GetAlphaM();
264 rBossakConstants.Gamma = bossak.GetGamma();
266 rBossakConstants.C0 =
267 (1.0 - rBossakConstants.Alpha) / (rBossakConstants.Gamma * DeltaTime);
268 rBossakConstants.C2 = 1.0 / (rBossakConstants.Gamma * DeltaTime);
269 rBossakConstants.C3 = (1.0 - rBossakConstants.Gamma) / rBossakConstants.Gamma;
280 template <
class TItemType>
281 void AddMassMatrixToRHS(
286 rItem.GetSecondDerivativesVector(mSecondDerivativeValuesVector[ThreadId], 0);
287 (mSecondDerivativeValuesVector[ThreadId]) *= (1.00 - mBossak.Alpha);
288 rItem.GetSecondDerivativesVector(mSecondDerivativeValuesVectorOld[ThreadId], 1);
289 noalias(mSecondDerivativeValuesVector[ThreadId]) +=
290 mBossak.Alpha * mSecondDerivativeValuesVectorOld[ThreadId];
293 prod(mMassMatrix[ThreadId], mSecondDerivativeValuesVector[ThreadId]);
306 template <
class TItemType>
307 void CalculateDynamicSystem(
311 typename TItemType::EquationIdVectorType& rEquationIdVector,
312 const ProcessInfo& rCurrentProcessInfo)
317 rEquationIdVector, rCurrentProcessInfo);
321 rItem.CalculateMassMatrix(mMassMatrix[
k], rCurrentProcessInfo);
325 if (mMassMatrix[
k].size1() != 0)
327 AddMassMatrixToRHS<TItemType>(rItem, rRHS_Contribution,
k);
329 noalias(rLHS_Contribution) += mBossak.C0 * mMassMatrix[
k];
344 template <
class TItemType>
345 void CalculateDynamicRHS(
348 typename TItemType::EquationIdVectorType& rEquationIdVector,
349 const ProcessInfo& rCurrentProcessInfo)
356 rEquationIdVector, rCurrentProcessInfo,
k);
358 rItem.CalculateMassMatrix(mMassMatrix[
k], rCurrentProcessInfo);
362 if (mMassMatrix[
k].size1() != 0)
364 AddMassMatrixToRHS(rItem, rRHS_Contribution,
k);
370 void UpdateScalarRateVariables(ModelPart& rModelPart)
373 double& r_current_rate = rNode.FastGetSolutionStepValue(mrScalarVariable.GetTimeDerivative());
374 const double old_rate = rNode.FastGetSolutionStepValue(mrScalarVariable.GetTimeDerivative(), 1);
375 const double current_value = rNode.FastGetSolutionStepValue(mrScalarVariable);
376 const double old_value = rNode.FastGetSolutionStepValue(mrScalarVariable, 1);
379 r_current_rate = mBossak.C2 * (current_value - old_value) - mBossak.C3 * old_rate;
382 rNode.FastGetSolutionStepValue(mrScalarVariable.GetTimeDerivative().GetTimeDerivative()) =
383 this->mAlphaBossak * old_rate + (1.0 - this->mAlphaBossak) * r_current_rate;
A scheme for steady and dynamic equations, using Bossak time integration.
Definition: bossak_relaxation_scalar_scheme.h:49
typename BaseType::TSystemVectorType SystemVectorType
Definition: bossak_relaxation_scalar_scheme.h:60
KRATOS_CLASS_POINTER_DEFINITION(BossakRelaxationScalarScheme)
void CalculateSystemContributions(Element &rElement, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationIdVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_relaxation_scalar_scheme.h:160
typename BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: bossak_relaxation_scalar_scheme.h:64
void CalculateRHSContribution(Condition &rCondition, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationIdVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_relaxation_scalar_scheme.h:192
void CalculateSystemContributions(Condition &rCondition, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHS_Contribution, Condition::EquationIdVectorType &rEquationIdVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_relaxation_scalar_scheme.h:181
void InitializeSolutionStep(ModelPart &rModelPart, SystemMatrixType &rA, SystemVectorType &rDx, SystemVectorType &rb) override
Definition: bossak_relaxation_scalar_scheme.h:99
std::string Info() const override
Turn back information as a string.
Definition: bossak_relaxation_scalar_scheme.h:207
void Update(ModelPart &rModelPart, DofsArrayType &rDofSet, SystemMatrixType &rA, SystemVectorType &rDx, SystemVectorType &rb) override
Definition: bossak_relaxation_scalar_scheme.h:124
typename BaseType::TSystemMatrixType SystemMatrixType
Definition: bossak_relaxation_scalar_scheme.h:58
BossakRelaxationScalarScheme(const double AlphaBossak, const double RelaxationFactor, const Variable< double > &rScalarVariable)
Constructor.
Definition: bossak_relaxation_scalar_scheme.h:76
~BossakRelaxationScalarScheme() override=default
Destructor.
typename BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: bossak_relaxation_scalar_scheme.h:62
void CalculateRHSContribution(Element &rElement, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationIdVector, const ProcessInfo &rCurrentProcessInfo) override
Definition: bossak_relaxation_scalar_scheme.h:171
int Check(ModelPart &rModelPart) override
Definition: bossak_relaxation_scalar_scheme.h:140
Base class for all Conditions.
Definition: condition.h:59
std::vector< std::size_t > EquationIdVectorType
Definition: condition.h:98
Base class for all Elements.
Definition: element.h:60
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
std::string & Name()
Definition: model_part.h:1811
bool HasNodalSolutionStepVariable(VariableData const &ThisVariable) const
Definition: model_part.h:544
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
Node NodeType
Definition: model_part.h:117
This class defines the node.
Definition: node.h:65
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
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
typename TDenseSpace::VectorType LocalSystemVectorType
Local system vector type definition.
Definition: scheme.h:80
virtual void InitializeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function called once at the beginning of each solution step.
Definition: scheme.h:272
typename TDenseSpace::MatrixType LocalSystemMatrixType
Local system matrix type definition.
Definition: scheme.h:77
virtual int Check(const ModelPart &rModelPart) const
This function is designed to be called once to perform all the checks needed on the input provided....
Definition: scheme.h:508
Definition: steady_scalar_scheme.h:37
typename BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: steady_scalar_scheme.h:52
void CalculateSystemContributions(Element &rElement, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationIdVector, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to be called in the builder and solver to introduce the selected time integ...
Definition: steady_scalar_scheme.h:95
typename BaseType::TSystemVectorType TSystemVectorType
Definition: steady_scalar_scheme.h:50
typename BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: steady_scalar_scheme.h:54
typename BaseType::DofsArrayType DofsArrayType
Definition: steady_scalar_scheme.h:46
void Update(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Performing the update of the solution.
Definition: steady_scalar_scheme.h:76
void CalculateDampingSystem(TItemType &rItem, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHS_Contribution, typename TItemType::EquationIdVectorType &rEquationIdVector, const ProcessInfo &rCurrentProcessInfo, const int ThreadId)
Definition: steady_scalar_scheme.h:198
typename BaseType::TSystemMatrixType TSystemMatrixType
Definition: steady_scalar_scheme.h:48
double mRelaxationFactor
Definition: steady_scalar_scheme.h:191
const std::string & Name() const
Definition: variable_data.h:201
const VariableType & GetTimeDerivative() const
This method returns the time derivative variable.
Definition: variable.h:336
#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
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
def Gamma(n, j)
Definition: quadrature.py:146
def Alpha(n, j)
Definition: quadrature.py:93
int k
Definition: quadrature.py:595
def num_threads
Definition: script.py:75