clang-format PreconditionerFactory_impl

This commit is contained in:
Tobias Meyer Andersen 2023-12-20 10:00:06 +01:00
parent 3d9b3a3013
commit 8177400602

View File

@ -23,10 +23,9 @@
#include <opm/simulators/linalg/PreconditionerFactory.hpp>
#include <opm/simulators/linalg/matrixblock.hh>
#include <opm/simulators/linalg/amgcpr.hh>
#include <opm/simulators/linalg/DILU.hpp>
#include <opm/simulators/linalg/ExtraSmoothers.hpp>
#include <opm/simulators/linalg/FlexibleSolver.hpp>
#include <opm/simulators/linalg/ilufirstelement.hh>
#include <opm/simulators/linalg/OwningBlockPreconditioner.hpp>
#include <opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp>
#include <opm/simulators/linalg/ParallelOverlappingILU0.hpp>
@ -34,33 +33,34 @@
#include <opm/simulators/linalg/PressureTransferPolicy.hpp>
#include <opm/simulators/linalg/PropertyTree.hpp>
#include <opm/simulators/linalg/WellOperators.hpp>
#include <opm/simulators/linalg/DILU.hpp>
#include <opm/simulators/linalg/ExtraSmoothers.hpp>
#include <opm/simulators/linalg/amgcpr.hh>
#include <opm/simulators/linalg/ilufirstelement.hh>
#include <opm/simulators/linalg/matrixblock.hh>
#include <dune/common/unused.hh>
#include <dune/istl/owneroverlapcopy.hh>
#include <dune/istl/preconditioners.hh>
#include <dune/istl/paamg/amg.hh>
#include <dune/istl/paamg/kamg.hh>
#include <dune/istl/paamg/fastamg.hh>
#include <dune/istl/paamg/kamg.hh>
#include <dune/istl/preconditioners.hh>
#include <config.h>
#if HAVE_CUDA
#include <opm/simulators/linalg/cuistl/CuSeqILU0.hpp>
#include <opm/simulators/linalg/cuistl/PreconditionerAdapter.hpp>
#include <opm/simulators/linalg/cuistl/PreconditionerConvertFieldTypeAdapter.hpp>
#include <opm/simulators/linalg/cuistl/CuBlockPreconditioner.hpp>
#include <opm/simulators/linalg/cuistl/CuDILU.hpp>
#include <opm/simulators/linalg/cuistl/CuJac.hpp>
#include <opm/simulators/linalg/cuistl/CuSeqILU0.hpp>
#include <opm/simulators/linalg/cuistl/PreconditionerAdapter.hpp>
#include <opm/simulators/linalg/cuistl/PreconditionerConvertFieldTypeAdapter.hpp>
#endif
namespace Opm {
namespace Opm
{
template <class Smoother>
struct AMGSmootherArgsHelper
{
struct AMGSmootherArgsHelper {
static auto args(const PropertyTree& prm)
{
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
@ -75,8 +75,7 @@ struct AMGSmootherArgsHelper
};
template <class M, class V, class C>
struct AMGSmootherArgsHelper<Opm::ParallelOverlappingILU0<M,V,V,C>>
{
struct AMGSmootherArgsHelper<Opm::ParallelOverlappingILU0<M, V, V, C>> {
static auto args(const PropertyTree& prm)
{
using Smoother = Opm::ParallelOverlappingILU0<M, V, V, C>;
@ -137,8 +136,7 @@ AMGHelper<Operator,Comm,Matrix,Vector>::criterion(const PropertyTree& prm)
template <class Operator, class Comm, class Matrix, class Vector>
template <class Smoother>
typename AMGHelper<Operator, Comm, Matrix, Vector>::PrecPtr
AMGHelper<Operator,Comm,Matrix,Vector>::
makeAmgPreconditioner(const Operator& op,
AMGHelper<Operator, Comm, Matrix, Vector>::makeAmgPreconditioner(const Operator& op,
const PropertyTree& prm,
bool useKamg)
{
@ -146,9 +144,8 @@ makeAmgPreconditioner(const Operator& op,
auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
if (useKamg) {
using Type = Dune::DummyUpdatePreconditioner<Dune::Amg::KAMG<Operator, Vector, Smoother>>;
return std::make_shared<Type>(op, crit, sargs,
prm.get<std::size_t>("max_krylov", 1),
prm.get<double>("min_reduction", 1e-1));
return std::make_shared<Type>(
op, crit, sargs, prm.get<std::size_t>("max_krylov", 1), prm.get<double>("min_reduction", 1e-1));
} else {
using Type = Dune::Amg::AMGCPR<Operator, Vector, Smoother>;
return std::make_shared<Type>(op, crit, sargs);
@ -156,8 +153,7 @@ makeAmgPreconditioner(const Operator& op,
}
template <class Operator, class Comm>
struct StandardPreconditioners
{
struct StandardPreconditioners {
static void add()
{
using namespace Dune;
@ -170,7 +166,8 @@ struct StandardPreconditioners
F::addCreator("ILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
return createParILU(op, prm, comm, 0);
});
F::addCreator("ParOverILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
F::addCreator("ParOverILU0",
[](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
return createParILU(op, prm, comm, prm.get<int>("ilulevel", 0));
});
F::addCreator("ILUn", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
@ -180,14 +177,14 @@ struct StandardPreconditioners
const int n = prm.get<int>("ilulevel", 0);
const double w = prm.get<double>("relaxation", 1.0);
const bool resort = prm.get<bool>("resort", false);
return wrapBlockPreconditioner<RebuildOnUpdatePreconditioner<Dune::SeqILU<M, V, V>, const M*>>(comm, &op.getmat(), n, w, resort);
return wrapBlockPreconditioner<RebuildOnUpdatePreconditioner<Dune::SeqILU<M, V, V>, const M*>>(
comm, &op.getmat(), n, w, resort);
});
F::addCreator("DILU", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
DUNE_UNUSED_PARAMETER(prm);
return wrapBlockPreconditioner<MultithreadDILU<M, V, V>>(comm, op.getmat());
});
F::addCreator("Jac", [](const O& op, const P& prm, const std::function<V()>&,
std::size_t, const C& comm) {
F::addCreator("Jac", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
const int n = prm.get<int>("repeats", 1);
const double w = prm.get<double>("relaxation", 1.0);
return wrapBlockPreconditioner<DummyUpdatePreconditioner<SeqJac<M, V, V>>>(comm, op.getmat(), n, w);
@ -223,8 +220,7 @@ struct StandardPreconditioners
auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
return prec;
}
else if (smoother == "DILU") {
} else if (smoother == "DILU") {
using SeqSmoother = Dune::MultithreadDILU<M, V, V>;
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
@ -232,8 +228,7 @@ struct StandardPreconditioners
auto crit = AMGHelper<O, C, M, V>::criterion(prm);
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
return prec;
}
else if (smoother == "Jac") {
} else if (smoother == "Jac") {
using SeqSmoother = SeqJac<M, V, V>;
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
@ -241,8 +236,7 @@ struct StandardPreconditioners
auto crit = AMGHelper<O, C, M, V>::criterion(prm);
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
return prec;
}
else if (smoother == "GS") {
} else if (smoother == "GS") {
using SeqSmoother = SeqGS<M, V, V>;
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
@ -250,8 +244,7 @@ struct StandardPreconditioners
auto crit = AMGHelper<O, C, M, V>::criterion(prm);
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
return prec;
}
else if (smoother == "SOR") {
} else if (smoother == "SOR") {
using SeqSmoother = SeqSOR<M, V, V>;
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
@ -259,8 +252,7 @@ struct StandardPreconditioners
auto crit = AMGHelper<O, C, M, V>::criterion(prm);
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
return prec;
}
else if (smoother == "SSOR") {
} else if (smoother == "SSOR") {
using SeqSmoother = SeqSSOR<M, V, V>;
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
@ -268,8 +260,7 @@ struct StandardPreconditioners
auto crit = AMGHelper<O, C, M, V>::criterion(prm);
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
return prec;
}
else if (smoother == "ILUn") {
} else if (smoother == "ILUn") {
using SeqSmoother = SeqILU<M, V, V>;
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
@ -283,34 +274,52 @@ struct StandardPreconditioners
});
}
F::addCreator("cpr", [](const O& op, const P& prm, const std::function<V()> weightsCalculator, std::size_t pressureIndex, const C& comm) {
F::addCreator("cpr",
[](const O& op,
const P& prm,
const std::function<V()> weightsCalculator,
std::size_t pressureIndex,
const C& comm) {
assert(weightsCalculator);
if (pressureIndex == std::numeric_limits<std::size_t>::max())
{
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Comm, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(op, prm, weightsCalculator, pressureIndex, comm);
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
op, prm, weightsCalculator, pressureIndex, comm);
});
F::addCreator("cprt", [](const O& op, const P& prm, const std::function<V()> weightsCalculator, std::size_t pressureIndex, const C& comm) {
F::addCreator("cprt",
[](const O& op,
const P& prm,
const std::function<V()> weightsCalculator,
std::size_t pressureIndex,
const C& comm) {
assert(weightsCalculator);
if (pressureIndex == std::numeric_limits<std::size_t>::max())
{
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Comm, true>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(op, prm, weightsCalculator, pressureIndex, comm);
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
op, prm, weightsCalculator, pressureIndex, comm);
});
if constexpr (std::is_same_v<O, WellModelGhostLastMatrixAdapter<M, V, V, true>>) {
F::addCreator("cprw",
[](const O& op, const P& prm, const std::function<V()> weightsCalculator, std::size_t pressureIndex, const C& comm) {
[](const O& op,
const P& prm,
const std::function<V()> weightsCalculator,
std::size_t pressureIndex,
const C& comm) {
assert(weightsCalculator);
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureBhpTransferPolicy<O, Comm, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(op, prm, weightsCalculator, pressureIndex, comm);
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
op, prm, weightsCalculator, pressureIndex, comm);
});
}
@ -318,7 +327,8 @@ struct StandardPreconditioners
F::addCreator("CUILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
const double w = prm.get<double>("relaxation", 1.0);
using field_type = typename V::field_type;
using CuILU0 = typename Opm::cuistl::CuSeqILU0<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
using CuILU0 = typename Opm::cuistl::
CuSeqILU0<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
auto cuILU0 = std::make_shared<CuILU0>(op.getmat(), w);
auto adapted = std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuILU0>>(cuILU0);
@ -329,7 +339,8 @@ struct StandardPreconditioners
F::addCreator("CUJac", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
const double w = prm.get<double>("relaxation", 1.0);
using field_type = typename V::field_type;
using CuJac = typename Opm::cuistl::CuJac<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
using CuJac =
typename Opm::cuistl::CuJac<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
auto cuJac = std::make_shared<CuJac>(op.getmat(), w);
auto adapted = std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuJac>>(cuJac);
@ -392,12 +403,10 @@ struct StandardPreconditioners
return is.size();
}
}
};
template <class Operator>
struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
{
struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
static void add()
{
using namespace Dune;
@ -482,8 +491,7 @@ struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
using Smoother = SeqILU<M, V, V>;
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm);
} else {
OPM_THROW(std::invalid_argument,
"Properties: No smoother with name " + smoother + ".");
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
}
});
F::addCreator("kamg", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
@ -507,8 +515,7 @@ struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
using Smoother = SeqILU<M, V, V>;
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
} else {
OPM_THROW(std::invalid_argument,
"Properties: No smoother with name " + smoother + ".");
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
}
});
F::addCreator("famg", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
@ -520,60 +527,73 @@ struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
});
}
if constexpr (std::is_same_v<O, WellModelMatrixAdapter<M, V, V, false>>) {
F::addCreator("cprw", [](const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
F::addCreator(
"cprw",
[](const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureBhpTransferPolicy<O, Dune::Amg::SequentialInformation, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(op, prm, weightsCalculator, pressureIndex);
using LevelTransferPolicy
= Opm::PressureBhpTransferPolicy<O, Dune::Amg::SequentialInformation, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
op, prm, weightsCalculator, pressureIndex);
});
}
F::addCreator("cpr", [](const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
if (pressureIndex == std::numeric_limits<std::size_t>::max())
{
F::addCreator(
"cpr",
[](const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Dune::Amg::SequentialInformation, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(op, prm, weightsCalculator, pressureIndex);
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
op, prm, weightsCalculator, pressureIndex);
});
F::addCreator("cprt", [](const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
if (pressureIndex == std::numeric_limits<std::size_t>::max())
{
F::addCreator(
"cprt",
[](const O& op, const P& prm, const std::function<V()>& weightsCalculator, std::size_t pressureIndex) {
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Dune::Amg::SequentialInformation, true>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(op, prm, weightsCalculator, pressureIndex);
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
op, prm, weightsCalculator, pressureIndex);
});
#if HAVE_CUDA
F::addCreator("CUILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
const double w = prm.get<double>("relaxation", 1.0);
using field_type = typename V::field_type;
using CuILU0 = typename Opm::cuistl::CuSeqILU0<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuILU0>>(std::make_shared<CuILU0>(op.getmat(), w));
using CuILU0 = typename Opm::cuistl::
CuSeqILU0<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuILU0>>(
std::make_shared<CuILU0>(op.getmat(), w));
});
F::addCreator("CUILU0Float", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
const double w = prm.get<double>("relaxation", 1.0);
using block_type = typename V::block_type;
using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
using matrix_type_to = typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
using CuILU0 = typename Opm::cuistl::CuSeqILU0<matrix_type_to, Opm::cuistl::CuVector<float>, Opm::cuistl::CuVector<float>>;
using matrix_type_to =
typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
using CuILU0 = typename Opm::cuistl::
CuSeqILU0<matrix_type_to, Opm::cuistl::CuVector<float>, Opm::cuistl::CuVector<float>>;
using Adapter = typename Opm::cuistl::PreconditionerAdapter<VTo, VTo, CuILU0>;
using Converter = typename Opm::cuistl::PreconditionerConvertFieldTypeAdapter<Adapter, M, V, V>;
auto converted = std::make_shared<Converter>(op.getmat());
auto adapted = std::make_shared<Adapter>(std::make_shared<CuILU0>(converted->getConvertedMatrix(), w));
converted->setUnderlyingPreconditioner(adapted);
return converted;
});
F::addCreator("CUJac", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
const double w = prm.get<double>("relaxation", 1.0);
using field_type = typename V::field_type;
using CUJac = typename Opm::cuistl::CuJac<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CUJac>>(std::make_shared<CUJac>(op.getmat(), w));
using CUJac =
typename Opm::cuistl::CuJac<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CUJac>>(
std::make_shared<CUJac>(op.getmat(), w));
});
F::addCreator("CUDILU", [](const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
@ -614,8 +634,8 @@ PreconditionerFactory<Operator,Comm>::instance()
template <class Operator, class Comm>
typename PreconditionerFactory<Operator, Comm>::PrecPtr
PreconditionerFactory<Operator,Comm>::
doCreate(const Operator& op, const PropertyTree& prm,
PreconditionerFactory<Operator, Comm>::doCreate(const Operator& op,
const PropertyTree& prm,
const std::function<Vector()> weightsCalculator,
std::size_t pressureIndex)
{
@ -639,10 +659,11 @@ doCreate(const Operator& op, const PropertyTree& prm,
template <class Operator, class Comm>
typename PreconditionerFactory<Operator, Comm>::PrecPtr
PreconditionerFactory<Operator,Comm>::
doCreate(const Operator& op, const PropertyTree& prm,
PreconditionerFactory<Operator, Comm>::doCreate(const Operator& op,
const PropertyTree& prm,
const std::function<Vector()> weightsCalculator,
std::size_t pressureIndex, const Comm& comm)
std::size_t pressureIndex,
const Comm& comm)
{
if (!defAdded_) {
StandardPreconditioners<Operator, Comm>::add();
@ -652,8 +673,7 @@ doCreate(const Operator& op, const PropertyTree& prm,
auto it = parallel_creators_.find(type);
if (it == parallel_creators_.end()) {
std::ostringstream msg;
msg << "Parallel preconditioner type " << type
<< " is not registered in the factory. Available types are: ";
msg << "Parallel preconditioner type " << type << " is not registered in the factory. Available types are: ";
for (const auto& prec : parallel_creators_) {
msg << prec.first << ' ';
}
@ -664,23 +684,23 @@ doCreate(const Operator& op, const PropertyTree& prm,
}
template <class Operator, class Comm>
void PreconditionerFactory<Operator,Comm>::
doAddCreator(const std::string& type, Creator c)
void
PreconditionerFactory<Operator, Comm>::doAddCreator(const std::string& type, Creator c)
{
creators_[type] = c;
}
template <class Operator, class Comm>
void PreconditionerFactory<Operator,Comm>::
doAddCreator(const std::string& type, ParCreator c)
void
PreconditionerFactory<Operator, Comm>::doAddCreator(const std::string& type, ParCreator c)
{
parallel_creators_[type] = c;
}
template <class Operator, class Comm>
typename PreconditionerFactory<Operator, Comm>::PrecPtr
PreconditionerFactory<Operator,Comm>::
create(const Operator& op, const PropertyTree& prm,
PreconditionerFactory<Operator, Comm>::create(const Operator& op,
const PropertyTree& prm,
const std::function<Vector()>& weightsCalculator,
std::size_t pressureIndex)
{
@ -689,9 +709,10 @@ create(const Operator& op, const PropertyTree& prm,
template <class Operator, class Comm>
typename PreconditionerFactory<Operator, Comm>::PrecPtr
PreconditionerFactory<Operator,Comm>::
create(const Operator& op, const PropertyTree& prm,
const std::function<Vector()>& weightsCalculator, const Comm& comm,
PreconditionerFactory<Operator, Comm>::create(const Operator& op,
const PropertyTree& prm,
const std::function<Vector()>& weightsCalculator,
const Comm& comm,
std::size_t pressureIndex)
{
return instance().doCreate(op, prm, weightsCalculator, pressureIndex, comm);
@ -700,23 +721,24 @@ create(const Operator& op, const PropertyTree& prm,
template <class Operator, class Comm>
typename PreconditionerFactory<Operator, Comm>::PrecPtr
PreconditionerFactory<Operator,Comm>::
create(const Operator& op, const PropertyTree& prm, const Comm& comm,
PreconditionerFactory<Operator, Comm>::create(const Operator& op,
const PropertyTree& prm,
const Comm& comm,
std::size_t pressureIndex)
{
return instance().doCreate(op, prm, std::function<Vector()>(), pressureIndex, comm);
}
template <class Operator, class Comm>
void PreconditionerFactory<Operator,Comm>::
addCreator(const std::string& type, Creator creator)
void
PreconditionerFactory<Operator, Comm>::addCreator(const std::string& type, Creator creator)
{
instance().doAddCreator(type, creator);
}
template <class Operator, class Comm>
void PreconditionerFactory<Operator,Comm>::
addCreator(const std::string& type, ParCreator creator)
void
PreconditionerFactory<Operator, Comm>::addCreator(const std::string& type, ParCreator creator)
{
instance().doAddCreator(type, creator);
}
@ -779,7 +801,6 @@ using OpBPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<MatrixBlock<dou
INSTANCE_PF_PAR(Dim) \
INSTANCE_PF_SEQ(Dim)
#else
#define INSTANCE_PF(Dim) \
INSTANCE_PF_SEQ(Dim)
#define INSTANCE_PF(Dim) INSTANCE_PF_SEQ(Dim)
#endif
}
} // namespace Opm