69 template<
class TSparseSpace,
185 typename TSchemeType::Pointer pScheme,
186 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
187 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
189 bool CalculateReactions =
false,
190 bool ReformDofSetAtEachStep =
false,
194 : BaseType(rModelPart, pScheme, pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag ),
221 typename TSchemeType::Pointer pScheme,
222 typename TLinearSolver::Pointer pNewLinearSolver,
223 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
225 bool CalculateReactions =
false,
226 bool ReformDofSetAtEachStep =
false,
230 : BaseType(rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag),
257 typename TSchemeType::Pointer pScheme,
258 typename TLinearSolver::Pointer pNewLinearSolver,
259 typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
260 typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
262 bool CalculateReactions =
false,
263 bool ReformDofSetAtEachStep =
false,
267 : BaseType(rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag ),
300 typename SolvingStrategyType::Pointer
Create(
305 return Kratos::make_shared<ClassType>(rModelPart, ThisParameters);
327 TSparseSpace::SetToZero(rA);
328 TSparseSpace::SetToZero(rDx);
329 TSparseSpace::SetToZero(rb);
352 ComputeNodalWeights();
384 ComputeNodalWeights();
416 bool is_converged =
false;
424 if (r_process_info.
Is(INTERACTION)) {
430 int inner_iteration = 0;
432 while (!is_converged && inner_iteration <
mThisParameters[
"inner_loop_iterations"].GetInt()) {
436 KRATOS_INFO(
"Simplified semi-smooth strategy") <<
BOLDFONT(
"INNER ITERATION: ") << inner_iteration << std::endl;
440 r_process_info[NL_ITERATION_NUMBER] = 1;
444 if (r_process_info[NL_ITERATION_NUMBER] == 1) r_process_info[NL_ITERATION_NUMBER] = 2;
448 if (is_converged)
KRATOS_INFO(
"Simplified semi-smooth strategy") <<
BOLDFONT(
"Simplified semi-smooth strategy. INNER ITERATION: ") <<
BOLDFONT(
FGRN(
"CONVERGED")) << std::endl;
473 typename TSchemeType::Pointer p_scheme = this->
GetScheme();
474 typename TBuilderAndSolverType::Pointer p_builder_and_solver = this->
GetBuilderAndSolver();
475 auto& r_dof_set = p_builder_and_solver->GetDofSet();
482 unsigned int iteration_number = 1;
483 r_model_part.
GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
484 bool is_converged =
false;
485 bool residual_is_updated =
false;
488 ComputeNodalWeights();
490 p_scheme->InitializeNonLinIteration(r_model_part, rA, rDx, rb);
502 TSparseSpace::SetToZero(rA);
503 TSparseSpace::SetToZero(rDx);
504 TSparseSpace::SetToZero(rb);
506 p_builder_and_solver->BuildAndSolve(p_scheme, r_model_part, rA, rDx, rb);
508 TSparseSpace::SetToZero(rDx);
509 TSparseSpace::SetToZero(rb);
511 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
520 p_scheme->FinalizeNonLinIteration(r_model_part, rA, rDx, rb);
525 p_builder_and_solver->CalculateReactions(p_scheme, r_model_part, rA, rDx, rb);
529 TSparseSpace::SetToZero(rb);
531 p_builder_and_solver->BuildRHS(p_scheme, r_model_part, rb);
540 r_model_part.
GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
543 ComputeNodalWeights();
546 p_scheme->InitializeNonLinIteration(r_model_part, rA, rDx, rb);
550 if (update_each_nl_iteration) {
551 p_builder_and_solver->SetUpDofSet(p_scheme, r_model_part);
552 p_builder_and_solver->SetUpSystem(r_model_part);
563 TSparseSpace::SetToZero(rA);
564 TSparseSpace::SetToZero(rDx);
565 TSparseSpace::SetToZero(rb);
567 p_builder_and_solver->BuildAndSolve(p_scheme, r_model_part, rA, rDx, rb);
569 TSparseSpace::SetToZero(rDx);
570 TSparseSpace::SetToZero(rb);
572 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
575 TSparseSpace::SetToZero(rDx);
576 TSparseSpace::SetToZero(rb);
578 p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
581 KRATOS_WARNING(
"NO DOFS") <<
"ATTENTION: no free DOFs!! " << std::endl;
590 p_scheme->FinalizeNonLinIteration(r_model_part, rA, rDx, rb);
593 residual_is_updated =
false;
597 p_builder_and_solver->CalculateReactions(p_scheme, r_model_part, rA, rDx, rb);
601 TSparseSpace::SetToZero(rb);
603 p_builder_and_solver->BuildRHS(p_scheme, r_model_part, rb);
604 residual_is_updated =
true;
619 if (!residual_is_updated) {
632 p_builder_and_solver->CalculateReactions(p_scheme, r_model_part, rA, rDx, rb);
645 "name" : "newton_raphson_mpc_contact_strategy",
646 "inner_loop_iterations" : 5,
647 "update_each_nl_iteration" : false,
648 "enforce_ntn" : false
654 return default_parameters;
663 return "newton_raphson_mpc_contact_strategy";
822 void ComputeNodalWeights()
828 auto& r_nodes_array = r_contact_model_part.
Nodes();
833 auto& r_conditions_array = r_contact_model_part.
Conditions();
836 const bool enforce_ntn =
false;
844 if (rCond.
Is(SLAVE)) {
845 auto& r_geometry = rCond.GetGeometry();
846 Vector lumping_factor;
847 lumping_factor = r_geometry.LumpingFactors(lumping_factor);
848 const double domain_size = r_geometry.DomainSize();
849 for (IndexType i_node = 0; i_node < r_geometry.size(); ++i_node) {
850 auto& r_node = r_geometry[i_node];
852 AtomicAdd(r_node.GetValue(NODAL_PAUX), 1.0);
854 AtomicAdd(r_node.GetValue(NODAL_MAUX), lumping_factor[i_node] * domain_size);
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
Base class for all Conditions.
Definition: condition.h:59
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
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
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
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
MeshType::MasterSlaveConstraintContainerType MasterSlaveConstraintContainerType
Definition: model_part.h:219
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
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
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
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
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
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
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
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
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
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 Predict() override
Operation to predict the solution ... if it is not called a trivial predictor is used in which the va...
Definition: residualbased_newton_raphson_strategy.h:625
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
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
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
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 SetNonHistoricalVariableToZero(const Variable< TType > &rVariable, TContainerType &rContainer)
Sets the nodal value of any variable to zero.
Definition: variable_utils.h:724
void SetFlag(const Flags &rFlag, const bool FlagValue, TContainerType &rContainer)
Sets a flag according to a given status over a given container.
Definition: variable_utils.h:900
#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_TRY
Definition: define.h:109
#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
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