14 #ifndef KRATOS_RESIDUAL_BASED_ADAMS_MOULTON_SCHEME_H_INCLUDED
15 #define KRATOS_RESIDUAL_BASED_ADAMS_MOULTON_SCHEME_H_INCLUDED
40 template<
class TSparseSpace,
class TDenseSpace >
42 :
public Scheme<TSparseSpace,TDenseSpace>
115 typename BaseType::Pointer
Clone()
override
117 return Kratos::make_shared<ResidualBasedAdamsMoultonScheme>(*
this);
163 const double delta_time = r_process_info[DELTA_TIME];
174 rNode.FastGetSolutionStepValue(RHS) = ZeroVector(3);
179 rElement.AddExplicitContribution(r_process_info);
184 array_1d<double,3>& velocity = rNode.FastGetSolutionStepValue(VELOCITY);
185 double& height = rNode.FastGetSolutionStepValue(HEIGHT);
186 const array_1d<double,3>& prediction = rNode.FastGetSolutionStepValue(RHS);
187 const double inv_mass = 1.0 / rNode.FastGetSolutionStepValue(NODAL_AREA);
188 if (rNode.IsFixed(VELOCITY_X) == false) {
189 velocity[0] += delta_time * inv_mass * prediction[0];
191 if (rNode.
IsFixed(VELOCITY_Y) ==
false) {
192 velocity[1] += delta_time * inv_mass * prediction[1];
194 if (rNode.
IsFixed(HEIGHT) ==
false) {
195 height += delta_time * inv_mass * prediction[2];
199 KRATOS_CATCH(
"ResidualBasedAdamsMoultonScheme.Predict");
219 const double dt_0 = r_process_info[DELTA_TIME];
222 <<
"ResidualBasedAdamsMoultonScheme. The time step must be constant.\nPrevious time step : " << dt_1 <<
"\nCurrent time step : " << dt_0 << std::endl;
241 rNode.FastGetSolutionStepValue(DISPERSION_H) = ZeroVector(3);
242 rNode.FastGetSolutionStepValue(DISPERSION_V) = ZeroVector(3);
245 rElement.InitializeNonLinearIteration(r_process_info);
248 rCondition.InitializeNonLinearIteration(r_process_info);
251 const double nodal_area = rNode.FastGetSolutionStepValue(NODAL_AREA);
252 rNode.FastGetSolutionStepValue(DISPERSION_H) /= nodal_area;
253 rNode.FastGetSolutionStepValue(DISPERSION_V) /= nodal_area;
255 ApplyLaplacianBoundaryConditions(rModelPart);
276 mpDofUpdater->UpdateDofs(rDofSet, rDx);
278 UpdateDerivatives(rModelPart, rDofSet, rA, rDx, rb);
300 TCalculateSystemContributions(rCurrentElement, rLHSContribution, rRHSContribution, rEquationId, rCurrentProcessInfo);
317 TCalculateRHSContribution(rCurrentElement, rRHSContribution, rEquationId, rCurrentProcessInfo);
336 TCalculateSystemContributions(rCurrentCondition, rLHSContribution, rRHSContribution, rEquationId, rCurrentProcessInfo);
355 TCalculateRHSContribution(rCurrentCondition, rRHSContribution, rEquationId, rCurrentProcessInfo);
357 KRATOS_CATCH(
"ResidualBasedAdamsMoultonScheme.CalculateRHSContribution");
365 this->mpDofUpdater->Clear();
380 "name" : "residual_based_adams_moulton_scheme"
384 const Parameters base_default_parameters = BaseType::GetDefaultParameters();
386 return default_parameters;
400 std::string
Info()
const override
402 return "ResidualBasedAdamsMoultonScheme";
420 std::vector< Matrix >
mM;
421 std::vector< Vector >
mU0;
422 std::vector< Vector >
mU1;
423 std::vector< Vector >
mDU;
449 const double dt_inv = 1.0 / rModelPart.
GetProcessInfo()[DELTA_TIME];
451 PredictDerivative(rNode, VELOCITY, ACCELERATION, dt_inv);
452 PredictDerivative(rNode, HEIGHT, VERTICAL_VELOCITY, dt_inv);
463 template<
class TDataType>
468 const double DtInverse)
478 d1 = DtInverse * 0.5 * (3*
f1 - 4*f2 + f3);
479 d2 = DtInverse * 0.5 * (
f1 - f3);
480 d3 = DtInverse * 0.5 * ( -
f1 + 4*f2 -3*f3);
499 const double dt_inv = 1.0 / rModelPart.
GetProcessInfo()[DELTA_TIME];
501 UpdateDerivative(rNode, VELOCITY, ACCELERATION, dt_inv);
502 UpdateDerivative(rNode, HEIGHT, VERTICAL_VELOCITY, dt_inv);
513 template<
class TDataType>
518 const double DtInverse)
530 d0 = DtInverse * (11*f0 - 18*
f1 + 9*f2 - 2*f3) / 6.0;
531 d1 = DtInverse * ( 2*f0 + 3*
f1 - 6*f2 + f3) / 6.0;
532 d2 = DtInverse * ( -f0 + 6*
f1 - 3*f2 - 2*f3) / 6.0;
533 d3 = DtInverse * ( 2*f0 - 9*
f1 + 18*f2 - 11*f3) / 6.0;
549 const double delta_time = rCurrentProcessInfo[DELTA_TIME];
552 if (rM.size1() != 0) {
573 const double delta_time = rCurrentProcessInfo[DELTA_TIME];
576 if (rM.size1() != 0) {
579 mDU[this_thread] = mU0[this_thread] - mU1[this_thread];
624 typename TSparseSpace::DofUpdaterPointerType mpDofUpdater = TSparseSpace::CreateDofUpdater();
642 template <
class TObjectType>
643 void TCalculateSystemContributions(
644 TObjectType& rObject,
645 LocalSystemMatrixType& rLHSContribution,
646 LocalSystemVectorType& rRHSContribution,
655 rObject.CalculateRightHandSide(rRHSContribution, rCurrentProcessInfo);
657 rObject.CalculateMassMatrix(mM[this_thread], rCurrentProcessInfo);
659 rObject.EquationIdVector(EquationId, rCurrentProcessInfo);
661 AddDynamicsToLHS(rLHSContribution, mM[this_thread], rCurrentProcessInfo);
663 AddDynamicsToRHS(rObject, rRHSContribution, mM[this_thread], rCurrentProcessInfo);
665 KRATOS_CATCH(
"ResidualBasedAdamsMoultonScheme.TCalculateSystemContributions");
675 template <
class TObjectType>
676 void TCalculateRHSContribution(
677 TObjectType& rObject,
678 LocalSystemVectorType& rRHSContribution,
680 const ProcessInfo& rCurrentProcessInfo
687 rObject.CalculateRightHandSide(rRHSContribution, rCurrentProcessInfo);
689 rObject.CalculateMassMatrix(mM[this_thread], rCurrentProcessInfo);
691 rObject.EquationIdVector(rEquationId,rCurrentProcessInfo);
693 AddDynamicsToRHS(rObject, rRHSContribution, mM[this_thread], rCurrentProcessInfo);
695 KRATOS_CATCH(
"ResidualBasedAdamsMoultonScheme.TCalculateRHSContribution");
702 void ApplyLaplacianBoundaryConditions(ModelPart& rModelPart)
705 if (rNode.IsFixed(VELOCITY_X)) {
706 rNode.FastGetSolutionStepValue(DISPERSION_H_X) = 0.0;
707 rNode.FastGetSolutionStepValue(DISPERSION_V_X) = 0.0;
709 if (rNode.
IsFixed(VELOCITY_Y)) {
710 rNode.FastGetSolutionStepValue(DISPERSION_H_Y) = 0.0;
711 rNode.FastGetSolutionStepValue(DISPERSION_V_Y) = 0.0;
Computes NODAL_AREA.
Definition: calculate_nodal_area_process.h:67
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: calculate_nodal_area_process.cpp:27
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
virtual void GetValuesVector(Vector &values, int Step=0) const
Definition: element.h:300
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
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
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
bool IsFixed(const VariableData &rDofVariable) const
Definition: node.h:897
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
void RecursivelyAddMissingParameters(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing contain at least all parameters...
Definition: kratos_parameters.cpp:1457
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
ProcessInfo & GetPreviousTimeStepInfo(IndexType StepsBefore=1)
Definition: process_info.h:187
Predictor-corrector semi imlicit scheme for the Boussinesq element.
Definition: residual_based_adams_moulton_scheme.h:43
ResidualBasedAdamsMoultonScheme(ResidualBasedAdamsMoultonScheme &rOther)
Copy Constructor.
Definition: residual_based_adams_moulton_scheme.h:103
std::vector< Vector > mU1
Values vector at the current time step.
Definition: residual_based_adams_moulton_scheme.h:422
void CalculateRHSContribution(Element &rCurrentElement, LocalSystemVectorType &rRHSContribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
This function is designed to calculate just the RHS contribution.
Definition: residual_based_adams_moulton_scheme.h:310
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: residual_based_adams_moulton_scheme.h:376
void PredictDerivatives(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb)
Performing the prediction of the derivatives.
Definition: residual_based_adams_moulton_scheme.h:441
void Predict(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Perform the prediction using the explicit Adams-Bashforth scheme.
Definition: residual_based_adams_moulton_scheme.h:152
KRATOS_CLASS_POINTER_DEFINITION(ResidualBasedAdamsMoultonScheme)
std::vector< Vector > mDU
Values vector at the previous time step.
Definition: residual_based_adams_moulton_scheme.h:423
~ResidualBasedAdamsMoultonScheme() override
Destructor.
Definition: residual_based_adams_moulton_scheme.h:123
std::vector< Matrix > mM
Definition: residual_based_adams_moulton_scheme.h:420
void AddDynamicsToRHS(Element &rCurrentElement, LocalSystemVectorType &rRHSContribution, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo)
It adds the dynamic RHS contribution of the elements b - M*a - D*v.
Definition: residual_based_adams_moulton_scheme.h:565
void AddDynamicsToLHS(LocalSystemMatrixType &rLHSContribution, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo)
It adds the dynamic LHS contribution of the elements LHS = 24/dt*M.
Definition: residual_based_adams_moulton_scheme.h:543
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residual_based_adams_moulton_scheme.h:56
std::string Info() const override
Turn back information as a string.
Definition: residual_based_adams_moulton_scheme.h:400
void CalculateRHSContribution(Condition &rCurrentCondition, LocalSystemVectorType &rRHSContribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
Functions that calculates the RHS of a "condition" object.
Definition: residual_based_adams_moulton_scheme.h:346
void Clear() override
Free memory allocated by this class.
Definition: residual_based_adams_moulton_scheme.h:363
void CalculateSystemContributions(Element &rCurrentElement, LocalSystemMatrixType &rLHSContribution, LocalSystemVectorType &rRHSContribution, 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: residual_based_adams_moulton_scheme.h:292
void AddDynamicsToRHS(Condition &rCurrentCondition, LocalSystemVectorType &rRHSContribution, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo)
It adds the dynamic RHS contribution of the condition RHS = fext - M*an0 - D*vn0 - K*dn0.
Definition: residual_based_adams_moulton_scheme.h:592
BaseType::DofsArrayType DofsArrayType
Definition: residual_based_adams_moulton_scheme.h:50
void UpdateDerivative(NodeType &rNode, const Variable< TDataType > &rPrimitiveVariable, const Variable< TDataType > &rDerivativeVariable, const double DtInverse)
Performing the prediction of the derivative.
Definition: residual_based_adams_moulton_scheme.h:514
void Update(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Performing the update of the solution.
Definition: residual_based_adams_moulton_scheme.h:266
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_adams_moulton_scheme.h:209
BaseType::Pointer Clone() override
Clone.
Definition: residual_based_adams_moulton_scheme.h:115
std::vector< Vector > mU0
First derivative matrix (usually mass matrix)
Definition: residual_based_adams_moulton_scheme.h:421
void PredictDerivative(NodeType &rNode, const Variable< TDataType > &rPrimitiveVariable, const Variable< TDataType > &rDerivativeVariable, const double DtInverse)
Performing the prediction of the derivative.
Definition: residual_based_adams_moulton_scheme.h:464
ModelPart::NodeType NodeType
Definition: residual_based_adams_moulton_scheme.h:60
ResidualBasedAdamsMoultonScheme(Parameters ThisParameters)
Constructor.
Definition: residual_based_adams_moulton_scheme.h:89
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: residual_based_adams_moulton_scheme.h:48
void InitializeNonLinIteration(ModelPart &rModelPart, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Calculate the global projection of the auxiliary fields.
Definition: residual_based_adams_moulton_scheme.h:232
BaseType::TSystemMatrixType TSystemMatrixType
Definition: residual_based_adams_moulton_scheme.h:52
ResidualBasedAdamsMoultonScheme()
Constructor.
Definition: residual_based_adams_moulton_scheme.h:75
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residual_based_adams_moulton_scheme.h:58
void UpdateDerivatives(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb)
Performing the update of the derivatives.
Definition: residual_based_adams_moulton_scheme.h:491
void CalculateSystemContributions(Condition &rCurrentCondition, LocalSystemMatrixType &rLHSContribution, LocalSystemVectorType &rRHSContribution, Element::EquationIdVectorType &rEquationId, const ProcessInfo &rCurrentProcessInfo) override
Functions totally analogous to the precedent but applied to the "condition" objects.
Definition: residual_based_adams_moulton_scheme.h:328
void Initialize(ModelPart &rModelPart) override
Initialize the nodal area and the derivatives recovery.
Definition: residual_based_adams_moulton_scheme.h:138
BaseType::TSystemVectorType TSystemVectorType
Definition: residual_based_adams_moulton_scheme.h:54
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
virtual void Initialize(ModelPart &rModelPart)
This is the place to initialize the Scheme.
Definition: scheme.h:168
typename TSparseSpace::DataType TDataType
Data type definition.
Definition: scheme.h:68
typename TDenseSpace::MatrixType LocalSystemMatrixType
Local system matrix type definition.
Definition: scheme.h:77
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
void InitializeSolutionStep(ConstructionUtility &rThisUtil, std::string ThermalSubModelPartName, std::string MechanicalSubModelPartName, std::string HeatFluxSubModelPartName, std::string HydraulicPressureSubModelPartName, bool thermal_conditions, bool mechanical_conditions, int phase)
Definition: add_custom_utilities_to_python.cpp:45
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 num_threads
Definition: script.py:75
subroutine d1(DSTRAN, D, dtime, NDI, NSHR, NTENS)
Definition: TensorModule.f:594
subroutine f1(T, Fm)
Definition: TensorModule.f:305
e
Definition: run_cpp_mpi_tests.py:31