46 #ifndef MUELU_HIERARCHYMANAGER_DECL_HPP
47 #define MUELU_HIERARCHYMANAGER_DECL_HPP
60 #include "MueLu_Hierarchy.hpp"
64 #include "MueLu_PerfUtils.hpp"
66 #ifdef HAVE_MUELU_INTREPID2
77 template <
class Scalar =
double,
class LocalOrdinal =
int,
class GlobalOrdinal = LocalOrdinal,
class Node = KokkosClassic::DefaultNode::DefaultNodeType>
79 #undef MUELU_HIERARCHYMANAGER_SHORT
81 typedef std::pair<std::string, const FactoryBase*>
keep_pair;
99 const int lastLevel = startLevel + numDesiredLevel - 1;
103 for (
int iLevel = startLevel; iLevel <= lastLevel; iLevel++)
141 if (l0->IsAvailable(
"Nullspace")) {
142 RCP<Matrix> A = Teuchos::rcp_dynamic_cast<Matrix>(Op);
143 if (A != Teuchos::null) {
145 TEUCHOS_TEST_FOR_EXCEPTION(static_cast<size_t>(A->GetFixedBlockSize()) > nullspace->getNumVectors(),
Exceptions::RuntimeError,
"user-provided nullspace has fewer vectors (" << nullspace->getNumVectors() <<
") than number of PDE equations (" << A->GetFixedBlockSize() <<
")");
147 this->
GetOStream(
Warnings0) <<
"Skipping dimension check of user-supplied nullspace because user-supplied operator is not a matrix" << std::endl;
151 #ifdef HAVE_MUELU_DEBUG
178 params->set(
"printLoadBalancingInfo",
true);
179 params->set(
"printCommInfo",
true);
210 std::map<int, std::vector<keep_pair> >::const_iterator it =
keep_.find(i);
211 if (it !=
keep_.end()) {
213 const std::vector<keep_pair>& keeps = it->second;
214 for (
size_t j = 0; j < keeps.size(); j++)
215 l->Keep(keeps[j].first, keeps[j].second);
217 if (i < numDesiredLevel_-1) {
227 #ifdef HAVE_MUELU_INTREPID2
232 int lastLevelID = numDesiredLevel_ - 1;
233 bool isLastLevel =
false;
235 while (!isLastLevel) {
236 bool r = H.
Setup(levelID,
237 LvlMngr(levelID-1, lastLevelID),
239 LvlMngr(levelID+1, lastLevelID));
241 isLastLevel = r || (levelID == lastLevelID);
257 numDesiredLevel_ = levelID;
264 #ifdef HAVE_MUELU_INTREPID2
265 typedef Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> FCi;
274 typedef std::map<std::string, RCP<const FactoryBase> >
FactoryMap;
291 return Teuchos::null;
293 if (levelID == lastLevelID+1)
294 return Teuchos::null;
319 std::map<int, std::vector<keep_pair> >
keep_;
324 for (
int i = 0; i < data.
size(); ++i) {
328 L->AddKeepFlag(name, &*
levelManagers_[data[i]]->GetFactory(name));
336 for (
int i = 0; i < data.
size(); ++i) {
348 else if (L->IsAvailable(name)) {
350 RCP<T> M = L->template Get< RCP<T> >(name);
363 for (
int i = 0; i < data.
size(); ++i) {
369 if (L->IsAvailable(name)) {
370 RCP<T> M = L->template Get< RCP<T> >(name);
372 RCP<Matrix> A = L->template Get<RCP<Matrix> >(
"A");
374 WriteFieldContainer<T>(fileName,*M,*AG->getColMap());
384 typedef LocalOrdinal
LO;
385 typedef GlobalOrdinal
GO;
389 size_t num_els = (size_t) fcont.extent(0);
390 size_t num_vecs =(size_t) fcont.extent(1);
398 for(
size_t j=0; j<num_vecs; j++) {
400 for(
size_t i=0; i<num_els; i++)
401 v[i] = colMap.getGlobalElement(fcont(i,j));
416 #define MUELU_HIERARCHYMANAGER_SHORT
417 #endif // MUELU_HIERARCHYMANAGER_HPP
virtual void SetupExtra(Hierarchy &) const
Setup extra data.
Important warning messages (one line)
This class specifies the default factory that should generate some data on a Level if the data does n...
Teuchos::Array< int > matricesToPrint_
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
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.
#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)
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.
std::map< std::string, RCP< const FactoryBase > > FactoryMap
Static class that holds the complete list of valid MueLu parameters.
void AllocateLevelMultiVectors(int numvecs)
virtual ~HierarchyManager()
Teuchos::RCP< FactoryManagerBase > LvlMngr(int levelID, int lastLevelID) const
Print even more statistics.
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)
Class that holds all level-specific information.
Teuchos::Array< int > nullspaceToPrint_
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_
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
void SetPRrebalance(bool doPRrebalance)
virtual void SetupOperator(Operator &) const
Setup Matrix object.
void SetImplicitTranspose(const bool &implicit)
Teuchos::Array< int > prolongatorsToPrint_
static Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Teuchos::Array< int > coordinatesToPrint_
std::map< int, std::vector< keep_pair > > keep_
HierarchyManager(int numDesiredLevel=MasterList::getDefault< int >("max levels"))
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.
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)
void WriteDataFC(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name, const std::string &ofname) const
void setlib(Xpetra::UnderlyingLib inlib)
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
Teuchos::Array< int > restrictorsToPrint_
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.