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.
convergence_criteria_factory.hpp
Go to the documentation of this file.
1 // KRATOS___
2 // // ) )
3 // // ___ ___
4 // // ____ //___) ) // ) )
5 // // / / // // / /
6 // ((____/ / ((____ ((___/ / MECHANICS
7 //
8 // License: geo_mechanics_application/license.txt
9 //
10 // Main authors: Richard Faasse
11 //
12 
13 #pragma once
14 
17 #include "parameters_utilities.h"
18 
19 namespace Kratos
20 {
21 
22 template <class TSparseSpace, class TDenseSpace>
24 {
25 public:
27 
28  static std::shared_ptr<ConvergenceCriteriaType> Create(const Parameters& rSolverSettings)
29  {
30  KRATOS_ERROR_IF_NOT(rSolverSettings.Has("convergence_criterion"))
31  << "No convergence_criterion is defined, aborting.";
32 
33  if (rSolverSettings["convergence_criterion"].GetString() ==
34  "displacement_criterion")
35  {
36  const std::vector<std::string> entries_to_copy = {
37  "displacement_absolute_tolerance",
38  "displacement_relative_tolerance"};
39  const Parameters convergence_inputs =
40  ParametersUtilities::CopyOptionalParameters(rSolverSettings, entries_to_copy);
41  return std::make_shared<DisplacementCriteria<TSparseSpace, TDenseSpace>>(convergence_inputs);
42  }
43  if (rSolverSettings["convergence_criterion"].GetString() ==
44  "residual_criterion")
45  {
46  const std::vector<std::string> entries_to_copy = {
47  "residual_absolute_tolerance", "residual_relative_tolerance"};
48  const auto convergence_inputs = ParametersUtilities::CopyOptionalParameters(
49  rSolverSettings, entries_to_copy);
50  return std::make_shared<ResidualCriteria<TSparseSpace, TDenseSpace>>(convergence_inputs);
51  }
52 
53  KRATOS_ERROR << "The convergence_criterion ("
54  << rSolverSettings["convergence_criterion"].GetString() << ") is unknown, "
55  << "supported criteria are: 'displacement_criterion', "
56  "'residual_criterion'."
57  << std::endl;
58  }
59 };
60 
61 } // namespace Kratos
Definition: convergence_criteria_factory.hpp:24
static std::shared_ptr< ConvergenceCriteriaType > Create(const Parameters &rSolverSettings)
Definition: convergence_criteria_factory.hpp:28
This is the base class to define the different convergence criterion considered.
Definition: convergence_criteria.h:58
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
bool Has(const std::string &rEntry) const
This method checks if the Parameter contains a certain entry.
Definition: kratos_parameters.cpp:520
static Parameters CopyOptionalParameters(const Parameters &rSourceParameters, const std::vector< std::string > &rNamesOfParametersToCopy)
Definition: parameters_utilities.cpp:27
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21