Commit d8d8390c authored by Timo Koch's avatar Timo Koch
Browse files

[solver] Simplify translate using a bit more memory

parent 05ca2c5c
...@@ -67,6 +67,9 @@ class IstlSolverFactoryBackend : public LinearSolver ...@@ -67,6 +67,9 @@ class IstlSolverFactoryBackend : public LinearSolver
using DofMapper = typename AMGTraits::DofMapper; using DofMapper = typename AMGTraits::DofMapper;
public: public:
//! translation table for solver parameters
static std::vector<std::array<std::string,2> > istlToDumuxSolverParams;
/*! /*!
* \brief Construct the backend for the sequential case only * \brief Construct the backend for the sequential case only
* *
...@@ -150,9 +153,7 @@ private: ...@@ -150,9 +153,7 @@ private:
const auto& loggingTree = Parameters::getTree(); const auto& loggingTree = Parameters::getTree();
auto matchingGroups = loggingTree.getSubGroups("LinearSolver", paramGroup); auto matchingGroups = loggingTree.getSubGroups("LinearSolver", paramGroup);
bool doThrow = false; for (const auto& [istlKey, dumuxKey] : istlToDumuxSolverParams)
for (const auto& [istlKey, dumuxKey] : istl2DumuxSolverParams)
{ {
for (const auto fullGroup : matchingGroups) for (const auto fullGroup : matchingGroups)
{ {
...@@ -166,7 +167,7 @@ private: ...@@ -166,7 +167,7 @@ private:
<< " " << dumuxName << std::endl << " " << dumuxName << std::endl
<< "Please use only one (e.g. " << dumuxName << "Please use only one (e.g. " << dumuxName
<< ")." << std::endl; << ")." << std::endl;
doThrow = true; DUNE_THROW(Dune::InvalidStateException, "Ambiguous parameters used for linear solver");
} }
params_[istlKey] = loggingTree.get<std::string>(dumuxName); params_[istlKey] = loggingTree.get<std::string>(dumuxName);
break; break;
...@@ -179,43 +180,11 @@ private: ...@@ -179,43 +180,11 @@ private:
} }
} }
for (const auto& [istlKey, dumuxKey] : istl2DumuxPreconditionerParams) // prevent throw in solve
{
for (const auto fullGroup : matchingGroups)
{
auto istlName = fullGroup + ".preconditioner." + istlKey;
auto dumuxName = fullGroup + "." + dumuxKey;
if(loggingTree.hasKey(dumuxName))
{
if(loggingTree.hasKeyOrDefaultKey(istlName))
{
std::cerr << "Found equivalent keys " << istlName
<< " " << dumuxName << std::endl
<< "Please use only one (e.g. " << dumuxName
<< ")." << std::endl;
doThrow = true;
}
params_["preconditioner." + istlKey] = loggingTree.get<std::string>(dumuxName);
break;
}
else if (loggingTree.hasKeyOrDefaultKey(istlName))
{
params_["preconditioner." + istlKey] = loggingTree.get<std::string>(istlName);
break;
}
}
}
params_.report();
if (!params_.hasKey("type")) if (!params_.hasKey("type"))
// prevent throw in solve
DUNE_THROW(Dune::InvalidStateException, "Solverfactory needs a specified \"type\" key to select the solver"); DUNE_THROW(Dune::InvalidStateException, "Solverfactory needs a specified \"type\" key to select the solver");
if (doThrow)
DUNE_THROW(Dune::InvalidStateException, "Ambiguous parameters used for linear solver");
} }
static std::vector<std::array<std::string,2> > istl2DumuxSolverParams;
static std::vector<std::array<std::string,2> > istl2DumuxPreconditionerParams;
std::shared_ptr<ParallelISTLHelper<GridView, AMGTraits>> phelper_; std::shared_ptr<ParallelISTLHelper<GridView, AMGTraits>> phelper_;
bool firstCall_; bool firstCall_;
Dune::InverseOperatorResult result_; Dune::InverseOperatorResult result_;
...@@ -223,37 +192,45 @@ private: ...@@ -223,37 +192,45 @@ private:
}; };
template<class Matrix, class Vector, class Geometry> template<class Matrix, class Vector, class Geometry>
std::vector<std::array<std::string,2> > IstlSolverFactoryBackend<Matrix, Vector, Geometry>::istl2DumuxSolverParams = std::vector<std::array<std::string, 2>>
{ IstlSolverFactoryBackend<Matrix, Vector, Geometry>::istlToDumuxSolverParams =
{"verbose", "Verbosity"}, {"maxit", "MaxIterations"}, {
{"reduction", "ResidualReduction"}, {"type", "Type"}, // solver params
{"restart", "Restart"}, // cycles before restarting {"verbose", "Verbosity"},
// maximum number of vectors to store for orthogonalization {"maxit", "MaxIterations"},
{"mmax", "MaxOrthogonalizationVectors"} {"reduction", "ResidualReduction"},
}; {"type", "Type"},
{"restart", "Restart"}, // cycles before restarting
template<class Matrix, class Vector, class Geometry> {"mmax", "MaxOrthogonalizationVectors"},
std::vector<std::array<std::string,2> > IstlSolverFactoryBackend<Matrix, Vector, Geometry>::istl2DumuxPreconditionerParams =
{ // preconditioner params
{"verbosity", "PreconditionerVerbosity"}, {"type", "PreconditionerType"}, {"preconditioner.verbosity", "PreconditionerVerbosity"},
{"iterations", "PreconditionerIterations"}, {"relaxation", "PreconditionerRelaxation"}, {"preconditioner.type", "PreconditionerType"},
{"n", "ILUOrder"}, {"resort", "ILUResort"}, {"preconditioner.iterations", "PreconditionerIterations"},
{"smootherRelaxation", "AmgSmootherRelaxation"}, {"preconditioner.relaxation", "PreconditionerRelaxation"},
{"smootherIterations", "AmgSmootherIterations"}, {"preconditioner.n", "ILUOrder"},
{"maxLevel", "AmgMaxLevel"}, {"coarsenTarget", "AmgCoarsenTarget"}, {"preconditioner.resort", "ILUResort"},
{"minCoarseningRate", "MinCoarseningRate"}, {"preconditioner.smootherRelaxation", "AmgSmootherRelaxation"},
{"prolongationDampingFactor", "AmgProlongationDampingFactor"}, {"preconditioner.smootherIterations", "AmgSmootherIterations"},
{"alpha", "AmgAlpha"}, {"beta", "AmgBeta"}, {"preconditioner.maxLevel", "AmgMaxLevel"},
{"additive", "AmgAdditive"}, {"gamma", "AmgGamma"}, {"preconditioner.coarsenTarget", "AmgCoarsenTarget"},
{"preSteps", "AmgPreSmoothingSteps"}, {"postSteps", "AmgPostSmoothingSteps"}, {"preconditioner.minCoarseningRate", "MinCoarseningRate"},
{"criterionSymmetric", "AmgCriterionSymmetric"}, {"strengthMeasure", "AmgStrengthMeasure"}, {"preconditioner.prolongationDampingFactor", "AmgProlongationDampingFactor"},
{"diagonalRowIndex", "AmgDiagonalRowIndex"}, {"preconditioner.alpha", "AmgAlpha"},
{"defaultAggregationSizeMode", "DefaultAggregationSizeMode"}, {"preconditioner.beta", "AmgBeta"},
{"defaultAggregationDimension", "defaultAggregationDimension"}, {"preconditioner.additive", "AmgAdditive"},
{"maxAggregateDistance", "MaxAggregateDistance"}, {"preconditioner.gamma", "AmgGamma"},
{"minAggregateSize", "MinAggregateSize"}, {"preconditioner.preSteps", "AmgPreSmoothingSteps"},
{"maxAggregateSize", "MaxAggregateSize"} {"preconditioner.postSteps", "AmgPostSmoothingSteps"},
}; {"preconditioner.criterionSymmetric", "AmgCriterionSymmetric"},
{"preconditioner.strengthMeasure", "AmgStrengthMeasure"},
{"preconditioner.diagonalRowIndex", "AmgDiagonalRowIndex"},
{"preconditioner.defaultAggregationSizeMode", "DefaultAggregationSizeMode"},
{"preconditioner.defaultAggregationDimension", "defaultAggregationDimension"},
{"preconditioner.maxAggregateDistance", "MaxAggregateDistance"},
{"preconditioner.minAggregateSize", "MinAggregateSize"},
{"preconditioner.maxAggregateSize", "MaxAggregateSize"}
};
} // end namespace Dumux } // end namespace Dumux
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment