Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit e77ea29d authored by frey_m's avatar frey_m
Browse files

AMR-Trilinos: use simpler interface

parent feeeeb0a
No related branches found
No related tags found
1 merge request!31Master
...@@ -6,6 +6,7 @@ MueLuBottomSolver::MueLuBottomSolver() ...@@ -6,6 +6,7 @@ MueLuBottomSolver::MueLuBottomSolver()
A_mp(Teuchos::null), A_mp(Teuchos::null),
tolerance_m(1.0e-4) tolerance_m(1.0e-4)
{ {
this->initMueLuList_m();
/* /*
hierarchy_mp = Teuchos::rcp(new hierarchy_t()); hierarchy_mp = Teuchos::rcp(new hierarchy_t());
...@@ -42,112 +43,22 @@ void MueLuBottomSolver::solve(const Teuchos::RCP<mv_t>& x, ...@@ -42,112 +43,22 @@ void MueLuBottomSolver::solve(const Teuchos::RCP<mv_t>& x,
void MueLuBottomSolver::setOperator(const Teuchos::RCP<matrix_t>& A) { void MueLuBottomSolver::setOperator(const Teuchos::RCP<matrix_t>& A) {
Teuchos::RCP<tentPFactory_t> TentativePFact = Teuchos::rcp( new tentPFactory_t() );
Teuchos::RCP<saPFactory_t> SaPFact = Teuchos::rcp( new saPFactory_t() );
Teuchos::RCP<transPFactory_t> RFact = Teuchos::rcp( new transPFactory_t());
Teuchos::RCP<rAPFactory_t> AFact = rcp(new rAPFactory_t());
AFact->setVerbLevel(Teuchos::VERB_HIGH);
fManager_t M; Teuchos::RCP<manager_t> mueluFactory = Teuchos::rcp(
M.SetFactory("Ptent", TentativePFact); new pListInterpreter_t(mueluList_m)
//M.SetFactory("P", SaPFact); );
//M.SetFactory("R", RFact);
// empty multigrid hierarchy with a finest level only
M.SetFactory("Smoother", Teuchos::null); //skips smoother setup hierarchy_mp = mueluFactory->CreateHierarchy();
M.SetFactory("CoarseSolver", Teuchos::null); //skips coarsest solve setup
hierarchy_mp->GetLevel(0)->Set("A", A_mp);
int startLevel = 0; hierarchy_mp->GetLevel(0)->Set("Nullspace", nullspace);
int maxLevels = 10; hierarchy_mp->GetLevel(0)->Set("Coordinates", coordinates);
// Indicate which Hierarchy operators we want to keep
hierarchy_mp = Teuchos::rcp(new hierarchy_t());
hierarchy_mp->Keep("P", SaPFact.get()); //SaPFact is the generating factory for P.
hierarchy_mp->Keep("R", RFact.get()); //RFact is the generating factory for R.
hierarchy_mp->Keep("Ptent", TentativePFact.get()); //SaPFact is the generating factory for P.
hierarchy_mp->SetCycle(MueLu::CycleType::VCYCLE);
hierarchy_mp->SetMaxCoarseSize(200);
hierarchy_mp->SetPRrebalance(true);
hierarchy_mp->SetImplicitTranspose(true);
Teuchos::ParameterList Aclist = *(AFact->GetValidParameterList());
Aclist.set("transpose: use implicit", true);
AFact->SetParameterList(Aclist);
// --------------------
// The Factory Manager will be configured to return the rebalanced versions of P, R, A by default.
// Everytime we want to use the non-rebalanced versions, we need to explicitly define the generating factory.
RFact->SetFactory("P", SaPFact);
//
AFact->SetFactory("P", SaPFact);
AFact->SetFactory("R", RFact);
// Transfer coordinates
Teuchos::RCP<coordTransferFactory_t> TransferCoordinatesFact = Teuchos::rcp(new coordTransferFactory_t());
AFact->AddTransferFactory(TransferCoordinatesFact); // FIXME REMOVE
// Repartitioning (creates "Importer" from "Partition")
Teuchos::RCP<repartFactory_t> RepartitionFact = Teuchos::rcp(new repartFactory_t());
{
Teuchos::ParameterList paramList;
paramList.set("repartition: start level", 2);
paramList.set("repartition: min rows per proc", 200);
paramList.set("repartition: max imbalance", 1.3);
RepartitionFact->SetParameterList(paramList);
}
RepartitionFact->SetFactory("A", AFact);
Teuchos::RCP<MueLu::Factory> ZoltanFact = Teuchos::rcp(new zoltan_t());
ZoltanFact->SetFactory("A", AFact);
ZoltanFact->SetFactory("Coordinates", TransferCoordinatesFact);
ZoltanFact->SetFactory("number of partitions", RepartitionFact);
// Reordering of the transfer operators
Teuchos::RCP<rebalTransferFactory_t> RebalancedPFact = Teuchos::rcp(new rebalTransferFactory_t());
RebalancedPFact->SetParameter("type", Teuchos::ParameterEntry(std::string("Interpolation")));
RebalancedPFact->SetFactory("P", SaPFact);
RebalancedPFact->SetFactory("Coordinates", TransferCoordinatesFact);
RebalancedPFact->SetFactory("Nullspace", M.GetFactory("Ptent")); // TODO
Teuchos::RCP<rebalTransferFactory_t> RebalancedRFact = Teuchos::rcp(new rebalTransferFactory_t());
RebalancedRFact->SetParameter("type", Teuchos::ParameterEntry(std::string("Restriction")));
RebalancedRFact->SetFactory("R", RFact);
// Compute Ac from rebalanced P and R
Teuchos::RCP<rebalAcFactory_t> RebalancedAFact = Teuchos::rcp(new rebalAcFactory_t());
RebalancedAFact->SetFactory("A", AFact);
// Configure FactoryManager
M.SetFactory("A", RebalancedAFact);
M.SetFactory("P", RebalancedPFact);
M.SetFactory("R", RebalancedRFact);
M.SetFactory("Nullspace", RebalancedPFact);
M.SetFactory("Coordinates", RebalancedPFact);
//M.SetFactory("Importer", RepartitionFact);
// -------------------
//M.SetFactory("A", AFact);
hierarchy_mp->IsPreconditioner(false); hierarchy_mp->IsPreconditioner(false);
hierarchy_mp->setDefaultVerbLevel(Teuchos::VERB_HIGH); hierarchy_mp->setDefaultVerbLevel(Teuchos::VERB_HIGH);
// Create Gauss-Seidel smoother.
std::string ifpackType = "RELAXATION";
Teuchos::ParameterList ifpackList;
ifpackList.set("relaxation: sweeps", (lo_t) 4);
ifpackList.set("relaxation: damping factor", (scalar_t) 1.0);
Teuchos::RCP<smootherPrototype_t> smootherPrototype = Teuchos::rcp(new smoother_t(ifpackType, ifpackList));
M.SetFactory("Smoother", Teuchos::rcp(new smootherFactory_t(smootherPrototype)));
// Create coarsest solver.
Teuchos::RCP<smootherFactory_t> coarseSolverPrototype = Teuchos::rcp( new solver_t() );
Teuchos::RCP<smootherFactory_t> coarseSolverFact = Teuchos::rcp( new smootherFactory_t(coarseSolverPrototype, Teuchos::null) );
M.SetFactory("CoarseSolver", coarseSolverFact);
A_mp = MueLu::TpetraCrs_To_XpetraMatrix<scalar_t, lo_t, go_t, node_t>(A); A_mp = MueLu::TpetraCrs_To_XpetraMatrix<scalar_t, lo_t, go_t, node_t>(A);
A_mp->SetFixedBlockSize(1); // only 1 DOF per node (pure Laplace problem) A_mp->SetFixedBlockSize(1); // only 1 DOF per node (pure Laplace problem)
...@@ -173,9 +84,11 @@ void MueLuBottomSolver::setOperator(const Teuchos::RCP<matrix_t>& A) { ...@@ -173,9 +84,11 @@ void MueLuBottomSolver::setOperator(const Teuchos::RCP<matrix_t>& A) {
Teuchos::RCP<xmv_t> xnullspace = MueLu::TpetraMultiVector_To_XpetraMultiVector(nullspace); Teuchos::RCP<xmv_t> xnullspace = MueLu::TpetraMultiVector_To_XpetraMultiVector(nullspace);
nullspace->putScalar(1.0); nullspace->putScalar(1.0);
finest_mp->Set("Nullspace", xnullspace); finest_mp->Set("Nullspace", xnullspace);
//finest_mp->Set("Coordinates", coordinates)
hierarchy_mp->Setup(M,startLevel,maxLevels); hierarchy_mp->Setup(M,startLevel,maxLevels);
mueluFactory->SetupHierarchy(*hierarchy_mp);
} }
...@@ -184,17 +97,62 @@ std::size_t MueLuBottomSolver::getNumIters() { ...@@ -184,17 +97,62 @@ std::size_t MueLuBottomSolver::getNumIters() {
} }
void MueLuBottomSolver::setupAggregation_m() { void MueLuBottomSolver::initMueLuList_m() {
mueluList_m.set("problem: type", "Poisson-3D");
} // mueluList_m.set("problem: symmetric", false);
mueluList_m.set("verbosity", "extreme");
mueluList_m.set("number of equations", 1);
mueluList_m.set("max levels", 8);
mueluList_m.set("cycle type", "V");
mueluList_m.set("coarse: max size", 200);
mueluList_m.set("multigrid algorithm", "sa");
mueluList_m.set("repartition: enable", true);
mueluList_m.set("repartition: rebalance P and R", true);
mueluList_m.set("repartition: partitioner", "zoltan2");
mueluList_m.set("repartition: min rows per proc", 800);
mueluList_m.set("repartition: start level", 2);
void MueLuBottomSolver::setupSmoother_m() { Teuchos::ParameterList reparms;
reparms.set("algorithm", "rcb");
// 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");
} mueluList_m.set("coarse: type", "KLU2");
mueluList_m.set("aggregation: type", "uncoupled");
mueluList_m.set("aggregation: min agg size", 3);
mueluList_m.set("aggregation: max agg size", 27);
void MueLuBottomSolver::setupCoarser_m() { mueluList_m.set("transpose: use implicit", true);
mueluList_m.set("reuse: type", "none");
} }
// void MueLuBottomSolver::setupSmoother_m(fManager_t& manager) {
// std::string ifpackType = "RELAXATION";
// Teuchos::ParameterList ifpackList;
// ifpackList.set("relaxation: sweeps", (lo_t) 4);
// ifpackList.set("relaxation: damping factor", (scalar_t) 1.0);
// Teuchos::RCP<smootherPrototype_t> smootherPrototype =
// Teuchos::rcp(new smoother_t(ifpackType, ifpackList));
//
// manager.SetFactory("Smoother", Teuchos::rcp(new smootherFactory_t(smootherPrototype)));
// }
//
//
// void MueLuBottomSolver::setupCoarseSolver_m(fManager_t& manager) {
// Teuchos::RCP<smootherFactory_t> coarseSolverPrototype =
// Teuchos::rcp( new solver_t() );
//
// Teuchos::RCP<smootherFactory_t> coarseSolverFact =
// Teuchos::rcp( new smootherFactory_t(coarseSolverPrototype, Teuchos::null) );
//
// manager.SetFactory("CoarseSolver", coarseSolverFact);
// }
...@@ -7,19 +7,7 @@ ...@@ -7,19 +7,7 @@
#include <MueLu_Level.hpp> #include <MueLu_Level.hpp>
#include <MueLu_Utilities.hpp> #include <MueLu_Utilities.hpp>
#include "MueLu_Factory.hpp" #include <MueLu_ParameterListInterpreter.hpp>
#include "MueLu_TentativePFactory.hpp"
#include "MueLu_SaPFactory.hpp"
#include "MueLu_SmootherFactory.hpp"
#include "MueLu_TransPFactory.hpp"
#include "MueLu_TrilinosSmoother.hpp"
#include "MueLu_DirectSolver.hpp"
#include "MueLu_RAPFactory.hpp"
#include "MueLu_RepartitionHeuristicFactory.hpp"
#include "MueLu_RebalanceTransferFactory.hpp"
#include "MueLu_CoordinatesTransferFactory.hpp"
#include "MueLu_Zoltan2Interface.hpp"
#include "MueLu_RebalanceAcFactory.hpp"
class MueLuBottomSolver : public BottomSolver<Teuchos::RCP<amr::matrix_t>, class MueLuBottomSolver : public BottomSolver<Teuchos::RCP<amr::matrix_t>,
Teuchos::RCP<amr::multivector_t> > Teuchos::RCP<amr::multivector_t> >
...@@ -40,22 +28,9 @@ public: ...@@ -40,22 +28,9 @@ public:
typedef Xpetra::MultiVector<scalar_t, lo_t, go_t, node_t> xmv_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::Utilities<scalar_t, lo_t, go_t, node_t> util_t;
typedef MueLu::TentativePFactory<scalar_t, lo_t, go_t, node_t> tentPFactory_t; typedef MueLu::ParameterListInterpreter<scalar_t, lo_t, go_t, node_t> pListInterpreter_t;
typedef MueLu::SaPFactory<scalar_t, lo_t, go_t, node_t> saPFactory_t; typedef MueLu::HierarchyManager<scalar_t, lo_t, go_t, node_t> manager_t;
typedef MueLu::TransPFactory<scalar_t, lo_t, go_t, node_t> transPFactory_t;
typedef MueLu::RAPFactory<scalar_t, lo_t, go_t, node_t> rAPFactory_t;
typedef MueLu::FactoryManager<scalar_t, lo_t, go_t, node_t> fManager_t;
typedef MueLu::CoordinatesTransferFactory<scalar_t, lo_t, go_t, node_t> coordTransferFactory_t;
typedef MueLu::RepartitionHeuristicFactory<scalar_t, lo_t, go_t, node_t> repartFactory_t;
typedef MueLu::Zoltan2Interface<scalar_t, lo_t, go_t, node_t> zoltan_t;
typedef MueLu::RebalanceTransferFactory<scalar_t, lo_t, go_t, node_t> rebalTransferFactory_t;
typedef MueLu::RebalanceAcFactory<scalar_t, lo_t, go_t, node_t> rebalAcFactory_t;
typedef MueLu::SmootherPrototype<scalar_t, lo_t, go_t, node_t> smootherPrototype_t;
typedef MueLu::SmootherFactory<scalar_t, lo_t, go_t, node_t> smootherFactory_t;
typedef MueLu::TrilinosSmoother<scalar_t, lo_t, go_t, node_t> smoother_t;
typedef MueLu::DirectSolver<scalar_t, lo_t, go_t, node_t> solver_t;
public: public:
MueLuBottomSolver(); MueLuBottomSolver();
...@@ -68,9 +43,7 @@ public: ...@@ -68,9 +43,7 @@ public:
std::size_t getNumIters(); std::size_t getNumIters();
private: private:
void setupAggregation_m(); void initMueLuList_m();
void setupSmoother_m();
void setupCoarser_m();
private: private:
Teuchos::RCP<hierarchy_t> hierarchy_mp; ///< manages the multigrid hierarchy Teuchos::RCP<hierarchy_t> hierarchy_mp; ///< manages the multigrid hierarchy
...@@ -81,6 +54,8 @@ private: ...@@ -81,6 +54,8 @@ private:
scalar_t tolerance_m; ///< stopping criteria of multigrid iteration scalar_t tolerance_m; ///< stopping criteria of multigrid iteration
Teuchos::ParameterList mueluList_m;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment