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" 99 template <class Scalar = Xpetra::Operator<>::scalar_type,
100 class LocalOrdinal =
typename Xpetra::Operator<Scalar>::local_ordinal_type,
101 class GlobalOrdinal =
typename Xpetra::Operator<Scalar, LocalOrdinal>::global_ordinal_type,
102 class Node =
typename Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
104 #undef MUELU_HIERARCHY_SHORT 107 typedef Teuchos::ScalarTraits<SC>
STS;
158 template<
class S2,
class LO2,
class GO2,
class N2>
168 void AddLevel(
const RCP<Level> & level);
174 RCP<Level> &
GetLevel(
const int levelID = 0);
225 bool Setup(
int coarseLevelID,
const RCP<const FactoryManagerBase> fineLevelManager ,
const RCP<const FactoryManagerBase> coarseLevelManager,
226 const RCP<const FactoryManagerBase> nextLevelManager = Teuchos::null);
234 void Clear(
int startLevel = 0);
256 bool InitialGuessIsZero =
false, LO startLevel = 0);
267 void Write(
const LO &start=-1,
const LO &end=-1);
300 void describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_HIGH)
const;
319 template<
class Node2>
320 Teuchos::RCP< Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
321 clone (
const RCP<Node2> &node2)
const;
379 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
380 template<
typename Node2>
381 Teuchos::RCP<Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
383 clone (
const Teuchos::RCP<Node2> &node2)
const {
385 typedef Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node2> CloneOperator;
388 Teuchos::RCP<New_H_Type> new_h = Teuchos::rcp(
new New_H_Type());
397 RCP<SmootherBase> Pre, Post;
398 RCP<CloneSmoother> clonePre, clonePost;
399 RCP<CloneOperator> cloneA, cloneR, cloneP;
400 RCP<Operator> A, R, P;
402 RCP<Level> level = this->
Levels_[i];
403 RCP<Level> clonelevel = rcp(
new Level());
405 if (level->IsAvailable(
"A")) {
406 A = level->template Get<RCP<Operator> >(
"A");
407 cloneA = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*A, node2);
408 clonelevel->template Set<RCP<CloneOperator> >(
"A", cloneA);
410 if (level->IsAvailable(
"R")){
411 R = level->template Get<RCP<Operator> >(
"R");
412 cloneR = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*R, node2);
413 clonelevel->template Set<RCP<CloneOperator> >(
"R", cloneR);
415 if (level->IsAvailable(
"P")){
416 P = level->template Get<RCP<Operator> >(
"P");
417 cloneP = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*P, node2);
418 clonelevel->template Set<RCP<CloneOperator> >(
"P", cloneP);
420 if (level->IsAvailable(
"PreSmoother")){
421 Pre = level->template Get<RCP<SmootherBase> >(
"PreSmoother");
422 clonePre = MueLu::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2> (Pre, cloneA, node2);
423 clonelevel->template Set<RCP<CloneSmoother> >(
"PreSmoother", clonePre);
425 if (level->IsAvailable(
"PostSmoother")){
426 Post = level->template Get<RCP<SmootherBase> >(
"PostSmoother");
427 clonePost = MueLu::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2> (Post, cloneA, node2);
428 clonelevel->
template Set<RCP<CloneSmoother> >(
"PostSmoother", clonePost);
430 new_h->Levels_[i] = clonelevel;
438 #define MUELU_HIERARCHY_SHORT 439 #endif // MUELU_HIERARCHY_DECL_HPP
void IsPreconditioner(const bool flag)
This class specifies the default factory that should generate some data on a Level if the data does n...
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
Hierarchy()
Default constructor.
void AddLevel(const RCP< Level > &level)
Add a level at the end of the hierarchy.
void SetMaxCoarseSize(Xpetra::global_size_t maxCoarseSize)
Xpetra::global_size_t GetMaxCoarseSize() const
void AddNewLevel()
Add a new level at the end of the hierarchy.
static Xpetra::global_size_t GetDefaultMaxCoarseSize()
void DumpCurrentGraph() const
void SetCycle(CycleType Cycle)
Supports VCYCLE and WCYCLE types.
void Clear(int startLevel=0)
Clear impermanent data from previous setup.
Namespace for MueLu classes and methods.
void Write(const LO &start=-1, const LO &end=-1)
Print matrices in the multigrid hierarchy to file.
bool GetImplicitTranspose() const
const RCP< const FactoryManagerBase > & GetLevelManager(const int levelID) const
Teuchos::ScalarTraits< SC > STS
MagnitudeType rate_
Convergece rate.
static const NoFactory * get()
void ReplaceCoordinateMap(Level &level)
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
Call Level::AddKeepFlag for each level of the Hierarchy.
Teuchos::RCP< Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > clone(const RCP< Node2 > &node2) const
void print(std::ostream &out=std::cout, const VerbLevel verbLevel=(MueLu::Parameters|MueLu::Statistics0)) const
Xpetra::UnderlyingLib lib()
Base class for factories (e.g., R, P, and A_coarse).
Print statistics that do not involve significant additional computation.
ConvData(std::pair< LO, MagnitudeType > p)
Xpetra::UnderlyingLib lib_
static CycleType GetDefaultCycle()
Class that holds all level-specific information.
std::string description() const
Return a simple one-line description of this object.
Class that provides default factories within Needs class.
void RemoveKeepFlag(const std::string &ename, const FactoryBase *factory, KeepType keep=MueLu::All)
Call Level::RemoveKeepFlag for each level of the Hierarchy.
void CheckLevel(Level &level, int levelID)
Helper function.
Always keep data, even accross run. This flag is set by Level::Keep(). This flag is propagated to coa...
ConvData(MagnitudeType tol)
static bool GetDefaultImplicitTranspose()
void SetPRrebalance(bool doPRrebalance)
Base class for smoothers.
int GetGlobalNumLevels() const
static int GetDefaultMaxLevels()
CycleType GetCycle() const
Returns multigrid cycle type (supports VCYCLE and WCYCLE)
Base class for MueLu classes.
void SetImplicitTranspose(const bool &implicit)
virtual ~Hierarchy()
Destructor.
Data struct for defining stopping criteria of multigrid iteration.
STS::magnitudeType MagnitudeType
void Delete(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Delete(ename, factory) for each level of the Hierarchy.
Array< RCP< Level > > Levels_
Container for Level objects.
static bool GetDefaultPRrebalance()
MagnitudeType GetRate() const
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the Hierarchy with some verbosity level to a FancyOStream object.
ReturnType Iterate(const MultiVector &B, MultiVector &X, ConvData conv=ConvData(), bool InitialGuessIsZero=false, LO startLevel=0)
Apply the multigrid preconditioner.
void Keep(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Keep(ename, factory) for each level of the Hierarchy.
bool isDumpingEnabled_
Graph dumping.
void setlib(Xpetra::UnderlyingLib inlib)
double GetOperatorComplexity() const
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.
void EnableGraphDumping(const std::string &filename, int levelID=1)
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Array< RCP< const FactoryManagerBase > > levelManagers_
Xpetra::global_size_t maxCoarseSize_