64 template<
class TSparseSpace,
178 typename TSchemeType::Pointer pScheme,
179 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
180 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
182 bool CalculateReactions =
false,
183 bool ReformDofSetAtEachStep =
false,
189 :
BaseType(rModelPart, pScheme, pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, CalculateReactions, ReformDofSetAtEachStep,
MoveMeshFlag ),
217 typename TSchemeType::Pointer pScheme,
218 typename TLinearSolver::Pointer pNewLinearSolver,
219 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
221 bool CalculateReactions =
false,
222 bool ReformDofSetAtEachStep =
false,
228 :
BaseType(rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, MaxIterations, CalculateReactions, ReformDofSetAtEachStep,
MoveMeshFlag),
256 typename TSchemeType::Pointer pScheme,
257 typename TLinearSolver::Pointer pNewLinearSolver,
258 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
259 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
261 bool CalculateReactions =
false,
262 bool ReformDofSetAtEachStep =
false,
268 :
ResidualBasedNewtonRaphsonStrategy<TSparseSpace, TDenseSpace, TLinearSolver>(rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, CalculateReactions, ReformDofSetAtEachStep,
MoveMeshFlag ),
302 typename SolvingStrategyType::Pointer
Create(
307 return Kratos::make_shared<ClassType>(rModelPart, ThisParameters);
324 const bool frictional = r_model_part.
Is(SLIP);
327 if (r_nodes_array.begin()->SolutionStepsDataHas(WEIGHTED_GAP)) {
338 const std::size_t
step = r_process_info[STEP];
403 r_process_info[NL_ITERATION_NUMBER] = 1;
473 bool is_converged =
false;
478 if (r_model_part.
IsNot(INTERACTION)) {
487 int inner_iteration = 0;
488 while (!is_converged && inner_iteration <
mThisParameters[
"inner_loop_iterations"].GetInt()) {
492 std::cout << std::endl <<
BOLDFONT(
"Simplified semi-smooth strategy. INNER ITERATION: ") << inner_iteration;;
496 r_process_info[NL_ITERATION_NUMBER] = 1;
497 r_process_info[INNER_LOOP_ITERATION] = inner_iteration;
506 if (is_converged) std::cout <<
BOLDFONT(
"Simplified semi-smooth strategy. INNER ITERATION: ") <<
BOLDFONT(
FGRN(
"CONVERGED")) << std::endl;
507 else std::cout <<
BOLDFONT(
"Simplified semi-smooth strategy. INNER ITERATION: ") <<
BOLDFONT(
FRED(
"NOT CONVERGED")) << std::endl;
535 "name" : "newton_raphson_contact_strategy",
536 "adaptative_strategy" : false,
537 "split_factor" : 10.0,
538 "max_number_splits" : 3,
539 "inner_loop_iterations" : 5
545 return default_parameters;
554 return "newton_raphson_contact_strategy";
625 auto& r_dof_set = p_builder_and_solver->GetDofSet();
633 r_process_info[NL_ITERATION_NUMBER] = iteration_number;
635 bool is_converged =
false;
636 bool residual_is_updated =
false;
637 p_scheme->InitializeNonLinIteration(r_model_part, rA, rDx, rb);
644 KRATOS_WARNING(
"Element inverted") <<
"INVERTED ELEMENT BEFORE FIRST SOLVE" << std::endl;
645 r_process_info[STEP] -= 1;
652 TSparseSpace::SetToZero(rA);
653 TSparseSpace::SetToZero(rDx);
654 TSparseSpace::SetToZero(rb);
656 p_builder_and_solver->BuildAndSolve(p_scheme, r_model_part, rA, rDx, rb);
658 TSparseSpace::SetToZero(rDx);
659 TSparseSpace::SetToZero(rb);
661 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
673 KRATOS_WARNING(
"Element inverted") <<
"INVERTED ELEMENT DURING DATABASE UPDATE" << std::endl;
674 r_process_info[STEP] -= 1;
679 p_scheme->FinalizeNonLinIteration(r_model_part, rA, rDx, rb);
687 TSparseSpace::SetToZero(rb);
689 p_builder_and_solver->BuildRHS(p_scheme, r_model_part, rb);
698 r_process_info[NL_ITERATION_NUMBER] = iteration_number;
700 p_scheme->InitializeNonLinIteration(r_model_part, rA, rDx, rb);
711 TSparseSpace::SetToZero(rA);
712 TSparseSpace::SetToZero(rDx);
713 TSparseSpace::SetToZero(rb);
715 p_builder_and_solver->BuildAndSolve(p_scheme, r_model_part, rA, rDx, rb);
718 TSparseSpace::SetToZero(rDx);
719 TSparseSpace::SetToZero(rb);
721 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
725 TSparseSpace::SetToZero(rDx);
726 TSparseSpace::SetToZero(rb);
728 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
731 KRATOS_WARNING(
"No DoFs") <<
"ATTENTION: no free DOFs!! " << std::endl;
743 KRATOS_WARNING(
"Element inverted") <<
"INVERTED ELEMENT DURING DATABASE UPDATE" << std::endl;
744 r_process_info[STEP] -= 1;
749 p_scheme->FinalizeNonLinIteration(r_model_part, rA, rDx, rb);
752 residual_is_updated =
false;
757 TSparseSpace::SetToZero(rb);
759 p_builder_and_solver->BuildRHS(p_scheme, r_model_part, rb);
760 residual_is_updated =
true;
774 if (residual_is_updated ==
false) {
787 p_builder_and_solver->CalculateReactions(p_scheme, r_model_part, rA, rDx, rb);
801 bool is_converged =
false;
804 KRATOS_WARNING(
"No python processes") <<
"If you have not implemented any method to recalculate BC or loads in function of time, this strategy will be USELESS" << std::endl;
807 KRATOS_WARNING(
"No python post processes") <<
"If you don't add the postprocesses and the time step if splitted you won't postprocess that steps" << std::endl;
812 const double original_delta_time = r_process_info[DELTA_TIME];
814 int split_number = 0;
817 while (is_converged ==
false && split_number <=
mThisParameters[
"max_number_splits"].GetInt()) {
820 double aux_delta_time, current_time;
821 const double aux_time =
SplitTimeStep(aux_delta_time, current_time);
822 current_time += aux_delta_time;
824 bool inside_the_split_is_converged =
false;
826 while (current_time <= aux_time) {
827 inner_iteration += 1;
828 r_process_info[STEP] += 1;
830 if (inner_iteration == 1) {
873 if (mpMyProcesses !=
nullptr)
888 current_time += aux_delta_time;
891 if (inside_the_split_is_converged)
896 if (is_converged ==
false)
900 r_process_info[DELTA_TIME] = original_delta_time;
933 bool inverted_element =
false;
938 for(
int i = 0; i < static_cast<int>(elements_array.size()); ++
i) {
939 auto it_elem = elements_array.begin() +
i;
940 auto& geom = it_elem->GetGeometry();
941 if (geom.DeterminantOfJacobian(0) < 0.0) {
950 std::vector<Matrix> deformation_gradient_matrices;
951 it_elem->CalculateOnIntegrationPoints( DEFORMATION_GRADIENT, deformation_gradient_matrices, r_process_info);
953 for (
IndexType i_gp = 0; i_gp < deformation_gradient_matrices.size(); ++i_gp) {
965 return inverted_element;
975 double& AuxDeltaTime,
983 CurrentTime = aux_time - AuxDeltaTime;
1004 KRATOS_ERROR <<
"It is impossible to move the mesh since the DISPLACEMENT var is not in the model_part. Either use SetMoveMeshFlag(False) or add DISPLACEMENT to the list of variables" << std::endl;
1031 const double AuxDeltaTime,
1032 const double AuxTime
1037 std::cout.precision(4);
1038 std::cout <<
"|----------------------------------------------------|" << std::endl;
1039 std::cout <<
"| " <<
BOLDFONT(
"SPLITTING TIME STEP") <<
" |" << std::endl;
1040 std::cout <<
"| " <<
BOLDFONT(
"COMING BACK TO TIME: ") << std::scientific << Time <<
" |" << std::endl;
1041 std::cout <<
"| " <<
BOLDFONT(
" NEW TIME STEP: ") << std::scientific << AuxDeltaTime <<
" |" << std::endl;
1042 std::cout <<
"| " <<
BOLDFONT(
" UNTIL TIME: ") << std::scientific << AuxTime <<
" |" << std::endl;
1043 std::cout <<
"|----------------------------------------------------|" << std::endl;
1053 std::cout <<
"|----------------------------------------------------|" << std::endl;
1054 std::cout <<
"| " <<
BOLDFONT(
FRED(
"ATTENTION: Max iterations exceeded")) <<
" |" << std::endl;
1055 std::cout <<
"|----------------------------------------------------|" << std::endl;
1065 std::cout <<
"|----------------------------------------------------|" << std::endl;
1066 std::cout <<
"| " <<
BOLDFONT(
FRED(
"ATTENTION: Max iterations exceeded")) <<
" |" << std::endl;
1067 std::cout <<
"| " <<
BOLDFONT(
FRED(
" Max number of splits exceeded ")) <<
" |" << std::endl;
1068 std::cout <<
"|----------------------------------------------------|" << std::endl;
Current class provides an implementation for the base builder and solving operations.
Definition: builder_and_solver.h:64
virtual int MyPID() const
Definition: communicator.cpp:91
This is the base class to define the different convergence criterion considered.
Definition: convergence_criteria.h:58
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
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
BaseType::NodesArrayType NodesArrayType
Definition: implicit_solving_strategy.h:92
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::ConditionsArrayType ConditionsArrayType
Definition: implicit_solving_strategy.h:96
BaseType::TSystemMatrixType TSystemMatrixType
Definition: implicit_solving_strategy.h:70
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: implicit_solving_strategy.h:78
BaseType::TDataType TDataType
Definition: implicit_solving_strategy.h:68
BaseType::ElementsArrayType ElementsArrayType
Definition: implicit_solving_strategy.h:94
static double Det(const TMatrixType &rA)
Calculates the determinant of a matrix of a square matrix of any size (no check performed on release ...
Definition: math_utils.h:597
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
Communicator & GetCommunicator()
Definition: model_part.h:1821
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
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
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
void OverwriteSolutionStepData(IndexType SourceSolutionStepIndex, IndexType DestinationSourceSolutionStepIndex)
Definition: node.h:365
void CloneSolutionStepData()
Definition: node.h:360
const PointType & GetInitialPosition() const
Definition: node.h:559
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
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
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
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
void SetCurrentTime(double NewTime)
Definition: process_info.cpp:63
void CloneSolutionStepInfo()
Definition: process_info.cpp:90
void ClearHistory(IndexType StepsBefore=0)
Definition: process_info.cpp:147
void SetAsTimeStepInfo()
Definition: process_info.cpp:29
This is the base Newton Raphson strategy.
Definition: residualbased_newton_raphson_strategy.h:66
BaseType::LocalSystemMatrixType LocalSystemMatrixType
Definition: residualbased_newton_raphson_strategy.h:97
TSparseSpace SparseSpaceType
Definition: residualbased_newton_raphson_strategy.h:85
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
BaseType::TDataType TDataType
Definition: residualbased_newton_raphson_strategy.h:83
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
BaseType::TSystemVectorType TSystemVectorType
Definition: residualbased_newton_raphson_strategy.h:93
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
bool mCalculateReactionsFlag
Flag telling if it is needed or not to compute the reactions.
Definition: residualbased_newton_raphson_strategy.h:1253
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: residualbased_newton_raphson_strategy.h:1069
TSystemVectorPointerType mpDx
The pointer to the convergence criteria employed.
Definition: residualbased_newton_raphson_strategy.h:1236
bool SolveSolutionStep() override
Solves the current step. This function returns true if a solution has been found, false otherwise.
Definition: residualbased_newton_raphson_strategy.h:884
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 AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: residualbased_newton_raphson_strategy.h:1351
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
BaseType::TSystemMatrixType TSystemMatrixType
Definition: residualbased_newton_raphson_strategy.h:91
bool GetKeepSystemConstantDuringIterations()
Get method for the flag mKeepSystemConstantDuringIterations.
Definition: residualbased_newton_raphson_strategy.h:1158
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
BaseType::TSystemVectorPointerType TSystemVectorPointerType
Definition: residualbased_newton_raphson_strategy.h:101
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
BaseType::LocalSystemVectorType LocalSystemVectorType
Definition: residualbased_newton_raphson_strategy.h:95
BaseType::TSystemMatrixPointerType TSystemMatrixPointerType
Definition: residualbased_newton_raphson_strategy.h:99
BaseType::DofsArrayType DofsArrayType
Definition: residualbased_newton_raphson_strategy.h:89
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
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 IndexType Size(VectorType const &rV)
return size of vector rV
Definition: ublas_space.h:190
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetVariable(const TVarType &rVariable, const TDataType &rValue, NodesContainerType &rNodes, const unsigned int Step=0)
Sets the nodal value of a scalar variable.
Definition: variable_utils.h:675
#define FGRN(x)
Definition: color_utilities.h:27
#define FRED(x)
Definition: color_utilities.h:26
#define BOLDFONT(x)
Definition: color_utilities.h:34
#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
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
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
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int step
Definition: face_heat.py:88
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
A
Definition: sensitivityMatrix.py:70
integer i
Definition: TensorModule.f:17