14 #if !defined(KRATOS_RESIDUAL_BASED_BDF_SCHEME )
15 #define KRATOS_RESIDUAL_BASED_BDF_SCHEME
80 template<
class TSparseSpace,
class TDenseSpace>
112 static constexpr
double ZeroTolerance = std::numeric_limits<double>::epsilon();
135 KRATOS_ERROR_IF(
mOrder < 1) <<
"ERROR:: Not possible to compute a BDF of order less than 1" << std::endl;
197 mpDofUpdater->UpdateDofs(rDofSet, rDx);
249 mpBDFUtility->ComputeAndSaveBDFCoefficients(r_current_process_info);
250 mBDF = r_current_process_info[BDF_COEFFICIENTS];
252 const double dt_0 = r_current_process_info[DELTA_TIME];
255 <<
"ResidualBasedBDFScheme. For higher orders than 2 the time step must be constant.\nPrevious time step : " << dt_1 <<
"\nCurrent time step : " << dt_0 << std::endl;
271 if(err!=0)
return err;
285 this->mpDofUpdater->Clear();
308 "name" : "base_bdf_scheme",
309 "integration_order" : 2
315 return default_parameters;
319 std::string
Info()
const override
321 return "ResidualBasedBDFScheme";
386 const int num_nodes =
static_cast<int>( rModelPart.
Nodes().size() );
389 const auto it_node_begin = rModelPart.
Nodes().begin();
392 auto it_node = it_node_begin +
Index;
433 if (rM.size1() != 0) {
434 noalias(rLHS_Contribution) += rM * std::pow(
mBDF[0], 2);
438 if (rD.size1() != 0) {
452 template <
class TObjectType>
454 TObjectType& rObject,
462 const auto& r_const_obj_ref = rObject;
465 if (rM.size1() != 0) {
466 r_const_obj_ref.GetSecondDerivativesVector(
mVector.
dot2un0[this_thread], 0);
471 if (rD.size1() != 0) {
472 r_const_obj_ref.GetFirstDerivativesVector(
mVector.
dotun0[this_thread], 0);
494 TemplateAddDynamicsToRHS<Element>(rElement, rRHS_Contribution, rD, rM, rCurrentProcessInfo);
514 TemplateAddDynamicsToRHS<Condition>(rCondition, rRHS_Contribution, rD, rM, rCurrentProcessInfo);
539 typename TSparseSpace::DofUpdaterPointerType mpDofUpdater = TSparseSpace::CreateDofUpdater();
Base class for all Conditions.
Definition: condition.h:59
Base class for all Elements.
Definition: element.h:60
std::vector< DofType::Pointer > DofsVectorType
Definition: element.h:100
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
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
IndexType GetBufferSize() const
This method gets the suffer size of the model part database.
Definition: model_part.h:1876
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
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
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
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
ProcessInfo & GetPreviousTimeStepInfo(IndexType StepsBefore=1)
Definition: process_info.h:187
BDF integration scheme (for dynamic problems)
Definition: residual_based_bdf_scheme.h:83
void Update(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Performing the update of the solution.
Definition: residual_based_bdf_scheme.h:186
void Predict(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb) override
Performing the prediction of the solution.
Definition: residual_based_bdf_scheme.h:213
ImplicitBaseType::DofsArrayType DofsArrayType
Definition: residual_based_bdf_scheme.h:97
std::string Info() const override
Turn back information as a string.
Definition: residual_based_bdf_scheme.h:319
void AddDynamicsToRHS(Condition &rCondition, LocalSystemVectorType &rRHS_Contribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo) override
It adds the dynamic RHS contribution of the condition.
Definition: residual_based_bdf_scheme.h:506
ImplicitBaseType::TDataType TDataType
Definition: residual_based_bdf_scheme.h:95
void TemplateAddDynamicsToRHS(TObjectType &rObject, LocalSystemVectorType &rRHS_Contribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo)
It adds the dynamic RHS contribution of the objects.
Definition: residual_based_bdf_scheme.h:453
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: residual_based_bdf_scheme.h:304
ResidualBasedImplicitTimeScheme< TSparseSpace, TDenseSpace > ImplicitBaseType
Definition: residual_based_bdf_scheme.h:93
GeneralVectors mVector
The BDF coefficients.
Definition: residual_based_bdf_scheme.h:357
Kratos::unique_ptr< TimeDiscretization::BDF > mpBDFUtility
The structure containing the derivatives.
Definition: residual_based_bdf_scheme.h:358
ResidualBasedBDFScheme(const std::size_t Order=2)
Constructor. The BDF method.
Definition: residual_based_bdf_scheme.h:123
ResidualBasedBDFScheme(ResidualBasedBDFScheme &rOther)
Definition: residual_based_bdf_scheme.h:144
ImplicitBaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residual_based_bdf_scheme.h:105
static constexpr double ZeroTolerance
Definition of epsilon.
Definition: residual_based_bdf_scheme.h:112
BaseTypePointer Clone() override
Definition: residual_based_bdf_scheme.h:158
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
virtual void UpdateSecondDerivative(NodesArrayType::iterator itNode)
Updating second time derivative (acceleration)
Definition: residual_based_bdf_scheme.h:412
Scheme< TSparseSpace, TDenseSpace > BaseType
Definition: residual_based_bdf_scheme.h:89
void AddDynamicsToLHS(LocalSystemMatrixType &rLHS_Contribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo) override
It adds the dynamic LHS contribution of the elements.
Definition: residual_based_bdf_scheme.h:425
~ResidualBasedBDFScheme() override
Definition: residual_based_bdf_scheme.h:166
void AddDynamicsToRHS(Element &rElement, LocalSystemVectorType &rRHS_Contribution, LocalSystemMatrixType &rD, LocalSystemMatrixType &rM, const ProcessInfo &rCurrentProcessInfo) override
It adds the dynamic RHS contribution of the elements.
Definition: residual_based_bdf_scheme.h:486
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
void UpdateDerivatives(ModelPart &rModelPart, DofsArrayType &rDofSet, TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb)
Performing the update of the derivatives.
Definition: residual_based_bdf_scheme.h:377
ImplicitBaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residual_based_bdf_scheme.h:107
void Clear() override
Free memory allocated by this class.
Definition: residual_based_bdf_scheme.h:283
KRATOS_CLASS_POINTER_DEFINITION(ResidualBasedBDFScheme)
virtual void UpdateFirstDerivative(NodesArrayType::iterator itNode)
Updating first time derivative (velocity)
Definition: residual_based_bdf_scheme.h:403
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: residual_based_bdf_scheme.h:325
const std::size_t mOrder
Definition: residual_based_bdf_scheme.h:355
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: residual_based_bdf_scheme.h:331
ModelPart::NodesContainerType NodesArrayType
Definition: residual_based_bdf_scheme.h:109
ImplicitBaseType::TSystemMatrixType TSystemMatrixType
Definition: residual_based_bdf_scheme.h:101
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: residual_based_bdf_scheme.h:266
Element::DofsVectorType DofsVectorType
Definition: residual_based_bdf_scheme.h:99
This is the base class for the implicit time schemes.
Definition: residual_based_implicit_time_scheme.h:55
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: residual_based_implicit_time_scheme.h:289
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: residual_based_implicit_time_scheme.h:273
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_implicit_time_scheme.h:245
BaseType::TDataType TDataType
Data type definition.
Definition: residual_based_implicit_time_scheme.h:71
BaseType::TSystemMatrixType TSystemMatrixType
Matrix type definition.
Definition: residual_based_implicit_time_scheme.h:73
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Local system vector type definition.
Definition: residual_based_implicit_time_scheme.h:79
BaseType::LocalSystemVectorType LocalSystemVectorType
Local system matrix type definition.
Definition: residual_based_implicit_time_scheme.h:77
BaseType::TSystemVectorType TSystemVectorType
Vector type definition.
Definition: residual_based_implicit_time_scheme.h:75
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33
unique_ptr< C > make_unique(Args &&...args)
Definition: smart_pointers.h:45
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
def num_threads
Definition: script.py:75
e
Definition: run_cpp_mpi_tests.py:31
Definition: residual_based_bdf_scheme.h:350
std::vector< Vector > dot2un0
First derivative.
Definition: residual_based_bdf_scheme.h:352
std::vector< Vector > dotun0
Definition: residual_based_bdf_scheme.h:351