13 #if !defined(KRATOS_RESIDUALBASED_DEM_COUPLED_NEWTON_RAPHSON_STRATEGY)
14 #define KRATOS_RESIDUALBASED_DEM_COUPLED_NEWTON_RAPHSON_STRATEGY
63 template <
class TSparseSpace,
118 ExplicitSolverStrategyType::Pointer pDEMStrategy,
119 typename TSchemeType::Pointer pScheme,
120 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
121 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
122 int MaxIterations = 30,
123 bool CalculateReactions =
false,
124 bool ReformDofSetAtEachStep =
false,
128 pNewConvergenceCriteria,
129 pNewBuilderAndSolver,
132 ReformDofSetAtEachStep,
146 if (p_builder_and_solver !=
nullptr) {
147 p_builder_and_solver->Clear();
205 update_dem_kinematics_process.Execute();
208 transfer_process.Execute();
209 update_dem_kinematics_process.Execute();
213 typename TSchemeType::Pointer p_scheme = this->
GetScheme();
214 typename TBuilderAndSolverType::Pointer p_builder_and_solver = this->
GetBuilderAndSolver();
215 auto& r_dof_set = p_builder_and_solver->GetDofSet();
218 TSystemVectorType& rDx = *this->
mpDx;
219 TSystemVectorType& rb = *this->
mpb;
222 unsigned int iteration_number = 1;
223 r_model_part.
GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
224 bool residual_is_updated =
false;
225 p_scheme->InitializeNonLinIteration(r_model_part, rA, rDx, rb);
231 TSparseSpace::SetToZero(rA);
232 TSparseSpace::SetToZero(rDx);
233 TSparseSpace::SetToZero(rb);
236 p_builder_and_solver->BuildAndSolveLinearizedOnPreviousIteration(p_scheme, r_model_part, rA, rDx, rb,
BaseType::MoveMeshFlag());
238 p_builder_and_solver->BuildAndSolve(p_scheme, r_model_part, rA, rDx, rb);
241 TSparseSpace::SetToZero(rDx);
242 TSparseSpace::SetToZero(rb);
244 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
253 p_scheme->FinalizeNonLinIteration(r_model_part, rA, rDx, rb);
258 TSparseSpace::SetToZero(rb);
259 p_builder_and_solver->BuildRHS(p_scheme, r_model_part, rb);
267 update_dem_kinematics_process.Execute();
270 transfer_process_damped.Execute();
271 update_dem_kinematics_process.Execute();
274 r_model_part.
GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
276 p_scheme->InitializeNonLinIteration(r_model_part, rA, rDx, rb);
287 TSparseSpace::SetToZero(rA);
288 TSparseSpace::SetToZero(rDx);
289 TSparseSpace::SetToZero(rb);
291 p_builder_and_solver->BuildAndSolve(p_scheme, r_model_part, rA, rDx, rb);
293 TSparseSpace::SetToZero(rDx);
294 TSparseSpace::SetToZero(rb);
296 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
299 TSparseSpace::SetToZero(rDx);
300 TSparseSpace::SetToZero(rb);
302 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
305 KRATOS_WARNING(
"NO DOFS") <<
"ATTENTION: no free DOFs!! " << std::endl;
314 p_scheme->FinalizeNonLinIteration(r_model_part, rA, rDx, rb);
317 residual_is_updated =
false;
319 if (is_converged ==
true) {
321 TSparseSpace::SetToZero(rb);
322 p_builder_and_solver->BuildRHS(p_scheme, r_model_part, rb);
323 residual_is_updated =
true;
334 <<
"Convergence achieved after " << iteration_number <<
" / "
340 p_builder_and_solver->CalculateReactions(p_scheme, r_model_part, rA, rDx, rb);
362 TSystemMatrixType& rA = *this->
mpA;
363 TSystemVectorType& rDx = *this->
mpDx;
364 TSystemVectorType& rb = *this->
mpb;
372 const int local_number_of_constraints = r_constraints_array.size();
373 const int global_number_of_constraints = r_comm.SumAll(local_number_of_constraints);
374 if (global_number_of_constraints != 0) {
377 const auto it_const_begin = r_constraints_array.
begin();
379 #pragma omp parallel for
380 for (
int i=0; i<static_cast<int>(local_number_of_constraints); ++
i)
381 (it_const_begin +
i)->ResetSlaveDofs(r_process_info);
383 #pragma omp parallel for
384 for (
int i=0; i<static_cast<int>(local_number_of_constraints); ++
i)
385 (it_const_begin +
i)->Apply(r_process_info);
389 TSparseSpace::SetToZero(rDx);
424 std::string
Info()
const override
426 return "ResidualBasedDEMCoupledNewtonRaphsonStrategy";
virtual const DataCommunicator & GetDataCommunicator() const
Definition: communicator.cpp:340
This is the base class to define the different convergence criterion considered.
Definition: convergence_criteria.h:58
Serial (do-nothing) version of a wrapper class for MPI communication.
Definition: data_communicator.h:318
iterator begin()
Iterator pointing to the beginning of the container.
Definition: data_value_container.h:209
Definition: explicit_solver_strategy.h:70
int mRebuildLevel
Definition: implicit_solving_strategy.h:263
bool mStiffnessMatrixIsBuilt
The current rebuild level.
Definition: implicit_solving_strategy.h:264
BaseType::TSystemMatrixType TSystemMatrixType
Definition: implicit_solving_strategy.h:70
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MasterSlaveConstraintContainerType & MasterSlaveConstraints(IndexType ThisIndex=0)
Definition: model_part.h:654
Communicator & GetCommunicator()
Definition: model_part.h:1821
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
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
This is the base Newton Raphson strategy coupled with the DEM strategy.
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:69
ExplicitSolverStrategy ExplicitSolverStrategyType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:75
bool SolveSolutionStep() override
Solves the current step. This function returns true if a solution has been found, false otherwise.
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:201
BaseType::TDataType TDataType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:83
ConvergenceCriteria< TSparseSpace, TDenseSpace > TConvergenceCriteriaType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:73
ResidualBasedDEMCoupledNewtonRaphsonStrategy(ModelPart &rModelPart, ExplicitSolverStrategyType::Pointer pDEMStrategy, typename TSchemeType::Pointer pScheme, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, int MaxIterations=30, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false)
Constructor specifying the builder and solver.
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:116
void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:176
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:89
BaseType::TSystemVectorType TSystemVectorType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:88
BaseType::TSchemeType TSchemeType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:85
ResidualBasedDEMCoupledNewtonRaphsonStrategy< TSparseSpace, TDenseSpace, TLinearSolver > ClassType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:81
ResidualBasedNewtonRaphsonStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:80
ResidualBasedDEMCoupledNewtonRaphsonStrategy()
Default constructor.
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:101
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:90
BaseType::TSystemMatrixType TSystemMatrixType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:87
TSparseSpace SparseSpaceType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:84
std::string Info() const override
Turn back information as a string.
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:424
~ResidualBasedDEMCoupledNewtonRaphsonStrategy() override
Destructor.
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:143
ExplicitSolverStrategy::Pointer mpDEMStrategy
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:475
void Initialize() override
Initialization of member variables and prior operations.
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:164
void Predict() override
Operation to predict the solution ... if it is not called a trivial predictor is used in which the va...
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:349
ResidualBasedDEMCoupledNewtonRaphsonStrategy(const ResidualBasedDEMCoupledNewtonRaphsonStrategy &Other)
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:501
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:190
BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:92
BaseType::DofsArrayType DofsArrayType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:86
BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:91
BaseType::TBuilderAndSolverType TBuilderAndSolverType
Definition: residualbased_DEM_coupled_newton_raphson_strategy.h:82
KRATOS_CLASS_POINTER_DEFINITION(ResidualBasedDEMCoupledNewtonRaphsonStrategy)
This is the base Newton Raphson strategy.
Definition: residualbased_newton_raphson_strategy.h:66
bool mUseOldStiffnessInFirstIteration
Flag telling if a full update of the database will be performed at the first iteration.
Definition: residualbased_newton_raphson_strategy.h:1259
TBuilderAndSolverType::Pointer GetBuilderAndSolver()
Get method for the builder and solver.
Definition: residualbased_newton_raphson_strategy.h:493
virtual void UpdateDatabase(TSystemMatrixType &rA, TSystemVectorType &rDx, TSystemVectorType &rb, const bool MoveMesh)
Here the database is updated.
Definition: residualbased_newton_raphson_strategy.h:1278
unsigned int mMaxIterationNumber
Definition: residualbased_newton_raphson_strategy.h:1261
TSchemeType::Pointer GetScheme()
Get method for the time scheme.
Definition: residualbased_newton_raphson_strategy.h:475
TSystemVectorPointerType mpb
The increment in the solution.
Definition: residualbased_newton_raphson_strategy.h:1237
TSystemMatrixPointerType mpA
The RHS vector of the system of equations.
Definition: residualbased_newton_raphson_strategy.h:1238
virtual void MaxIterationsExceeded()
This method prints information after reach the max number of iterations.
Definition: residualbased_newton_raphson_strategy.h:1340
bool mCalculateReactionsFlag
Flag telling if it is needed or not to compute the reactions.
Definition: residualbased_newton_raphson_strategy.h:1253
TSystemVectorPointerType mpDx
The pointer to the convergence criteria employed.
Definition: residualbased_newton_raphson_strategy.h:1236
BaseType::TSchemeType TSchemeType
Definition: residualbased_newton_raphson_strategy.h:87
void Initialize() override
Initialization of member variables and prior operations.
Definition: residualbased_newton_raphson_strategy.h:672
void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: residualbased_newton_raphson_strategy.h:781
BaseType::TBuilderAndSolverType TBuilderAndSolverType
Definition: residualbased_newton_raphson_strategy.h:81
bool GetKeepSystemConstantDuringIterations()
Get method for the flag mKeepSystemConstantDuringIterations.
Definition: residualbased_newton_raphson_strategy.h:1158
void Clear() override
Clears the internal storage.
Definition: residualbased_newton_raphson_strategy.h:707
virtual void EchoInfo(const unsigned int IterationNumber)
This method returns the components of the system of equations depending of the echo level.
Definition: residualbased_newton_raphson_strategy.h:1298
TConvergenceCriteriaType::Pointer mpConvergenceCriteria
The pointer to the builder and solver employed.
Definition: residualbased_newton_raphson_strategy.h:1234
bool mInitializeWasPerformed
The maximum number of iterations, 30 by default.
Definition: residualbased_newton_raphson_strategy.h:1263
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: residualbased_newton_raphson_strategy.h:848
Solving strategy base class This is the base class from which we will derive all the strategies (impl...
Definition: solving_strategy.h:64
TSparseSpace::VectorPointerType TSystemVectorPointerType
Definition: solving_strategy.h:77
TDenseSpace::MatrixType LocalSystemMatrixType
Definition: solving_strategy.h:79
TSparseSpace::DataType TDataType
Definition: solving_strategy.h:69
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
int GetEchoLevel()
This returns the level of echo for the solving strategy.
Definition: solving_strategy.h:271
TSparseSpace::MatrixType TSystemMatrixType
Definition: solving_strategy.h:71
TSparseSpace::MatrixPointerType TSystemMatrixPointerType
Definition: solving_strategy.h:75
bool MoveMeshFlag()
This function returns the flag that says if the mesh is moved.
Definition: solving_strategy.h:290
TSparseSpace::VectorType TSystemVectorType
Definition: solving_strategy.h:73
virtual void MoveMesh()
This function is designed to move the mesh.
Definition: solving_strategy.h:330
TDenseSpace::VectorType LocalSystemVectorType
Definition: solving_strategy.h:81
Definition: transfer_nodal_forces_to_fem.h:32
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: transfer_nodal_forces_to_fem.cpp:32
static IndexType Size(VectorType const &rV)
return size of vector rV
Definition: ublas_space.h:190
Definition: update_dem_kinematics_process.h:29
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: update_dem_kinematics_process.cpp:29
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
#define KRATOS_WARNING(label)
Definition: logger.h:265
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
integer i
Definition: TensorModule.f:17