MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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:
89  HierarchyManager(int numDesiredLevel = MasterList::getDefault<int>("max levels"))
90  : numDesiredLevel_(numDesiredLevel)
91  , maxCoarseSize_(MasterList::getDefault<int>("coarse: max size"))
93  , doPRrebalance_(MasterList::getDefault<bool>("repartition: rebalance P and R"))
94  , doPRViaCopyrebalance_(MasterList::getDefault<bool>("repartition: explicit via new copy 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"))
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 
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  std::stringstream msg;
156  msg << "User-provided nullspace has fewer vectors ("
157  << nullspace->getNumVectors() << ") than number of PDE equations ("
158  << A->GetFixedBlockSize() << "). ";
159 
161  msg << "It depends on the PDE, if this is a problem or not.";
162  this->GetOStream(Warnings0) << msg.str() << std::endl;
163  } else {
164  msg << "Add the missing nullspace vectors! (You can suppress this check. See the MueLu user guide for details.)";
165  TEUCHOS_TEST_FOR_EXCEPTION(static_cast<size_t>(A->GetFixedBlockSize()) > nullspace->getNumVectors(), Exceptions::RuntimeError, msg.str());
166  }
167  }
168  } else {
169  this->GetOStream(Warnings0) << "Skipping dimension check of user-supplied nullspace because user-supplied operator is not a matrix" << std::endl;
170  }
171  }
172 
173 #ifdef HAVE_MUELU_DEBUG
174  // Reset factories' data used for debugging
175  for (int i = 0; i < levelManagers_.size(); i++)
176  levelManagers_[i]->ResetDebugData();
177 
178 #endif
179 
180  // Setup Matrix
181  // TODO: I should certainly undo this somewhere...
182 
183  Xpetra::UnderlyingLib lib = Op->getDomainMap()->lib();
184  H.setlib(lib);
185 
186  SetupOperator(*Op);
187  SetupExtra(H);
188 
189  // Setup Hierarchy
192  if (graphOutputLevel_ >= 0 || graphOutputLevel_ == -1)
193  H.EnableGraphDumping("dep_graph", graphOutputLevel_);
194 
196  RCP<Matrix> Amat = rcp_dynamic_cast<Matrix>(Op);
197 
198  if (!Amat.is_null()) {
199  RCP<ParameterList> params = rcp(new ParameterList());
200  params->set("printLoadBalancingInfo", true);
201  params->set("printCommInfo", true);
202 
204  } else {
205  VerboseObject::GetOStream(Warnings1) << "Fine level operator is not a matrix, statistics are not available" << std::endl;
206  }
207  }
208 
213 
214  H.Clear();
215 
216  // There are few issues with using Keep in the interpreter:
217  // 1. Hierarchy::Keep interface takes a name and a factory. If
218  // factories are different on different levels, the AddNewLevel() call
219  // in Hierarchy does not work properly, as it assume that factories are
220  // the same.
221  // 2. FactoryManager does not have a Keep option, only Hierarchy and
222  // Level have it
223  // 3. Interpreter constructs factory managers, but not levels. So we
224  // cannot set up Keep flags there.
225  //
226  // The solution implemented here does the following:
227  // 1. Construct hierarchy with dummy levels. This avoids
228  // Hierarchy::AddNewLevel() calls which will propagate wrong
229  // inheritance.
230  // 2. Interpreter constructs keep_ array with names and factories for
231  // that level
232  // 3. For each level, we call Keep(name, factory) for each keep_
233  for (int i = 0; i < numDesiredLevel_; i++) {
234  std::map<int, std::vector<keep_pair>>::const_iterator it = keep_.find(i);
235  if (it != keep_.end()) {
236  RCP<Level> l = H.GetLevel(i);
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);
240  }
241  if (i < numDesiredLevel_ - 1) {
242  RCP<Level> newLevel = rcp(new Level());
243  H.AddLevel(newLevel);
244  }
245  }
246 
247  // Matrices to print
248  for (auto iter = matricesToPrint_.begin(); iter != matricesToPrint_.end(); iter++)
249  ExportDataSetKeepFlags(H, iter->second, iter->first);
250 
251  // Vectors, aggregates and other things that need special case handling
252  ExportDataSetKeepFlags(H, nullspaceToPrint_, "Nullspace");
253  ExportDataSetKeepFlags(H, coordinatesToPrint_, "Coordinates");
254  // NOTE: Aggregates use the next level's Factory
256 #ifdef HAVE_MUELU_INTREPID2
257  ExportDataSetKeepFlags(H, elementToNodeMapsToPrint_, "pcoarsen: element to node map");
258 #endif
259 
260  // Data to save only (these do not have a level, so we do all levels)
261  for (int i = 0; i < dataToSave_.size(); i++)
263 
264  int levelID = 0;
265  int lastLevelID = numDesiredLevel_ - 1;
266  bool isLastLevel = false;
267 
268  while (!isLastLevel) {
269  bool r = H.Setup(levelID,
270  LvlMngr(levelID - 1, lastLevelID),
271  LvlMngr(levelID, lastLevelID),
272  LvlMngr(levelID + 1, lastLevelID));
273  if (levelID < H.GetNumLevels())
274  H.GetLevel(levelID)->print(H.GetOStream(Developer), verbosity_);
275 
276  isLastLevel = r || (levelID == lastLevelID);
277  levelID++;
278  }
279  if (!matvecParams_.is_null())
282  // Set hierarchy description.
283  // This is cached, but involves and MPI_Allreduce.
284  H.description();
287 
288  // When we reuse hierarchy, it is necessary that we don't
289  // change the number of levels. We also cannot make requests
290  // for coarser levels, because we don't construct all the
291  // data on previous levels. For instance, let's say our first
292  // run constructed three levels. If we try to do requests during
293  // next setup for the fourth level, it would need Aggregates
294  // which we didn't construct for level 3 because we reused P.
295  // To fix this situation, we change the number of desired levels
296  // here.
297  numDesiredLevel_ = levelID;
298 
299  // Matrix prints
300  for (auto iter = matricesToPrint_.begin(); iter != matricesToPrint_.end(); iter++) {
301  WriteData<Matrix>(H, iter->second, iter->first);
302  }
303 
304  // Vectors, aggregates and all things we need to print manually
305  WriteData<MultiVector>(H, nullspaceToPrint_, "Nullspace");
306  WriteData<MultiVector>(H, coordinatesToPrint_, "Coordinates");
307  WriteDataAggregates(H, aggregatesToPrint_, "Aggregates");
308 
309 #ifdef HAVE_MUELU_INTREPID2
310  typedef Kokkos::DynRankView<LocalOrdinal, typename Node::device_type> FCi;
311  WriteDataFC<FCi>(H, elementToNodeMapsToPrint_, "pcoarsen: element to node map", "el2node");
312 #endif
313 
314  } // SetupHierarchy
315 
317 
318  typedef std::map<std::string, RCP<const FactoryBase>> FactoryMap;
319 
320  protected: // TODO: access function
322  virtual void SetupOperator(Operator& /* Op */) const {}
323 
325  // TODO: merge with SetupMatrix ?
326  virtual void SetupExtra(Hierarchy& /* H */) const {}
327 
328  // TODO this was private
329  // Used in SetupHierarchy() to access levelManagers_
330  // Inputs i=-1 and i=size() are allowed to simplify calls to hierarchy->Setup()
331  Teuchos::RCP<FactoryManagerBase> LvlMngr(int levelID, int lastLevelID) const {
332  // NOTE: the order of 'if' statements is important
333  if (levelID == -1) // levelID = -1 corresponds to the finest level
334  return Teuchos::null;
335 
336  if (levelID == lastLevelID + 1) // levelID = 'lastLevelID+1' corresponds to the last level (i.e., no nextLevel)
337  return Teuchos::null;
338 
339  if (levelManagers_.size() == 0) { // default factory manager.
340  // The default manager is shared across levels, initialized only if needed and deleted with the HierarchyManager
341  static RCP<FactoryManagerBase> defaultMngr = rcp(new FactoryManager());
342  return defaultMngr;
343  }
344 
345  return GetFactoryManager(levelID);
346  }
347 
350 
351  mutable int numDesiredLevel_;
354 
359 
367 
369 
372 
374  // Items here get handled manually
379 
380  // Data we'll need to save, not necessarily print
382 
383  // Matrices we'll need to print
384  std::map<std::string, Teuchos::Array<int>> matricesToPrint_;
385 
387 
388  std::map<int, std::vector<keep_pair>> keep_;
390 
391  private:
392  // Set the keep flags for Export Data
393  void ExportDataSetKeepFlags(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name) const {
394  for (int i = 0; i < data.size(); ++i) {
395  if (data[i] < H.GetNumLevels()) {
396  RCP<Level> L = H.GetLevel(data[i]);
397  if (!L.is_null() && data[i] < levelManagers_.size())
398  L->AddKeepFlag(name, &*levelManagers_[data[i]]->GetFactory(name));
399  }
400  }
401  }
402 
403  void ExportDataSetKeepFlagsNextLevel(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name) const {
404  for (int i = 0; i < data.size(); ++i) {
405  if (data[i] < H.GetNumLevels()) {
406  RCP<Level> L = H.GetLevel(data[i]);
407  if (!L.is_null() && data[i] + 1 < levelManagers_.size())
408  L->AddKeepFlag(name, &*levelManagers_[data[i] + 1]->GetFactory(name));
409  }
410  }
411  }
412 
413  // Set the keep flags for Export Data
414  void ExportDataSetKeepFlagsAll(Hierarchy& H, const std::string& name) const {
415  for (int i = 0; i < H.GetNumLevels(); i++) {
416  RCP<Level> L = H.GetLevel(i);
417  if (!L.is_null() && i < levelManagers_.size())
418  L->AddKeepFlag(name, &*levelManagers_[i]->GetFactory(name));
419  }
420  }
421 
422  template <class T>
423  void WriteData(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name) const {
424  for (int i = 0; i < data.size(); ++i) {
425  std::string fileName;
426  if (H.getObjectLabel() != "")
427  fileName = H.getObjectLabel() + "_" + name + "_" + Teuchos::toString(data[i]) + ".m";
428  else
429  fileName = name + "_" + Teuchos::toString(data[i]) + ".m";
430 
431  if (data[i] < H.GetNumLevels()) {
432  RCP<Level> L = H.GetLevel(data[i]);
433  if (data[i] < levelManagers_.size() && L->IsAvailable(name, &*levelManagers_[data[i]]->GetFactory(name))) {
434  // Try generating factory
435  RCP<T> M = L->template Get<RCP<T>>(name, &*levelManagers_[data[i]]->GetFactory(name));
436  if (!M.is_null()) {
438  }
439  } else if (L->IsAvailable(name)) {
440  // Try nofactory
441  RCP<T> M = L->template Get<RCP<T>>(name);
442  if (!M.is_null()) {
444  }
445  }
446  }
447  }
448  }
449 
450  void WriteDataAggregates(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name) const {
451  for (int i = 0; i < data.size(); ++i) {
452  const std::string fileName = name + "_" + Teuchos::toString(data[i]) + ".m";
453 
454  if (data[i] < H.GetNumLevels()) {
455  RCP<Level> L = H.GetLevel(data[i]);
456 
457  // NOTE: Aggregates use the next level's factory
458  RCP<Aggregates> agg;
459  if (data[i] + 1 < H.GetNumLevels() && L->IsAvailable(name, &*levelManagers_[data[i] + 1]->GetFactory(name))) {
460  // Try generating factory
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");
464  }
465  if (!agg.is_null()) {
466  std::ofstream ofs(fileName);
467  Teuchos::FancyOStream fofs(rcp(&ofs, false));
468  agg->print(fofs, Teuchos::VERB_EXTREME);
469  }
470  }
471  }
472  }
473 
474  template <class T>
475  void WriteDataFC(Hierarchy& H, const Teuchos::Array<int>& data, const std::string& name, const std::string& ofname) const {
476  for (int i = 0; i < data.size(); ++i) {
477  const std::string fileName = ofname + "_" + Teuchos::toString(data[i]) + ".m";
478 
479  if (data[i] < H.GetNumLevels()) {
480  RCP<Level> L = H.GetLevel(data[i]);
481 
482  if (L->IsAvailable(name)) {
483  RCP<T> M = L->template Get<RCP<T>>(name);
484  if (!M.is_null()) {
485  RCP<Matrix> A = L->template Get<RCP<Matrix>>("A");
486  RCP<const CrsGraph> AG = A->getCrsGraph();
487  WriteFieldContainer<T>(fileName, *M, *AG->getColMap());
488  }
489  }
490  }
491  }
492  }
493 
494  // For dumping an IntrepidPCoarsening element-to-node map to disk
495  template <class T>
496  void WriteFieldContainer(const std::string& fileName, T& fcont, const Map& colMap) const {
497  size_t num_els = (size_t)fcont.extent(0);
498  size_t num_vecs = (size_t)fcont.extent(1);
499 
500  // Generate rowMap
501  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());
502 
503  // Fill multivector to use *petra dump routines
505 
506  for (size_t j = 0; j < num_vecs; j++) {
507  Teuchos::ArrayRCP<GO> v = vec->getDataNonConst(j);
508  for (size_t i = 0; i < num_els; i++)
509  v[i] = colMap.getGlobalElement(fcont(i, j));
510  }
511 
512  Xpetra::IO<GO, LO, GO, NO>::Write(fileName, *vec);
513  }
514 
515  // Levels
516  Array<RCP<FactoryManagerBase>> levelManagers_; // one FactoryManager per level (the last levelManager is used for all the remaining levels)
517 
518 }; // class HierarchyManager
519 
520 } // namespace MueLu
521 
522 #define MUELU_HIERARCHYMANAGER_SHORT
523 #endif // MUELU_HIERARCHYMANAGER_HPP
524 
525 // TODO: split into _decl/_def
526 // TODO: default value for first param (FactoryManager()) should not be duplicated (code maintainability)
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
MueLu::DefaultNode Node
Static class that holds the complete list of valid MueLu parameters.
Teuchos::RCP< FactoryManagerBase > LvlMngr(int levelID, int lastLevelID) const
Print even more statistics.
Additional warnings.
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.
Definition: MueLu_Level.hpp:99
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
size_t global_size_t
void SetMatvecParams(RCP< ParameterList > matvecParams)
Teuchos::Array< int > aggregatesToPrint_
void SetPRViaCopyrebalance(bool doPRViaCopyrebalance)
TransListIter iter
virtual void SetupOperator(Operator &) const
Setup Matrix object.
void SetImplicitTranspose(const bool &implicit)
std::map< std::string, Teuchos::Array< int > > matricesToPrint_
size_type size() const
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)
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
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
bool is_null() const