15 #if !defined(KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY )
16 #define KRATOS_MPM_RESIDUAL_BASED_NEWTON_RAPHSON_STRATEGY
62 template<
class TSparseSpace,
120 typename TSchemeType::Pointer pScheme,
121 typename TLinearSolver::Pointer pNewLinearSolver,
122 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
123 int MaxIterations = 30,
124 bool CalculateReactions =
false,
125 bool ReformDofSetAtEachStep =
false,
128 rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria,
129 MaxIterations, CalculateReactions, ReformDofSetAtEachStep,
MoveMeshFlag)
135 typename TSchemeType::Pointer pScheme,
136 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
137 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
138 int MaxIterations = 30,
139 bool CalculateReactions =
false,
140 bool ReformDofSetAtEachStep =
false,
143 rModelPart, pScheme, pNewConvergenceCriteria, pNewBuilderAndSolver,
144 MaxIterations, CalculateReactions, ReformDofSetAtEachStep,
MoveMeshFlag)
159 typename TSchemeType::Pointer p_scheme = this->
GetScheme();
160 typename TBuilderAndSolverType::Pointer p_builder_and_solver = this->
GetBuilderAndSolver();
162 TSystemMatrixType& rA = *(this->
mpA);
163 TSystemVectorType& rDx = *(this->
mpDx);
164 TSystemVectorType& rb = *(this->
mpb);
165 DofsArrayType& r_dof_set = p_builder_and_solver->GetDofSet();
168 unsigned int iteration_number = 1;
170 bool is_converged =
false;
181 KRATOS_INFO_IF(
"MPMNewtonRaphsonStrategy", this->
GetEchoLevel() >= 3) <<
"SetToZero the matrix and vectors of the system" << std::endl;
183 TSparseSpace::SetToZero(rA);
184 TSparseSpace::SetToZero(rDx);
185 TSparseSpace::SetToZero(rb);
193 TSparseSpace::SetToZero(rDx);
194 TSparseSpace::SetToZero(rb);
203 KRATOS_INFO(
"MPMNewtonRaphsonStrategy") <<
"SystemMatrix = " << rA << std::endl;
204 KRATOS_INFO(
"MPMNewtonRaphsonStrategy") <<
"solution obtained = " << rDx << std::endl;
205 KRATOS_INFO(
"MPMNewtonRaphsonStrategy") <<
"RHS = " << rb << std::endl;
209 std::stringstream matrix_market_name;
213 std::stringstream matrix_market_vectname;
219 r_dof_set = p_builder_and_solver->GetDofSet();
226 if (is_converged ==
true)
233 TSparseSpace::SetToZero(rb);
239 KRATOS_INFO_IF(
"MPMNewtonRaphsonStrategy", this->
GetEchoLevel() >= 3 && !is_converged) <<
"Starting Nonlinear iteration" << std::endl;
242 while (is_converged ==
false &&
255 KRATOS_INFO_IF(
"MPMNewtonRaphsonStrategy", this->
GetEchoLevel() >= 3) <<
"Iteration Number: " << iteration_number << std::endl;
259 TSparseSpace::SetToZero(rA);
260 TSparseSpace::SetToZero(rDx);
261 TSparseSpace::SetToZero(rb);
268 TSparseSpace::SetToZero(rDx);
269 TSparseSpace::SetToZero(rb);
277 TSparseSpace::SetToZero(rDx);
278 TSparseSpace::SetToZero(rb);
286 KRATOS_WARNING(
"MPMNewtonRaphsonStrategy") <<
"ATTENTION: no free DOFs!! " << std::endl;
290 r_dof_set = p_builder_and_solver->GetDofSet();
299 if (is_converged ==
true)
303 TSparseSpace::SetToZero(rb);
This is the base class to define the different convergence criterion considered.
Definition: convergence_criteria.h:58
Implicit solving strategy base class This is the base class from which we will derive all the implici...
Definition: implicit_solving_strategy.h:61
Scheme< TSparseSpace, TDenseSpace > TSchemeType
Definition: implicit_solving_strategy.h:82
int mRebuildLevel
Definition: implicit_solving_strategy.h:263
bool mStiffnessMatrixIsBuilt
The current rebuild level.
Definition: implicit_solving_strategy.h:264
BuilderAndSolver< TSparseSpace, TDenseSpace, TLinearSolver > TBuilderAndSolverType
Definition: implicit_solving_strategy.h:84
Short class definition.
Definition: mpm_residual_based_newton_raphson_strategy.hpp:68
BaseType::TSystemVectorType TSystemVectorType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:91
BaseType::DofsArrayType DofsArrayType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:87
KRATOS_CLASS_POINTER_DEFINITION(MPMResidualBasedNewtonRaphsonStrategy)
BaseType::TDataType TDataType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:81
BaseType::TBuilderAndSolverType TBuilderAndSolverType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:79
BaseType::TSystemMatrixType TSystemMatrixType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:89
MPMResidualBasedNewtonRaphsonStrategy(ModelPart &rModelPart, typename TSchemeType::Pointer pScheme, typename TLinearSolver::Pointer pNewLinearSolver, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, int MaxIterations=30, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false)
Definition: mpm_residual_based_newton_raphson_strategy.hpp:118
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:95
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:93
BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:97
BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:99
BaseType::TSchemeType TSchemeType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:85
MPMResidualBasedNewtonRaphsonStrategy(ModelPart &rModelPart, bool MoveMeshFlag=false)
Definition: mpm_residual_based_newton_raphson_strategy.hpp:110
virtual ~MPMResidualBasedNewtonRaphsonStrategy()
Definition: mpm_residual_based_newton_raphson_strategy.hpp:150
ConvergenceCriteria< TSparseSpace, TDenseSpace > TConvergenceCriteriaType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:72
MPMResidualBasedNewtonRaphsonStrategy(ModelPart &rModelPart, typename TSchemeType::Pointer pScheme, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, int MaxIterations=30, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false)
Definition: mpm_residual_based_newton_raphson_strategy.hpp:133
TSparseSpace SparseSpaceType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:83
bool SolveSolutionStep() override
Solves the current step. This function returns true if a solution has been found, false otherwise.
Definition: mpm_residual_based_newton_raphson_strategy.hpp:157
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: mpm_residual_based_newton_raphson_strategy.hpp:77
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
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.
Definition: residualbased_newton_raphson_strategy.h:66
TBuilderAndSolverType::Pointer GetBuilderAndSolver()
Get method for the builder and solver.
Definition: residualbased_newton_raphson_strategy.h:493
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
TSystemVectorPointerType mpDx
The pointer to the convergence criteria employed.
Definition: residualbased_newton_raphson_strategy.h:1236
bool GetKeepSystemConstantDuringIterations()
Get method for the flag mKeepSystemConstantDuringIterations.
Definition: residualbased_newton_raphson_strategy.h:1158
TConvergenceCriteriaType::Pointer mpConvergenceCriteria
The pointer to the builder and solver employed.
Definition: residualbased_newton_raphson_strategy.h:1234
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
static IndexType Size(VectorType const &rV)
return size of vector rV
Definition: ublas_space.h:190
#define KRATOS_INFO(label)
Definition: logger.h:250
#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
bool WriteMatrixMarketVector(const char *FileName, VectorType &V)
Definition: matrix_market_interface.h:539
bool WriteMatrixMarketMatrix(const char *FileName, CompressedMatrixType &M, bool Symmetric)
Definition: matrix_market_interface.h:308