46 #ifndef MUELU_HIERARCHYUTILS_DEF_HPP 47 #define MUELU_HIERARCHYUTILS_DEF_HPP 49 #include <Xpetra_Matrix.hpp> 50 #include <Xpetra_Operator.hpp> 55 #include "MueLu_SmootherFactory.hpp" 56 #include "MueLu_FactoryManager.hpp" 65 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 for (ParameterList::ConstIterator it = paramList.begin(); it != paramList.end(); it++) {
68 const std::string& levelName = it->first;
71 if (paramList.isSublist(levelName) && levelName.find(
"level ") == 0 && levelName.size() > 6) {
72 int levelID = strtol(levelName.substr(6).c_str(), 0, 0);
79 RCP<Level> level = H.
GetLevel(levelID);
82 TEUCHOS_TEST_FOR_EXCEPTION(M.is_null(),
Exceptions::InvalidArgument,
"MueLu::Utils::AddNonSerializableDataToHierarchy: cannot get FactoryManager");
85 const ParameterList& levelList = paramList.sublist(levelName);
86 for (ParameterList::ConstIterator it2 = levelList.begin(); it2 != levelList.end(); it2++) {
87 const std::string& name = it2->first;
88 TEUCHOS_TEST_FOR_EXCEPTION(name !=
"A" && name !=
"P" && name !=
"R" &&
89 name !=
"Nullspace" && name !=
"Coordinates" &&
91 "MueLu::Utils::AddNonSerializableDataToHierarchy: parameter list contains unknown data type");
94 level->Set(name, Teuchos::getValue<RCP<Matrix > > (it2->second),
NoFactory::get());
99 else if( name ==
"P" || name ==
"R") {
101 level->Set(name, Teuchos::getValue<RCP<Matrix > > (it2->second), M->GetFactory(name).get());
103 else if (name ==
"Nullspace")
106 level->Set(name, Teuchos::getValue<RCP<MultiVector > >(it2->second),
NoFactory::get());
110 else if(name ==
"Coordinates")
113 level->Set(name, Teuchos::getValue<RCP<Xpetra::MultiVector<double, LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
116 #ifdef HAVE_MUELU_MATLAB 120 size_t typeNameStart = name.find_first_not_of(
' ');
121 size_t typeNameEnd = name.find(
' ', typeNameStart);
122 std::string typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
123 std::transform(typeName.begin(), typeName.end(), typeName.begin(), ::tolower);
125 if(typeName ==
"matrix")
126 level->Set(name, Teuchos::getValue<RCP<Matrix> >(it2->second),
NoFactory::get());
127 else if(typeName ==
"multivector")
128 level->Set(name, Teuchos::getValue<RCP<MultiVector> >(it2->second),
NoFactory::get());
129 else if(typeName ==
"map")
130 level->Set(name, Teuchos::getValue<RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
131 else if(typeName ==
"ordinalvector")
132 level->Set(name, Teuchos::getValue<RCP<Xpetra::Vector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node> > >(it2->second),
NoFactory::get());
133 else if(typeName ==
"scalar")
134 level->Set(name, Teuchos::getValue<Scalar>(it2->second),
NoFactory::get());
135 else if(typeName ==
"double")
136 level->Set(name, Teuchos::getValue<double>(it2->second),
NoFactory::get());
137 else if(typeName ==
"complex")
138 level->Set(name, Teuchos::getValue<std::complex<double> >(it2->second),
NoFactory::get());
139 else if(typeName ==
"int")
140 level->Set(name, Teuchos::getValue<int>(it2->second),
NoFactory::get());
141 else if(typeName ==
"string")
142 level->Set(name, Teuchos::getValue<std::string>(it2->second),
NoFactory::get());
152 #define MUELU_HIERARCHY_UTILS_SHORT 153 #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)
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...
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
static const NoFactory * get()
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
Exception throws to report invalid user entry.
static const RCP< const NoFactory > getRCP()
Static Get() functions.