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
70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 typedef typename Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::coordinateType,
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" && name !=
"DualNodeID2PrimalNodeID" &&
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")
134 else if(name ==
"DualNodeID2PrimalNodeID")
139 #ifdef HAVE_MUELU_INTREPID2
140 else if (name ==
"pcoarsen: element to node map")
143 level->
Set(name, Teuchos::getValue<
RCP<Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> > >(it2->second),
NoFactory::get());
147 #ifdef HAVE_MUELU_MATLAB
150 size_t typeNameStart = name.find_first_not_of(
' ');
151 size_t typeNameEnd = name.find(
' ', typeNameStart);
152 std::string
typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
153 std::transform(typeName.begin(), typeName.end(), typeName.begin(),
::tolower);
155 if(typeName ==
"matrix")
157 else if(typeName ==
"multivector")
159 else if(typeName ==
"map")
160 level->
Set(name, Teuchos::getValue<
RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
161 else if(typeName ==
"ordinalvector")
162 level->
Set(name, Teuchos::getValue<
RCP<Xpetra::Vector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
163 else if(typeName ==
"scalar")
165 else if(typeName ==
"double")
167 else if(typeName ==
"complex")
168 level->
Set(name, Teuchos::getValue<std::complex<double> >(it2->second),
NoFactory::get());
169 else if(typeName ==
"int")
171 else if(typeName ==
"string")
176 throw std::runtime_error(
"Invalid non-serializable data on list");
180 }
else if (paramList.
isSublist(levelName) && levelName.find(
"user data") != std::string::npos) {
191 const std::string& name = it2->first;
193 name !=
"Nullspace" && name !=
"Coordinates" && name !=
"pcoarsen: element to node map" &&
194 name !=
"Node Comm" && name !=
"DualNodeID2PrimalNodeID" &&
195 name !=
"output stream" &&
197 std::string(
"MueLu::Utils::AddNonSerializableDataToHierarchy: user data parameter list contains unknown data type (") + name +
")");
198 if( name ==
"P" || name ==
"R" || name ==
"K" || name ==
"M") {
201 }
else if (name ==
"Mdiag") {
204 }
else if (name ==
"Nullspace") {
209 }
else if(name ==
"Coordinates") {
214 else if(name ==
"Node Comm") {
218 else if(name ==
"DualNodeID2PrimalNodeID")
223 #ifdef HAVE_MUELU_INTREPID2
224 else if (name ==
"pcoarsen: element to node map")
227 level->
Set(name, Teuchos::getValue<
RCP<Kokkos::DynRankView<LocalOrdinal,typename Node::device_type> > >(it2->second),
NoFactory::get());
230 else if (name ==
"output stream")
236 size_t typeNameStart = name.find_first_not_of(
' ');
237 size_t typeNameEnd = name.find(
' ', typeNameStart);
238 std::string
typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
239 size_t varNameStart = name.find_first_not_of(
' ', typeNameEnd);
240 std::string varName = name.substr(varNameStart, name.size());
241 std::transform(typeName.begin(), typeName.end(), typeName.begin(),
::tolower);
243 if(typeName ==
"matrix")
245 else if(typeName ==
"multivector")
247 else if(typeName ==
"vector")
249 else if(typeName ==
"map")
250 level->
Set(varName, Teuchos::getValue<
RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
251 else if(typeName ==
"ordinalvector")
252 level->
Set(varName, Teuchos::getValue<
RCP<Xpetra::Vector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
253 else if(typeName ==
"scalar")
255 else if(typeName ==
"double")
257 else if(typeName ==
"complex")
258 level->
Set(varName, Teuchos::getValue<std::complex<double> >(it2->second),
NoFactory::get());
259 else if(typeName ==
"int")
261 else if(typeName ==
"string")
262 level->
Set(varName, Teuchos::getValue<std::string>(it2->second),
NoFactory::get());
263 else if(typeName ==
"array<go>")
265 else if(typeName ==
"array<lo>")
267 else if(typeName ==
"arrayrcp<lo>")
269 else if(typeName ==
"arrayrcp<go>")
272 throw std::runtime_error(
"Invalid non-serializable data on list");
280 #define MUELU_HIERARCHY_UTILS_SHORT
281 #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
MueLu::DefaultLocalOrdinal LocalOrdinal
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
Add non-serializable data to Hierarchy.
#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()
MueLu::DefaultGlobalOrdinal GlobalOrdinal
bool isSublist(const std::string &name) const
params_t::ConstIterator ConstIterator
static void SetMueLuOStream(const Teuchos::RCP< Teuchos::FancyOStream > &mueluOStream)
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.