46 #ifndef MUELU_LEVEL_HPP
47 #define MUELU_LEVEL_HPP
55 #include <Teuchos_Describable.hpp>
56 #include <Teuchos_FancyOStream.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
172 <<
" on level " <<
toString(
GetLevelID()) <<
", as it has not been requested and no keep flags were set for it" << std::endl;
200 "\"" << ename <<
"\" has not been requested (counter = " <<
NumRequests(fac, ename) <<
", "
201 "KeepFlag = " <<
GetKeepFlag(ename, fac) <<
"). " << std::endl <<
202 "Generating factory:" << *fac <<
" NoFactory = " <<
NoFactory::get());
208 "\"" << ename <<
"\" has not been generated by " << *fac);
210 return map_[fac][ename]->template GetData<T>();
216 rValue = Get<T>(ename, factory);
231 "\"" << ename <<
"\" generated by " << *fac <<
" is not available.");
233 return map_[fac][ename]->GetTypeName();
260 if (!
IsKey(factory, ename))
333 if (!
IsKey(factory, ename))
336 return Get(factory, ename)->IsAvailable();
344 if (!
IsKey(factory, ename))
365 #if defined(HAVE_MUELU_BOOST) && defined(HAVE_MUELU_BOOST_FOR_REAL) && defined(BOOST_VERSION) && (BOOST_VERSION >= 104400)
366 void UpdateGraph(std::map<const FactoryBase*, BoostVertex>& vindices,
367 std::map<std::pair<BoostVertex, BoostVertex>, std::string>& edges,
369 BoostGraph& graph)
const;
415 typedef const std::string
Key2;
430 TwoKeyMap::const_iterator it =
map_.find(factory);
431 return (it !=
map_.end()) ? (it->second).count(ename) :
false;
435 TwoKeyMap::const_iterator it =
map_.find(factory);
436 if (it ==
map_.end())
438 for (SubMap::const_iterator sit = it->second.begin(); sit != it->second.end(); sit++) {
439 if (sit->second->IsAvailable())
447 "Internal logic error: if counter == 0, the entry in countTable_ should have been deleted");
448 return v->IsRequested();
452 if (!
IsKey(factory, ename))
460 "Internal logic error: if counter == 0, the entry in countTable_ should have been deleted");
461 return v->IsRequested(requestedBy);
465 TwoKeyMap::const_iterator it =
map_.find(factory);
466 if (it ==
map_.end())
468 for (SubMap::const_iterator sit = it->second.begin(); sit != it->second.end(); sit++)
475 TwoKeyMap::const_iterator it =
map_.find(factory);
478 SubMap::const_iterator sit = it->second.find(ename);
488 "NumRequests(): Internal logic error: if counter == 0, the entry in countTable_ should have been deleted");
493 TwoKeyMap::const_iterator it =
map_.find(factory);
494 if (it ==
map_.end())
498 for (SubMap::const_iterator sit = it->second.begin(); sit != it->second.end(); sit++)
499 cnt += sit->second->NumAllRequests();
512 #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'.
Teuchos::FancyOStream & GetOStream(MsgType type, int thisProcRankOnly=0) const
Get an output stream for outputting the input message type.
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
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