46 #ifndef MUELU_LEVEL_HPP
47 #define MUELU_LEVEL_HPP
55 #include <Teuchos_Describable.hpp>
56 #include <Teuchos_FancyOStream.hpp>
61 #include <Xpetra_Map.hpp>
68 #include "MueLu_Utilities.hpp"
168 map_[factory][ename]->SetData(entry);
171 GetOStream(
Warnings1) <<
"Level::Set: unable to store \"" << ename <<
"\" generated by factory " << factory->ShortClassName() <<
"["<<factory->GetID()<<
"]"
172 <<
"(" << factory <<
")"
173 <<
" on level " <<
toString(
GetLevelID()) <<
", as it has not been requested and no keep flags were set for it" << std::endl;
201 "\"" << ename <<
"\" has not been requested (counter = " <<
NumRequests(fac, ename) <<
", "
202 "KeepFlag = " <<
GetKeepFlag(ename, fac) <<
"). " << std::endl <<
203 "Generating factory:" << *fac <<
" NoFactory = " <<
NoFactory::get());
209 "\"" << ename <<
"\" has not been generated by " << *fac);
211 return map_[fac][ename]->template GetData<T>();
217 rValue = Get<T>(ename, factory);
232 "\"" << ename <<
"\" generated by " << *fac <<
" is not available.");
234 return map_[fac][ename]->GetTypeName();
261 if (!
IsKey(factory, ename))
334 if (!
IsKey(factory, ename))
337 return Get(factory, ename)->IsAvailable();
345 if (!
IsKey(factory, ename))
366 #if defined(HAVE_MUELU_BOOST) && defined(HAVE_MUELU_BOOST_FOR_REAL) && defined(BOOST_VERSION) && (BOOST_VERSION >= 104400)
367 void UpdateGraph(std::map<const FactoryBase*, BoostVertex>& vindices,
368 std::map<std::pair<BoostVertex, BoostVertex>, std::string>& edges,
370 BoostGraph& graph)
const;
416 typedef const std::string
Key2;
431 TwoKeyMap::const_iterator it =
map_.find(factory);
432 return (it !=
map_.end()) ? (it->second).count(ename) :
false;
436 TwoKeyMap::const_iterator it =
map_.find(factory);
437 if (it ==
map_.end())
439 for (SubMap::const_iterator sit = it->second.begin(); sit != it->second.end(); sit++) {
440 if (sit->second->IsAvailable())
448 "Internal logic error: if counter == 0, the entry in countTable_ should have been deleted");
449 return v->IsRequested();
453 if (!
IsKey(factory, ename))
461 "Internal logic error: if counter == 0, the entry in countTable_ should have been deleted");
462 return v->IsRequested(requestedBy);
466 TwoKeyMap::const_iterator it =
map_.find(factory);
467 if (it ==
map_.end())
469 for (SubMap::const_iterator sit = it->second.begin(); sit != it->second.end(); sit++)
476 TwoKeyMap::const_iterator it =
map_.find(factory);
479 SubMap::const_iterator sit = it->second.find(ename);
489 "NumRequests(): Internal logic error: if counter == 0, the entry in countTable_ should have been deleted");
494 TwoKeyMap::const_iterator it =
map_.find(factory);
495 if (it ==
map_.end())
499 for (SubMap::const_iterator sit = it->second.begin(); sit != it->second.end(); sit++)
500 cnt += sit->second->NumAllRequests();
513 #endif // MUELU_LEVEL_HPP
void Keep(const std::string &ename, const FactoryBase *factory)
Request to keep variable 'ename' generated by 'factory' after the setup phase.
RCP< Level > & GetPreviousLevel()
Previous level.
RCP< const Teuchos::Comm< int > > comm_
KeepType GetKeepFlag(const std::string &ename, const FactoryBase *factory) const
Get the flag combination set for variable 'ename' generated by 'factory'.
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access). Usage: Level->Get< RCP<Matrix> >("A", factory) if factory == NULL => use default factory.
virtual void CallBuild(Level &requestedLevel) const =0
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
bool IsKept(const std::string &ename, const FactoryBase *factory, KeepType keep) const
void DeclareDependencies(const FactoryBase *factory, bool bRequestOnly=false, bool bReleaseOnly=false)
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput() to declare factory depe...
bool IsRequested(const Value &v) const
void Release(const FactoryBase &factory)
Decrement the storage counter for all the inputs of a factory.
Xpetra::UnderlyingLib lib_
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
KeepType GetKeepFlag() const
Returns the keep flag combination.
RCP< Level > previousLevel_
User data are always kept. This flag is set automatically when Level::Set("data", data) is used...
void SetPreviousLevel(const RCP< Level > &previousLevel)
void SetFactoryManager(const RCP< const FactoryManagerBase > &factoryManager)
Set default factories (used internally by Hierarchy::SetLevel()).
int CountRequestedFactory(const FactoryBase *factory) const
static const NoFactory * get()
void setlib(Xpetra::UnderlyingLib lib2)
RequestMode GetRequestMode() const
const Value & Get(const FactoryBase *factory, const std::string &ename) const
Base class for factories (e.g., R, P, and A_coarse).
void Clear()
Delete all data that have been retained after the setup phase using Final flag.
bool IsRequestedBy(const FactoryBase *factory, const std::string &ename, const FactoryBase *requestedBy) const
const FactoryBase * GetFactory(const std::string &varname, const FactoryBase *factory) const
If input factory == NULL, returns the default factory. Else, return input factory.
bool IsRequestedBy(const Value &v, const FactoryBase *requestedBy) const
Class that holds all level-specific information.
Level(RCP< FactoryManagerBase > &factoryManager)
static RequestMode requestMode_
void Delete(const std::string &ename, const FactoryBase *factory)
Delete data that have been retained after the setup phase (using Keep(), AddKeepFlag(), or internal MueLu logic).
int levelID_
Map of a map (Key1 -> SubMap)
std::string GetTypeName(const std::string &ename, const FactoryBase *factory=NoFactory::get())
GetTypeName returns type string of variable stored using ename and factory.
void RemoveKeepFlag(const std::string &ename, const FactoryBase *factory, KeepType keep=MueLu::All)
std::string description() const
Return a simple one-line description of this object.
Xpetra::UnderlyingLib lib()
Always keep data, even accross run. This flag is set by Level::Keep(). This flag is propagated to coa...
virtual ~Level()
Destructor.
int NumRequests(const FactoryBase *factory, const std::string &ename) const
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
bool IsAvailableFactory(const FactoryBase *factory) const
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
Base class for MueLu classes.
void print(std::ostream &out, const VerbLevel verbLevel=Default) const
Printing method.
Teuchos::map< Key1, SubMap > TwoKeyMap
Sub-map container (Key2 -> Value)
void SetLevelID(int levelID)
Set level number.
RCP< const FactoryManagerBase > factoryManager_
bool IsRequestedFactory(const FactoryBase *factory) const
Teuchos::map< Key2, Value > SubMap
const RCP< const FactoryManagerBase > GetFactoryManager()
returns the current factory manager
int GetLevelID() const
Return level number.
Exception throws to report errors in the internal logical of the program.
void SetComm(RCP< const Teuchos::Comm< int > > const &comm)
bool IsRequested(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need has been requested. Note: this tells nothing about whether the need's value exist...
bool IsKey(const FactoryBase *factory, const std::string &ename) const
Test whether some information about (ename, factory) are stored.
int NumAllRequests() const
Returns the number of times the data has been requested.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
RCP< const Teuchos::Comm< int > > GetComm() const
void Get(const std::string &ename, T &rValue, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access).
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
void Request(const FactoryBase &factory)
Increment the storage counter for all the inputs of a factory.
RCP< VariableContainer > Value