MueLu  Version of the Day
MueLu_HierarchyManager.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_HIERARCHYMANAGER_DECL_HPP
47 #define MUELU_HIERARCHYMANAGER_DECL_HPP
48 
49 #include <string>
50 #include <map>
51 
52 #include <Teuchos_Array.hpp>
53 
54 #include <Xpetra_Operator.hpp>
55 #include <Xpetra_IO.hpp>
56 
57 #include "MueLu_ConfigDefs.hpp"
58 
59 #include "MueLu_Exceptions.hpp"
60 #include "MueLu_Aggregates.hpp"
61 #include "MueLu_Hierarchy.hpp"
63 #include "MueLu_Level.hpp"
64 #include "MueLu_MasterList.hpp"
65 #include "MueLu_PerfUtils.hpp"
66 
67 #ifdef HAVE_MUELU_INTREPID2
68 #include "Kokkos_DynRankView.hpp"
69 #endif
70 
71 namespace MueLu {
72 
73  // This class stores the configuration of a Hierarchy.
74  // The class also provides an algorithm to build a Hierarchy from the configuration.
75  //
76  // See also: FactoryManager
77  //
78  template <class Scalar = DefaultScalar,
81  class Node = DefaultNode>
82  class HierarchyManager : public HierarchyFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
83 #undef MUELU_HIERARCHYMANAGER_SHORT
84 #include "MueLu_UseShortNames.hpp"
85  typedef std::pair<std::string, const FactoryBase*> keep_pair;
86 
87  public:
88 
90  HierarchyManager(int numDesiredLevel = MasterList::getDefault<int>("max levels")) :
91  numDesiredLevel_(numDesiredLevel),
92  maxCoarseSize_(MasterList::getDefault<int>("coarse: max size")),
94  doPRrebalance_(MasterList::getDefault<bool>("repartition: rebalance P and R")),
95  implicitTranspose_(MasterList::getDefault<bool>("transpose: use implicit")),
96  fuseProlongationAndUpdate_(MasterList::getDefault<bool>("fuse prolongation and update")),
97  suppressNullspaceDimensionCheck_(MasterList::getDefault<bool>("nullspace: suppress dimension check")),
98  sizeOfMultiVectors_(MasterList::getDefault<int>("number of vectors")),
99  graphOutputLevel_(-2) { }
100 
102  virtual ~HierarchyManager() = default;
103 
105  void AddFactoryManager(int startLevel, int numDesiredLevel, RCP<FactoryManagerBase> manager) {
106  const int lastLevel = startLevel + numDesiredLevel - 1;
107  if (levelManagers_.size() < lastLevel + 1)
108  levelManagers_.resize(lastLevel + 1);
109 
110  for (int iLevel = startLevel; iLevel <= lastLevel; iLevel++)
111  levelManagers_[iLevel] = manager;
112  }
113 
115  RCP<FactoryManagerBase> GetFactoryManager(int levelID) const {
116  // NOTE: last levelManager is used for all the remaining levels
117  return (levelID >= levelManagers_.size() ? levelManagers_[levelManagers_.size()-1] : levelManagers_[levelID]);
118  }
119 
121  size_t getNumFactoryManagers() const {
122  return levelManagers_.size();
123  }
124 
126  void CheckConfig() {
127  for (int i = 0; i < levelManagers_.size(); i++)
128  TEUCHOS_TEST_FOR_EXCEPTION(levelManagers_[i] == Teuchos::null, Exceptions::RuntimeError, "MueLu:HierarchyConfig::CheckConfig(): Undefined configuration for level:");
129  }
130 
132 
133  virtual RCP<Hierarchy> CreateHierarchy() const {
134  return rcp(new Hierarchy());
135  }
136 
137  virtual RCP<Hierarchy> CreateHierarchy(const std::string& label) const {
138  return rcp(new Hierarchy(label));
139  }
140 
142  virtual void SetupHierarchy(Hierarchy& H) const {
143  TEUCHOS_TEST_FOR_EXCEPTION(!H.GetLevel(0)->IsAvailable("A"), Exceptions::RuntimeError, "No fine level operator");
144 
145  RCP<Level> l0 = H.GetLevel(0);
146  RCP<Operator> Op = l0->Get<RCP<Operator>>("A");
147 
148  // Compare nullspace dimension to NumPDEs and throw/warn based on user input
149  if (l0->IsAvailable("Nullspace")) {
150  RCP<Matrix> A = Teuchos::rcp_dynamic_cast<Matrix>(Op);
151  if (A != Teuchos::null) {
152  RCP<MultiVector> nullspace = l0->Get<RCP<MultiVector>>("Nullspace");
153 
154  if (static_cast<size_t>(A->GetFixedBlockSize()) > nullspace->getNumVectors())
155  {
156  std::stringstream msg;
157  msg << "User-provided nullspace has fewer vectors ("
158  << nullspace->getNumVectors() << ") than number of PDE equations ("
159  << A->GetFixedBlockSize() << "). ";
160 
162  {
163  msg << "It depends on the PDE, if this is a problem or not.";
164  this->GetOStream(Warnings0) << msg.str() << std::endl;
165  }
166  else
167  {
168  msg << "Add the missing nullspace vectors! (You can suppress this check. See the MueLu user guide for details.)";
169  TEUCHOS_TEST_FOR_EXCEPTION(static_cast<size_t>(A->GetFixedBlockSize()) > nullspace->getNumVectors(), Exceptions::RuntimeError, msg.str());
170  }
171  }
172  } else {
173  this->GetOStream(Warnings0) << "Skipping dimension check of user-supplied nullspace because user-supplied operator is not a matrix" << std::endl;
174  }
175  }
176 
177 #ifdef HAVE_MUELU_DEBUG
178  // Reset factories' data used for debugging
179  for (int i = 0; i < levelManagers_.size(); i++)
180  levelManagers_[i]->ResetDebugData();
181 
182 #endif
183 
184  // Setup Matrix
185  // TODO: I should certainly undo this somewhere...
186 
187  Xpetra::UnderlyingLib lib = Op->getDomainMap()->lib();
188  H.setlib(lib);
189 
190  SetupOperator(*Op);
191  SetupExtra(H);
192 
193  // Setup Hierarchy
196  if (graphOutputLevel_ >= 0 || graphOutputLevel_ == -1)
197  H.EnableGraphDumping("dep_graph", graphOutputLevel_);
198 
200  RCP<Matrix> Amat = rcp_dynamic_cast<Matrix>(Op);
201 
202  if (!Amat.is_null()) {
203  RCP<ParameterList> params = rcp(new ParameterList());
204  params->set("printLoadBalancingInfo", true);
205  params->set("printCommInfo", true);
206 
208  } else {
209  VerboseObject::GetOStream(Warnings1) << "Fine level operator is not a matrix, statistics are not available" << std::endl;
210  }
211  }
212 
216 
217  H.Clear();
218 
219  // There are few issues with using Keep in the interpreter:
220  // 1. Hierarchy::Keep interface takes a name and a factory. If
221  // factories are different on different levels, the AddNewLevel() call
222  // in Hierarchy does not work properly, as it assume that factories are
223  // the same.
224  // 2. FactoryManager does not have a Keep option, only Hierarchy and
225  // Level have it
226  // 3. Interpreter constructs factory managers, but not levels. So we
227  // cannot set up Keep flags there.
228  //
229  // The solution implemented here does the following:
230  // 1. Construct hierarchy with dummy levels. This avoids
231  // Hierarchy::AddNewLevel() calls which will propagate wrong
232  // inheritance.
233  // 2. Interpreter constructs keep_ array with names and factories for
234  // that level
235  // 3. For each level, we call Keep(name, factory) for each keep_
236  for (int i = 0; i < numDesiredLevel_; i++) {
237  std::map<int, std::vector<keep_pair> >::const_iterator it = keep_.find(i);
238  if (it != keep_.end()) {
239  RCP<Level> l = H.GetLevel(i);
240  const std::vector<keep_pair>& keeps = it->second;
241  for (size_t j = 0; j < keeps.size(); j++)
242  l->Keep(keeps[j].first, keeps[j].second);
243  }
244  if (i < numDesiredLevel_-1) {
245  RCP<Level> newLevel = rcp(new Level());
246  H.AddLevel(newLevel);
247  }
248  }
249 
250  // Matrices to print
251  for(auto iter=matricesToPrint_.begin(); iter!=matricesToPrint_.end(); iter++)
252  ExportDataSetKeepFlags(H,iter->second,iter->first);
253 
254  // Vectors, aggregates and other things that need special case handling
255  ExportDataSetKeepFlags(H, nullspaceToPrint_, "Nullspace");
256  ExportDataSetKeepFlags(H, coordinatesToPrint_, "Coordinates");
257  // NOTE: Aggregates use the next level's Factory
259 #ifdef HAVE_MUELU_INTREPID2
260  ExportDataSetKeepFlags(H,elementToNodeMapsToPrint_, "pcoarsen: element to node map");
261 #endif
262 
263  // Data to save only (these do not have a level, so we do all levels)
264  for(int i=0; i<dataToSave_.size(); i++)
266 
267  int levelID = 0;
268  int lastLevelID = numDesiredLevel_ - 1;
269  bool isLastLevel = false;
270 
271  while (!isLastLevel) {
272  bool r = H.Setup(levelID,
273  LvlMngr(levelID-1, lastLevelID),
274  LvlMngr(levelID, lastLevelID),
275  LvlMngr(levelID+1, lastLevelID));
276  if (levelID < H.GetNumLevels())
277  H.GetLevel(levelID)->print(H.GetOStream(Developer), verbosity_);
278 
279  isLastLevel = r || (levelID == lastLevelID);
280  levelID++;
281  }
282  if (!matvecParams_.is_null())
285  // Set hierarchy description.
286  // This is cached, but involves and MPI_Allreduce.
287  H.description();
289 
290  // When we reuse hierarchy, it is necessary that we don't
291  // change the number of levels. We also cannot make requests
292  // for coarser levels, because we don't construct all the
293  // data on previous levels. For instance, let's say our first
294  // run constructed three levels. If we try to do requests during
295  // next setup for the fourth level, it would need Aggregates
296  // which we didn't construct for level 3 because we reused P.
297  // To fix this situation, we change the number of desired levels
298  // here.
299  numDesiredLevel_ = levelID;
300 
301  // Matrix prints
302  for(auto iter = matricesToPrint_.begin(); iter != matricesToPrint_.end(); iter++) {
303  WriteData<Matrix>(H,iter->second,iter->first);
304  }
305 
306  // Vectors, aggregates and all things we need to print manually
307  WriteData<MultiVector>(H, nullspaceToPrint_, "Nullspace");
308  WriteData<MultiVector>(H, coordinatesToPrint_, "Coordinates");
309  WriteDataAggregates(H, aggregatesToPrint_, "Aggregates");
310 
311 
312 
313 #ifdef HAVE_MUELU_INTREPID2
314  typedef Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> FCi;
315  WriteDataFC<FCi>(H,elementToNodeMapsToPrint_, "pcoarsen: element to node map","el2node");
316 #endif
317 
318 
319  } //SetupHierarchy
320 
322 
323  typedef std::map<std::string, RCP<const FactoryBase> > FactoryMap;
324 
325  protected: //TODO: access function
326 
328  virtual void SetupOperator(Operator& /* Op */) const { }
329 
331  // TODO: merge with SetupMatrix ?
332  virtual void SetupExtra(Hierarchy& /* H */) const { }
333 
334  // TODO this was private
335  // Used in SetupHierarchy() to access levelManagers_
336  // Inputs i=-1 and i=size() are allowed to simplify calls to hierarchy->Setup()
337  Teuchos::RCP<FactoryManagerBase> LvlMngr(int levelID, int lastLevelID) const {
338  // NOTE: the order of 'if' statements is important
339  if (levelID == -1) // levelID = -1 corresponds to the finest level
340  return Teuchos::null;
341 
342  if (levelID == lastLevelID+1) // levelID = 'lastLevelID+1' corresponds to the last level (i.e., no nextLevel)
343  return Teuchos::null;
344 
345  if (levelManagers_.size() == 0) { // default factory manager.
346  // The default manager is shared across levels, initialized only if needed and deleted with the HierarchyManager
347  static RCP<FactoryManagerBase> defaultMngr = rcp(new FactoryManager());
348  return defaultMngr;
349  }
350 
351  return GetFactoryManager(levelID);
352  }
353 
356 
357  mutable int numDesiredLevel_;
358  Xpetra::global_size_t maxCoarseSize_;
360 
364 
372 
374 
377 
379  // Items here get handled manually
380  Teuchos::Array<int> nullspaceToPrint_;
381  Teuchos::Array<int> coordinatesToPrint_;
382  Teuchos::Array<int> aggregatesToPrint_;
383  Teuchos::Array<int> elementToNodeMapsToPrint_;
384 
385  // Data we'll need to save, not necessarily print
386  Teuchos::Array<std::string> dataToSave_;
387 
388  // Matrices we'll need to print
389  std::map<std::string,Teuchos::Array<int> > matricesToPrint_;
390 
391  Teuchos::RCP<Teuchos::ParameterList> matvecParams_;
392 
393  std::map<int, std::vector<keep_pair> > keep_;
395 
396  private:
397  // Set the keep flags for Export Data
398  void ExportDataSetKeepFlags(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name) const {
399  for (int i = 0; i < data.size(); ++i) {
400  if (data[i] < H.GetNumLevels()) {
401  RCP<Level> L = H.GetLevel(data[i]);
402  if(!L.is_null() && data[i] < levelManagers_.size())
403  L->AddKeepFlag(name, &*levelManagers_[data[i]]->GetFactory(name));
404  }
405  }
406  }
407 
408  void ExportDataSetKeepFlagsNextLevel(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name) const {
409  for (int i = 0; i < data.size(); ++i) {
410  if (data[i] < H.GetNumLevels()) {
411  RCP<Level> L = H.GetLevel(data[i]);
412  if(!L.is_null() && data[i]+1 < levelManagers_.size())
413  L->AddKeepFlag(name, &*levelManagers_[data[i]+1]->GetFactory(name));
414  }
415  }
416  }
417 
418  // Set the keep flags for Export Data
419  void ExportDataSetKeepFlagsAll(Hierarchy& H, const std::string& name) const {
420  for (int i=0; i < H.GetNumLevels(); i++ ) {
421  RCP<Level> L = H.GetLevel(i);
422  if(!L.is_null() && i < levelManagers_.size())
423  L->AddKeepFlag(name, &*levelManagers_[i]->GetFactory(name));
424  }
425  }
426 
427 
428  template<class T>
429  void WriteData(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name) const {
430  for (int i = 0; i < data.size(); ++i) {
431  std::string fileName;
432  if (H.getObjectLabel() != "")
433  fileName = H.getObjectLabel() + "_" + name + "_" + Teuchos::toString(data[i]) + ".m";
434  else
435  fileName = name + "_" + Teuchos::toString(data[i]) + ".m";
436 
437  if (data[i] < H.GetNumLevels()) {
438  RCP<Level> L = H.GetLevel(data[i]);
439  if (data[i] < levelManagers_.size() && L->IsAvailable(name,&*levelManagers_[data[i]]->GetFactory(name))) {
440  // Try generating factory
441  RCP<T> M = L->template Get< RCP<T> >(name,&*levelManagers_[data[i]]->GetFactory(name));
442  if (!M.is_null()) {
443  Xpetra::IO<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Write(fileName,* M);
444  }
445  }
446  else if (L->IsAvailable(name)) {
447  // Try nofactory
448  RCP<T> M = L->template Get< RCP<T> >(name);
449  if (!M.is_null()) {
450  Xpetra::IO<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Write(fileName,* M);
451  }
452  }
453  }
454  }
455  }
456 
457  void WriteDataAggregates(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name) const {
458  for (int i = 0; i < data.size(); ++i) {
459  const std::string fileName = name + "_" + Teuchos::toString(data[i]) + ".m";
460 
461  if (data[i] < H.GetNumLevels()) {
462  RCP<Level> L = H.GetLevel(data[i]);
463 
464  // NOTE: Aggregates use the next level's factory
465  RCP<Aggregates> agg;
466  if(data[i]+1 < H.GetNumLevels() && L->IsAvailable(name,&*levelManagers_[data[i]+1]->GetFactory(name))) {
467  // Try generating factory
468  agg = L->template Get< RCP<Aggregates> >(name,&*levelManagers_[data[i]+1]->GetFactory(name));
469  }
470  else if (L->IsAvailable(name)) {
471  agg = L->template Get<RCP<Aggregates> >("Aggregates");
472  }
473  if(!agg.is_null()) {
474  std::ofstream ofs(fileName);
475  Teuchos::FancyOStream fofs(rcp(&ofs,false));
476  agg->print(fofs,Teuchos::VERB_EXTREME);
477  }
478  }
479  }
480  }
481 
482  template<class T>
483  void WriteDataFC(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name, const std::string & ofname) const {
484  for (int i = 0; i < data.size(); ++i) {
485  const std::string fileName = ofname + "_" + Teuchos::toString(data[i]) + ".m";
486 
487  if (data[i] < H.GetNumLevels()) {
488  RCP<Level> L = H.GetLevel(data[i]);
489 
490  if (L->IsAvailable(name)) {
491  RCP<T> M = L->template Get< RCP<T> >(name);
492  if (!M.is_null()) {
493  RCP<Matrix> A = L->template Get<RCP<Matrix> >("A");
494  RCP<const CrsGraph> AG = A->getCrsGraph();
495  WriteFieldContainer<T>(fileName,*M,*AG->getColMap());
496  }
497  }
498  }
499  }
500  }
501 
502  // For dumping an IntrepidPCoarsening element-to-node map to disk
503  template<class T>
504  void WriteFieldContainer(const std::string& fileName, T & fcont,const Map &colMap) const {
505 
506  size_t num_els = (size_t) fcont.extent(0);
507  size_t num_vecs =(size_t) fcont.extent(1);
508 
509  // Generate rowMap
510  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());
511 
512  // Fill multivector to use *petra dump routines
513  RCP<GOMultiVector> vec = Xpetra::MultiVectorFactory<GO, LO, GO, NO>::Build(rowMap,num_vecs);
514 
515  for(size_t j=0; j<num_vecs; j++) {
516  Teuchos::ArrayRCP<GO> v = vec->getDataNonConst(j);
517  for(size_t i=0; i<num_els; i++)
518  v[i] = colMap.getGlobalElement(fcont(i,j));
519  }
520 
521  Xpetra::IO<GO,LO,GO,NO>::Write(fileName,*vec);
522  }
523 
524 
525 
526  // Levels
527  Array<RCP<FactoryManagerBase> > levelManagers_; // one FactoryManager per level (the last levelManager is used for all the remaining levels)
528 
529  }; // class HierarchyManager
530 
531 } // namespace MueLu
532 
533 #define MUELU_HIERARCHYMANAGER_SHORT
534 #endif // MUELU_HIERARCHYMANAGER_HPP
535 
536 //TODO: split into _decl/_def
537 // TODO: default value for first param (FactoryManager()) should not be duplicated (code maintainability)
Important warning messages (one line)
void ExportDataSetKeepFlagsNextLevel(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
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
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< std::string > dataToSave_
Teuchos::Array< int > elementToNodeMapsToPrint_
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 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 WriteDataAggregates(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
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
MueLu::DefaultNode Node
Static class that holds the complete list of valid MueLu parameters.
virtual void SetupHierarchy(Hierarchy &H) const
Setup Hierarchy object.
Print even more statistics.
Additional warnings.
Teuchos::RCP< FactoryManagerBase > LvlMngr(int levelID, int lastLevelID) const
Teuchos::RCP< Teuchos::ParameterList > matvecParams_
MueLu::DefaultScalar Scalar
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:99
Teuchos::Array< int > nullspaceToPrint_
Lists of entities to be exported (or saved)
std::map< std::string, Teuchos::Array< int > > matricesToPrint_
Array< RCP< FactoryManagerBase > > levelManagers_
void ExportDataSetKeepFlags(Hierarchy &H, const Teuchos::Array< int > &data, const std::string &name) const
bool suppressNullspaceDimensionCheck_
Flag to indicate whether the check of the nullspace dimension is suppressed.
void describe(Teuchos::FancyOStream &out, const VerbLevel verbLevel=Default) const
Print the Hierarchy with some verbosity level to a FancyOStream object.
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)
virtual void SetupExtra(Hierarchy &) const
Setup extra data.
void SetPRrebalance(bool doPRrebalance)
int graphOutputLevel_
-2 = no output, -1 = all levels
void SetMatvecParams(RCP< ParameterList > matvecParams)
void ExportDataSetKeepFlagsAll(Hierarchy &H, const std::string &name) const
Teuchos::Array< int > aggregatesToPrint_
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.
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"))
Constructor.
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)
std::string description() const
Return a simple one-line description of this object.
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.
void EnableGraphDumping(const std::string &filename, int levelID=1)
Provides methods to build a multigrid hierarchy and apply multigrid cycles.