mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
clang-format PreconditionerFactory_impl
This commit is contained in:
parent
3d9b3a3013
commit
8177400602
@ -23,10 +23,9 @@
|
|||||||
#include <opm/simulators/linalg/PreconditionerFactory.hpp>
|
#include <opm/simulators/linalg/PreconditionerFactory.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include <opm/simulators/linalg/matrixblock.hh>
|
#include <opm/simulators/linalg/DILU.hpp>
|
||||||
#include <opm/simulators/linalg/amgcpr.hh>
|
#include <opm/simulators/linalg/ExtraSmoothers.hpp>
|
||||||
#include <opm/simulators/linalg/FlexibleSolver.hpp>
|
#include <opm/simulators/linalg/FlexibleSolver.hpp>
|
||||||
#include <opm/simulators/linalg/ilufirstelement.hh>
|
|
||||||
#include <opm/simulators/linalg/OwningBlockPreconditioner.hpp>
|
#include <opm/simulators/linalg/OwningBlockPreconditioner.hpp>
|
||||||
#include <opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp>
|
#include <opm/simulators/linalg/OwningTwoLevelPreconditioner.hpp>
|
||||||
#include <opm/simulators/linalg/ParallelOverlappingILU0.hpp>
|
#include <opm/simulators/linalg/ParallelOverlappingILU0.hpp>
|
||||||
@ -34,33 +33,34 @@
|
|||||||
#include <opm/simulators/linalg/PressureTransferPolicy.hpp>
|
#include <opm/simulators/linalg/PressureTransferPolicy.hpp>
|
||||||
#include <opm/simulators/linalg/PropertyTree.hpp>
|
#include <opm/simulators/linalg/PropertyTree.hpp>
|
||||||
#include <opm/simulators/linalg/WellOperators.hpp>
|
#include <opm/simulators/linalg/WellOperators.hpp>
|
||||||
#include <opm/simulators/linalg/DILU.hpp>
|
#include <opm/simulators/linalg/amgcpr.hh>
|
||||||
#include <opm/simulators/linalg/ExtraSmoothers.hpp>
|
#include <opm/simulators/linalg/ilufirstelement.hh>
|
||||||
|
#include <opm/simulators/linalg/matrixblock.hh>
|
||||||
|
|
||||||
#include <dune/common/unused.hh>
|
#include <dune/common/unused.hh>
|
||||||
#include <dune/istl/owneroverlapcopy.hh>
|
#include <dune/istl/owneroverlapcopy.hh>
|
||||||
#include <dune/istl/preconditioners.hh>
|
|
||||||
#include <dune/istl/paamg/amg.hh>
|
#include <dune/istl/paamg/amg.hh>
|
||||||
#include <dune/istl/paamg/kamg.hh>
|
|
||||||
#include <dune/istl/paamg/fastamg.hh>
|
#include <dune/istl/paamg/fastamg.hh>
|
||||||
|
#include <dune/istl/paamg/kamg.hh>
|
||||||
|
#include <dune/istl/preconditioners.hh>
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#if HAVE_CUDA
|
#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/CuBlockPreconditioner.hpp>
|
||||||
#include <opm/simulators/linalg/cuistl/CuDILU.hpp>
|
#include <opm/simulators/linalg/cuistl/CuDILU.hpp>
|
||||||
#include <opm/simulators/linalg/cuistl/CuJac.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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm
|
||||||
|
|
||||||
template<class Smoother>
|
|
||||||
struct AMGSmootherArgsHelper
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template <class Smoother>
|
||||||
|
struct AMGSmootherArgsHelper {
|
||||||
static auto args(const PropertyTree& prm)
|
static auto args(const PropertyTree& prm)
|
||||||
{
|
{
|
||||||
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
||||||
@ -74,9 +74,8 @@ struct AMGSmootherArgsHelper
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class M, class V, class C>
|
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)
|
static auto args(const PropertyTree& prm)
|
||||||
{
|
{
|
||||||
using Smoother = Opm::ParallelOverlappingILU0<M, V, V, C>;
|
using Smoother = Opm::ParallelOverlappingILU0<M, V, V, C>;
|
||||||
@ -110,7 +109,7 @@ void setUseFixedOrder(C, ...)
|
|||||||
|
|
||||||
template <class Operator, class Comm, class Matrix, class Vector>
|
template <class Operator, class Comm, class Matrix, class Vector>
|
||||||
typename AMGHelper<Operator, Comm, Matrix, Vector>::Criterion
|
typename AMGHelper<Operator, Comm, Matrix, Vector>::Criterion
|
||||||
AMGHelper<Operator,Comm,Matrix,Vector>::criterion(const PropertyTree& prm)
|
AMGHelper<Operator, Comm, Matrix, Vector>::criterion(const PropertyTree& prm)
|
||||||
{
|
{
|
||||||
Criterion criterion(15, prm.get<int>("coarsenTarget", 1200));
|
Criterion criterion(15, prm.get<int>("coarsenTarget", 1200));
|
||||||
criterion.setDefaultValuesIsotropic(2);
|
criterion.setDefaultValuesIsotropic(2);
|
||||||
@ -137,8 +136,7 @@ AMGHelper<Operator,Comm,Matrix,Vector>::criterion(const PropertyTree& prm)
|
|||||||
template <class Operator, class Comm, class Matrix, class Vector>
|
template <class Operator, class Comm, class Matrix, class Vector>
|
||||||
template <class Smoother>
|
template <class Smoother>
|
||||||
typename AMGHelper<Operator, Comm, Matrix, Vector>::PrecPtr
|
typename AMGHelper<Operator, Comm, Matrix, Vector>::PrecPtr
|
||||||
AMGHelper<Operator,Comm,Matrix,Vector>::
|
AMGHelper<Operator, Comm, Matrix, Vector>::makeAmgPreconditioner(const Operator& op,
|
||||||
makeAmgPreconditioner(const Operator& op,
|
|
||||||
const PropertyTree& prm,
|
const PropertyTree& prm,
|
||||||
bool useKamg)
|
bool useKamg)
|
||||||
{
|
{
|
||||||
@ -146,31 +144,30 @@ makeAmgPreconditioner(const Operator& op,
|
|||||||
auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
|
auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
|
||||||
if (useKamg) {
|
if (useKamg) {
|
||||||
using Type = Dune::DummyUpdatePreconditioner<Dune::Amg::KAMG<Operator, Vector, Smoother>>;
|
using Type = Dune::DummyUpdatePreconditioner<Dune::Amg::KAMG<Operator, Vector, Smoother>>;
|
||||||
return std::make_shared<Type>(op, crit, sargs,
|
return std::make_shared<Type>(
|
||||||
prm.get<std::size_t>("max_krylov", 1),
|
op, crit, sargs, prm.get<std::size_t>("max_krylov", 1), prm.get<double>("min_reduction", 1e-1));
|
||||||
prm.get<double>("min_reduction", 1e-1));
|
|
||||||
} else {
|
} else {
|
||||||
using Type = Dune::Amg::AMGCPR<Operator, Vector, Smoother>;
|
using Type = Dune::Amg::AMGCPR<Operator, Vector, Smoother>;
|
||||||
return std::make_shared<Type>(op, crit, sargs);
|
return std::make_shared<Type>(op, crit, sargs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
struct StandardPreconditioners
|
struct StandardPreconditioners {
|
||||||
{
|
|
||||||
static void add()
|
static void add()
|
||||||
{
|
{
|
||||||
using namespace Dune;
|
using namespace Dune;
|
||||||
using O = Operator;
|
using O = Operator;
|
||||||
using C = Comm;
|
using C = Comm;
|
||||||
using F = PreconditionerFactory<O,C>;
|
using F = PreconditionerFactory<O, C>;
|
||||||
using M = typename F::Matrix;
|
using M = typename F::Matrix;
|
||||||
using V = typename F::Vector;
|
using V = typename F::Vector;
|
||||||
using P = PropertyTree;
|
using P = PropertyTree;
|
||||||
F::addCreator("ILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
|
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);
|
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));
|
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) {
|
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 int n = prm.get<int>("ilulevel", 0);
|
||||||
const double w = prm.get<double>("relaxation", 1.0);
|
const double w = prm.get<double>("relaxation", 1.0);
|
||||||
const bool resort = prm.get<bool>("resort", false);
|
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) {
|
F::addCreator("DILU", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
|
||||||
DUNE_UNUSED_PARAMETER(prm);
|
DUNE_UNUSED_PARAMETER(prm);
|
||||||
return wrapBlockPreconditioner<MultithreadDILU<M, V, V>>(comm, op.getmat());
|
return wrapBlockPreconditioner<MultithreadDILU<M, V, V>>(comm, op.getmat());
|
||||||
});
|
});
|
||||||
F::addCreator("Jac", [](const O& op, const P& prm, const std::function<V()>&,
|
F::addCreator("Jac", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
|
||||||
std::size_t, const C& comm) {
|
|
||||||
const int n = prm.get<int>("repeats", 1);
|
const int n = prm.get<int>("repeats", 1);
|
||||||
const double w = prm.get<double>("relaxation", 1.0);
|
const double w = prm.get<double>("relaxation", 1.0);
|
||||||
return wrapBlockPreconditioner<DummyUpdatePreconditioner<SeqJac<M, V, V>>>(comm, op.getmat(), n, w);
|
return wrapBlockPreconditioner<DummyUpdatePreconditioner<SeqJac<M, V, V>>>(comm, op.getmat(), n, w);
|
||||||
@ -219,98 +216,110 @@ struct StandardPreconditioners
|
|||||||
// TODO: merge this with ILUn, and possibly simplify the factory to only work with ILU?
|
// TODO: merge this with ILUn, and possibly simplify the factory to only work with ILU?
|
||||||
if (smoother == "ILU0" || smoother == "ParOverILU0") {
|
if (smoother == "ILU0" || smoother == "ParOverILU0") {
|
||||||
using Smoother = Opm::ParallelOverlappingILU0<M, V, V, C>;
|
using Smoother = Opm::ParallelOverlappingILU0<M, V, V, C>;
|
||||||
auto crit = AMGHelper<O,C,M,V>::criterion(prm);
|
auto crit = AMGHelper<O, C, M, V>::criterion(prm);
|
||||||
auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
|
auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
|
||||||
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||||
return prec;
|
return prec;
|
||||||
}
|
} else if (smoother == "DILU") {
|
||||||
else if (smoother == "DILU") {
|
|
||||||
using SeqSmoother = Dune::MultithreadDILU<M, V, V>;
|
using SeqSmoother = Dune::MultithreadDILU<M, V, V>;
|
||||||
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
||||||
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
||||||
SmootherArgs sargs;
|
SmootherArgs sargs;
|
||||||
auto crit = AMGHelper<O,C,M,V>::criterion(prm);
|
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);
|
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||||
return prec;
|
return prec;
|
||||||
}
|
} else if (smoother == "Jac") {
|
||||||
else if (smoother == "Jac") {
|
|
||||||
using SeqSmoother = SeqJac<M, V, V>;
|
using SeqSmoother = SeqJac<M, V, V>;
|
||||||
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
||||||
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
||||||
SmootherArgs sargs;
|
SmootherArgs sargs;
|
||||||
auto crit = AMGHelper<O,C,M,V>::criterion(prm);
|
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);
|
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||||
return prec;
|
return prec;
|
||||||
}
|
} else if (smoother == "GS") {
|
||||||
else if (smoother == "GS") {
|
|
||||||
using SeqSmoother = SeqGS<M, V, V>;
|
using SeqSmoother = SeqGS<M, V, V>;
|
||||||
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
||||||
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
||||||
SmootherArgs sargs;
|
SmootherArgs sargs;
|
||||||
auto crit = AMGHelper<O,C,M,V>::criterion(prm);
|
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);
|
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||||
return prec;
|
return prec;
|
||||||
}
|
} else if (smoother == "SOR") {
|
||||||
else if (smoother == "SOR") {
|
|
||||||
using SeqSmoother = SeqSOR<M, V, V>;
|
using SeqSmoother = SeqSOR<M, V, V>;
|
||||||
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
||||||
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
||||||
SmootherArgs sargs;
|
SmootherArgs sargs;
|
||||||
auto crit = AMGHelper<O,C,M,V>::criterion(prm);
|
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);
|
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||||
return prec;
|
return prec;
|
||||||
}
|
} else if (smoother == "SSOR") {
|
||||||
else if (smoother == "SSOR") {
|
|
||||||
using SeqSmoother = SeqSSOR<M, V, V>;
|
using SeqSmoother = SeqSSOR<M, V, V>;
|
||||||
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
||||||
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
||||||
SmootherArgs sargs;
|
SmootherArgs sargs;
|
||||||
auto crit = AMGHelper<O,C,M,V>::criterion(prm);
|
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);
|
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||||
return prec;
|
return prec;
|
||||||
}
|
} else if (smoother == "ILUn") {
|
||||||
else if (smoother == "ILUn") {
|
|
||||||
using SeqSmoother = SeqILU<M, V, V>;
|
using SeqSmoother = SeqILU<M, V, V>;
|
||||||
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
using Smoother = Dune::BlockPreconditioner<V, V, C, SeqSmoother>;
|
||||||
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
|
||||||
SmootherArgs sargs;
|
SmootherArgs sargs;
|
||||||
auto crit = AMGHelper<O,C,M,V>::criterion(prm);
|
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);
|
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
|
||||||
return prec;
|
return prec;
|
||||||
}else {
|
} 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("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);
|
assert(weightsCalculator);
|
||||||
if (pressureIndex == std::numeric_limits<std::size_t>::max())
|
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
|
||||||
{
|
OPM_THROW(std::logic_error,
|
||||||
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
|
"Pressure index out of bounds. It needs to specified for CPR");
|
||||||
}
|
}
|
||||||
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Comm, false>;
|
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);
|
assert(weightsCalculator);
|
||||||
if (pressureIndex == std::numeric_limits<std::size_t>::max())
|
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
|
||||||
{
|
OPM_THROW(std::logic_error,
|
||||||
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
|
"Pressure index out of bounds. It needs to specified for CPR");
|
||||||
}
|
}
|
||||||
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Comm, true>;
|
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>>) {
|
if constexpr (std::is_same_v<O, WellModelGhostLastMatrixAdapter<M, V, V, true>>) {
|
||||||
F::addCreator("cprw",
|
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);
|
assert(weightsCalculator);
|
||||||
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
|
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>;
|
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) {
|
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);
|
const double w = prm.get<double>("relaxation", 1.0);
|
||||||
using field_type = typename V::field_type;
|
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 cuILU0 = std::make_shared<CuILU0>(op.getmat(), w);
|
||||||
|
|
||||||
auto adapted = std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuILU0>>(cuILU0);
|
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) {
|
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);
|
const double w = prm.get<double>("relaxation", 1.0);
|
||||||
using field_type = typename V::field_type;
|
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 cuJac = std::make_shared<CuJac>(op.getmat(), w);
|
||||||
|
|
||||||
auto adapted = std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuJac>>(cuJac);
|
auto adapted = std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuJac>>(cuJac);
|
||||||
@ -350,10 +361,10 @@ struct StandardPreconditioners
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static typename PreconditionerFactory<Operator,Comm>::PrecPtr
|
static typename PreconditionerFactory<Operator, Comm>::PrecPtr
|
||||||
createParILU(const Operator& op, const PropertyTree& prm, const Comm& comm, const int ilulevel)
|
createParILU(const Operator& op, const PropertyTree& prm, const Comm& comm, const int ilulevel)
|
||||||
{
|
{
|
||||||
using F = PreconditionerFactory<Operator,Comm>;
|
using F = PreconditionerFactory<Operator, Comm>;
|
||||||
using M = typename F::Matrix;
|
using M = typename F::Matrix;
|
||||||
using V = typename F::Vector;
|
using V = typename F::Vector;
|
||||||
|
|
||||||
@ -392,18 +403,16 @@ struct StandardPreconditioners
|
|||||||
return is.size();
|
return is.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Operator>
|
template <class Operator>
|
||||||
struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
|
struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
|
||||||
{
|
|
||||||
static void add()
|
static void add()
|
||||||
{
|
{
|
||||||
using namespace Dune;
|
using namespace Dune;
|
||||||
using O = Operator;
|
using O = Operator;
|
||||||
using C = Dune::Amg::SequentialInformation;
|
using C = Dune::Amg::SequentialInformation;
|
||||||
using F = PreconditionerFactory<O,C>;
|
using F = PreconditionerFactory<O, C>;
|
||||||
using M = typename F::Matrix;
|
using M = typename F::Matrix;
|
||||||
using V = typename F::Vector;
|
using V = typename F::Vector;
|
||||||
using P = PropertyTree;
|
using P = PropertyTree;
|
||||||
@ -462,57 +471,55 @@ struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
|
|||||||
const std::string smoother = prm.get<std::string>("smoother", "ParOverILU0");
|
const std::string smoother = prm.get<std::string>("smoother", "ParOverILU0");
|
||||||
if (smoother == "ILU0" || smoother == "ParOverILU0") {
|
if (smoother == "ILU0" || smoother == "ParOverILU0") {
|
||||||
using Smoother = SeqILU<M, V, V>;
|
using Smoother = SeqILU<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
||||||
} else if (smoother == "Jac") {
|
} else if (smoother == "Jac") {
|
||||||
using Smoother = SeqJac<M, V, V>;
|
using Smoother = SeqJac<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
||||||
} else if (smoother == "GS") {
|
} else if (smoother == "GS") {
|
||||||
using Smoother = SeqGS<M, V, V>;
|
using Smoother = SeqGS<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
||||||
} else if (smoother == "DILU") {
|
} else if (smoother == "DILU") {
|
||||||
using Smoother = MultithreadDILU<M, V, V>;
|
using Smoother = MultithreadDILU<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
||||||
} else if (smoother == "SOR") {
|
} else if (smoother == "SOR") {
|
||||||
using Smoother = SeqSOR<M, V, V>;
|
using Smoother = SeqSOR<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
||||||
} else if (smoother == "SSOR") {
|
} else if (smoother == "SSOR") {
|
||||||
using Smoother = SeqSSOR<M, V, V>;
|
using Smoother = SeqSSOR<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
||||||
} else if (smoother == "ILUn") {
|
} else if (smoother == "ILUn") {
|
||||||
using Smoother = SeqILU<M, V, V>;
|
using Smoother = SeqILU<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm);
|
||||||
} else {
|
} else {
|
||||||
OPM_THROW(std::invalid_argument,
|
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
|
||||||
"Properties: No smoother with name " + smoother + ".");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
F::addCreator("kamg", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
F::addCreator("kamg", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
||||||
const std::string smoother = prm.get<std::string>("smoother", "ParOverILU0");
|
const std::string smoother = prm.get<std::string>("smoother", "ParOverILU0");
|
||||||
if (smoother == "ILU0" || smoother == "ParOverILU0") {
|
if (smoother == "ILU0" || smoother == "ParOverILU0") {
|
||||||
using Smoother = SeqILU<M, V, V>;
|
using Smoother = SeqILU<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
||||||
} else if (smoother == "Jac") {
|
} else if (smoother == "Jac") {
|
||||||
using Smoother = SeqJac<M, V, V>;
|
using Smoother = SeqJac<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
||||||
} else if (smoother == "SOR") {
|
} else if (smoother == "SOR") {
|
||||||
using Smoother = SeqSOR<M, V, V>;
|
using Smoother = SeqSOR<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
||||||
} else if (smoother == "GS") {
|
} else if (smoother == "GS") {
|
||||||
using Smoother = SeqGS<M, V, V>;
|
using Smoother = SeqGS<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
||||||
} else if (smoother == "SSOR") {
|
} else if (smoother == "SSOR") {
|
||||||
using Smoother = SeqSSOR<M, V, V>;
|
using Smoother = SeqSSOR<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
||||||
} else if (smoother == "ILUn") {
|
} else if (smoother == "ILUn") {
|
||||||
using Smoother = SeqILU<M, V, V>;
|
using Smoother = SeqILU<M, V, V>;
|
||||||
return AMGHelper<O,C,M,V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
return AMGHelper<O, C, M, V>::template makeAmgPreconditioner<Smoother>(op, prm, true);
|
||||||
} else {
|
} else {
|
||||||
OPM_THROW(std::invalid_argument,
|
OPM_THROW(std::invalid_argument, "Properties: No smoother with name " + smoother + ".");
|
||||||
"Properties: No smoother with name " + smoother + ".");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
F::addCreator("famg", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
F::addCreator("famg", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
||||||
auto crit = AMGHelper<O,C,M,V>::criterion(prm);
|
auto crit = AMGHelper<O, C, M, V>::criterion(prm);
|
||||||
Dune::Amg::Parameters parms;
|
Dune::Amg::Parameters parms;
|
||||||
parms.setNoPreSmoothSteps(1);
|
parms.setNoPreSmoothSteps(1);
|
||||||
parms.setNoPostSmoothSteps(1);
|
parms.setNoPostSmoothSteps(1);
|
||||||
@ -520,60 +527,73 @@ struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if constexpr (std::is_same_v<O, WellModelMatrixAdapter<M, V, V, false>>) {
|
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()) {
|
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, Dune::Amg::SequentialInformation, false>;
|
using LevelTransferPolicy
|
||||||
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(op, prm, weightsCalculator, pressureIndex);
|
= 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) {
|
F::addCreator(
|
||||||
if (pressureIndex == std::numeric_limits<std::size_t>::max())
|
"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");
|
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>;
|
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) {
|
F::addCreator(
|
||||||
if (pressureIndex == std::numeric_limits<std::size_t>::max())
|
"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");
|
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>;
|
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
|
#if HAVE_CUDA
|
||||||
F::addCreator("CUILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
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);
|
const double w = prm.get<double>("relaxation", 1.0);
|
||||||
using field_type = typename V::field_type;
|
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::
|
||||||
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuILU0>>(std::make_shared<CuILU0>(op.getmat(), w));
|
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) {
|
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);
|
const double w = prm.get<double>("relaxation", 1.0);
|
||||||
using block_type = typename V::block_type;
|
using block_type = typename V::block_type;
|
||||||
using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
|
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 matrix_type_to =
|
||||||
using CuILU0 = typename Opm::cuistl::CuSeqILU0<matrix_type_to, Opm::cuistl::CuVector<float>, Opm::cuistl::CuVector<float>>;
|
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 Adapter = typename Opm::cuistl::PreconditionerAdapter<VTo, VTo, CuILU0>;
|
||||||
using Converter = typename Opm::cuistl::PreconditionerConvertFieldTypeAdapter<Adapter, M, V, V>;
|
using Converter = typename Opm::cuistl::PreconditionerConvertFieldTypeAdapter<Adapter, M, V, V>;
|
||||||
auto converted = std::make_shared<Converter>(op.getmat());
|
auto converted = std::make_shared<Converter>(op.getmat());
|
||||||
auto adapted = std::make_shared<Adapter>(std::make_shared<CuILU0>(converted->getConvertedMatrix(), w));
|
auto adapted = std::make_shared<Adapter>(std::make_shared<CuILU0>(converted->getConvertedMatrix(), w));
|
||||||
converted->setUnderlyingPreconditioner(adapted);
|
converted->setUnderlyingPreconditioner(adapted);
|
||||||
return converted;
|
return converted;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
F::addCreator("CUJac", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
|
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);
|
const double w = prm.get<double>("relaxation", 1.0);
|
||||||
using field_type = typename V::field_type;
|
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 =
|
||||||
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CUJac>>(std::make_shared<CUJac>(op.getmat(), w));
|
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) {
|
F::addCreator("CUDILU", [](const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
|
||||||
@ -599,28 +619,28 @@ struct StandardPreconditioners<Operator,Dune::Amg::SequentialInformation>
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
PreconditionerFactory<Operator,Comm>::PreconditionerFactory()
|
PreconditionerFactory<Operator, Comm>::PreconditionerFactory()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
PreconditionerFactory<Operator,Comm>&
|
PreconditionerFactory<Operator, Comm>&
|
||||||
PreconditionerFactory<Operator,Comm>::instance()
|
PreconditionerFactory<Operator, Comm>::instance()
|
||||||
{
|
{
|
||||||
static PreconditionerFactory singleton;
|
static PreconditionerFactory singleton;
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
typename PreconditionerFactory<Operator,Comm>::PrecPtr
|
typename PreconditionerFactory<Operator, Comm>::PrecPtr
|
||||||
PreconditionerFactory<Operator,Comm>::
|
PreconditionerFactory<Operator, Comm>::doCreate(const Operator& op,
|
||||||
doCreate(const Operator& op, const PropertyTree& prm,
|
const PropertyTree& prm,
|
||||||
const std::function<Vector()> weightsCalculator,
|
const std::function<Vector()> weightsCalculator,
|
||||||
std::size_t pressureIndex)
|
std::size_t pressureIndex)
|
||||||
{
|
{
|
||||||
if (!defAdded_) {
|
if (!defAdded_) {
|
||||||
StandardPreconditioners<Operator,Comm>::add();
|
StandardPreconditioners<Operator, Comm>::add();
|
||||||
defAdded_ = true;
|
defAdded_ = true;
|
||||||
}
|
}
|
||||||
const std::string& type = prm.get<std::string>("type", "ParOverILU0");
|
const std::string& type = prm.get<std::string>("type", "ParOverILU0");
|
||||||
@ -638,22 +658,22 @@ doCreate(const Operator& op, const PropertyTree& prm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
typename PreconditionerFactory<Operator,Comm>::PrecPtr
|
typename PreconditionerFactory<Operator, Comm>::PrecPtr
|
||||||
PreconditionerFactory<Operator,Comm>::
|
PreconditionerFactory<Operator, Comm>::doCreate(const Operator& op,
|
||||||
doCreate(const Operator& op, const PropertyTree& prm,
|
const PropertyTree& prm,
|
||||||
const std::function<Vector()> weightsCalculator,
|
const std::function<Vector()> weightsCalculator,
|
||||||
std::size_t pressureIndex, const Comm& comm)
|
std::size_t pressureIndex,
|
||||||
|
const Comm& comm)
|
||||||
{
|
{
|
||||||
if (!defAdded_) {
|
if (!defAdded_) {
|
||||||
StandardPreconditioners<Operator,Comm>::add();
|
StandardPreconditioners<Operator, Comm>::add();
|
||||||
defAdded_ = true;
|
defAdded_ = true;
|
||||||
}
|
}
|
||||||
const std::string& type = prm.get<std::string>("type", "ParOverILU0");
|
const std::string& type = prm.get<std::string>("type", "ParOverILU0");
|
||||||
auto it = parallel_creators_.find(type);
|
auto it = parallel_creators_.find(type);
|
||||||
if (it == parallel_creators_.end()) {
|
if (it == parallel_creators_.end()) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "Parallel preconditioner type " << type
|
msg << "Parallel preconditioner type " << type << " is not registered in the factory. Available types are: ";
|
||||||
<< " is not registered in the factory. Available types are: ";
|
|
||||||
for (const auto& prec : parallel_creators_) {
|
for (const auto& prec : parallel_creators_) {
|
||||||
msg << prec.first << ' ';
|
msg << prec.first << ' ';
|
||||||
}
|
}
|
||||||
@ -664,23 +684,23 @@ doCreate(const Operator& op, const PropertyTree& prm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
void PreconditionerFactory<Operator,Comm>::
|
void
|
||||||
doAddCreator(const std::string& type, Creator c)
|
PreconditionerFactory<Operator, Comm>::doAddCreator(const std::string& type, Creator c)
|
||||||
{
|
{
|
||||||
creators_[type] = c;
|
creators_[type] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
void PreconditionerFactory<Operator,Comm>::
|
void
|
||||||
doAddCreator(const std::string& type, ParCreator c)
|
PreconditionerFactory<Operator, Comm>::doAddCreator(const std::string& type, ParCreator c)
|
||||||
{
|
{
|
||||||
parallel_creators_[type] = c;
|
parallel_creators_[type] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
typename PreconditionerFactory<Operator,Comm>::PrecPtr
|
typename PreconditionerFactory<Operator, Comm>::PrecPtr
|
||||||
PreconditionerFactory<Operator,Comm>::
|
PreconditionerFactory<Operator, Comm>::create(const Operator& op,
|
||||||
create(const Operator& op, const PropertyTree& prm,
|
const PropertyTree& prm,
|
||||||
const std::function<Vector()>& weightsCalculator,
|
const std::function<Vector()>& weightsCalculator,
|
||||||
std::size_t pressureIndex)
|
std::size_t pressureIndex)
|
||||||
{
|
{
|
||||||
@ -688,10 +708,11 @@ create(const Operator& op, const PropertyTree& prm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
typename PreconditionerFactory<Operator,Comm>::PrecPtr
|
typename PreconditionerFactory<Operator, Comm>::PrecPtr
|
||||||
PreconditionerFactory<Operator,Comm>::
|
PreconditionerFactory<Operator, Comm>::create(const Operator& op,
|
||||||
create(const Operator& op, const PropertyTree& prm,
|
const PropertyTree& prm,
|
||||||
const std::function<Vector()>& weightsCalculator, const Comm& comm,
|
const std::function<Vector()>& weightsCalculator,
|
||||||
|
const Comm& comm,
|
||||||
std::size_t pressureIndex)
|
std::size_t pressureIndex)
|
||||||
{
|
{
|
||||||
return instance().doCreate(op, prm, weightsCalculator, pressureIndex, comm);
|
return instance().doCreate(op, prm, weightsCalculator, pressureIndex, comm);
|
||||||
@ -699,87 +720,87 @@ create(const Operator& op, const PropertyTree& prm,
|
|||||||
|
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
typename PreconditionerFactory<Operator,Comm>::PrecPtr
|
typename PreconditionerFactory<Operator, Comm>::PrecPtr
|
||||||
PreconditionerFactory<Operator,Comm>::
|
PreconditionerFactory<Operator, Comm>::create(const Operator& op,
|
||||||
create(const Operator& op, const PropertyTree& prm, const Comm& comm,
|
const PropertyTree& prm,
|
||||||
|
const Comm& comm,
|
||||||
std::size_t pressureIndex)
|
std::size_t pressureIndex)
|
||||||
{
|
{
|
||||||
return instance().doCreate(op, prm, std::function<Vector()>(), pressureIndex, comm);
|
return instance().doCreate(op, prm, std::function<Vector()>(), pressureIndex, comm);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
void PreconditionerFactory<Operator,Comm>::
|
void
|
||||||
addCreator(const std::string& type, Creator creator)
|
PreconditionerFactory<Operator, Comm>::addCreator(const std::string& type, Creator creator)
|
||||||
{
|
{
|
||||||
instance().doAddCreator(type, creator);
|
instance().doAddCreator(type, creator);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Operator, class Comm>
|
template <class Operator, class Comm>
|
||||||
void PreconditionerFactory<Operator,Comm>::
|
void
|
||||||
addCreator(const std::string& type, ParCreator creator)
|
PreconditionerFactory<Operator, Comm>::addCreator(const std::string& type, ParCreator creator)
|
||||||
{
|
{
|
||||||
instance().doAddCreator(type, creator);
|
instance().doAddCreator(type, creator);
|
||||||
}
|
}
|
||||||
|
|
||||||
using CommSeq = Dune::Amg::SequentialInformation;
|
using CommSeq = Dune::Amg::SequentialInformation;
|
||||||
|
|
||||||
template<int Dim>
|
template <int Dim>
|
||||||
using OpFSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Dune::FieldMatrix<double,Dim,Dim>>,
|
using OpFSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Dune::FieldMatrix<double, Dim, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>>;
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>>;
|
||||||
template<int Dim>
|
template <int Dim>
|
||||||
using OpBSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Opm::MatrixBlock<double,Dim,Dim>>,
|
using OpBSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Opm::MatrixBlock<double, Dim, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>>;
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>>;
|
||||||
|
|
||||||
template<int Dim, bool overlap>
|
template <int Dim, bool overlap>
|
||||||
using OpW = WellModelMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double,Dim,Dim>>,
|
using OpW = WellModelMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double, Dim, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
overlap>;
|
overlap>;
|
||||||
|
|
||||||
template<int Dim, bool overlap>
|
template <int Dim, bool overlap>
|
||||||
using OpWG = WellModelGhostLastMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double,Dim,Dim>>,
|
using OpWG = WellModelGhostLastMatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double, Dim, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
overlap>;
|
overlap>;
|
||||||
|
|
||||||
#if HAVE_MPI
|
#if HAVE_MPI
|
||||||
using CommPar = Dune::OwnerOverlapCopyCommunication<int,int>;
|
using CommPar = Dune::OwnerOverlapCopyCommunication<int, int>;
|
||||||
|
|
||||||
template<int Dim>
|
template <int Dim>
|
||||||
using OpFPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<Dune::FieldMatrix<double,Dim,Dim>>,
|
using OpFPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<Dune::FieldMatrix<double, Dim, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
CommPar>;
|
CommPar>;
|
||||||
|
|
||||||
template<int Dim>
|
template <int Dim>
|
||||||
using OpBPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<MatrixBlock<double,Dim,Dim>>,
|
using OpBPar = Dune::OverlappingSchwarzOperator<Dune::BCRSMatrix<MatrixBlock<double, Dim, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
Dune::BlockVector<Dune::FieldVector<double,Dim>>,
|
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
|
||||||
CommPar>;
|
CommPar>;
|
||||||
|
|
||||||
#define INSTANCE_PF_PAR(Dim) \
|
#define INSTANCE_PF_PAR(Dim) \
|
||||||
template class PreconditionerFactory<OpBSeq<Dim>,CommPar>; \
|
template class PreconditionerFactory<OpBSeq<Dim>, CommPar>; \
|
||||||
template class PreconditionerFactory<OpFPar<Dim>,CommPar>; \
|
template class PreconditionerFactory<OpFPar<Dim>, CommPar>; \
|
||||||
template class PreconditionerFactory<OpBPar<Dim>,CommPar>; \
|
template class PreconditionerFactory<OpBPar<Dim>, CommPar>; \
|
||||||
template class PreconditionerFactory<OpW<Dim,false>,CommPar>; \
|
template class PreconditionerFactory<OpW<Dim, false>, CommPar>; \
|
||||||
template class PreconditionerFactory<OpWG<Dim,true>,CommPar>; \
|
template class PreconditionerFactory<OpWG<Dim, true>, CommPar>; \
|
||||||
template class PreconditionerFactory<OpBPar<Dim>,CommSeq>;
|
template class PreconditionerFactory<OpBPar<Dim>, CommSeq>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INSTANCE_PF_SEQ(Dim) \
|
#define INSTANCE_PF_SEQ(Dim) \
|
||||||
template class PreconditionerFactory<OpFSeq<Dim>,CommSeq>; \
|
template class PreconditionerFactory<OpFSeq<Dim>, CommSeq>; \
|
||||||
template class PreconditionerFactory<OpBSeq<Dim>,CommSeq>; \
|
template class PreconditionerFactory<OpBSeq<Dim>, CommSeq>; \
|
||||||
template class PreconditionerFactory<OpW<Dim,false>,CommSeq>; \
|
template class PreconditionerFactory<OpW<Dim, false>, CommSeq>; \
|
||||||
template class PreconditionerFactory<OpWG<Dim,true>,CommSeq>;
|
template class PreconditionerFactory<OpWG<Dim, true>, CommSeq>;
|
||||||
|
|
||||||
#if HAVE_MPI
|
#if HAVE_MPI
|
||||||
#define INSTANCE_PF(Dim) \
|
#define INSTANCE_PF(Dim) \
|
||||||
INSTANCE_PF_PAR(Dim) \
|
INSTANCE_PF_PAR(Dim) \
|
||||||
INSTANCE_PF_SEQ(Dim)
|
INSTANCE_PF_SEQ(Dim)
|
||||||
#else
|
#else
|
||||||
#define INSTANCE_PF(Dim) \
|
#define INSTANCE_PF(Dim) INSTANCE_PF_SEQ(Dim)
|
||||||
INSTANCE_PF_SEQ(Dim)
|
|
||||||
#endif
|
#endif
|
||||||
}
|
} // namespace Opm
|
||||||
|
Loading…
Reference in New Issue
Block a user