Commit 5559ff44 authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Merge branch 'cherry-pick-8bc74fb0' into 'OPAL-2021.1'

Resolve "Missing attributes values for AMR solver" in OPAL-2021.1

See merge request !576
parents e309f627 b0727c83
......@@ -21,7 +21,7 @@
#ifndef MUELU_BOTTOM_SOLVER_H
#define MUELU_BOTTOM_SOLVER_H
#include "BottomSolver.h"
#include "Solvers/AMR_MG/BottomSolver.h"
#include "Amr/AmrDefs.h"
......@@ -52,54 +52,51 @@ public:
typedef amr::AmrIntVect_t AmrIntVect_t;
// typedef amr::AmrGeometry_t AmrGeometry_t;
typedef MueLu::Hierarchy<scalar_t, lo_t, go_t, node_t> hierarchy_t;
typedef MueLu::Level level_t;
typedef Xpetra::Matrix<scalar_t, lo_t, go_t, node_t> xmatrix_t;
typedef Xpetra::MultiVector<scalar_t, lo_t, go_t, node_t> xmv_t;
typedef MueLu::Utilities<scalar_t, lo_t, go_t, node_t> util_t;
typedef MueLu::ParameterListInterpreter<scalar_t, lo_t, go_t, node_t> pListInterpreter_t;
typedef MueLu::HierarchyManager<scalar_t, lo_t, go_t, node_t> manager_t;
public:
MueLuBottomSolver(const bool& rebalance,
const std::string& reuse);
void solve(const Teuchos::RCP<mv_t>& x,
const Teuchos::RCP<mv_t>& b);
void setOperator(const Teuchos::RCP<matrix_t>& A,
Level* level_p = nullptr);
std::size_t getNumIters();
/*
* MueLu reuse option.
* Either none, RP, RAP or full
* Either NONE, RP, RAP, SYMBOLIC or FULL
*/
static std::string convertToMueLuReuseOption(const std::string& reuse);
private:
void initMueLuList_m(const std::string& reuse);
private:
Teuchos::RCP<hierarchy_t> hierarchy_mp; ///< manages the multigrid hierarchy
Teuchos::RCP<manager_t> factory_mp; ///< sets up hierarchy
Teuchos::RCP<xmatrix_t> A_mp; ///< MueLu requires Xpetra
lo_t nSweeps_m; ///< the number of multigrid iterations
Teuchos::ParameterList mueluList_m;
bool rebalance_m; ///< use subcommunicators (less communication)
IpplTimings::TimerRef setupTimer_m;
};
#include "MueLuBottomSolver.hpp"
#include "Solvers/AMR_MG/MueLuBottomSolver.hpp"
#endif
......@@ -109,7 +109,6 @@ void MueLuBottomSolver<Level>::setOperator(const Teuchos::RCP<matrix_t>& A,
hierarchy_mp->IsPreconditioner(false);
hierarchy_mp->GetLevel(0)->Set("A", A_mp);
Teuchos::RCP<level_t> finest_p = hierarchy_mp->GetLevel(0);
finest_p->Set("A", A_mp);
......@@ -130,20 +129,20 @@ std::size_t MueLuBottomSolver<Level>::getNumIters() {
template <class Level>
std::string
MueLuBottomSolver<Level>::convertToMueLuReuseOption(const std::string& reuse) {
std::map<std::string, std::string> map;
map["NONE"] = "none";
map["RP"] = "RP";
map["RAP"] = "RAP";
map["S"] = "S";
map["FULL"] = "full";
map["NONE"] = "none";
map["RP"] = "RP";
map["RAP"] = "RAP";
map["SYMBOLIC"] = "S";
map["FULL"] = "full";
auto muelu = map.find(reuse);
if ( muelu == map.end() )
throw OpalException("MueLuBottomSolver::convertToMueLuReuseOption()",
"No MueLu reuse option '" + reuse + "'.");
return muelu->second;
}
......@@ -161,7 +160,7 @@ void MueLuBottomSolver<Level>::initMueLuList_m(const std::string& reuse) {
mueluList_m.set("sa: damping factor", 1.33); // default: 1.33
mueluList_m.set("sa: use filtered matrix", true);
mueluList_m.set("filtered matrix: reuse eigenvalue", false); // false: more expensive
mueluList_m.set("repartition: enable", rebalance_m);
mueluList_m.set("repartition: rebalance P and R", rebalance_m);
mueluList_m.set("repartition: partitioner", "zoltan2");
......@@ -173,7 +172,7 @@ void MueLuBottomSolver<Level>::initMueLuList_m(const std::string& reuse) {
// reparms.set("partitioning_approach", "partition");
mueluList_m.set("repartition: params", reparms);
mueluList_m.set("smoother: type", "CHEBYSHEV");
mueluList_m.set("smoother: pre or post", "both");
Teuchos::ParameterList smparms;
......@@ -182,7 +181,6 @@ void MueLuBottomSolver<Level>::initMueLuList_m(const std::string& reuse) {
smparms.set("chebyshev: zero starting solution", true);
mueluList_m.set("smoother: params", smparms);
mueluList_m.set("coarse: type", "RELAXATION");
Teuchos::ParameterList cparms;
cparms.set("relaxation: type", "Gauss-Seidel");
......@@ -202,4 +200,3 @@ void MueLuBottomSolver<Level>::initMueLuList_m(const std::string& reuse) {
mueluList_m.set("reuse: type", reuse);
}
......@@ -22,7 +22,7 @@
#ifndef MUELU_PRECONDITIONER_H
#define MUELU_PRECONDITIONER_H
#include "AmrPreconditioner.h"
#include "Solvers/AMR_MG/AmrPreconditioner.h"
#include "Amr/AmrDefs.h"
#include <MueLu.hpp>
......@@ -33,44 +33,42 @@ class MueLuPreconditioner : public AmrPreconditioner<amr::matrix_t, Level>
{
public:
typedef amr::Preconditioner Preconditioner;
typedef amr::scalar_t scalar_t;
typedef amr::local_ordinal_t lo_t;
typedef amr::global_ordinal_t go_t;
typedef amr::AmrBox_t AmrBox_t;
typedef MueLu::TpetraOperator<
scalar_t,
lo_t,
go_t,
amr::node_t
> precond_t;
typedef amr::AmrIntVect_t AmrIntVect_t;
typedef std::map<std::string, Preconditioner> map_t;
public:
explicit MueLuPreconditioner(const std::string& reuse);
void create(const Teuchos::RCP<amr::matrix_t>& A, Level* level_p = nullptr);
Teuchos::RCP<amr::operator_t> get();
static void fillMap(map_t& map);
static std::string convertToMueLuReuseOption(const std::string& reuse);
private:
void init_m(const std::string& reuse);
private:
Teuchos::ParameterList params_m;
Teuchos::RCP<precond_t> prec_mp;
};
#include "MueLuPreconditioner.hpp"
#include "Solvers/AMR_MG/MueLuPreconditioner.hpp"
#endif
......@@ -56,20 +56,20 @@ void MueLuPreconditioner<Level>::fillMap(map_t& map) {
template <class Level>
std::string
MueLuPreconditioner<Level>::convertToMueLuReuseOption(const std::string& reuse) {
std::map<std::string, std::string> map;
map["NONE"] = "none";
map["RP"] = "RP";
map["RAP"] = "RAP";
map["S"] = "S";
map["FULL"] = "full";
map["NONE"] = "none";
map["RP"] = "RP";
map["RAP"] = "RAP";
map["SYMBOLIC"] = "S";
map["FULL"] = "full";
auto muelu = map.find(reuse);
if ( muelu == map.end() )
throw OpalException("MueLuPreconditioner::convertToMueLuReuseOption()",
"No MueLu reuse option '" + reuse + "'.");
return muelu->second;
}
......@@ -87,7 +87,7 @@ void MueLuPreconditioner<Level>::init_m(const std::string& reuse) {
params_m.set("sa: damping factor", 1.33); // default: 1.33
params_m.set("sa: use filtered matrix", true);
params_m.set("filtered matrix: reuse eigenvalue", false); // false: more expensive
params_m.set("repartition: enable", false);
params_m.set("repartition: rebalance P and R", false);
params_m.set("repartition: partitioner", "zoltan2");
......@@ -99,8 +99,7 @@ void MueLuPreconditioner<Level>::init_m(const std::string& reuse) {
// reparms.set("partitioning_approach", "partition");
params_m.set("repartition: params", reparms);
params_m.set("smoother: type", "CHEBYSHEV");
params_m.set("smoother: pre or post", "both");
Teuchos::ParameterList smparms;
......@@ -108,7 +107,7 @@ void MueLuPreconditioner<Level>::init_m(const std::string& reuse) {
smparms.set("chebyshev: assume matrix does not change", false);
smparms.set("chebyshev: zero starting solution", true);
params_m.set("smoother: params", smparms);
params_m.set("smoother: type", "CHEBYSHEV");
params_m.set("smoother: pre or post", "both");
......
......@@ -118,7 +118,7 @@ namespace {
AMR_MG_NORM, // AMR, norm convergence criteria
AMR_MG_VERBOSE, // AMR, enable solver info writing (SDDS file)
AMR_MG_REBALANCE, // AMR, rebalance smoothed aggregation (SA) preconditioner
AMR_MG_REUSE, // AMR, reuse type of SA (none, RP, RAP, S or full)
AMR_MG_REUSE, // AMR, reuse type of SA (NONE, RP, RAP, SYMBOLIC or FULL)
AMR_MG_TOL, // AMR, tolerance of solver
#endif
// FOR XXX BASED SOLVER
......@@ -199,7 +199,21 @@ FieldSolver::FieldSolver():
itsAttr[ITSOLVER] = Attributes::makePredefinedString("ITSOLVER",
"Type of iterative solver.",
{"CG", "BICGSTAB", "GMRES"},
{"CG",
"BICGSTAB",
"GMRES",
"MINRES",
"PCPG",
"STOCHASTIC_CG",
"RECYCLING_CG",
"RECYCLING_GMRES",
"KLU2",
"SUPERLU",
"UMFPACK",
"PARDISO_MKL",
"MUMPS",
"LAPACK",
"SA"},
"CG");
itsAttr[INTERPL] = Attributes::makePredefinedString("INTERPL",
......@@ -325,7 +339,7 @@ FieldSolver::FieldSolver():
itsAttr[AMR_MG_REUSE] = Attributes::makePredefinedString("AMR_MG_REUSE",
"Reuse type of Smoothed Aggregation.",
{"NONE", "RP", "RAP"},
{"NONE", "RP", "RAP", "SYMBOLIC", "FULL"},
"RAP");
itsAttr[AMR_MG_TOL] = Attributes::makeReal("AMR_MG_TOL",
......
......@@ -149,6 +149,18 @@ StringConstant::StringConstant():
CREATE_STRINGCONSTANT("CG");
CREATE_STRINGCONSTANT("BICGSTAB");
CREATE_STRINGCONSTANT("GMRES");
CREATE_STRINGCONSTANT("MINRES");
CREATE_STRINGCONSTANT("PCPG");
CREATE_STRINGCONSTANT("STOCHASTIC_CG");
CREATE_STRINGCONSTANT("RECYCLING_CG");
CREATE_STRINGCONSTANT("RECYCLING_GMRES");
CREATE_STRINGCONSTANT("KLU2");
CREATE_STRINGCONSTANT("SUPERLU");
CREATE_STRINGCONSTANT("UMFPACK");
CREATE_STRINGCONSTANT("PARDISO_MKL");
CREATE_STRINGCONSTANT("MUMPS");
CREATE_STRINGCONSTANT("LAPACK");
CREATE_STRINGCONSTANT("SA");
// FieldSolver / INTERPL
CREATE_STRINGCONSTANT("CONSTANT");
......@@ -171,8 +183,7 @@ StringConstant::StringConstant():
CREATE_STRINGCONSTANT("RILUK");
CREATE_STRINGCONSTANT("BLOCK_JACOBI");
CREATE_STRINGCONSTANT("BLOCK_GS");
CREATE_STRINGCONSTANT("SA");
// additionally: NONE, JACOBI, GS
// additionally: NONE, JACOBI, GS, SA
// FieldSolver / AMR_MG_INTERP
CREATE_STRINGCONSTANT("TRILINEAR");
......@@ -187,6 +198,8 @@ StringConstant::StringConstant():
// FieldSolver / AMR_MG_REUSE
CREATE_STRINGCONSTANT("RP");
CREATE_STRINGCONSTANT("RAP");
CREATE_STRINGCONSTANT("SYMBOLIC");
CREATE_STRINGCONSTANT("FULL");
// additionally: NONE
// Option / PSDUMPFRAME
......
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