46 #ifndef MUELU_HIERARCHYUTILS_DEF_HPP
47 #define MUELU_HIERARCHYUTILS_DEF_HPP
57 #include "MueLu_SmootherFactory.hpp"
58 #include "MueLu_FactoryManager.hpp"
61 #ifdef HAVE_MUELU_INTREPID2
70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
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" &&
97 name !=
"Node Comm" &&
99 std::string(
"MueLu::Utils::AddNonSerializableDataToHierarchy: parameter list contains unknown data type(") + name +
")");
107 else if(name ==
"P" || name ==
"R" || name ==
"K" || name ==
"M") {
111 else if (name ==
"Mdiag")
116 else if (name ==
"Nullspace")
123 else if(name ==
"Coordinates")
129 else if(name ==
"Node Comm")
135 #ifdef HAVE_MUELU_INTREPID2
136 else if (name ==
"pcoarsen: element to node map")
139 level->
Set(name, Teuchos::getValue<
RCP<Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> > >(it2->second),
NoFactory::get());
143 #ifdef HAVE_MUELU_MATLAB
146 size_t typeNameStart = name.find_first_not_of(
' ');
147 size_t typeNameEnd = name.find(
' ', typeNameStart);
148 std::string
typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
149 std::transform(typeName.begin(), typeName.end(), typeName.begin(),
::tolower);
151 if(typeName ==
"matrix")
153 else if(typeName ==
"multivector")
155 else if(typeName ==
"map")
157 else if(typeName ==
"ordinalvector")
159 else if(typeName ==
"scalar")
161 else if(typeName ==
"double")
163 else if(typeName ==
"complex")
164 level->
Set(name, Teuchos::getValue<std::complex<double> >(it2->second),
NoFactory::get());
165 else if(typeName ==
"int")
167 else if(typeName ==
"string")
172 throw std::runtime_error(
"Invalid non-serializable data on list");
176 }
else if (paramList.
isSublist(levelName) && levelName.find(
"user data") != std::string::npos) {
187 const std::string& name = it2->first;
189 name !=
"Nullspace" && name !=
"Coordinates" && name !=
"pcoarsen: element to node map" &&
190 name !=
"Node Comm" &&
192 std::string(
"MueLu::Utils::AddNonSerializableDataToHierarchy: user data parameter list contains unknown data type (") + name +
")");
193 if( name ==
"P" || name ==
"R" || name ==
"K" || name ==
"M") {
196 }
else if (name ==
"Mdiag") {
199 }
else if (name ==
"Nullspace") {
204 }
else if(name ==
"Coordinates") {
209 else if(name ==
"Node Comm") {
213 #ifdef HAVE_MUELU_INTREPID2
214 else if (name ==
"pcoarsen: element to node map")
217 level->
Set(name, Teuchos::getValue<
RCP<Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> > >(it2->second),
NoFactory::get());
222 size_t typeNameStart = name.find_first_not_of(
' ');
223 size_t typeNameEnd = name.find(
' ', typeNameStart);
224 std::string
typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
225 size_t varNameStart = name.find_first_not_of(
' ', typeNameEnd);
226 std::string varName = name.substr(varNameStart, name.size());
227 std::transform(typeName.begin(), typeName.end(), typeName.begin(),
::tolower);
229 if(typeName ==
"matrix")
231 else if(typeName ==
"multivector")
233 else if(typeName ==
"vector")
235 else if(typeName ==
"map")
237 else if(typeName ==
"ordinalvector")
239 else if(typeName ==
"scalar")
241 else if(typeName ==
"double")
243 else if(typeName ==
"complex")
244 level->
Set(varName, Teuchos::getValue<std::complex<double> >(it2->second),
NoFactory::get());
245 else if(typeName ==
"int")
247 else if(typeName ==
"string")
248 level->
Set(varName, Teuchos::getValue<std::string>(it2->second),
NoFactory::get());
249 else if(typeName ==
"array<go>")
251 else if(typeName ==
"array<lo>")
253 else if(typeName ==
"arrayrcp<lo>")
255 else if(typeName ==
"arrayrcp<go>")
258 throw std::runtime_error(
"Invalid non-serializable data on list");
266 #define MUELU_HIERARCHY_UTILS_SHORT
267 #endif // MUELU_HIERARCHYHELPERS_DEF_HPP
This class specifies the default factory that should generate some data on a Level if the data does n...
ConstIterator end() const
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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)
bool IsParamMuemexVariable(const std::string &name)
static const NoFactory * get()
bool isSublist(const std::string &name) const
params_t::ConstIterator ConstIterator
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
void AddKeepFlag(const std::string &ename, const FactoryBase *factory=NoFactory::get(), KeepType keep=MueLu::Keep)
ConstIterator begin() const
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.
void print(std::ostream &out, const VerbLevel verbLevel=Default) const
Printing method.
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.