46 #ifndef MUELU_HIERARCHYUTILS_DEF_HPP 47 #define MUELU_HIERARCHYUTILS_DEF_HPP 51 #include <Xpetra_Matrix.hpp> 52 #include <Xpetra_Operator.hpp> 57 #include "MueLu_SmootherFactory.hpp" 58 #include "MueLu_FactoryManager.hpp" 61 #ifdef HAVE_MUELU_INTREPID2 62 #include "Kokkos_DynRankView.hpp" 70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 typedef typename Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::magnitudeType,
73 LocalOrdinal, GlobalOrdinal, Node> realvaluedmultivector_type;
76 const std::string& levelName = it->first;
78 if (paramList.
isSublist(levelName) && levelName.find(
"level ") == 0 && levelName.size() > 6) {
79 int levelID = strtol(levelName.substr(6).c_str(), 0, 0);
94 const std::string& name = it2->first;
96 name !=
"Nullspace" && name !=
"Coordinates" && name !=
"pcoarsen: element to node map" &&
98 "MueLu::Utils::AddNonSerializableDataToHierarchy: parameter list contains unknown data type");
106 else if(name ==
"P" || name ==
"R" || name ==
"K" || name ==
"M") {
110 else if (name ==
"Nullspace")
117 else if(name ==
"Coordinates")
123 #ifdef HAVE_MUELU_INTREPID2 124 else if (name ==
"pcoarsen: element to node map")
127 level->
Set(name, Teuchos::getValue<
RCP<Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> > >(it2->second),
NoFactory::get());
131 #ifdef HAVE_MUELU_MATLAB 134 size_t typeNameStart = name.find_first_not_of(
' ');
135 size_t typeNameEnd = name.find(
' ', typeNameStart);
136 std::string
typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
144 level->
Set(name, Teuchos::getValue<
RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
145 else if(
typeName ==
"ordinalvector")
146 level->
Set(name, Teuchos::getValue<
RCP<Xpetra::Vector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
152 level->
Set(name, Teuchos::getValue<std::complex<double> >(it2->second),
NoFactory::get());
160 throw std::runtime_error(
"Invalid non-serializable data on list");
164 }
else if (paramList.
isSublist(levelName) && levelName.find(
"user data") != std::string::npos) {
175 const std::string& name = it2->first;
177 name !=
"Nullspace" && name !=
"Coordinates" &&
179 "MueLu::Utils::AddNonSerializableDataToHierarchy: user data parameter list contains unknown data type!");
180 if( name ==
"P" || name ==
"R") {
183 }
else if (name ==
"Nullspace") {
188 }
else if(name ==
"Coordinates") {
195 size_t typeNameStart = name.find_first_not_of(
' ');
196 size_t typeNameEnd = name.find(
' ', typeNameStart);
197 std::string
typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
198 size_t varNameStart = name.find_first_not_of(
' ', typeNameEnd);
199 std::string varName = name.substr(varNameStart, name.size());
207 level->
Set(varName, Teuchos::getValue<
RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
208 else if(
typeName ==
"ordinalvector")
209 level->
Set(varName, Teuchos::getValue<
RCP<Xpetra::Vector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
215 level->
Set(varName, Teuchos::getValue<std::complex<double> >(it2->second),
NoFactory::get());
219 level->
Set(varName, Teuchos::getValue<std::string>(it2->second),
NoFactory::get());
229 throw std::runtime_error(
"Invalid non-serializable data on list");
237 #define MUELU_HIERARCHY_UTILS_SHORT 238 #endif // MUELU_HIERARCHYHELPERS_DEF_HPP This class specifies the default factory that should generate some data on a Level if the data does n...
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
ConstIterator begin() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
bool isSublist(const std::string &name) const
void AddNewLevel()
Add a new level at the end of the hierarchy.
User data are always kept. This flag is set automatically when Level::Set("data", data) is used...
std::string tolower(const std::string &str)
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
static const NoFactory * get()
ConstIterator end() const
params_t::ConstIterator ConstIterator
void print(std::ostream &out, const VerbLevel verbLevel=Default) const
Printing method.
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
bool IsParamValidVariable(const std::string &name)
void Set(const std::string &ename, const T &entry, const FactoryBase *factory=NoFactory::get())
void SetFactory(const std::string &varName, const RCP< const FactoryBase > &factory)
Set Factory.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
std::string typeName(const T &t)
Exception throws to report invalid user entry.
static const RCP< const NoFactory > getRCP()
Static Get() functions.