changed: move the LinearSolverVerbosity parameter to Opm::Parameters

This commit is contained in:
Arne Morten Kvarving 2024-07-01 14:13:14 +02:00
parent ffdbd2f127
commit 59f586189e
7 changed files with 44 additions and 34 deletions

View File

@ -44,11 +44,13 @@
#ifndef EWOMS_ISTL_SOLVER_WRAPPERS_HH
#define EWOMS_ISTL_SOLVER_WRAPPERS_HH
#include <dune/istl/solvers.hh>
#include <opm/models/utils/propertysystem.hh>
#include <opm/models/utils/parametersystem.hh>
#include <opm/simulators/linalg/linalgproperties.hh>
#include <dune/istl/solvers.hh>
#include <opm/simulators/linalg/linalgparameters.hh>
#include <opm/simulators/linalg/linalgproperties.hh>
namespace Opm::Linear {
@ -82,7 +84,7 @@ namespace Opm::Linear {
\
int verbosity = 0; \
if (parOperator.overlap().myRank() == 0) \
verbosity = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>(); \
verbosity = Parameters::get<TypeTag, Parameters::LinearSolverVerbosity>(); \
solver_ = std::make_shared<RawSolver>(parOperator, parScalarProduct, \
parPreCond, tolerance, maxIter, \
verbosity); \
@ -137,7 +139,7 @@ public:
int verbosity = 0;
if (parOperator.overlap().myRank() == 0)
verbosity = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>();
verbosity = Parameters::get<TypeTag, Parameters::LinearSolverVerbosity>();
int restartAfter = Parameters::get<TypeTag, Properties::GMResRestart>();
solver_ = std::make_shared<RawSolver>(parOperator,
parScalarProduct,

View File

@ -55,6 +55,16 @@ struct LinearSolverOverlapSize { using type = Properties::UndefinedProperty; };
template<class TypeTag, class MyTypeTag>
struct LinearSolverTolerance { using type = Properties::UndefinedProperty; };
/*!
* \brief Specifies the verbosity of the linear solver
*
* By default it is 0, i.e. it doesn't print anything. Setting this
* property to 1 prints aggregated convergence rates, 2 prints the
* convergence rate of every iteration of the scheme.
*/
template<class TypeTag, class MyTypeTag>
struct LinearSolverVerbosity { using type = Properties::UndefinedProperty; };
} // namespace Opm::Parameters
#endif

View File

@ -45,16 +45,6 @@ struct PreconditionerWrapper { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag>
struct LinearSolverScalar { using type = UndefinedProperty; };
/*!
* \brief Specifies the verbosity of the linear solver
*
* By default it is 0, i.e. it doesn't print anything. Setting this
* property to 1 prints aggregated convergence rates, 2 prints the
* convergence rate of every iteration of the scheme.
*/
template<class TypeTag, class MyTypeTag>
struct LinearSolverVerbosity { using type = UndefinedProperty; };
//! Maximum number of iterations eyecuted by the linear solver
template<class TypeTag, class MyTypeTag>
struct LinearSolverMaxIterations { using type = UndefinedProperty; };

View File

@ -208,7 +208,7 @@ protected:
int verbosity = 0;
if (parOperator.overlap().myRank() == 0)
verbosity = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>();
verbosity = Parameters::get<TypeTag, Parameters::LinearSolverVerbosity>();
bicgstabSolver->setVerbosity(verbosity);
bicgstabSolver->setMaxIterations(Parameters::get<TypeTag, Properties::LinearSolverMaxIterations>());
bicgstabSolver->setLinearOperator(&parOperator);
@ -274,7 +274,7 @@ protected:
int verbosity = 0;
if (this->simulator_.vanguard().gridView().comm().rank() == 0)
verbosity = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>();
verbosity = Parameters::get<TypeTag, Parameters::LinearSolverVerbosity>();
using SmootherArgs = typename Dune::Amg::SmootherTraits<ParallelSmoother>::Arguments;

View File

@ -160,7 +160,7 @@ public:
("The size of the algebraic overlap for the linear solver");
Parameters::registerParam<TypeTag, Properties::LinearSolverMaxIterations>
("The maximum number of iterations of the linear solver");
Parameters::registerParam<TypeTag, Properties::LinearSolverVerbosity>
Parameters::registerParam<TypeTag, Parameters::LinearSolverVerbosity>
("The verbosity level of the linear solver");
PreconditionerWrapper::registerParameters();
@ -388,10 +388,6 @@ protected:
namespace Opm::Properties {
//! make the linear solver shut up by default
template<class TypeTag>
struct LinearSolverVerbosity<TypeTag, TTag::ParallelBaseLinearSolver> { static constexpr int value = 0; };
//! set the preconditioner relaxation parameter to 1.0 by default
template<class TypeTag>
struct PreconditionerRelaxation<TypeTag, TTag::ParallelBaseLinearSolver>
@ -471,6 +467,11 @@ template<class TypeTag>
struct LinearSolverOverlapSize<TypeTag, Properties::TTag::ParallelBaseLinearSolver>
{ static constexpr unsigned value = 2; };
//! make the linear solver shut up by default
template<class TypeTag>
struct LinearSolverVerbosity<TypeTag, Properties::TTag::ParallelBaseLinearSolver>
{ static constexpr int value = 0; };
} // namespace Opm::Parameters
#endif

View File

@ -152,7 +152,7 @@ protected:
int verbosity = 0;
if (parOperator.overlap().myRank() == 0)
verbosity = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>();
verbosity = Parameters::get<TypeTag, Parameters::LinearSolverVerbosity>();
bicgstabSolver->setVerbosity(verbosity);
bicgstabSolver->setMaxIterations(Parameters::get<TypeTag, Properties::LinearSolverMaxIterations>());
bicgstabSolver->setLinearOperator(&parOperator);

View File

@ -29,22 +29,26 @@
#if HAVE_SUPERLU
#include <opm/models/linear/istlsparsematrixbackend.hh>
#include <opm/models/utils/parametersystem.hh>
#include <opm/simulators/linalg/linalgproperties.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/version.hh>
#include <dune/istl/superlu.hh>
#include <opm/material/common/Unused.hpp>
#include <dune/istl/superlu.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/version.hh>
#include <opm/models/linear/istlsparsematrixbackend.hh>
#include <opm/models/utils/parametersystem.hh>
#include <opm/simulators/linalg/linalgproperties.hh>
namespace Opm::Properties::TTag {
struct SuperLULinearSolver {};
} // namespace Opm::Properties::TTag
namespace Opm {
namespace Linear {
namespace Opm::Linear {
template <class Scalar, class TypeTag, class Matrix, class Vector>
class SuperLUSolve_;
@ -69,7 +73,7 @@ public:
static void registerParameters()
{
Parameters::registerParam<TypeTag, Properties::LinearSolverVerbosity>
Parameters::registerParam<TypeTag, Parameters::LinearSolverVerbosity>
("The verbosity level of the linear solver");
}
@ -110,7 +114,7 @@ public:
{
Vector bTmp(b);
int verbosity = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>();
int verbosity = Parameters::get<TypeTag, Parameters::LinearSolverVerbosity>();
Dune::InverseOperatorResult result;
Dune::SuperLU<Matrix> solver(A, verbosity > 0);
solver.apply(x, bTmp, result);
@ -173,9 +177,12 @@ public:
namespace Opm::Properties {
template<class TypeTag>
struct LinearSolverVerbosity<TypeTag, TTag::SuperLULinearSolver> { static constexpr int value = 0; };
struct LinearSolverVerbosity<TypeTag, TTag::SuperLULinearSolver>
{ static constexpr int value = 0; };
template<class TypeTag>
struct LinearSolverBackend<TypeTag, TTag::SuperLULinearSolver> { using type = Opm::Linear::SuperLUBackend<TypeTag>; };
struct LinearSolverBackend<TypeTag, TTag::SuperLULinearSolver>
{ using type = Opm::Linear::SuperLUBackend<TypeTag>; };
} // namespace Opm::Properties