KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
residualbased_newton_raphson_mpc_contact_strategy.h
Go to the documentation of this file.
1 // KRATOS ______ __ __ _____ __ __ __
2 // / ____/___ ____ / /_____ ______/ /_/ ___// /________ _______/ /___ ___________ _/ /
3 // / / / __ \/ __ \/ __/ __ `/ ___/ __/\__ \/ __/ ___/ / / / ___/ __/ / / / ___/ __ `/ /
4 // / /___/ /_/ / / / / /_/ /_/ / /__/ /_ ___/ / /_/ / / /_/ / /__/ /_/ /_/ / / / /_/ / /
5 // \____/\____/_/ /_/\__/\__,_/\___/\__//____/\__/_/ \__,_/\___/\__/\__,_/_/ \__,_/_/ MECHANICS
6 //
7 // License: BSD License
8 // license: ContactStructuralMechanicsApplication/license.txt
9 //
10 // Main authors: Vicente Mataix Ferrandiz
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
22 #include "includes/define.h"
23 #include "includes/model_part.h"
24 #include "includes/variables.h"
25 
26 /* Strategies */
28 
29 /* Contact criteria */
31 
32 /* Utilities */
35 #include "utilities/math_utils.h"
37 
38 // /* Processes */
39 // #include "processes/fast_transfer_between_model_parts_process.h"
40 
41 namespace Kratos {
42 
45 
49 
53 
57 
61 
69 template<class TSparseSpace,
70  class TDenseSpace, // = DenseSpace<double>,
71  class TLinearSolver //= LinearSolver<TSparseSpace,TDenseSpace>
72  >
73 
75  public ResidualBasedNewtonRaphsonStrategy< TSparseSpace, TDenseSpace, TLinearSolver >
76 {
77 public:
80 
83 
86 
89 
92 
95 
98 
101 
104 
106  using TDataType = typename BaseType::TDataType;
107 
109  using SparseSpaceType = TSparseSpace;
110 
113 
116 
119 
122 
125 
128 
131 
134 
137 
140 
143 
146 
148  using IndexType = std::size_t;
149 
151  using SizeType = std::size_t;
152 
157  {
158  }
159 
166  : BaseType(rModelPart)
167  {
168  // Validate and assign defaults
169  ThisParameters = this->ValidateAndAssignParameters(ThisParameters, this->GetDefaultParameters());
170  this->AssignSettings(ThisParameters);
171  }
172 
184  ModelPart& rModelPart,
185  typename TSchemeType::Pointer pScheme,
186  typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
187  typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
188  IndexType MaxIterations = 30,
189  bool CalculateReactions = false,
190  bool ReformDofSetAtEachStep = false,
191  bool MoveMeshFlag = false,
192  Parameters ThisParameters = Parameters(R"({})")
193  )
194  : BaseType(rModelPart, pScheme, pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag ),
195  mThisParameters(ThisParameters)
196  {
197  KRATOS_TRY;
198 
199  // We create the contact criteria
200  mpMPCContactCriteria = Kratos::make_shared<TMPCContactCriteriaType>();
201 
202  Parameters default_parameters = GetDefaultParameters();
203  mThisParameters.ValidateAndAssignDefaults(default_parameters);
204 
205  KRATOS_CATCH("");
206  }
207 
220  ModelPart& rModelPart,
221  typename TSchemeType::Pointer pScheme,
222  typename TLinearSolver::Pointer pNewLinearSolver,
223  typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
224  IndexType MaxIterations = 30,
225  bool CalculateReactions = false,
226  bool ReformDofSetAtEachStep = false,
227  bool MoveMeshFlag = false,
228  Parameters ThisParameters = Parameters(R"({})")
229  )
230  : BaseType(rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag),
231  mThisParameters(ThisParameters)
232  {
233  KRATOS_TRY;
234 
235  // We create the contact criteria
236  mpMPCContactCriteria = Kratos::make_shared<TMPCContactCriteriaType>();
237 
238  Parameters default_parameters = GetDefaultParameters();
239  mThisParameters.ValidateAndAssignDefaults(default_parameters);
240 
241  KRATOS_CATCH("");
242  }
243 
256  ModelPart& rModelPart,
257  typename TSchemeType::Pointer pScheme,
258  typename TLinearSolver::Pointer pNewLinearSolver,
259  typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria,
260  typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver,
261  IndexType MaxIterations = 30,
262  bool CalculateReactions = false,
263  bool ReformDofSetAtEachStep = false,
264  bool MoveMeshFlag = false,
265  Parameters ThisParameters = Parameters(R"({})")
266  )
267  : BaseType(rModelPart, pScheme, pNewLinearSolver, pNewConvergenceCriteria, pNewBuilderAndSolver, MaxIterations, CalculateReactions, ReformDofSetAtEachStep, MoveMeshFlag ),
268  mThisParameters(ThisParameters)
269  {
270  KRATOS_TRY;
271 
272  // We create the contact criteria
273  mpMPCContactCriteria = Kratos::make_shared<TMPCContactCriteriaType>();
274 
275  Parameters default_parameters = GetDefaultParameters();
276  mThisParameters.ValidateAndAssignDefaults(default_parameters);
277 
278  KRATOS_CATCH("");
279  }
280 
285  = default;
286 
290 
294 
300  typename SolvingStrategyType::Pointer Create(
301  ModelPart& rModelPart,
302  Parameters ThisParameters
303  ) const override
304  {
305  return Kratos::make_shared<ClassType>(rModelPart, ThisParameters);
306  }
307 
312  void Predict() override
313  {
314  KRATOS_TRY
315 
317 
318  // Getting model part
319  ModelPart& r_model_part = StrategyBaseType::GetModelPart();
320 
321  // We get the system
325 
326  // We solve the system in order to check the active set once
327  TSparseSpace::SetToZero(rA);
328  TSparseSpace::SetToZero(rDx);
329  TSparseSpace::SetToZero(rb);
330 
331  typename TSchemeType::Pointer p_scheme = BaseType::GetScheme();
332  typename TBuilderAndSolverType::Pointer p_builder_and_solver = BaseType::GetBuilderAndSolver();
333  p_builder_and_solver->BuildAndSolve(p_scheme, BaseType::GetModelPart(), rA, rDx, rb);
334 
335  // Check active set
336  const SizeType echo_level_convergence_criteria = BaseType::mpConvergenceCriteria->GetEchoLevel();
337  BaseType::mpConvergenceCriteria->SetEchoLevel(0);
338  mpMPCContactCriteria->PostCriteria(r_model_part, BaseType::GetBuilderAndSolver()->GetDofSet(), rA, rDx, rb);
339  BaseType::mpConvergenceCriteria->SetEchoLevel(echo_level_convergence_criteria);
340 
341  KRATOS_CATCH("")
342  }
343 
347  void Initialize() override
348  {
349  KRATOS_TRY;
350 
351  // Computing nodal weights
352  ComputeNodalWeights();
353 
355 
356  KRATOS_CATCH("");
357  }
358 
365  double Solve() override
366  {
367  this->Initialize();
368  this->InitializeSolutionStep();
369  this->Predict();
370  this->SolveSolutionStep();
371  this->FinalizeSolutionStep(); // TODO: Comment for proper work of interaction
372 
373  return 0.0;
374  }
375 
381  void InitializeSolutionStep() override
382  {
383  // Computing nodal weights
384  ComputeNodalWeights();
385 
387 
388 // // If enforcing NTN
389 // const bool enforce_ntn = mThisParameters["enforce_ntn"].GetBool();
390 // if (enforce_ntn) {
391 // EnforcingNTN();
392 // }
393  }
394 
399  void FinalizeSolutionStep() override
400  {
401  KRATOS_TRY;
402 
404 
405  KRATOS_CATCH("");
406  }
407 
412  bool SolveSolutionStep() override
413  {
414  KRATOS_TRY;
415 
416  bool is_converged = false;
417 
418  // Getting model part
419  ModelPart& r_model_part = StrategyBaseType::GetModelPart();
420 
421  // We get the process info
422  ProcessInfo& r_process_info = r_model_part.GetProcessInfo();
423 
424  if (r_process_info.Is(INTERACTION)) {
425  // We get the system
429 
430  int inner_iteration = 0;
431  const SizeType echo_level_convergence_criteria = BaseType::mpConvergenceCriteria->GetEchoLevel();
432  while (!is_converged && inner_iteration < mThisParameters["inner_loop_iterations"].GetInt()) {
433  ++inner_iteration;
434 
435  if (echo_level_convergence_criteria > 0 && r_model_part.GetCommunicator().MyPID() == 0 ) {
436  KRATOS_INFO("Simplified semi-smooth strategy") << BOLDFONT("INNER ITERATION: ") << inner_iteration << std::endl;
437  }
438 
439  // We solve one loop
440  r_process_info[NL_ITERATION_NUMBER] = 1;
441  is_converged = AuxiliarySolveSolutionStep();
442 
443  // We check the convergence
444  if (r_process_info[NL_ITERATION_NUMBER] == 1) r_process_info[NL_ITERATION_NUMBER] = 2; // Trigger check
445  is_converged = mpMPCContactCriteria->PostCriteria(r_model_part, BaseType::GetBuilderAndSolver()->GetDofSet(), rA, rDx, rb);
446 
447  if (echo_level_convergence_criteria > 0 && r_model_part.GetCommunicator().MyPID() == 0 ) {
448  if (is_converged) KRATOS_INFO("Simplified semi-smooth strategy") << BOLDFONT("Simplified semi-smooth strategy. INNER ITERATION: ") << BOLDFONT(FGRN("CONVERGED")) << std::endl;
449  else KRATOS_INFO("Simplified semi-smooth strategy") << BOLDFONT("INNER ITERATION: ") << BOLDFONT(FRED("NOT CONVERGED")) << std::endl;
450  }
451  }
452  } else {
453  is_converged = AuxiliarySolveSolutionStep();
454  }
455 
456  return is_converged;
457 
458  KRATOS_CATCH("");
459  }
460 
461 
466  {
467  // Getting flag INTERACTION
468  ModelPart& r_model_part = StrategyBaseType::GetModelPart();
469  const bool update_each_nl_iteration = mThisParameters["update_each_nl_iteration"].GetBool();
470  VariableUtils().SetFlag(INTERACTION, update_each_nl_iteration, r_model_part.GetSubModelPart("ComputingContact").Conditions());
471 
472  // Pointers needed in the solution
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();
476 
480 
481  // Initializing the parameters of the Newton-Raphson cycle
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;
486 
487  // Computing nodal weights
488  ComputeNodalWeights();
489 
490  p_scheme->InitializeNonLinIteration(r_model_part, rA, rDx, rb);
491  BaseType::mpConvergenceCriteria->InitializeNonLinearIteration(r_model_part, r_dof_set, rA, rDx, rb);
492  is_converged = BaseType::mpConvergenceCriteria->PreCriteria(r_model_part, p_builder_and_solver->GetDofSet(), rA, rDx, rb);
493 
494 // // If enforcing NTN
495 // const bool enforce_ntn = mThisParameters["enforce_ntn"].GetBool();
496 // if (enforce_ntn) {
497 // EnforcingNTN();
498 // }
499 
500  // Function to perform the building and the solving phase.
502  TSparseSpace::SetToZero(rA);
503  TSparseSpace::SetToZero(rDx);
504  TSparseSpace::SetToZero(rb);
505 
506  p_builder_and_solver->BuildAndSolve(p_scheme, r_model_part, rA, rDx, rb);
507  } else {
508  TSparseSpace::SetToZero(rDx); //Dx=0.00;
509  TSparseSpace::SetToZero(rb);
510 
511  p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
512  }
513 
514  // Debugging info
515  BaseType::EchoInfo(iteration_number);
516 
517  // Updating the results stored in the database
519 
520  p_scheme->FinalizeNonLinIteration(r_model_part, rA, rDx, rb);
521  BaseType::mpConvergenceCriteria->FinalizeNonLinearIteration(r_model_part, r_dof_set, rA, rDx, rb);
522 
523  // Calculate reactions if required
525  p_builder_and_solver->CalculateReactions(p_scheme, r_model_part, rA, rDx, rb);
526 
527  if (is_converged) {
528  if (BaseType::mpConvergenceCriteria->GetActualizeRHSflag()) {
529  TSparseSpace::SetToZero(rb);
530 
531  p_builder_and_solver->BuildRHS(p_scheme, r_model_part, rb);
532  }
533 
534  is_converged = BaseType::mpConvergenceCriteria->PostCriteria(r_model_part, p_builder_and_solver->GetDofSet(), rA, rDx, rb);
535  }
536 
537  // Iteration Cycle... performed only for NonLinearProblems
538  while (!is_converged && iteration_number++ < BaseType::mMaxIterationNumber) {
539  // Setting the number of iteration
540  r_model_part.GetProcessInfo()[NL_ITERATION_NUMBER] = iteration_number;
541 
542  // Computing nodal weights
543  ComputeNodalWeights();
544 
545  // Calling InitializeNonLinIteration
546  p_scheme->InitializeNonLinIteration(r_model_part, rA, rDx, rb);
547  BaseType::mpConvergenceCriteria->InitializeNonLinearIteration(r_model_part, r_dof_set, rA, rDx, rb);
548 
549  // Shaping correctly the system
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);
553  p_builder_and_solver->ResizeAndInitializeVectors(p_scheme, BaseType::mpA, BaseType::mpDx, BaseType::mpb, r_model_part);
554  }
555 
556  is_converged = BaseType::mpConvergenceCriteria->PreCriteria(r_model_part, p_builder_and_solver->GetDofSet(), rA, rDx, rb);
557 
558  // Call the linear system solver to find the correction mDx for the it is not called if there is no system to solve
559  if (SparseSpaceType::Size(rDx) != 0) {
562  //A = 0.00;
563  TSparseSpace::SetToZero(rA);
564  TSparseSpace::SetToZero(rDx);
565  TSparseSpace::SetToZero(rb);
566 
567  p_builder_and_solver->BuildAndSolve(p_scheme, r_model_part, rA, rDx, rb);
568  } else {
569  TSparseSpace::SetToZero(rDx);
570  TSparseSpace::SetToZero(rb);
571 
572  p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
573  }
574  } else {
575  TSparseSpace::SetToZero(rDx);
576  TSparseSpace::SetToZero(rb);
577 
578  p_builder_and_solver->BuildRHSAndSolve(p_scheme, r_model_part, rA, rDx, rb);
579  }
580  } else {
581  KRATOS_WARNING("NO DOFS") << "ATTENTION: no free DOFs!! " << std::endl;
582  }
583 
584  // Debugging info
585  BaseType::EchoInfo(iteration_number);
586 
587  // Updating the results stored in the database
589 
590  p_scheme->FinalizeNonLinIteration(r_model_part, rA, rDx, rb);
591  BaseType::mpConvergenceCriteria->FinalizeNonLinearIteration(r_model_part, r_dof_set, rA, rDx, rb);
592 
593  residual_is_updated = false;
594 
595  // Calculate reactions if required
597  p_builder_and_solver->CalculateReactions(p_scheme, r_model_part, rA, rDx, rb);
598 
599  if (is_converged) {
600  if (BaseType::mpConvergenceCriteria->GetActualizeRHSflag()) {
601  TSparseSpace::SetToZero(rb);
602 
603  p_builder_and_solver->BuildRHS(p_scheme, r_model_part, rb);
604  residual_is_updated = true;
605  }
606 
607  is_converged = BaseType::mpConvergenceCriteria->PostCriteria(r_model_part, p_builder_and_solver->GetDofSet(), rA, rDx, rb);
608  }
609  }
610 
611  // Plots a warning if the maximum number of iterations is exceeded
612  if (iteration_number >= BaseType::mMaxIterationNumber) {
614  } else {
615  KRATOS_INFO_IF("NR-Strategy", this->GetEchoLevel() > 0) << "Convergence achieved after " << iteration_number << " / " << BaseType::mMaxIterationNumber << " iterations" << std::endl;
616  }
617 
618  // Recalculate residual if needed (note that some convergence criteria need it to be recalculated)
619  if (!residual_is_updated) {
620  // NOTE:
621  // The following part will be commented because it is time consuming
622  // and there is no obvious reason to be here. If someone need this
623  // part please notify the community via mailing list before uncommenting it.
624  // Pooyan.
625 
626 // TSparseSpace::SetToZero(mb);
627 // p_builder_and_solver->BuildRHS(p_scheme, r_model_part, mb);
628  }
629 
630  // Calculate reactions if required
632  p_builder_and_solver->CalculateReactions(p_scheme, r_model_part, rA, rDx, rb);
633 
634  return is_converged;
635  }
636 
642  {
643  Parameters default_parameters = Parameters(R"(
644  {
645  "name" : "newton_raphson_mpc_contact_strategy",
646  "inner_loop_iterations" : 5,
647  "update_each_nl_iteration" : false,
648  "enforce_ntn" : false
649  })" );
650 
651  // Getting base class default parameters
652  const Parameters base_default_parameters = BaseType::GetDefaultParameters();
653  default_parameters.RecursivelyAddMissingParameters(base_default_parameters);
654  return default_parameters;
655  }
656 
661  static std::string Name()
662  {
663  return "newton_raphson_mpc_contact_strategy";
664  }
665 
669 
673 
677 
681 
682 protected:
683 
686 
690 
692  typename TConvergenceCriteriaType::Pointer mpMPCContactCriteria;
693 
697 
701 
706  void AssignSettings(const Parameters ThisParameters) override
707  {
708  BaseType::AssignSettings(ThisParameters);
709 
710  // We create the contact criteria
711  mpMPCContactCriteria = Kratos::make_shared<TMPCContactCriteriaType>();
712 
713  // Copy the parameters
714  mThisParameters = ThisParameters;
715  }
716 
720 
724 
729 
735  {
736  };
737 
738 private:
739 
745 
749 
753 
754 // /**
755 // * @brief This inforces NTN formulation
756 // */
757 // void EnforcingNTN()
758 // {
759 // // List of enforced nodes to not repeat
760 // std::unordered_set<IndexType> enforced_nodes;
761 //
762 // // Getting contact model part
763 // ModelPart& r_root_model_part = StrategyBaseType::GetModelPart().GetRootModelPart();
764 // ModelPart& r_computing_contact_model_part = StrategyBaseType::GetModelPart().GetSubModelPart("ComputingContact");
765 //
766 // // The process info
767 // const auto& r_process_info = r_root_model_part.GetProcessInfo();
768 //
769 // // Reset the pointers of the conditions
770 // for (auto& r_cond : r_computing_contact_model_part.Conditions()) {
771 // if (r_cond.Has(CONSTRAINT_POINTER)) {
772 // r_cond.SetValue(CONSTRAINT_POINTER, nullptr);
773 // }
774 // }
775 //
776 // // Iterate over the constraints
777 // IndexType counter = 1;
778 // for (auto& r_const : r_root_model_part.MasterSlaveConstraints()) {
779 // r_const.SetId(counter);
780 // ++counter;
781 // }
782 //
783 // // Auxiliary classes
784 // Matrix original_relation_matrix, relation_matrix;
785 // Vector original_constant_vector, constant_vector;
786 // ModelPart::DofsVectorType original_master_dofs, master_dofs, original_slave_dofs, slave_dofs;
787 //
788 // // Iterate over the constraints
789 // for (auto& r_const : r_computing_contact_model_part.MasterSlaveConstraints()) {
790 // // Getting original system
791 // r_const.GetLocalSystem(original_relation_matrix, original_constant_vector, r_process_info);
792 // r_const.GetDofList(original_slave_dofs, original_master_dofs, r_process_info);
793 //
794 // // TODO: Finish rebuild
795 //
796 // // Creating new constraint
797 // r_root_model_part.CreateNewMasterSlaveConstraint("LinearMasterSlaveConstraint", counter, master_dofs, slave_dofs, relation_matrix, constant_vector);
798 //
799 // // Setting to remove the old constraints
800 // r_const.Set(TO_ERASE, true);
801 //
802 // ++counter;
803 // }
804 //
805 // // Remove old constraints
806 // r_root_model_part.RemoveMasterSlaveConstraintsFromAllLevels(TO_ERASE);
807 //
808 // // Transfer constraints from the root to the computing model part
809 // FastTransferBetweenModelPartsProcess(r_computing_contact_model_part, r_root_model_part, FastTransferBetweenModelPartsProcess::EntityTransfered::CONSTRAINTS).Execute();
810 //
811 // // Reorder ids
812 // counter = 1;
813 // for (auto& r_const : r_root_model_part.MasterSlaveConstraints()) {
814 // r_const.SetId(counter);
815 // ++counter;
816 // }
817 // }
818 
822  void ComputeNodalWeights()
823  {
824  // Getting contact model part
825  ModelPart& r_contact_model_part = StrategyBaseType::GetModelPart().GetSubModelPart("Contact");
826 
827  // Reset the NODAL_PAUX and NODAL_MAUX
828  auto& r_nodes_array = r_contact_model_part.Nodes();
829  VariableUtils().SetNonHistoricalVariableToZero(NODAL_PAUX, r_nodes_array);
830  VariableUtils().SetNonHistoricalVariableToZero(NODAL_MAUX, r_nodes_array);
831 
832  // We set the constraints active and inactive in function of the active set
833  auto& r_conditions_array = r_contact_model_part.Conditions();
834 
835  // If enforcing NTN
836  const bool enforce_ntn = false;
837 // const bool enforce_ntn = mThisParameters["enforce_ntn"].GetBool();
838 // if (enforce_ntn) {
839 // VariableUtils().SetNonHistoricalVariable(NODAL_PAUX, 1.0, r_nodes_array);
840 // }
841 
842  block_for_each(r_conditions_array, [&](Condition& rCond) {
843  // Only slave conditions
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];
851  if (!enforce_ntn) {
852  AtomicAdd(r_node.GetValue(NODAL_PAUX), 1.0);
853  }
854  AtomicAdd(r_node.GetValue(NODAL_MAUX), lumping_factor[i_node] * domain_size);
855  }
856  }
857  });
858  }
859 
864 
868 
875 
876 }; /* Class ResidualBasedNewtonRaphsonMPCContactStrategy */
884 } // namespace Kratos
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
Custom convergence criteria for the contact problem.
Definition: mpc_contact_criteria.h:56
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
Contact Newton Raphson class.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:76
std::size_t IndexType
Index type definition.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:148
Parameters GetDefaultParameters() const override
This method returns the defaulr parameters in order to avoid code duplication.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:641
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:706
SolvingStrategyType::Pointer Create(ModelPart &rModelPart, Parameters ThisParameters) const override
Create method.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:300
void InitializeSolutionStep() override
Performs all the required operations that should be done (for each step) before solving the solution ...
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:381
std::size_t SizeType
Size type definition.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:151
bool SolveSolutionStep() override
Solves the current step.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:412
ResidualBasedNewtonRaphsonMPCContactStrategy()
Default constructor.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:156
typename ModelPart::MasterSlaveConstraintContainerType ConstraintArrayType
Array type for constraints.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:145
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_mpc_contact_strategy.h:312
void Initialize() override
Initialization of member variables and prior operations.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:347
ResidualBasedNewtonRaphsonMPCContactStrategy(ModelPart &rModelPart, Parameters ThisParameters)
Default constructor. (with parameters)
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:165
bool AuxiliarySolveSolutionStep()
Solves the current step. This function returns true if a solution has been found, false otherwise....
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:465
double Solve() override
The problem of interest is solved.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:365
ResidualBasedNewtonRaphsonMPCContactStrategy(const ResidualBasedNewtonRaphsonMPCContactStrategy &Other)
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:734
Parameters mThisParameters
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:691
void FinalizeSolutionStep() override
Performs all the required operations that should be done (for each step) after solving the solution s...
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:399
TConvergenceCriteriaType::Pointer mpMPCContactCriteria
The configuration parameters.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:692
static std::string Name()
Returns the name of the class as used in the settings (snake_case format)
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:661
ResidualBasedNewtonRaphsonMPCContactStrategy(ModelPart &rModelPart, typename TSchemeType::Pointer pScheme, typename TLinearSolver::Pointer pNewLinearSolver, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, IndexType MaxIterations=30, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false, Parameters ThisParameters=Parameters(R"({})"))
Default constructor.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:219
ResidualBasedNewtonRaphsonMPCContactStrategy(ModelPart &rModelPart, typename TSchemeType::Pointer pScheme, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, IndexType MaxIterations=30, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false, Parameters ThisParameters=Parameters(R"({})"))
Default constructor.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:183
KRATOS_CLASS_POINTER_DEFINITION(ResidualBasedNewtonRaphsonMPCContactStrategy)
Pointer definition of ResidualBasedNewtonRaphsonMPCContactStrategy.
ResidualBasedNewtonRaphsonMPCContactStrategy(ModelPart &rModelPart, typename TSchemeType::Pointer pScheme, typename TLinearSolver::Pointer pNewLinearSolver, typename TConvergenceCriteriaType::Pointer pNewConvergenceCriteria, typename TBuilderAndSolverType::Pointer pNewBuilderAndSolver, IndexType MaxIterations=30, bool CalculateReactions=false, bool ReformDofSetAtEachStep=false, bool MoveMeshFlag=false, Parameters ThisParameters=Parameters(R"({})"))
Default constructor.
Definition: residualbased_newton_raphson_mpc_contact_strategy.h:255
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