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>
66#include "MueLu_FactoryManager.hpp"
104#undef MUELU_HIERARCHY_SHORT
107 typedef Teuchos::ScalarTraits<SC>
STS;
135 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);
275 bool InitialGuessIsZero =
false, LO startLevel = 0);
286 void Write(
const LO &start=-1,
const LO &end=-1,
const std::string &suffix=
"");
319 void describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::VERB_HIGH)
const;
373 const Teuchos::Array<MagnitudeType>& residualNorm)
const;
377 const MultiVector& B,
const LO iteration,
448#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.
int WCycleStartLevel_
Level at which to start W-cycle.
std::string description() const
Return a simple one-line description of this object.
std::string description_
cache description to avoid recreating in each call to description() - use ResetDescription() to force...
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.
void ResetDescription()
force recreation of cached description_ next time description() is called:
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.
bool isPreconditioner_
Hierarchy may be used in a standalone mode, or as a preconditioner.
void SetPRrebalance(bool doPRrebalance)
CycleType GetCycle() const
Returns multigrid cycle type (supports VCYCLE and WCYCLE)
Xpetra::global_size_t GetMaxCoarseSize() const
ConvergenceStatus IsConverged(const Teuchos::Array< MagnitudeType > &residualNorm, const MagnitudeType convergenceTolerance) const
Decide if the multigrid iteration is converged.
void DeleteLevelMultiVectors()
ConvergenceStatus Iterate(const MultiVector &B, MultiVector &X, ConvData conv=ConvData(), bool InitialGuessIsZero=false, LO startLevel=0)
Apply the multigrid preconditioner.
void SetCycleStartLevel(int cycleStart)
void DumpCurrentGraph(int level) const
int sizeOfAllocatedLevelMultiVectors_
Caching (Multi)Vectors used in Hierarchy::Iterate()
static bool GetDefaultImplicitTranspose()
void SetMatvecParams(RCP< ParameterList > matvecParams)
static Xpetra::global_size_t GetDefaultMaxCoarseSize()
Xpetra::UnderlyingLib lib_
Epetra/Tpetra mode.
void Clear(int startLevel=0)
Clear impermanent data from previous setup.
void EnableGraphDumping(const std::string &filename, int levelID=1)
bool IsCalculationOfResidualRequired(const LO startLevel, const ConvData &conv) const
Decide if the residual needs to be computed.
void SetMaxCoarseSize(Xpetra::global_size_t maxCoarseSize)
CycleType Cycle_
V- or W-cycle.
ConvergenceStatus ComputeResidualAndPrintHistory(const Operator &A, const MultiVector &X, const MultiVector &B, const LO iteration, const LO startLevel, const ConvData &conv, MagnitudeType &previousResidualNorm)
Compute the residual norm and print it depending on the verbosity level.
Teuchos::ScalarTraits< SC > STS
double GetOperatorComplexity() const
MagnitudeType rate_
Convergece rate.
void PrintResidualHistory(const LO iteration, const Teuchos::Array< MagnitudeType > &residualNorm) const
Print residualNorm for this iteration to the screen.
Array< RCP< MultiVector > > coarseX_
void AllocateLevelMultiVectors(int numvecs, bool forceMapCheck=false)
void print(std::ostream &out=std::cout, const VerbLevel verbLevel=(MueLu::Parameters|MueLu::Statistics0)) const
Hierarchy::print is local hierarchy function, thus the statistics can be different from global ones.
double scalingFactor_
Scaling factor to be applied to coarse grid correction.
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
Xpetra::UnderlyingLib lib()
static bool GetDefaultFuseProlongationAndUpdate()
const RCP< const FactoryManagerBase > & GetLevelManager(const int levelID) const
MagnitudeType GetRate() const
Array< RCP< MultiVector > > coarseImport_
bool isDumpingEnabled_
Graph dumping.
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()
static int GetDefaultCycleStartLevel()
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_
Level managers used during the Setup.
bool GetImplicitTranspose() const
void SetImplicitTranspose(const bool &implicit)
void ReplaceCoordinateMap(Level &level)
Class that holds all level-specific information.
static const NoFactory * get()
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.
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
Data struct for defining stopping criteria of multigrid iteration.
ConvData(std::pair< LO, MagnitudeType > p)
ConvData(MagnitudeType tol)