46 #ifndef MUELU_HIERARCHY_DECL_HPP
47 #define MUELU_HIERARCHY_DECL_HPP
49 #include <Teuchos_ParameterList.hpp>
50 #include <Teuchos_Ptr.hpp>
52 #include <Xpetra_ConfigDefs.hpp>
53 #include <Xpetra_Matrix_fwd.hpp>
54 #include <Xpetra_MultiVector_fwd.hpp>
55 #include <Xpetra_MultiVectorFactory_fwd.hpp>
56 #include <Xpetra_Operator_fwd.hpp>
58 #include <Xpetra_Cloner.hpp>
67 #include "MueLu_FactoryManager.hpp"
105 #undef MUELU_HIERARCHY_SHORT
108 typedef Teuchos::ScalarTraits<SC>
STS;
136 Hierarchy(
const RCP<Matrix> & A,
const std::string& label);
167 template<
class S2,
class LO2,
class GO2,
class N2>
177 void AddLevel(
const RCP<Level> & level);
183 RCP<Level> &
GetLevel(
const int levelID = 0);
239 bool Setup(
int coarseLevelID,
const RCP<const FactoryManagerBase> fineLevelManager ,
const RCP<const FactoryManagerBase> coarseLevelManager,
240 const RCP<const FactoryManagerBase> nextLevelManager = Teuchos::null);
248 void Clear(
int startLevel = 0);
272 ReturnType Iterate(
const MultiVector& B, MultiVector& X, ConvData conv = ConvData(),
273 bool InitialGuessIsZero =
false, LO startLevel = 0);
284 void Write(
const LO &start=-1,
const LO &end=-1,
const std::string &suffix=
"");
317 void describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_HIGH)
const;
336 #ifdef HAVE_MUELU_DEPRECATED_CODE
337 template<
class Node2>
338 Teuchos::RCP< Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
340 clone (
const RCP<Node2> &node2)
const;
422 #ifdef HAVE_MUELU_DEPRECATED_CODE
423 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
424 template<
typename Node2>
425 Teuchos::RCP<Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
428 clone (
const Teuchos::RCP<Node2> &node2)
const {
430 typedef Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node2> CloneOperator;
433 Teuchos::RCP<New_H_Type> new_h = Teuchos::rcp(
new New_H_Type());
434 new_h->Levels_.resize(this->GetNumLevels());
435 new_h->maxCoarseSize_ = maxCoarseSize_;
436 new_h->implicitTranspose_ = implicitTranspose_;
437 new_h->fuseProlongationAndUpdate_ = fuseProlongationAndUpdate_;
438 new_h->isPreconditioner_ = isPreconditioner_;
439 new_h->isDumpingEnabled_ = isDumpingEnabled_;
440 new_h->dumpLevel_ = dumpLevel_;
441 new_h->dumpFile_ = dumpFile_;
443 RCP<SmootherBase> Pre, Post;
444 RCP<CloneSmoother> clonePre, clonePost;
445 RCP<CloneOperator> cloneA, cloneR, cloneP;
446 RCP<Operator> A, R, P;
447 for (
int i = 0; i < GetNumLevels(); i++) {
448 RCP<Level> level = this->Levels_[i];
449 RCP<Level> clonelevel = rcp(
new Level());
451 if (level->IsAvailable(
"A")) {
452 A = level->template Get<RCP<Operator> >(
"A");
453 cloneA = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*A, node2);
454 clonelevel->template Set<RCP<CloneOperator> >(
"A", cloneA);
456 if (level->IsAvailable(
"R")){
457 R = level->template Get<RCP<Operator> >(
"R");
458 cloneR = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*R, node2);
459 clonelevel->template Set<RCP<CloneOperator> >(
"R", cloneR);
461 if (level->IsAvailable(
"P")){
462 P = level->template Get<RCP<Operator> >(
"P");
463 cloneP = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*P, node2);
464 clonelevel->template Set<RCP<CloneOperator> >(
"P", cloneP);
466 if (level->IsAvailable(
"PreSmoother")){
467 Pre = level->template Get<RCP<SmootherBase> >(
"PreSmoother");
468 clonePre = MueLu::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2> (Pre, cloneA, node2);
469 clonelevel->template Set<RCP<CloneSmoother> >(
"PreSmoother", clonePre);
471 if (level->IsAvailable(
"PostSmoother")){
472 Post = level->template Get<RCP<SmootherBase> >(
"PostSmoother");
473 clonePost = MueLu::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2> (Post, cloneA, node2);
474 clonelevel->
template Set<RCP<CloneSmoother> >(
"PostSmoother", clonePost);
476 new_h->Levels_[i] = clonelevel;
485 #define MUELU_HIERARCHY_SHORT
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Base class for MueLu classes.
Base class for factories (e.g., R, P, and A_coarse).
Class that provides default factories within Needs class.
This class specifies the default factory that should generate some data on a Level if the data does n...
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
void AddLevel(const RCP< Level > &level)
Add a level at the end of the hierarchy.
double GetSmootherComplexity() const
void Write(const LO &start=-1, const LO &end=-1, const std::string &suffix="")
Print matrices in the multigrid hierarchy to file.
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
Array< RCP< MultiVector > > residual_
void CheckLevel(Level &level, int levelID)
Helper function.
std::string description() const
Return a simple one-line description of this object.
void IsPreconditioner(const bool flag)
static CycleType GetDefaultCycle()
Array< RCP< Level > > Levels_
Container for Level objects.
static bool GetDefaultPRrebalance()
Array< RCP< MultiVector > > coarseRhs_
Array< RCP< MultiVector > > coarseExport_
void setlib(Xpetra::UnderlyingLib inlib)
bool Setup(int coarseLevelID, const RCP< const FactoryManagerBase > fineLevelManager, const RCP< const FactoryManagerBase > coarseLevelManager, const RCP< const FactoryManagerBase > nextLevelManager=Teuchos::null)
Multi-level setup phase: build a new level of the hierarchy.
STS::magnitudeType MagnitudeType
void SetFuseProlongationAndUpdate(const bool &fuse)
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the Hierarchy with some verbosity level to a FancyOStream object.
virtual ~Hierarchy()
Destructor.
void SetPRrebalance(bool doPRrebalance)
CycleType GetCycle() const
Returns multigrid cycle type (supports VCYCLE and WCYCLE)
Xpetra::global_size_t GetMaxCoarseSize() const
void DeleteLevelMultiVectors()
int sizeOfAllocatedLevelMultiVectors_
static bool GetDefaultImplicitTranspose()
void SetMatvecParams(RCP< ParameterList > matvecParams)
static Xpetra::global_size_t GetDefaultMaxCoarseSize()
Xpetra::UnderlyingLib lib_
void Clear(int startLevel=0)
Clear impermanent data from previous setup.
void EnableGraphDumping(const std::string &filename, int levelID=1)
const RCP< const FactoryManagerBase > & GetLevelManager(const int levelID) const
ReturnType Iterate(const MultiVector &B, MultiVector &X, ConvData conv=ConvData(), bool InitialGuessIsZero=false, LO startLevel=0)
Apply the multigrid preconditioner.
void SetMaxCoarseSize(Xpetra::global_size_t maxCoarseSize)
Teuchos::ScalarTraits< SC > STS
double GetOperatorComplexity() const
MagnitudeType rate_
Convergece rate.
Array< RCP< MultiVector > > coarseX_
void print(std::ostream &out=std::cout, const VerbLevel verbLevel=(MueLu::Parameters|MueLu::Statistics0)) const
Hierarchy(const Hierarchy &h)
Copy constructor is not implemented.
bool GetFuseProlongationAndUpdate() const
void Delete(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Delete(ename, factory) for each level of the Hierarchy.
int GetGlobalNumLevels() const
void Keep(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Keep(ename, factory) for each level of the Hierarchy.
Xpetra::UnderlyingLib lib()
static bool GetDefaultFuseProlongationAndUpdate()
void AllocateLevelMultiVectors(int numvecs)
MagnitudeType GetRate() const
Array< RCP< MultiVector > > coarseImport_
bool isDumpingEnabled_
Graph dumping.
void DumpCurrentGraph() const
Xpetra::global_size_t maxCoarseSize_
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
Call Level::AddKeepFlag for each level of the Hierarchy.
static int GetDefaultMaxLevels()
Array< RCP< MultiVector > > correction_
void SetCycle(CycleType Cycle)
Supports VCYCLE and WCYCLE types.
void AddNewLevel()
Add a new level at the end of the hierarchy.
void RemoveKeepFlag(const std::string &ename, const FactoryBase *factory, KeepType keep=MueLu::All)
Call Level::RemoveKeepFlag for each level of the Hierarchy.
bool fuseProlongationAndUpdate_
void SetProlongatorScalingFactor(double scalingFactor)
Specify damping factor alpha such that x = x + alpha*P*c, where c is the coarse grid correction.
Array< RCP< const FactoryManagerBase > > levelManagers_
bool GetImplicitTranspose() const
void SetImplicitTranspose(const bool &implicit)
void ReplaceCoordinateMap(Level &level)
Class that holds all level-specific information.
static const NoFactory * get()
Base class for smoothers.
Namespace for MueLu classes and methods.
@ Keep
Always keep data, even accross run. This flag is set by Level::Keep(). This flag is propagated to coa...
KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
@ Parameters
Print parameters.
@ Statistics0
Print statistics that do not involve significant additional computation.
Data struct for defining stopping criteria of multigrid iteration.
ConvData(std::pair< LO, MagnitudeType > p)
ConvData(MagnitudeType tol)