Manual cherrypicked improvements from f2ed2b6dc3 and 8aad027

These were a bit hidden, but found. They add a few more customization
options and kamg as a sequential solver. The latter will be broken if
we use update, though.
This commit is contained in:
hnil 2020-03-24 17:08:42 +01:00 committed by Markus Blatt
parent 2e4824cbc7
commit fce9f5e57c
2 changed files with 45 additions and 6 deletions

View File

@ -97,8 +97,8 @@ public:
finesmoother_,
levelTransferPolicy_,
coarseSolverPolicy_,
transpose ? 1 : 0,
transpose ? 0 : 1)
prm.get<int>("pre_smooth"),
prm.get<int>("post_smooth"))
, prm_(prm)
{
if (prm.get<int>("verbosity") > 10) {

View File

@ -29,6 +29,7 @@
#include <opm/simulators/linalg/amgcpr.hh>
#include <dune/istl/paamg/amg.hh>
#include <dune/istl/paamg/kamg.hh>
#include <dune/istl/paamg/fastamg.hh>
#include <dune/istl/preconditioners.hh>
@ -129,7 +130,9 @@ private:
criterion.setAlpha(prm.get<double>("alpha"));
criterion.setBeta(prm.get<double>("beta"));
criterion.setMaxLevel(prm.get<int>("maxlevel"));
criterion.setSkipIsolated(false);
criterion.setSkipIsolated(prm.get<bool>("skip_isolated"));
criterion.setNoPreSmoothSteps(prm.get<int>("pre_smooth"));
criterion.setNoPostSmoothSteps(prm.get<int>("post_smooth"));
criterion.setDebugLevel(prm.get<int>("verbosity"));
return criterion;
}
@ -148,11 +151,21 @@ private:
}
template <class Smoother>
static PrecPtr makeAmgPreconditioner(const Operator& op, const boost::property_tree::ptree& prm)
static PrecPtr makeAmgPreconditioner(const Operator& op, const boost::property_tree::ptree& prm, bool useKamg = false)
{
auto crit = amgCriterion(prm);
auto sargs = amgSmootherArgs<Smoother>(prm);
return std::make_shared<Dune::Amg::AMGCPR<Operator, Vector, Smoother>>(op, crit, sargs);
if(useKamg){
return std::make_shared<
Dune::DummyUpdatePreconditioner<
Dune::Amg::KAMG< Operator, Vector, Smoother>
>
>(op, crit, sargs,
prm.get<size_t>("max_krylov"),
prm.get<double>("min_reduction") );
}else{
return std::make_shared<Dune::Amg::AMGCPR<Operator, Vector, Smoother>>(op, crit, sargs);
}
}
// Add a useful default set of preconditioners to the factory.
@ -207,7 +220,7 @@ private:
});
doAddCreator("amg", [](const O& op, const P& prm, const std::function<Vector()>&, const C& comm) {
const std::string smoother = prm.get<std::string>("smoother");
if (smoother == "ILU0") {
if (smoother == "ILU0" || smoother == "ParOverILU0") {
using Smoother = Opm::ParallelOverlappingILU0<M, V, V, C>;
auto crit = amgCriterion(prm);
auto sargs = amgSmootherArgs<Smoother>(prm);
@ -304,6 +317,32 @@ private:
throw std::runtime_error(msg);
}
});
doAddCreator("kamg", [](const O& op, const P& prm, const std::function<Vector()>&) {
const std::string smoother = prm.get<std::string>("smoother");
if (smoother == "ILU0") {
using Smoother = SeqILU0<M, V, V>;
return makeAmgPreconditioner<Smoother>(op, prm, true);
} else if (smoother == "Jac") {
using Smoother = SeqJac<M, V, V>;
return makeAmgPreconditioner<Smoother>(op, prm, true);
} else if (smoother == "SOR") {
using Smoother = SeqSOR<M, V, V>;
return makeAmgPreconditioner<Smoother>(op, prm, true);
// } else if (smoother == "GS") {
// using Smoother = SeqGS<M, V, V>;
// return makeAmgPreconditioner<Smoother>(op, prm, true);
} else if (smoother == "SSOR") {
using Smoother = SeqSSOR<M, V, V>;
return makeAmgPreconditioner<Smoother>(op, prm, true);
} else if (smoother == "ILUn") {
using Smoother = SeqILUn<M, V, V>;
return makeAmgPreconditioner<Smoother>(op, prm, true);
} else {
std::string msg("No such smoother: ");
msg += smoother;
throw std::runtime_error(msg);
}
});
doAddCreator("famg", [](const O& op, const P& prm, const std::function<Vector()>&) {
auto crit = amgCriterion(prm);
Dune::Amg::Parameters parms;