15 #if !defined(KRATOS_ADAPTIVE_RESIDUALBASED_NEWTON_RAPHSON_STRATEGY )
16 #define KRATOS_ADAPTIVE_RESIDUALBASED_NEWTON_RAPHSON_STRATEGY
85 template<
class TSparseSpace,
155 if (p_builder_and_solver !=
nullptr) {
163 KRATOS_WARNING(
"AdaptiveResidualBasedNewtonRaphsonStrategy") <<
"BuilderAndSolver is not initialized. Please assign one before settings flags" << std::endl;
175 typename TSchemeType::Pointer pScheme,
176 typename TLinearSolver::Pointer pNewLinearSolver,
177 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
178 int MaxIterations = 30,
179 int MinIterations = 4,
180 bool CalculateReactions =
false,
181 bool ReformDofSetAtEachStep =
false,
183 double ReductionFactor = 0.5,
184 double IncreaseFactor = 1.3,
185 int NumberOfCycles = 5
237 KRATOS_WATCH(
"AdaptiveResidualBasedNewtonRaphsonStrategy is chosen");
259 typename TSchemeType::Pointer pScheme,
260 typename TLinearSolver::Pointer pNewLinearSolver,
261 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
262 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
263 int MaxIterations = 30,
264 int MinIterations = 4,
265 bool CalculateReactions =
false,
266 bool ReformDofSetAtEachStep =
false,
268 double ReductionFactor = 0.5,
269 double IncreaseFactor = 1.3,
270 int NumberOfCycles = 5
396 typename SolvingStrategyType::Pointer
Create(
401 return Kratos::make_shared<ClassType>(rModelPart, ThisParameters);
446 typename TSchemeType::Pointer pScheme =
GetScheme();
459 if (pBuilderAndSolver->GetDofSetIsInitializedFlag() ==
false ||
472 std::cout <<
" " << std::endl;
490 int iteration_number=1;
493 bool is_converged =
false;
501 TSparseSpace::SetToZero(mA);
502 TSparseSpace::SetToZero(mDx);
503 TSparseSpace::SetToZero(
mb);
509 TSparseSpace::SetToZero(mDx);
510 TSparseSpace::SetToZero(
mb);
518 std::cout <<
"SystemMatrix = " << mA << std::endl;
519 std::cout <<
"solution obtained = " << mDx << std::endl;
520 std::cout <<
"RHS = " <<
mb << std::endl;
524 std::stringstream matrix_market_name;
537 if (is_converged==
true)
544 TSparseSpace::SetToZero(
mb);
554 while( is_converged ==
false &&
571 TSparseSpace::SetToZero(mA);
572 TSparseSpace::SetToZero(mDx);
573 TSparseSpace::SetToZero(
mb);
579 TSparseSpace::SetToZero(mDx);
580 TSparseSpace::SetToZero(
mb);
587 std::cout <<
"ATTENTION: no free DOFs!! " << std::endl;
601 if (is_converged==
true)
606 TSparseSpace::SetToZero(
mb);
626 bool is_converged =
false;
627 int number_of_cycles = 0;
631 KRATOS_WATCH(
"****************** inside cyclic_lopp*******************");
643 if(is_converged ==
false)
646 double CurrentTime =
model_part.GetProcessInfo()[TIME];
672 double DeltaTime =
model_part.GetProcessInfo()[DELTA_TIME];
674 model_part.GetProcessInfo()[DELTA_TIME] = New_Dt;
691 TSparseSpace::SetToZero(
mb);
740 TSystemMatrixType& mA = *
mpA;
779 std::cout <<
"Newton Raphson strategy Clear function used" << std::endl;
811 "name" : "adaptative_newton_raphson_strategy",
813 "reduction_factor" : 0.5,
814 "increase_factor" : 1.3,
815 "number_of_cycles" : 5,
816 "max_iteration" : 10,
817 "reform_dofs_at_each_step" : false,
818 "compute_reactions" : false,
819 "builder_and_solver_settings" : {},
820 "convergence_criteria_settings" : {},
821 "linear_solver_settings" : {},
822 "scheme_settings" : {}
828 return default_parameters;
837 return "adaptative_newton_raphson_strategy";
870 std::string
Info()
const override
872 return "AdaptiveResidualBasedNewtonRaphsonStrategy";
996 typename TSchemeType::Pointer pScheme =
GetScheme();
1000 if (pScheme->SchemeIsInitialized() ==
false)
1004 if (pScheme->ElementsAreInitialized() ==
false)
1025 typename TSchemeType::Pointer pScheme =
GetScheme();
1053 std::cout <<
"***************************************************" << std::endl;
1054 std::cout <<
"******* ATTENTION: max iterations exceeded ********" << std::endl;
1055 std::cout <<
"***************************************************" << std::endl;
1057 std::cout <<
"*****************REDUCTION CYCLE********************" << std::endl;
1058 std::cout << cycle_number << std::endl;
1059 std::cout <<
"***************************************************" << std::endl;
1065 std::cout <<
"***************************************************" << std::endl;
1066 std::cout <<
"******* ATTENTION: INcreasing dt ********" << std::endl;
1067 std::cout <<
"***************************************************" << std::endl;
1069 std::cout <<
"*****************OLD DT********************" << std::endl;
1070 std::cout << old_dt << std::endl;
1071 std::cout <<
"*****************NEW DT********************" << std::endl;
1072 std::cout << new_dt << std::endl;
1084 (
i)->
X() = (
i)->X0() +
i->GetSolutionStepValue(DISPLACEMENT_X , 1);
1085 (
i)->
Y() = (
i)->Y0() +
i->GetSolutionStepValue(DISPLACEMENT_Y , 1);
1086 (
i)->
Z() = (
i)->Z0() +
i->GetSolutionStepValue(DISPLACEMENT_Z , 1);
1107 if (ThisParameters[
"convergence_criteria_settings"].
Has(
"name")) {
1108 KRATOS_ERROR <<
"IMPLEMENTATION PENDING IN CONSTRUCTOR WITH PARAMETERS" << std::endl;
1112 if (ThisParameters[
"scheme_settings"].
Has(
"name")) {
1113 KRATOS_ERROR <<
"IMPLEMENTATION PENDING IN CONSTRUCTOR WITH PARAMETERS" << std::endl;
1117 if (ThisParameters[
"builder_and_solver_settings"].
Has(
"name")) {
1118 KRATOS_ERROR <<
"IMPLEMENTATION PENDING IN CONSTRUCTOR WITH PARAMETERS" << std::endl;
Short class definition.
Definition: adaptive_residualbased_newton_raphson_strategy.h:91
void MaxIterationsExceeded(int cycle_number)
Definition: adaptive_residualbased_newton_raphson_strategy.h:1051
AdaptiveResidualBasedNewtonRaphsonStrategy(ModelPart &rModelPart, typename TSchemeType::Pointer pScheme, typename TLinearSolver::Pointer pNewLinearSolver, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, int MaxIterations=30, int MinIterations=4, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false, double ReductionFactor=0.5, double IncreaseFactor=1.3, int NumberOfCycles=5)
Definition: adaptive_residualbased_newton_raphson_strategy.h:173
TSystemVectorPointerType mpDx
Definition: adaptive_residualbased_newton_raphson_strategy.h:953
TBuilderAndSolverType::Pointer GetBuilderAndSolver()
Definition: adaptive_residualbased_newton_raphson_strategy.h:343
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: adaptive_residualbased_newton_raphson_strategy.h:122
void SetMaxIterationNumber(int MaxIterationNumber)
Definition: adaptive_residualbased_newton_raphson_strategy.h:367
~AdaptiveResidualBasedNewtonRaphsonStrategy() override
Definition: adaptive_residualbased_newton_raphson_strategy.h:323
void SetScheme(typename TSchemeType::Pointer pScheme)
Definition: adaptive_residualbased_newton_raphson_strategy.h:329
BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: adaptive_residualbased_newton_raphson_strategy.h:127
std::string Info() const override
Turn back information as a string.
Definition: adaptive_residualbased_newton_raphson_strategy.h:870
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: adaptive_residualbased_newton_raphson_strategy.h:882
void CalculateOutputData() override
Definition: adaptive_residualbased_newton_raphson_strategy.h:764
bool mCalculateReactionsFlag
Definition: adaptive_residualbased_newton_raphson_strategy.h:972
AdaptiveResidualBasedNewtonRaphsonStrategy(ModelPart &rModelPart, Parameters ThisParameters)
Default constructor. (with parameters)
Definition: adaptive_residualbased_newton_raphson_strategy.h:146
double mReductionFactor
Definition: adaptive_residualbased_newton_raphson_strategy.h:981
BaseType::TSchemeType TSchemeType
Definition: adaptive_residualbased_newton_raphson_strategy.h:112
void SetCalculateReactionsFlag(bool CalculateReactionsFlag)
Definition: adaptive_residualbased_newton_raphson_strategy.h:348
TSystemMatrixType & GetSystemMatrix() override
This method returns the LHS matrix.
Definition: adaptive_residualbased_newton_raphson_strategy.h:854
TConvergenceCriteriaType::Pointer mpConvergenceCriteria
Definition: adaptive_residualbased_newton_raphson_strategy.h:948
void SetBuilderAndSolver(typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver)
Definition: adaptive_residualbased_newton_raphson_strategy.h:339
AdaptiveResidualBasedNewtonRaphsonStrategy()
Default constructor.
Definition: adaptive_residualbased_newton_raphson_strategy.h:137
TSchemeType::Pointer GetScheme()
Definition: adaptive_residualbased_newton_raphson_strategy.h:333
int mMaxIterationNumber
default = 30
Definition: adaptive_residualbased_newton_raphson_strategy.h:977
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: adaptive_residualbased_newton_raphson_strategy.h:1095
SolvingStrategyType::Pointer Create(ModelPart &rModelPart, Parameters ThisParameters) const override
Create method.
Definition: adaptive_residualbased_newton_raphson_strategy.h:396
double Solve() override
The problem of interest is solved.
Definition: adaptive_residualbased_newton_raphson_strategy.h:623
BaseType::TBuilderAndSolverType TBuilderAndSolverType
Definition: adaptive_residualbased_newton_raphson_strategy.h:106
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: adaptive_residualbased_newton_raphson_strategy.h:124
TSystemVectorPointerType mpb
Definition: adaptive_residualbased_newton_raphson_strategy.h:954
bool IsConverged() override
Definition: adaptive_residualbased_newton_raphson_strategy.h:736
unsigned int GetMaxIterationNumber()
Definition: adaptive_residualbased_newton_raphson_strategy.h:371
double mIncreaseFactor
Definition: adaptive_residualbased_newton_raphson_strategy.h:982
int mMinIterationNumber
Definition: adaptive_residualbased_newton_raphson_strategy.h:978
void SetEchoLevel(int Level) override
This sets the level of echo for the solving strategy.
Definition: adaptive_residualbased_newton_raphson_strategy.h:382
AdaptiveResidualBasedNewtonRaphsonStrategy(ModelPart &rModelPart, typename TSchemeType::Pointer pScheme, typename TLinearSolver::Pointer pNewLinearSolver, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, int MaxIterations=30, int MinIterations=4, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false, double ReductionFactor=0.5, double IncreaseFactor=1.3, int NumberOfCycles=5)
Definition: adaptive_residualbased_newton_raphson_strategy.h:257
TBuilderAndSolverType::Pointer mpBuilderAndSolver
Definition: adaptive_residualbased_newton_raphson_strategy.h:946
TSystemMatrixPointerType mpA
Definition: adaptive_residualbased_newton_raphson_strategy.h:955
TSchemeType::Pointer mpScheme
Definition: adaptive_residualbased_newton_raphson_strategy.h:942
void Predict() override
Definition: adaptive_residualbased_newton_raphson_strategy.h:408
void Clear() override
Clears the internal storage.
Definition: adaptive_residualbased_newton_raphson_strategy.h:776
void SetReformDofSetAtEachStepFlag(bool flag)
Definition: adaptive_residualbased_newton_raphson_strategy.h:357
BaseType::TSystemMatrixType TSystemMatrixType
Definition: adaptive_residualbased_newton_raphson_strategy.h:118
KRATOS_CLASS_POINTER_DEFINITION(AdaptiveResidualBasedNewtonRaphsonStrategy)
AdaptiveResidualBasedNewtonRaphsonStrategy(const AdaptiveResidualBasedNewtonRaphsonStrategy &Other)
bool mReformDofSetAtEachStep
Definition: adaptive_residualbased_newton_raphson_strategy.h:965
bool mInitializeWasPerformed
Definition: adaptive_residualbased_newton_raphson_strategy.h:979
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: adaptive_residualbased_newton_raphson_strategy.h:876
BaseType::DofsArrayType DofsArrayType
Definition: adaptive_residualbased_newton_raphson_strategy.h:116
int mNumberOfCycles
Definition: adaptive_residualbased_newton_raphson_strategy.h:984
TSparseSpace SparseSpaceType
Definition: adaptive_residualbased_newton_raphson_strategy.h:110
BaseType::TDataType TDataType
Definition: adaptive_residualbased_newton_raphson_strategy.h:108
BaseType::TSystemVectorType TSystemVectorType
Definition: adaptive_residualbased_newton_raphson_strategy.h:120
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: adaptive_residualbased_newton_raphson_strategy.h:807
bool GetCalculateReactionsFlag()
Definition: adaptive_residualbased_newton_raphson_strategy.h:352
TLinearSolver::Pointer mpLinearSolver
Definition: adaptive_residualbased_newton_raphson_strategy.h:944
void ReductionStrategy(ModelPart &model_part, double NewTime)
Definition: adaptive_residualbased_newton_raphson_strategy.h:1077
bool mSolutionStepIsInitialized
Definition: adaptive_residualbased_newton_raphson_strategy.h:974
void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: adaptive_residualbased_newton_raphson_strategy.h:1020
BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition: adaptive_residualbased_newton_raphson_strategy.h:126
AdaptiveResidualBasedNewtonRaphsonStrategy< TSparseSpace, TDenseSpace, TLinearSolver > ClassType
Definition: adaptive_residualbased_newton_raphson_strategy.h:104
bool CyclicSolve()
Definition: adaptive_residualbased_newton_raphson_strategy.h:440
ConvergenceCriteria< TSparseSpace, TDenseSpace > TConvergenceCriteriaType
Definition: adaptive_residualbased_newton_raphson_strategy.h:95
bool GetReformDofSetAtEachStepFlag()
Definition: adaptive_residualbased_newton_raphson_strategy.h:362
SolvingStrategy< TSparseSpace, TDenseSpace > SolvingStrategyType
Definition: adaptive_residualbased_newton_raphson_strategy.h:100
void PrintIncreaseOfDeltaTime(double old_dt, double new_dt)
Definition: adaptive_residualbased_newton_raphson_strategy.h:1063
static std::string Name()
Returns the name of the class as used in the settings (snake_case format)
Definition: adaptive_residualbased_newton_raphson_strategy.h:835
void Initialize() override
Initialization of member variables and prior operations.
Definition: adaptive_residualbased_newton_raphson_strategy.h:991
ImplicitSolvingStrategy< TSparseSpace, TDenseSpace, TLinearSolver > BaseType
Definition: adaptive_residualbased_newton_raphson_strategy.h:102
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
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
BaseType::TSystemVectorType TSystemVectorType
Definition: implicit_solving_strategy.h:72
void SetRebuildLevel(int Level) override
This sets the build level.
Definition: implicit_solving_strategy.h:207
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: implicit_solving_strategy.h:283
int mRebuildLevel
Definition: implicit_solving_strategy.h:263
bool mStiffnessMatrixIsBuilt
The current rebuild level.
Definition: implicit_solving_strategy.h:264
BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: implicit_solving_strategy.h:76
BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition: implicit_solving_strategy.h:74
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: implicit_solving_strategy.h:80
BaseType::TSystemMatrixType TSystemMatrixType
Definition: implicit_solving_strategy.h:70
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: implicit_solving_strategy.h:78
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: implicit_solving_strategy.h:169
BaseType::TDataType TDataType
Definition: implicit_solving_strategy.h:68
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
int GetInt() const
This method returns the integer contained in the current Parameter.
Definition: kratos_parameters.cpp:666
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
bool GetBool() const
This method returns the boolean contained in the current Parameter.
Definition: kratos_parameters.cpp:675
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
Current class provides an implementation for standard elimination builder and solving operations.
Definition: residualbased_elimination_builder_and_solver.h:76
This class provides the implementation of the basic tasks that are needed by the solution strategy.
Definition: scheme.h:56
Solving strategy base class This is the base class from which we will derive all the strategies (impl...
Definition: solving_strategy.h:64
ModelPart & GetModelPart()
Operations to get the pointer to the model.
Definition: solving_strategy.h:350
virtual Parameters ValidateAndAssignParameters(Parameters ThisParameters, const Parameters DefaultParameters) const
This method validate and assign default parameters.
Definition: solving_strategy.h:507
int GetEchoLevel()
This returns the level of echo for the solving strategy.
Definition: solving_strategy.h:271
bool MoveMeshFlag()
This function returns the flag that says if the mesh is moved.
Definition: solving_strategy.h:290
int mEchoLevel
Definition: solving_strategy.h:485
virtual void MoveMesh()
This function is designed to move the mesh.
Definition: solving_strategy.h:330
static void Resize(MatrixType &rA, SizeType m, SizeType n)
Definition: ublas_space.h:558
static void Clear(MatrixPointerType &pA)
Definition: ublas_space.h:578
static IndexType Size(VectorType const &rV)
return size of vector rV
Definition: ublas_space.h:190
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_WARNING(label)
Definition: logger.h:265
bool Has(const std::string &ModelerName)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:24
TSpaceType::VectorPointerType CreateEmptyVectorPointer(TSpaceType &dummy)
Definition: add_strategies_to_python.cpp:187
TSpaceType::MatrixPointerType CreateEmptyMatrixPointer(TSpaceType &dummy)
Definition: add_strategies_to_python.cpp:181
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
bool WriteMatrixMarketMatrix(const char *FileName, CompressedMatrixType &M, bool Symmetric)
Definition: matrix_market_interface.h:308
model_part
Definition: face_heat.py:14
delta_time
Definition: generate_frictional_mortar_condition.py:130
integer i
Definition: TensorModule.f:17
double precision function mb(a)
Definition: TensorModule.f:849