15 #if !defined(KRATOS_PORO_EXPLICIT_CD_SCHEME_HPP_INCLUDED)
16 #define KRATOS_PORO_EXPLICIT_CD_SCHEME_HPP_INCLUDED
55 template <
class TSparseSpace,
59 :
public Scheme<TSparseSpace, TDenseSpace> {
103 :
Scheme<TSparseSpace, TDenseSpace>() {}
148 mDeltaTime = r_current_process_info[DELTA_TIME];
149 mAlpha = r_current_process_info[RAYLEIGH_ALPHA];
150 mBeta = r_current_process_info[RAYLEIGH_BETA];
151 mTheta = r_current_process_info[THETA_FACTOR];
155 const SizeType dim = r_current_process_info[DOMAIN_SIZE];
179 int NElems =
static_cast<int>(rModelPart.
Elements().size());
180 ModelPart::ElementsContainerType::iterator el_begin = rModelPart.
ElementsBegin();
183 for(
int i = 0;
i < NElems;
i++)
185 ModelPart::ElementsContainerType::iterator itElem = el_begin +
i;
210 const auto it_node_begin = rModelPart.
NodesBegin();
213 #pragma omp parallel for schedule(guided,512)
214 for (
int i = 0; i < static_cast<int>(r_nodes.size()); ++
i) {
215 auto it_node = (it_node_begin +
i);
216 it_node->SetValue(NODAL_MASS, 0.0);
219 double& r_flux_residual = it_node->FastGetSolutionStepValue(FLUX_RESIDUAL);
223 r_flux_residual = 0.0;
226 Matrix& rInitialStress = it_node->FastGetSolutionStepValue(INITIAL_STRESS_TENSOR);
227 if(rInitialStress.size1() != 3)
228 rInitialStress.
resize(3,3,
false);
317 #pragma omp parallel for schedule(guided,512)
318 for(
int i=0; i<static_cast<int>(rModelPart.
Elements().size()); ++
i) {
319 auto it_elem = it_elem_begin +
i;
320 it_elem->InitializeNonLinearIteration(r_current_process_info);
324 #pragma omp parallel for schedule(guided,512)
325 for(
int i=0; i<static_cast<int>(rModelPart.
Conditions().size()); ++
i) {
326 auto it_elem = it_cond_begin +
i;
327 it_elem->InitializeNonLinearIteration(r_current_process_info);
359 #pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512)
360 for (
int i = 0; i < static_cast<int>(r_conditions.size()); ++
i) {
361 auto it_cond = r_conditions.begin() +
i;
365 #pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512)
366 for (
int i = 0; i < static_cast<int>(r_elements.size()); ++
i) {
367 auto it_elem = r_elements.begin() +
i;
392 rCurrentElement.
AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, FORCE_RESIDUAL, rCurrentProcessInfo);
415 rCurrentCondition.
AddExplicitContribution(RHS_Contribution, RESIDUAL_VECTOR, FORCE_RESIDUAL, rCurrentProcessInfo);
444 const SizeType dim = r_current_process_info[DOMAIN_SIZE];
447 mDeltaTime = r_current_process_info[DELTA_TIME];
450 const auto it_node_begin = rModelPart.
NodesBegin();
453 const IndexType disppos = it_node_begin->GetDofPosition(DISPLACEMENT_X);
455 #pragma omp parallel for schedule(guided,512)
456 for (
int i = 0; i < static_cast<int>(r_nodes.size()); ++
i) {
476 array_1d<double, 3>& r_displacement = itCurrentNode->FastGetSolutionStepValue(DISPLACEMENT);
478 noalias(displacement_aux) = r_displacement;
479 array_1d<double, 3>& r_displacement_old = itCurrentNode->FastGetSolutionStepValue(DISPLACEMENT_OLD);
481 const double nodal_mass = itCurrentNode->GetValue(NODAL_MASS);
483 double& r_current_water_pressure = itCurrentNode->FastGetSolutionStepValue(WATER_PRESSURE);
484 double& r_current_dt_water_pressure = itCurrentNode->FastGetSolutionStepValue(DT_WATER_PRESSURE);
486 const array_1d<double, 3>& r_external_force = itCurrentNode->FastGetSolutionStepValue(EXTERNAL_FORCE);
487 const array_1d<double, 3>& r_external_force_old = itCurrentNode->FastGetSolutionStepValue(EXTERNAL_FORCE,1);
488 const array_1d<double, 3>& r_internal_force = itCurrentNode->FastGetSolutionStepValue(INTERNAL_FORCE);
489 const array_1d<double, 3>& r_internal_force_old = itCurrentNode->FastGetSolutionStepValue(INTERNAL_FORCE,1);
491 std::array<bool, 3> fix_displacements = {
false,
false,
false};
492 fix_displacements[0] = (itCurrentNode->GetDof(DISPLACEMENT_X, DisplacementPosition).IsFixed());
493 fix_displacements[1] = (itCurrentNode->GetDof(DISPLACEMENT_Y, DisplacementPosition + 1).IsFixed());
495 fix_displacements[2] = (itCurrentNode->GetDof(DISPLACEMENT_Z, DisplacementPosition + 2).IsFixed());
498 if (fix_displacements[
j] ==
false) {
509 if( itCurrentNode->IsFixed(WATER_PRESSURE) == false ) {
511 r_current_water_pressure = 0.0;
512 r_current_dt_water_pressure = 0.0;
515 noalias(r_displacement_old) = displacement_aux;
516 const array_1d<double, 3>& r_velocity_old = itCurrentNode->FastGetSolutionStepValue(VELOCITY,1);
518 array_1d<double, 3>& r_acceleration = itCurrentNode->FastGetSolutionStepValue(ACCELERATION);
567 #pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512)
568 for (
int i = 0; i < static_cast<int>(r_conditions.size()); ++
i) {
569 auto it_cond = r_conditions.begin() +
i;
573 #pragma omp parallel for firstprivate(RHS_Contribution, equation_id_vector_dummy), schedule(guided,512)
574 for (
int i = 0; i < static_cast<int>(r_elements.size()); ++
i) {
575 auto it_elem = r_elements.begin() +
i;
635 const int NNodes =
static_cast<int>(rModelPart.
Nodes().size());
636 ModelPart::NodesContainerType::iterator node_begin = rModelPart.
NodesBegin();
639 #pragma omp parallel for
640 for(
int i = 0;
i < NNodes;
i++)
642 ModelPart::NodesContainerType::iterator itNode = node_begin +
i;
644 itNode->FastGetSolutionStepValue(NODAL_AREA) = 0.0;
645 Matrix& rNodalStress = itNode->FastGetSolutionStepValue(NODAL_EFFECTIVE_STRESS_TENSOR);
646 if(rNodalStress.size1() != 3)
647 rNodalStress.
resize(3,3,
false);
649 array_1d<double,3>& r_nodal_grad_pressure = itNode->FastGetSolutionStepValue(NODAL_WATER_PRESSURE_GRADIENT);
651 itNode->FastGetSolutionStepValue(NODAL_DAMAGE_VARIABLE) = 0.0;
652 itNode->FastGetSolutionStepValue(NODAL_JOINT_AREA) = 0.0;
653 itNode->FastGetSolutionStepValue(NODAL_JOINT_WIDTH) = 0.0;
654 itNode->FastGetSolutionStepValue(NODAL_JOINT_DAMAGE) = 0.0;
660 #pragma omp parallel for
661 for(
int n = 0;
n < NNodes;
n++)
663 ModelPart::NodesContainerType::iterator itNode = node_begin +
n;
665 const double& NodalArea = itNode->FastGetSolutionStepValue(NODAL_AREA);
666 if (NodalArea>1.0e-20)
668 const double InvNodalArea = 1.0/NodalArea;
669 Matrix& rNodalStress = itNode->FastGetSolutionStepValue(NODAL_EFFECTIVE_STRESS_TENSOR);
670 array_1d<double,3>& r_nodal_grad_pressure = itNode->FastGetSolutionStepValue(NODAL_WATER_PRESSURE_GRADIENT);
671 for(
unsigned int i = 0;
i<3;
i++)
673 r_nodal_grad_pressure[
i] *= InvNodalArea;
674 for(
unsigned int j = 0;
j<3;
j++)
676 rNodalStress(
i,
j) *= InvNodalArea;
679 double& NodalDamage = itNode->FastGetSolutionStepValue(NODAL_DAMAGE_VARIABLE);
680 NodalDamage *= InvNodalArea;
683 const double& NodalJointArea = itNode->FastGetSolutionStepValue(NODAL_JOINT_AREA);
684 if (NodalJointArea>1.0e-20)
686 const double InvNodalJointArea = 1.0/NodalJointArea;
687 double& NodalJointWidth = itNode->FastGetSolutionStepValue(NODAL_JOINT_WIDTH);
688 NodalJointWidth *= InvNodalJointArea;
689 double& NodalJointDamage = itNode->FastGetSolutionStepValue(NODAL_JOINT_DAMAGE);
690 NodalJointDamage *= InvNodalJointArea;
Base class for all Conditions.
Definition: condition.h:59
virtual void CalculateRightHandSide(VectorType &rRightHandSideVector, const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:440
virtual void AddExplicitContribution(const ProcessInfo &rCurrentProcessInfo)
Definition: condition.h:609
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
Base class for all Elements.
Definition: element.h:60
virtual void AddExplicitContribution(const ProcessInfo &rCurrentProcessInfo)
Definition: element.h:622
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
void resize(std::size_t NewSize1, std::size_t NewSize2, bool preserve=0)
Definition: amatrix_interface.h:224
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
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
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
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
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
An explicit forward euler scheme with a split of the inertial term.
Definition: poro_explicit_cd_scheme.hpp:59
void FinalizeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Function called once at the end of a solution step, after convergence is reached if an iterative proc...
Definition: poro_explicit_cd_scheme.hpp:625
BaseType::TSystemMatrixType TSystemMatrixType
Definition: poro_explicit_cd_scheme.hpp:70
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: poro_explicit_cd_scheme.hpp:76
void FinalizeNonLinIteration(ModelPart &rModelPart, 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: poro_explicit_cd_scheme.hpp:531
void Predict(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b) override
Performing the prediction of the solution.
Definition: poro_explicit_cd_scheme.hpp:333
virtual void UpdateTranslationalDegreesOfFreedom(NodeIterator itCurrentNode, const IndexType DisplacementPosition, const SizeType DomainSize=3)
This method updates the translation DoF.
Definition: poro_explicit_cd_scheme.hpp:470
double mDeltaTime
Definition: poro_explicit_cd_scheme.hpp:742
void InitializeElements(ModelPart &rModelPart) override
This is the place to initialize the elements.
Definition: poro_explicit_cd_scheme.hpp:173
virtual void CalculateRHSContributionResidual(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &rCurrentProcessInfo)
This function is designed to calculate just the RHS contribution.
Definition: poro_explicit_cd_scheme.hpp:589
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: poro_explicit_cd_scheme.hpp:258
virtual ~PoroExplicitCDScheme()
Definition: poro_explicit_cd_scheme.hpp:107
BaseType::TSystemVectorType TSystemVectorType
Definition: poro_explicit_cd_scheme.hpp:71
Scheme< TSparseSpace, TDenseSpace > BaseType
The definition of the base type.
Definition: poro_explicit_cd_scheme.hpp:66
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: poro_explicit_cd_scheme.hpp:72
ModelPart::NodeIterator NodeIterator
Definition fo the node iterator.
Definition: poro_explicit_cd_scheme.hpp:86
virtual void CalculateRHSContributionResidual(Condition &rCurrentCondition, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &rCurrentProcessInfo)
Functions that calculates the RHS of a "condition" object.
Definition: poro_explicit_cd_scheme.hpp:610
virtual void InitializeExplicitScheme(ModelPart &rModelPart, const SizeType DomainSize=3)
This method initializes some rutines related with the explicit scheme.
Definition: poro_explicit_cd_scheme.hpp:199
ModelPart::NodesContainerType NodesArrayType
Definition: poro_explicit_cd_scheme.hpp:77
BaseType::DofsArrayType DofsArrayType
Some definitions related with the base class.
Definition: poro_explicit_cd_scheme.hpp:69
double mAlpha
Definition: poro_explicit_cd_scheme.hpp:743
double mTheta
Definition: poro_explicit_cd_scheme.hpp:745
double mGCoefficient
Definition: poro_explicit_cd_scheme.hpp:746
std::size_t IndexType
Definition of the index type.
Definition: poro_explicit_cd_scheme.hpp:83
ModelPart::ElementsContainerType ElementsArrayType
The arrays of elements and nodes.
Definition: poro_explicit_cd_scheme.hpp:75
std::size_t SizeType
Definition of the size type.
Definition: poro_explicit_cd_scheme.hpp:80
virtual void CalculateAndAddRHS(ModelPart &rModelPart)
Definition: poro_explicit_cd_scheme.hpp:348
void InitializeNonLinIteration(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
It initializes the non-linear iteration.
Definition: poro_explicit_cd_scheme.hpp:305
int Check(const ModelPart &rModelPart) const override
This function is designed to be called once to perform all the checks needed on the input provided.
Definition: poro_explicit_cd_scheme.hpp:121
void Update(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Performing the update of the solution.
Definition: poro_explicit_cd_scheme.hpp:428
void Initialize(ModelPart &rModelPart) override
This is the place to initialize the Scheme. This is intended to be called just once when the strategy...
Definition: poro_explicit_cd_scheme.hpp:140
double mBeta
Definition: poro_explicit_cd_scheme.hpp:744
KRATOS_CLASS_POINTER_DEFINITION(PoroExplicitCDScheme)
Counted pointer of PoroExplicitCDScheme.
virtual void InitializeResidual(ModelPart &rModelPart)
This method initializes the residual in the nodes of the model part.
Definition: poro_explicit_cd_scheme.hpp:278
void CalculateRHSContribution(Condition &rCurrentCondition, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &rCurrentProcessInfo) override
Functions that calculates the RHS of a "condition" object.
Definition: poro_explicit_cd_scheme.hpp:404
static constexpr double numerical_limit
The definition of the numerical limit.
Definition: poro_explicit_cd_scheme.hpp:89
virtual void SchemeCustomInitialization(ModelPart &rModelPart, const SizeType DomainSize=3)
This method performs some custom operations to initialize the scheme.
Definition: poro_explicit_cd_scheme.hpp:240
void CalculateRHSContribution(Element &rCurrentElement, LocalSystemVectorType &RHS_Contribution, Element::EquationIdVectorType &EquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: poro_explicit_cd_scheme.hpp:381
PoroExplicitCDScheme()
Default constructor.
Definition: poro_explicit_cd_scheme.hpp:102
virtual void CalculateAndAddRHSFinal(ModelPart &rModelPart)
Definition: poro_explicit_cd_scheme.hpp:547
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
bool SchemeIsInitialized()
This method returns if the scheme is initialized.
Definition: scheme.h:179
void SetSchemeIsInitialized(bool SchemeIsInitializedFlag=true)
This method sets if the elements have been initialized or not (true by default)
Definition: scheme.h:188
ModelPart::ElementsContainerType ElementsArrayType
Elements containers definition.
Definition: scheme.h:89
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
virtual void FinalizeSolutionStep(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function called once at the end of a solution step, after convergence is reached if an iterative proc...
Definition: scheme.h:294
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
void SetElementsAreInitialized(bool ElementsAreInitializedFlag=true)
This method sets if the elements have been initialized or not (true by default)
Definition: scheme.h:206
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
ModelPart::ConditionsContainerType ConditionsArrayType
Conditions containers definition.
Definition: scheme.h:92
virtual void FinalizeNonLinIteration(ModelPart &rModelPart, TSystemMatrixType &A, TSystemVectorType &Dx, TSystemVectorType &b)
Function to be called when it is needed to finalize an iteration. It is designed to be called at the ...
Definition: scheme.h:393
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetVariable(const TVarType &rVariable, const TDataType &rValue, NodesContainerType &rNodes, const unsigned int Step=0)
Sets the nodal value of a scalar variable.
Definition: variable_utils.h:675
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
int n
manufactured solution and derivatives (u=0 at z=0 dudz=0 at z=domain_height)
Definition: ode_solve.py:402
int j
Definition: quadrature.py:648
A
Definition: sensitivityMatrix.py:70
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17