46 #ifndef MUELU_HIERARCHYMANAGER_DECL_HPP 47 #define MUELU_HIERARCHYMANAGER_DECL_HPP 52 #include <Teuchos_Array.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++)
144 RCP<Operator> Op = l0->Get<RCP<Operator> >(
"A");
146 if (l0->IsAvailable(
"Nullspace")) {
147 RCP<Matrix> A = Teuchos::rcp_dynamic_cast<Matrix>(Op);
148 if (A != Teuchos::null) {
149 Teuchos::RCP<MultiVector> nullspace = l0->Get<RCP<MultiVector> >(
"Nullspace");
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();
179 RCP<Matrix> Amat = rcp_dynamic_cast<Matrix>(Op);
181 if (!Amat.is_null()) {
182 RCP<ParameterList> params = rcp(
new ParameterList());
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);
224 RCP<Level> newLevel = rcp(
new Level());
233 #ifdef HAVE_MUELU_INTREPID2 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);
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;
295 Teuchos::RCP<FactoryManagerBase>
LvlMngr(
int levelID,
int lastLevelID)
const {
298 return Teuchos::null;
300 if (levelID == lastLevelID+1)
301 return Teuchos::null;
305 static RCP<FactoryManagerBase> defaultMngr = rcp(
new FactoryManager());
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;
348 if (H.getObjectLabel() !=
"")
349 fileName = H.getObjectLabel() +
"_" + name +
"_" +
Teuchos::toString(data[i]) +
".m";
357 RCP<T> M = L->template Get< RCP<T> >(name,&*
levelManagers_[data[i]]->GetFactory(name));
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);
376 void WriteDataFC(
Hierarchy& H,
const Teuchos::Array<int>& data,
const std::string& name,
const std::string & ofname)
const {
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");
387 RCP<const CrsGraph> AG = A->getCrsGraph();
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);
403 Teuchos::RCP<const Map> rowMap = Xpetra::MapFactory<LO,GO,NO>::Build(colMap.lib(),Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid(),fcont.extent(0),colMap.getIndexBase(),colMap.getComm());
406 RCP<GOMultiVector> vec = Xpetra::MultiVectorFactory<GO, LO, GO, NO>::Build(rowMap,num_vecs);
408 for(
size_t j=0; j<num_vecs; j++) {
409 Teuchos::ArrayRCP<GO> v = vec->getDataNonConst(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 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
KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
virtual void SetupOperator(Operator &) const
Setup Matrix object.
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
static void SetDefaultVerbLevel(const VerbLevel defaultVerbLevel)
Set the default (global) verbosity level.
void AddLevel(const RCP< Level > &level)
Add a level at the end of the hierarchy.
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 WriteData(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
void Clear(int startLevel=0)
Clear impermanent data from previous setup.
void SetFuseProlongationAndUpdate(const bool &fuse)
Namespace for MueLu classes and methods.
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
bool IsPrint(MsgType type, int thisProcRankOnly=-1) const
Find out whether we need to print out information for a specific message type.
std::map< std::string, RCP< const FactoryBase > > FactoryMap
Static class that holds the complete list of valid MueLu parameters.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
void AllocateLevelMultiVectors(int numvecs)
virtual ~HierarchyManager()
Print even more statistics.
Teuchos::RCP< FactoryManagerBase > LvlMngr(int levelID, int lastLevelID) const
Teuchos::RCP< Teuchos::ParameterList > matvecParams_
MueLu::DefaultScalar Scalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Teuchos::Array< int > nullspaceToPrint_
Array< RCP< FactoryManagerBase > > levelManagers_
void ExportDataSetKeepFlags(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the Hierarchy with some verbosity level to a FancyOStream object.
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
virtual void SetupExtra(Hierarchy &) const
Setup extra data.
void SetPRrebalance(bool doPRrebalance)
void SetMatvecParams(RCP< ParameterList > matvecParams)
void SetImplicitTranspose(const bool &implicit)
void WriteDataFC(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name, const std::string &ofname) const
virtual RCP< Hierarchy > CreateHierarchy() const
Create an empty Hierarchy object.
Teuchos::Array< int > prolongatorsToPrint_
virtual RCP< Hierarchy > CreateHierarchy(const std::string &label) const
Create a labeled empty Hierarchy object.
void WriteFieldContainer(const std::string &fileName, T &fcont, const Map &colMap) const
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
size_t getNumFactoryManagers() const
returns number of factory managers stored in levelManagers_ vector.
void setlib(Xpetra::UnderlyingLib inlib)
Xpetra::global_size_t maxCoarseSize_
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 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.