13 #ifndef KRATOS_FLUX_CORRECTED_SHALLOW_WATER_SCHEME_H_INCLUDED
14 #define KRATOS_FLUX_CORRECTED_SHALLOW_WATER_SCHEME_H_INCLUDED
54 template<
class TSparseSpace,
class TDenseSpace>
138 r_node.SetValue(POSITIVE_FLUX, ZeroVector(mLimiters.size()));
139 r_node.SetValue(NEGATIVE_FLUX, ZeroVector(mLimiters.size()));
140 r_node.SetValue(POSITIVE_RATIO, 1.0);
141 r_node.SetValue(NEGATIVE_RATIO, 1.0);
144 r_elem.SetValue(CUMULATIVE_CORRECTIONS, ZeroVector(3*r_elem.GetGeometry().size()));
147 r_cond.SetValue(CUMULATIVE_CORRECTIONS, ZeroVector(3*r_cond.GetGeometry().size()));
174 r_elem.GetValue(CUMULATIVE_CORRECTIONS) = ZeroVector(3*r_elem.GetGeometry().size());
177 r_cond.GetValue(CUMULATIVE_CORRECTIONS) = ZeroVector(3*r_cond.GetGeometry().size());
198 r_node.GetValue(POSITIVE_FLUX) = ZeroVector(mLimiters.size());
199 r_node.GetValue(NEGATIVE_FLUX) = ZeroVector(mLimiters.size());
200 r_node.GetValue(POSITIVE_RATIO) = 1.0;
201 r_node.GetValue(NEGATIVE_RATIO) = 1.0;
205 ComputeAntiFluxes(r_elem, rModelPart.GetProcessInfo());
209 ComputeLimiters(r_node);
233 rCurrentElement.
CalculateLocalSystem(rLHS_Contribution, rRHS_Contribution, rCurrentProcessInfo);
264 KRATOS_CATCH(
"FluxCorrectedShallowWaterScheme.CalculateSystemContributions");
313 KRATOS_CATCH(
"FluxCorrectedShallowWaterScheme.Calculate_RHS_Contribution");
336 rCurrentCondition.
CalculateLocalSystem(rLHS_Contribution, rRHS_Contribution, rCurrentProcessInfo);
367 KRATOS_CATCH(
"FluxCorrectedShallowWaterScheme.CalculateSystemContributions");
416 KRATOS_CATCH(
"FluxCorrectedShallowWaterScheme.Calculate_RHS_Contribution");
432 std::string
Info()
const override
434 return "FluxCorrectedShallowWaterScheme";
480 if (rM.size1() != 0) {
485 if (rD.size1() != 0) {
486 noalias(rLHS_Contribution) += rD;
507 if (rM.size1() != 0) {
512 if (rD.size1() != 0) {
517 template<
class EntityType>
522 rEntity.CalculateMassMatrix(
mrMc[
t], rProcessInfo);
524 rEntity.CalculateDampingMatrix(
mrD[
t], rProcessInfo);
526 rEntity.GetValuesVector(
mrUn0[
t]);
528 rEntity.GetFirstDerivativesVector(
mrDotUn0[
t]);
534 auto r_geom = rEntity.GetGeometry();
542 r_geom[
i].GetValue(POSITIVE_FLUX)[limiter] += flux;
544 r_geom[
i].GetValue(NEGATIVE_FLUX)[limiter] += flux;
546 r_geom[
i].UnSetLock();
553 double& pos_ratio = rNode.
GetValue(POSITIVE_RATIO);
554 double& neg_ratio = rNode.
GetValue(NEGATIVE_RATIO);
559 const double pos_flux = rNode.
GetValue(POSITIVE_FLUX)[limiter];
560 const double neg_flux = rNode.
GetValue(NEGATIVE_FLUX)[limiter];
561 if (pos_flux > 0.0) {
562 pos_ratio =
std::min(pos_ratio, incr.max / pos_flux);
564 if (neg_flux < 0.0) {
565 neg_ratio =
std::min(neg_ratio, incr.min / neg_flux);
570 template<
class EntityType>
580 if (rD.size1() != 0) {
582 auto& cum = rEntity.GetValue(CUMULATIVE_CORRECTIONS);
583 auto aec =
prod(rD, rU) +
prod(rMl - rMc, rDotU);
584 auto delta = aec - cum;
588 for (
auto& r_node : rEntity.GetGeometry())
590 c =
std::min({
c, r_node.GetValue(POSITIVE_RATIO), r_node.GetValue(NEGATIVE_RATIO)});
599 template<
class EntityType>
617 const IndexType size = rConsistentMassMatrix.size1();
619 if (rLumpedMassMatrix.size1() != size) {
620 rLumpedMassMatrix.resize(size,size,
false);
628 l += rConsistentMassMatrix(
i,
j);
629 rLumpedMassMatrix(
i,
j) = 0.0;
631 rLumpedMassMatrix(
i,
i) =
l;
638 "update_velocities" : false,
639 "limiting_variables" : ["HEIGHT"]
646 return rThisParameters[
"order"].
GetInt();
651 return rThisParameters[
"update_velocities"].
GetBool();
657 limiter_parameters.
AddValue(
"limiting_variables", rThisParameters[
"limiting_variables"]);
658 return limiter_parameters;
Base class for all Conditions.
Definition: condition.h:59
virtual void GetFirstDerivativesVector(Vector &values, int Step=0) const
Definition: condition.h:313
virtual void CalculateMassMatrix(MatrixType &rMassMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:574
virtual void CalculateDampingMatrix(MatrixType &rDampingMatrix, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:586
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
virtual void GetValuesVector(Vector &values, int Step=0) const
Definition: condition.h:303
Base class for all Elements.
Definition: element.h:60
virtual void GetFirstDerivativesVector(Vector &values, int Step=0) const
Definition: element.h:310
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 GetValuesVector(Vector &values, int Step=0) const
Definition: element.h:300
virtual void CalculateLocalSystem(MatrixType &rLeftHandSideMatrix, VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:405
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
Short class definition.
Definition: find_global_nodal_neighbours_process.h:40
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: find_global_nodal_neighbours_for_entities_process.cpp:76
virtual void ApplySlipCondition(TLocalMatrixType &rLocalMatrix, TLocalVectorType &rLocalVector, GeometryType &rGeometry) const override
Apply slip boundary conditions to the rotated local contributions. @detail This function takes the lo...
Definition: flow_rate_slip_utility.h:99
BDF integration scheme (for dynamic problems) with flux correction for extra diffusion to ensure mono...
Definition: flux_corrected_shallow_water_scheme.h:57
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: flux_corrected_shallow_water_scheme.h:79
void InitializeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
It initializes the cumulative corrections variable.
Definition: flux_corrected_shallow_water_scheme.h:164
void Initialize(ModelPart &rModelPart) override
This is the place to initialize the Scheme.
Definition: flux_corrected_shallow_water_scheme.h:130
void InitializeNonLinIteration(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
It initializes a non-linear iteration (for the element)
Definition: flux_corrected_shallow_water_scheme.h:188
void CalculateSystemContributions(Element &rCurrentElement, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to be called in the builder and solver to introduce the selected time integ...
Definition: flux_corrected_shallow_water_scheme.h:221
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: flux_corrected_shallow_water_scheme.h:81
SWBaseType::BDFBaseType BDFBaseType
Definition: flux_corrected_shallow_water_scheme.h:65
std::vector< Matrix > & mrMc
Definition: flux_corrected_shallow_water_scheme.h:454
BaseTypePointer Clone() override
Definition: flux_corrected_shallow_water_scheme.h:109
std::vector< Vector > & mrDotUn0
Definition: flux_corrected_shallow_water_scheme.h:452
void CalculateRHSContribution(Element &rCurrentElement, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: flux_corrected_shallow_water_scheme.h:274
KRATOS_CLASS_POINTER_DEFINITION(FluxCorrectedShallowWaterScheme)
void CalculateRHSContribution(Condition &rCurrentCondition, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: flux_corrected_shallow_water_scheme.h:377
static void ValidateThisParameters(Parameters &rThisParameters)
Definition: flux_corrected_shallow_water_scheme.h:635
BaseType::Pointer BaseTypePointer
Definition: flux_corrected_shallow_water_scheme.h:71
BDFBaseType::ImplicitBaseType ImplicitBaseType
Definition: flux_corrected_shallow_water_scheme.h:67
FluxCorrectedShallowWaterScheme(const std::size_t Order=2, bool UpdateVelocities=false)
Definition: flux_corrected_shallow_water_scheme.h:90
ShallowWaterResidualBasedBDFScheme< TSparseSpace, TDenseSpace > SWBaseType
Definition: flux_corrected_shallow_water_scheme.h:63
std::string Info() const override
Turn back information as a string.
Definition: flux_corrected_shallow_water_scheme.h:432
std::vector< Matrix > & mrD
Definition: flux_corrected_shallow_water_scheme.h:455
ModelPart::NodeType NodeType
Definition: flux_corrected_shallow_water_scheme.h:83
~FluxCorrectedShallowWaterScheme() override
Definition: flux_corrected_shallow_water_scheme.h:115
std::vector< Vector > & mrUn0
Definition: flux_corrected_shallow_water_scheme.h:453
static std::size_t GetOrder(Parameters &rThisParameters)
Definition: flux_corrected_shallow_water_scheme.h:644
FluxCorrectedShallowWaterScheme(FluxCorrectedShallowWaterScheme &rOther)
Definition: flux_corrected_shallow_water_scheme.h:102
ImplicitBaseType::BaseType BaseType
Definition: flux_corrected_shallow_water_scheme.h:69
BaseType::TSystemVectorType TSystemVectorType
Definition: flux_corrected_shallow_water_scheme.h:77
void AddFluxCorrection(EntityType &rEntity, LocalSystemVectorType &rRHS, const LocalSystemMatrixType &rMc, const LocalSystemMatrixType &rMl, const LocalSystemMatrixType &rD, const LocalSystemVectorType &rU, const LocalSystemVectorType &rDotU)
Definition: flux_corrected_shallow_water_scheme.h:571
void AddMonotonicDynamicsToRHS(LocalSystemVectorType &rRHS_Contribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM, LocalSystemVectorType &rU, LocalSystemVectorType &rDotU)
It adds the dynamic RHS contribution of the elements.
Definition: flux_corrected_shallow_water_scheme.h:498
static bool GetUpdateVelocities(Parameters &rThisParameters)
Definition: flux_corrected_shallow_water_scheme.h:649
std::vector< Matrix > mMl
Definition: flux_corrected_shallow_water_scheme.h:450
BaseType::DofsArrayType DofsArrayType
Definition: flux_corrected_shallow_water_scheme.h:73
void AddMonotonicDynamicsToLHS(LocalSystemMatrixType &rLHS_Contribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM)
It adds the dynamic LHS contribution of the elements.
Definition: flux_corrected_shallow_water_scheme.h:473
void AddFluxCorrection(EntityType &rEntity, LocalSystemMatrixType &rLHS, LocalSystemVectorType &rRHS, const LocalSystemMatrixType &rMc, const LocalSystemMatrixType &rMl, const LocalSystemMatrixType &rD, const LocalSystemVectorType &rU, const LocalSystemVectorType &rDotU)
Definition: flux_corrected_shallow_water_scheme.h:600
void CalculateSystemContributions(Condition &rCurrentCondition, LocalSystemMatrixType &rLHS_Contribution, LocalSystemVectorType &rRHS_Contribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to be called in the builder and solver to introduce the selected time integ...
Definition: flux_corrected_shallow_water_scheme.h:324
void ComputeLumpedMassMatrix(const LocalSystemMatrixType &rConsistentMassMatrix, LocalSystemMatrixType &rLumpedMassMatrix)
Definition: flux_corrected_shallow_water_scheme.h:613
BaseType::TSystemMatrixType TSystemMatrixType
Definition: flux_corrected_shallow_water_scheme.h:75
void ComputeAntiFluxes(EntityType &rEntity, const ProcessInfo &rProcessInfo)
Definition: flux_corrected_shallow_water_scheme.h:518
FluxCorrectedShallowWaterScheme(Parameters ThisParameters)
Definition: flux_corrected_shallow_water_scheme.h:96
void ComputeLimiters(NodeType &rNode)
Definition: flux_corrected_shallow_water_scheme.h:551
FluxLimiter< LocalSystemVectorType > mLimiters
Definition: flux_corrected_shallow_water_scheme.h:457
static Parameters GetLimiterParameters(Parameters &rThisParameters)
Definition: flux_corrected_shallow_water_scheme.h:654
double ComputeUnlimitedFlux(const TLocalVectorType &rContributions, const NodeType &rNode, IndexType iNode, IndexType iVar)
Definition: flux_limiter.h:121
IndexType size()
Definition: flux_limiter.h:119
AllowableIncrements ComputeAllowableIncrements(const NodeType &rNode, IndexType iVar)
Definition: flux_limiter.h:125
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: node.h:466
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
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
void AddValue(const std::string &rEntry, const Parameters &rOtherValue)
This method sets a non-existing parameter with a given parameter.
Definition: kratos_parameters.cpp:455
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
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
BDF integration scheme (for dynamic problems)
Definition: residual_based_bdf_scheme.h:83
GeneralVectors mVector
The BDF coefficients.
Definition: residual_based_bdf_scheme.h:357
ImplicitBaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residual_based_bdf_scheme.h:105
void InitializeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
It initializes time step solution. Only for reasons if the time step solution is restarted.
Definition: residual_based_bdf_scheme.h:236
BaseType::Pointer BaseTypePointer
Definition: residual_based_bdf_scheme.h:91
ImplicitBaseType::TSystemVectorType TSystemVectorType
Definition: residual_based_bdf_scheme.h:103
Vector mBDF
The integration order.
Definition: residual_based_bdf_scheme.h:356
ImplicitBaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residual_based_bdf_scheme.h:107
ImplicitBaseType::TSystemMatrixType TSystemMatrixType
Definition: residual_based_bdf_scheme.h:101
This is the base class for the implicit time schemes.
Definition: residual_based_implicit_time_scheme.h:55
GeneralMatrices mMatrix
Definition: residual_based_implicit_time_scheme.h:351
std::size_t IndexType
Index type definition.
Definition: residual_based_implicit_time_scheme.h:89
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
typename TDenseSpace::MatrixType LocalSystemMatrixType
Local system matrix type definition.
Definition: scheme.h:77
BDF integration scheme (for dynamic problems)
Definition: shallow_water_residual_based_bdf_scheme.h:57
void Initialize(ModelPart &rModelPart) override
Initialize the nodal area and the derivatives recovery.
Definition: shallow_water_residual_based_bdf_scheme.h:317
void UpdateVelocities(ModelPart &rModelPart)
Updating the velocities.
Definition: shallow_water_residual_based_bdf_scheme.h:513
FlowRateSlipToolType mRotationTool
Definition: shallow_water_residual_based_bdf_scheme.h:469
void InitializeNonLinIteration(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Calculate the global projection of the dispersive field.
Definition: shallow_water_residual_based_bdf_scheme.h:332
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static double min(double a, double b)
Definition: GeometryFunctions.h:71
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
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
int t
Definition: ode_solve.py:392
int j
Definition: quadrature.py:648
def num_threads
Definition: script.py:75
integer i
Definition: TensorModule.f:17
double precision, dimension(3, 3), public delta
Definition: TensorModule.f:16
integer l
Definition: TensorModule.f:17
std::vector< Vector > dot2un0
First derivative.
Definition: residual_based_bdf_scheme.h:352
std::vector< Vector > dotun0
Definition: residual_based_bdf_scheme.h:351
std::vector< Matrix > M
Definition: residual_based_implicit_time_scheme.h:347
std::vector< Matrix > D
First derivative matrix (usually mass matrix)
Definition: residual_based_implicit_time_scheme.h:348