46 #ifndef MUELU_HIERARCHYMANAGER_DECL_HPP
47 #define MUELU_HIERARCHYMANAGER_DECL_HPP
54 #include <Xpetra_Operator.hpp>
55 #include <Xpetra_IO.hpp>
60 #include "MueLu_Hierarchy.hpp"
64 #include "MueLu_PerfUtils.hpp"
66 #ifdef HAVE_MUELU_INTREPID2
82 #undef MUELU_HIERARCHYMANAGER_SHORT
84 typedef std::pair<std::string, const FactoryBase*>
keep_pair;
104 const int lastLevel = startLevel + numDesiredLevel - 1;
108 for (
int iLevel = startLevel; iLevel <= lastLevel; iLevel++)
146 if (l0->IsAvailable(
"Nullspace")) {
147 RCP<Matrix> A = Teuchos::rcp_dynamic_cast<Matrix>(Op);
148 if (A != Teuchos::null) {
150 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() <<
")");
152 this->
GetOStream(
Warnings0) <<
"Skipping dimension check of user-supplied nullspace because user-supplied operator is not a matrix" << std::endl;
156 #ifdef HAVE_MUELU_DEBUG
166 Xpetra::UnderlyingLib lib = Op->getDomainMap()->lib();
183 params->set(
"printLoadBalancingInfo",
true);
184 params->set(
"printCommInfo",
true);
216 std::map<int, std::vector<keep_pair> >::const_iterator it =
keep_.find(i);
217 if (it !=
keep_.end()) {
219 const std::vector<keep_pair>& keeps = it->second;
220 for (
size_t j = 0; j < keeps.size(); j++)
221 l->Keep(keeps[j].first, keeps[j].second);
223 if (i < numDesiredLevel_-1) {
233 #ifdef HAVE_MUELU_INTREPID2
238 int lastLevelID = numDesiredLevel_ - 1;
239 bool isLastLevel =
false;
241 while (!isLastLevel) {
242 bool r = H.
Setup(levelID,
243 LvlMngr(levelID-1, lastLevelID),
245 LvlMngr(levelID+1, lastLevelID));
247 isLastLevel = r || (levelID == lastLevelID);
264 numDesiredLevel_ = levelID;
271 #ifdef HAVE_MUELU_INTREPID2
272 typedef Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> FCi;
281 typedef std::map<std::string, RCP<const FactoryBase> >
FactoryMap;
298 return Teuchos::null;
300 if (levelID == lastLevelID+1)
301 return Teuchos::null;
329 std::map<int, std::vector<keep_pair> >
keep_;
334 for (
int i = 0; i < data.
size(); ++i) {
338 L->AddKeepFlag(name, &*
levelManagers_[data[i]]->GetFactory(name));
346 for (
int i = 0; i < data.
size(); ++i) {
347 std::string fileName;
359 Xpetra::IO<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Write(fileName,* M);
362 else if (L->IsAvailable(name)) {
364 RCP<T> M = L->template Get< RCP<T> >(name);
366 Xpetra::IO<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Write(fileName,* M);
377 for (
int i = 0; i < data.
size(); ++i) {
383 if (L->IsAvailable(name)) {
384 RCP<T> M = L->template Get< RCP<T> >(name);
386 RCP<Matrix> A = L->template Get<RCP<Matrix> >(
"A");
388 WriteFieldContainer<T>(fileName,*M,*AG->getColMap());
399 size_t num_els = (size_t) fcont.extent(0);
400 size_t num_vecs =(size_t) fcont.extent(1);
406 RCP<GOMultiVector> vec = Xpetra::MultiVectorFactory<GO, LO, GO, NO>::Build(rowMap,num_vecs);
408 for(
size_t j=0; j<num_vecs; j++) {
410 for(
size_t i=0; i<num_els; i++)
411 v[i] = colMap.getGlobalElement(fcont(i,j));
414 Xpetra::IO<GO,LO,GO,NO>::Write(fileName,*vec);
426 #define MUELU_HIERARCHYMANAGER_SHORT
427 #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_
MueLu::DefaultLocalOrdinal LocalOrdinal
virtual std::string getObjectLabel() const
KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
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
static void SetDefaultVerbLevel(const VerbLevel defaultVerbLevel)
Set the default (global) verbosity level.
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_
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.
void SetFuseProlongationAndUpdate(const bool &fuse)
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.
Teuchos::RCP< Teuchos::ParameterList > matvecParams_
void WriteData(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
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
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Teuchos::Array< int > nullspaceToPrint_
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)
void SetMatvecParams(RCP< ParameterList > matvecParams)
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
virtual void SetupOperator(Operator &) const
Setup Matrix object.
void SetImplicitTranspose(const bool &implicit)
Teuchos::Array< int > prolongatorsToPrint_
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.
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
bool fuseProlongationAndUpdate_
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.