Go to the documentation of this file.
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"
100 template <class Scalar = Xpetra::Operator<>::scalar_type,
101 class LocalOrdinal =
typename Xpetra::Operator<Scalar>::local_ordinal_type,
102 class GlobalOrdinal =
typename Xpetra::Operator<Scalar, LocalOrdinal>::global_ordinal_type,
103 class Node =
typename Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal>::node_type>
105 #undef MUELU_HIERARCHY_SHORT
108 typedef Teuchos::ScalarTraits<SC>
STS;
164 template<
class S2,
class LO2,
class GO2,
class N2>
174 void AddLevel(
const RCP<Level> & level);
180 RCP<Level> &
GetLevel(
const int levelID = 0);
234 bool Setup(
int coarseLevelID,
const RCP<const FactoryManagerBase> fineLevelManager ,
const RCP<const FactoryManagerBase> coarseLevelManager,
235 const RCP<const FactoryManagerBase> nextLevelManager = Teuchos::null);
243 void Clear(
int startLevel = 0);
267 ReturnType Iterate(
const MultiVector& B, MultiVector& X, ConvData conv = ConvData(),
268 bool InitialGuessIsZero =
false, LO startLevel = 0);
279 void Write(
const LO &start=-1,
const LO &end=-1,
const std::string &suffix=
"");
312 void describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_HIGH)
const;
331 template<
class Node2>
332 Teuchos::RCP< Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
333 clone (
const RCP<Node2> &node2)
const;
410 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
411 template<
typename Node2>
412 Teuchos::RCP<Hierarchy<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
414 clone (
const Teuchos::RCP<Node2> &node2)
const {
416 typedef Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node2> CloneOperator;
419 Teuchos::RCP<New_H_Type> new_h = Teuchos::rcp(
new New_H_Type());
420 new_h->Levels_.resize(this->GetNumLevels());
421 new_h->maxCoarseSize_ = maxCoarseSize_;
422 new_h->implicitTranspose_ = implicitTranspose_;
423 new_h->isPreconditioner_ = isPreconditioner_;
424 new_h->isDumpingEnabled_ = isDumpingEnabled_;
425 new_h->dumpLevel_ = dumpLevel_;
426 new_h->dumpFile_ = dumpFile_;
428 RCP<SmootherBase> Pre, Post;
429 RCP<CloneSmoother> clonePre, clonePost;
430 RCP<CloneOperator> cloneA, cloneR, cloneP;
431 RCP<Operator> A, R, P;
432 for (
int i = 0; i < GetNumLevels(); i++) {
433 RCP<Level> level = this->Levels_[i];
434 RCP<Level> clonelevel = rcp(
new Level());
436 if (level->IsAvailable(
"A")) {
437 A = level->template Get<RCP<Operator> >(
"A");
438 cloneA = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*A, node2);
439 clonelevel->template Set<RCP<CloneOperator> >(
"A", cloneA);
441 if (level->IsAvailable(
"R")){
442 R = level->template Get<RCP<Operator> >(
"R");
443 cloneR = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*R, node2);
444 clonelevel->template Set<RCP<CloneOperator> >(
"R", cloneR);
446 if (level->IsAvailable(
"P")){
447 P = level->template Get<RCP<Operator> >(
"P");
448 cloneP = Xpetra::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2>(*P, node2);
449 clonelevel->template Set<RCP<CloneOperator> >(
"P", cloneP);
451 if (level->IsAvailable(
"PreSmoother")){
452 Pre = level->template Get<RCP<SmootherBase> >(
"PreSmoother");
453 clonePre = MueLu::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2> (Pre, cloneA, node2);
454 clonelevel->template Set<RCP<CloneSmoother> >(
"PreSmoother", clonePre);
456 if (level->IsAvailable(
"PostSmoother")){
457 Post = level->template Get<RCP<SmootherBase> >(
"PostSmoother");
458 clonePost = MueLu::clone<Scalar, LocalOrdinal, GlobalOrdinal, Node, Node2> (Post, cloneA, node2);
459 clonelevel->
template Set<RCP<CloneSmoother> >(
"PostSmoother", clonePost);
461 new_h->Levels_[i] = clonelevel;
469 #define MUELU_HIERARCHY_SHORT
470 #endif // MUELU_HIERARCHY_DECL_HPP
bool isDumpingEnabled_
Graph dumping.
void EnableGraphDumping(const std::string &filename, int levelID=1)
int GetGlobalNumLevels() const
static bool GetDefaultImplicitTranspose()
void AddNewLevel()
Add a new level at the end of the hierarchy.
void CheckLevel(Level &level, int levelID)
Helper function.
DASHPOS string(SUBSTRING ${CLASS} 0 ${DASHPOS} CLASS_NAME) set(CONDITION_NAME "") set(CONDITION_NAME_END "") string(SUBSTRING $
ConvData(std::pair< LO, MagnitudeType > p)
static Xpetra::global_size_t GetDefaultMaxCoarseSize()
void SetCycle(CycleType Cycle)
Supports VCYCLE and WCYCLE types.
Array< RCP< MultiVector > > coarseRhs_
void DumpCurrentGraph() const
Array< RCP< MultiVector > > coarseExport_
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
ConvData(MagnitudeType tol)
void Keep(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Keep(ename, factory) for each level of the Hierarchy.
void SetImplicitTranspose(const bool &implicit)
void SetProlongatorScalingFactor(double scalingFactor)
Specify damping factor alpha such that x = x + alpha*P*c, where c is the coarse grid correction.
int sizeOfAllocatedLevelMultiVectors_
Xpetra::UnderlyingLib lib()
Array< RCP< Level > > Levels_
Container for Level objects.
void DeleteLevelMultiVectors()
void AddLevel(const RCP< Level > &level)
Add a level at the end of the hierarchy.
std::string description() const
Return a simple one-line description of this object.
Namespace for MueLu classes and methods.
void Write(const LO &start=-1, const LO &end=-1, const std::string &suffix="")
Print matrices in the multigrid hierarchy to file.
Hierarchy(const Hierarchy &h)
Copy constructor is not implemented.
Array< RCP< MultiVector > > residual_
Array< RCP< const FactoryManagerBase > > levelManagers_
void setlib(Xpetra::UnderlyingLib inlib)
Base class for MueLu classes.
const RCP< const FactoryManagerBase > & GetLevelManager(const int levelID) const
@ Parameters
Print parameters.
@ Statistics0
Print statistics that do not involve significant additional computation.
ReturnType Iterate(const MultiVector &B, MultiVector &X, ConvData conv=ConvData(), bool InitialGuessIsZero=false, LO startLevel=0)
Apply the multigrid preconditioner.
Xpetra::UnderlyingLib lib_
void Clear(int startLevel=0)
Clear impermanent data from previous setup.
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.
bool GetImplicitTranspose() const
void print(std::ostream &out=std::cout, const VerbLevel verbLevel=(MueLu::Parameters|MueLu::Statistics0)) const
static CycleType GetDefaultCycle()
void RemoveKeepFlag(const std::string &ename, const FactoryBase *factory, KeepType keep=MueLu::All)
Call Level::RemoveKeepFlag for each level of the Hierarchy.
Base class for smoothers.
static int GetDefaultMaxLevels()
void Delete(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Call Level::Delete(ename, factory) for each level of the Hierarchy.
STS::magnitudeType MagnitudeType
Array< RCP< MultiVector > > coarseImport_
Class that provides default factories within Needs class.
Base class for factories (e.g., R, P, and A_coarse).
Teuchos::ScalarTraits< SC > STS
MagnitudeType GetRate() const
void SetPRrebalance(bool doPRrebalance)
double GetOperatorComplexity() const
virtual ~Hierarchy()
Destructor.
void SetMaxCoarseSize(Xpetra::global_size_t maxCoarseSize)
Array< RCP< MultiVector > > coarseX_
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the Hierarchy with some verbosity level to a FancyOStream object.
Data struct for defining stopping criteria of multigrid iteration.
static bool GetDefaultPRrebalance()
MagnitudeType rate_
Convergece rate.
void ReplaceCoordinateMap(Level &level)
Array< RCP< MultiVector > > correction_
static const NoFactory * get()
@ Keep
Always keep data, even accross run. This flag is set by Level::Keep(). This flag is propagated to coa...
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
Call Level::AddKeepFlag for each level of the Hierarchy.
void AllocateLevelMultiVectors(int numvecs)
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Xpetra::global_size_t GetMaxCoarseSize() const
CycleType GetCycle() const
Returns multigrid cycle type (supports VCYCLE and WCYCLE)
This class specifies the default factory that should generate some data on a Level if the data does n...
Teuchos::RCP< Hierarchy< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > clone(const RCP< Node2 > &node2) const
Class that holds all level-specific information.
Xpetra::global_size_t maxCoarseSize_
void IsPreconditioner(const bool flag)
double GetSmootherComplexity() const