46 #ifndef MUELU_HIERARCHYMANAGER_DECL_HPP
47 #define MUELU_HIERARCHYMANAGER_DECL_HPP
60 #include "MueLu_Aggregates.hpp"
61 #include "MueLu_Hierarchy.hpp"
65 #include "MueLu_PerfUtils.hpp"
67 #ifdef HAVE_MUELU_INTREPID2
68 #include "Kokkos_DynRankView.hpp"
83 #undef MUELU_HIERARCHYMANAGER_SHORT
85 typedef std::pair<std::string, const FactoryBase*>
keep_pair;
89 HierarchyManager(
int numDesiredLevel = MasterList::getDefault<int>(
"max levels"))
106 const int lastLevel = startLevel + numDesiredLevel - 1;
110 for (
int iLevel = startLevel; iLevel <= lastLevel; iLevel++)
149 if (l0->IsAvailable(
"Nullspace")) {
150 RCP<Matrix> A = Teuchos::rcp_dynamic_cast<Matrix>(Op);
151 if (A != Teuchos::null) {
154 if (static_cast<size_t>(A->GetFixedBlockSize()) > nullspace->getNumVectors()) {
155 std::stringstream msg;
156 msg <<
"User-provided nullspace has fewer vectors ("
157 << nullspace->getNumVectors() <<
") than number of PDE equations ("
158 << A->GetFixedBlockSize() <<
"). ";
161 msg <<
"It depends on the PDE, if this is a problem or not.";
164 msg <<
"Add the missing nullspace vectors! (You can suppress this check. See the MueLu user guide for details.)";
169 this->
GetOStream(
Warnings0) <<
"Skipping dimension check of user-supplied nullspace because user-supplied operator is not a matrix" << std::endl;
173 #ifdef HAVE_MUELU_DEBUG
200 params->set(
"printLoadBalancingInfo",
true);
201 params->set(
"printCommInfo",
true);
234 std::map<int, std::vector<keep_pair>>::const_iterator it =
keep_.find(i);
235 if (it !=
keep_.end()) {
237 const std::vector<keep_pair>& keeps = it->second;
238 for (
size_t j = 0; j < keeps.size(); j++)
239 l->Keep(keeps[j].first, keeps[j].second);
241 if (i < numDesiredLevel_ - 1) {
256 #ifdef HAVE_MUELU_INTREPID2
265 int lastLevelID = numDesiredLevel_ - 1;
266 bool isLastLevel =
false;
268 while (!isLastLevel) {
269 bool r = H.
Setup(levelID,
270 LvlMngr(levelID - 1, lastLevelID),
272 LvlMngr(levelID + 1, lastLevelID));
276 isLastLevel = r || (levelID == lastLevelID);
297 numDesiredLevel_ = levelID;
301 WriteData<Matrix>(H,
iter->second,
iter->first);
309 #ifdef HAVE_MUELU_INTREPID2
310 typedef Kokkos::DynRankView<LocalOrdinal, typename Node::device_type> FCi;
318 typedef std::map<std::string, RCP<const FactoryBase>>
FactoryMap;
334 return Teuchos::null;
336 if (levelID == lastLevelID + 1)
337 return Teuchos::null;
388 std::map<int, std::vector<keep_pair>>
keep_;
394 for (
int i = 0; i < data.
size(); ++i) {
398 L->AddKeepFlag(name, &*
levelManagers_[data[i]]->GetFactory(name));
404 for (
int i = 0; i < data.
size(); ++i) {
408 L->AddKeepFlag(name, &*
levelManagers_[data[i] + 1]->GetFactory(name));
424 for (
int i = 0; i < data.
size(); ++i) {
425 std::string fileName;
439 }
else if (L->IsAvailable(name)) {
441 RCP<T> M = L->template Get<RCP<T>>(name);
451 for (
int i = 0; i < data.
size(); ++i) {
461 agg = L->template Get<RCP<Aggregates>>(name, &*
levelManagers_[data[i] + 1]->GetFactory(name));
462 }
else if (L->IsAvailable(name)) {
463 agg = L->template Get<RCP<Aggregates>>(
"Aggregates");
466 std::ofstream ofs(fileName);
476 for (
int i = 0; i < data.
size(); ++i) {
482 if (L->IsAvailable(name)) {
483 RCP<T> M = L->template Get<RCP<T>>(name);
487 WriteFieldContainer<T>(fileName, *M, *AG->getColMap());
497 size_t num_els = (size_t)fcont.extent(0);
498 size_t num_vecs = (size_t)fcont.extent(1);
506 for (
size_t j = 0; j < num_vecs; j++) {
508 for (
size_t i = 0; i < num_els; i++)
509 v[i] = colMap.getGlobalElement(fcont(i, j));
522 #define MUELU_HIERARCHYMANAGER_SHORT
523 #endif // MUELU_HIERARCHYMANAGER_HPP
virtual void SetupExtra(Hierarchy &) const
Setup extra data.
Important warning messages (one line)
virtual ~HierarchyManager()=default
Destructor.
This class specifies the default factory that should generate some data on a Level if the data does n...
MueLu::DefaultLocalOrdinal LocalOrdinal
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
virtual std::string getObjectLabel() const
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
static Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &map, size_t NumVectors, bool zeroOut=true)
void WriteDataAggregates(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
void ExportDataSetKeepFlags(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
virtual RCP< Hierarchy > CreateHierarchy(const std::string &label) const
Create a labeled empty Hierarchy object.
void AddLevel(const RCP< Level > &level)
Add a level at the end of the hierarchy.
void CheckForEmptySmoothersAndCoarseSolve()
Teuchos::Array< std::string > dataToSave_
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::Array< int > elementToNodeMapsToPrint_
static void Write(const std::string &fileName, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &M)
void SetMaxCoarseSize(Xpetra::global_size_t maxCoarseSize)
Print information primarily of interest to developers.
void AddFactoryManager(int startLevel, int numDesiredLevel, RCP< FactoryManagerBase > manager)
One-liner description of what is happening.
void Clear(int startLevel=0)
Clear impermanent data from previous setup.
void SetFuseProlongationAndUpdate(const bool &fuse)
std::map< std::string, RCP< const FactoryBase > > FactoryMap
Static class that holds the complete list of valid MueLu parameters.
Teuchos::RCP< FactoryManagerBase > LvlMngr(int levelID, int lastLevelID) const
Print even more statistics.
Teuchos::RCP< Teuchos::ParameterList > matvecParams_
void WriteData(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
static void SetDefaultVerbLevel(const VerbLevel defaultVerbLevel)
Set the default (global) verbosity level.
size_t getNumFactoryManagers() const
returns number of factory managers stored in levelManagers_ vector.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
MueLu::DefaultScalar Scalar
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Teuchos::Array< int > nullspaceToPrint_
Lists of entities to be exported (or saved)
static Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int >> &comm, LocalGlobal lg=Xpetra::GloballyDistributed)
std::string description() const
Return a simple one-line description of this object.
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
Array< RCP< FactoryManagerBase > > levelManagers_
bool suppressNullspaceDimensionCheck_
Flag to indicate whether the check of the nullspace dimension is suppressed.
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
void ExportDataSetKeepFlagsAll(Hierarchy &H, const std::string &name) const
void AllocateLevelMultiVectors(int numvecs, bool forceMapCheck=false)
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
void SetPRrebalance(bool doPRrebalance)
int graphOutputLevel_
-2 = no output, -1 = all levels
void SetMatvecParams(RCP< ParameterList > matvecParams)
Teuchos::Array< int > aggregatesToPrint_
void SetPRViaCopyrebalance(bool doPRViaCopyrebalance)
virtual void SetupOperator(Operator &) const
Setup Matrix object.
void SetImplicitTranspose(const bool &implicit)
std::map< std::string, Teuchos::Array< int > > matricesToPrint_
Teuchos::Array< int > coordinatesToPrint_
std::map< int, std::vector< keep_pair > > keep_
Exception throws to report errors in the internal logical of the program.
std::pair< std::string, const FactoryBase * > keep_pair
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the Hierarchy with some verbosity level to a FancyOStream object.
void WriteDataFC(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name, const std::string &ofname) const
void setlib(Xpetra::UnderlyingLib inlib)
bool doPRViaCopyrebalance_
Xpetra::global_size_t maxCoarseSize_
virtual RCP< Hierarchy > CreateHierarchy() const
Create an empty Hierarchy object.
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 WriteFieldContainer(const std::string &fileName, T &fcont, const Map &colMap) const
bool fuseProlongationAndUpdate_
void EnableGraphDumping(const std::string &filename, int levelID=1)
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
std::string toString(const T &t)
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
void ExportDataSetKeepFlagsNextLevel(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const