53 template<
class TSparseSpace,
126 typename ConvergenceCriteriaBaseType::Pointer pFirstCriterion,
127 typename ConvergenceCriteriaBaseType::Pointer pSecondCriterion,
128 const bool PrintingOutput =
false,
131 :
BaseType(pFirstCriterion, pSecondCriterion),
132 mpConditionNumberUtility(pConditionNumberUtility)
135 mOptions.
Set(MortarAndConvergenceCriteria::PRINTING_OUTPUT, PrintingOutput);
136 mOptions.
Set(MortarAndConvergenceCriteria::TABLE_IS_INITIALIZED,
false);
137 mOptions.
Set(MortarAndConvergenceCriteria::CONDITION_NUMBER_IS_INITIALIZED,
false);
145 ,mOptions(rOther.mOptions)
146 ,mpConditionNumberUtility(rOther.mpConditionNumberUtility)
166 typename ConvergenceCriteriaBaseType::Pointer
Create(
Parameters ThisParameters)
const override
168 return Kratos::make_shared<ClassType>(ThisParameters);
192 if (r_process_info.
Has(TABLE_UTILITY)) {
200 if (mpConditionNumberUtility !=
nullptr) {
202 const double condition_number = mpConditionNumberUtility->GetConditionNumber(copy_A);
204 if (r_process_info.
Has(TABLE_UTILITY)) {
205 std::cout.precision(4);
207 auto& r_table = p_table->GetTable();
208 r_table << condition_number;
210 if (mOptions.
IsNot(MortarAndConvergenceCriteria::PRINTING_OUTPUT))
211 KRATOS_INFO(
"MortarAndConvergenceCriteria") <<
"\n" <<
BOLDFONT(
"CONDITION NUMBER:") <<
"\t " << std::scientific << condition_number << std::endl;
213 KRATOS_INFO(
"MortarAndConvergenceCriteria") <<
"\n" <<
"CONDITION NUMBER:" <<
"\t" << std::scientific << condition_number << std::endl;
217 if (criterion_result ==
true && rModelPart.
GetCommunicator().
MyPID() == 0 && this->GetEchoLevel() > 0)
218 if (r_process_info.
Has(TABLE_UTILITY)) {
220 p_table->PrintFooter();
223 return criterion_result;
235 if (r_process_info.
Has(TABLE_UTILITY) && mOptions.
IsNot(MortarAndConvergenceCriteria::TABLE_IS_INITIALIZED)) {
237 (p_table->GetTable()).SetBold(mOptions.
IsNot(MortarAndConvergenceCriteria::PRINTING_OUTPUT));
238 (p_table->GetTable()).AddColumn(
"ITER", 4);
241 mOptions.
Set(MortarAndConvergenceCriteria::TABLE_IS_INITIALIZED,
true);
244 if (r_process_info.
Has(TABLE_UTILITY) && mpConditionNumberUtility !=
nullptr
245 && mOptions.
IsNot(MortarAndConvergenceCriteria::CONDITION_NUMBER_IS_INITIALIZED)) {
247 (p_table->GetTable()).AddColumn(
"COND.NUM.", 10);
248 mOptions.
Set(MortarAndConvergenceCriteria::CONDITION_NUMBER_IS_INITIALIZED,
true);
272 std::cout.precision(4);
273 if (mOptions.
IsNot(MortarAndConvergenceCriteria::PRINTING_OUTPUT))
274 std::cout <<
"\n\n" <<
BOLDFONT(
"CONVERGENCE CHECK") <<
"\tSTEP: " << rModelPart.
GetProcessInfo()[STEP] <<
"\tTIME: " << std::scientific << rModelPart.
GetProcessInfo()[TIME] <<
"\tDELTA TIME: " << std::scientific << rModelPart.
GetProcessInfo()[DELTA_TIME] << std::endl;
276 std::cout <<
"\n\n" <<
"CONVERGENCE CHECK" <<
"\tSTEP: " << rModelPart.
GetProcessInfo()[STEP] <<
"\tTIME: " << std::scientific << rModelPart.
GetProcessInfo()[TIME] <<
"\tDELTA TIME: " << std::scientific << rModelPart.
GetProcessInfo()[DELTA_TIME] << std::endl;
278 if (r_process_info.
Has(TABLE_UTILITY)) {
280 p_table->PrintHeader();
314 "name" : "mortar_and_criteria",
315 "print_convergence_criterion" : false
321 return default_parameters;
330 return "mortar_and_criteria";
346 std::string
Info()
const override
348 return "MortarAndConvergenceCriteria";
389 mpConditionNumberUtility =
nullptr;
392 mOptions.
Set(MortarAndConvergenceCriteria::PRINTING_OUTPUT, ThisParameters[
"print_convergence_criterion"].GetBool());
393 mOptions.
Set(MortarAndConvergenceCriteria::TABLE_IS_INITIALIZED,
false);
394 mOptions.
Set(MortarAndConvergenceCriteria::CONDITION_NUMBER_IS_INITIALIZED,
false);
417 template<
class TSparseSpace,
class TDenseSpace>
419 template<
class TSparseSpace,
class TDenseSpace>
421 template<
class TSparseSpace,
class TDenseSpace>
This convergence criteria checks simultaneously two convergence criteria (both must be satisfied)
Definition: and_criteria.h:60
BaseType::TSystemMatrixType TSystemMatrixType
Definition: and_criteria.h:79
BaseType::DofsArrayType DofsArrayType
Definition: and_criteria.h:77
void Initialize(ModelPart &rModelPart) override
This function initialize the convergence criteria.
Definition: and_criteria.h:228
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: and_criteria.h:337
void FinalizeSolutionStep(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &A, const TSystemVectorType &Dx, const TSystemVectorType &b) override
This function finalizes the solution step.
Definition: and_criteria.h:282
BaseType::TSystemVectorType TSystemVectorType
Definition: and_criteria.h:81
bool PostCriteria(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &A, const TSystemVectorType &Dx, const TSystemVectorType &b) override
Criteria that need to be called after getting the solution.
Definition: and_criteria.h:210
void InitializeSolutionStep(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &A, const TSystemVectorType &Dx, const TSystemVectorType &b) override
This function initializes the solution step.
Definition: and_criteria.h:242
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
virtual Parameters ValidateAndAssignParameters(Parameters ThisParameters, const Parameters DefaultParameters) const
This method validate and assign default parameters.
Definition: convergence_criteria.h:466
virtual void AssignSettings(const Parameters ThisParameters)
This method assigns settings to member variables.
Definition: convergence_criteria.h:479
bool Has(const Variable< TDataType > &rThisVariable) const
Checks if the data container has a value associated with a given variable.
Definition: data_value_container.h:382
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
static Flags Create(IndexType ThisPosition, bool Value=true)
Definition: flags.h:138
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Communicator & GetCommunicator()
Definition: model_part.h:1821
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
Custom AND convergence criteria for the mortar condition.
Definition: mortar_and_criteria.h:58
void InitializeSolutionStep(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb) override
This function initializes the solution step.
Definition: mortar_and_criteria.h:260
ConditionNumberUtility::Pointer ConditionNumberUtilityPointerType
The condition number utility pointer definition.
Definition: mortar_and_criteria.h:96
void AssignSettings(const Parameters ThisParameters) override
This method assigns settings to member variables.
Definition: mortar_and_criteria.h:384
void Initialize(ModelPart &rModelPart) override
This function initialize the convergence criteria.
Definition: mortar_and_criteria.h:230
KRATOS_DEFINE_LOCAL_FLAG(PRINTING_OUTPUT)
Local Flags.
MortarAndConvergenceCriteria(MortarAndConvergenceCriteria const &rOther)
Definition: mortar_and_criteria.h:143
KRATOS_DEFINE_LOCAL_FLAG(CONDITION_NUMBER_IS_INITIALIZED)
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: mortar_and_criteria.h:352
MortarAndConvergenceCriteria(Kratos::Parameters ThisParameters)
Default constructor. (with parameters)
Definition: mortar_and_criteria.h:114
std::size_t IndexType
The index type definition.
Definition: mortar_and_criteria.h:93
KRATOS_CLASS_POINTER_DEFINITION(MortarAndConvergenceCriteria)
Pointer definition of MortarAndConvergenceCriteria.
std::string Info() const override
Turn back information as a string.
Definition: mortar_and_criteria.h:346
void FinalizeSolutionStep(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb) override
This function finalizes the solution step.
Definition: mortar_and_criteria.h:295
static std::string Name()
Returns the name of the class as used in the settings (snake_case format)
Definition: mortar_and_criteria.h:328
TableStreamUtility::Pointer TablePrinterPointerType
The table stream definition TODO: Replace by logger.
Definition: mortar_and_criteria.h:90
MortarAndConvergenceCriteria()
Default constructor.
Definition: mortar_and_criteria.h:105
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mortar_and_criteria.h:358
ConvergenceCriteriaBaseType::Pointer Create(Parameters ThisParameters) const override
Create method.
Definition: mortar_and_criteria.h:166
~MortarAndConvergenceCriteria() override=default
bool PostCriteria(ModelPart &rModelPart, DofsArrayType &rDofSet, const TSystemMatrixType &rA, const TSystemVectorType &rDx, const TSystemVectorType &rb) override
Criteria that need to be called after getting the solution.
Definition: mortar_and_criteria.h:180
Parameters GetDefaultParameters() const override
This method provides the defaults parameters to avoid conflicts between the different constructors.
Definition: mortar_and_criteria.h:310
KRATOS_DEFINE_LOCAL_FLAG(TABLE_IS_INITIALIZED)
MortarAndConvergenceCriteria(typename ConvergenceCriteriaBaseType::Pointer pFirstCriterion, typename ConvergenceCriteriaBaseType::Pointer pSecondCriterion, const bool PrintingOutput=false, ConditionNumberUtilityPointerType pConditionNumberUtility=nullptr)
Definition: mortar_and_criteria.h:125
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
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
#define BOLDFONT(x)
Definition: color_utilities.h:34
#define KRATOS_INFO(label)
Definition: logger.h:250
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21