MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_HierarchyUtils_def.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef MUELU_HIERARCHYUTILS_DEF_HPP
11#define MUELU_HIERARCHYUTILS_DEF_HPP
12
13#include "Teuchos_ScalarTraits.hpp"
14
15#include <Xpetra_Matrix.hpp>
16#include <Xpetra_Operator.hpp>
17
20#include "MueLu_FactoryManager.hpp"
21
22// TODO/FIXME: DeclareInput(, **this**) cannot be used here
23#ifdef HAVE_MUELU_INTREPID2
24#include "Kokkos_DynRankView.hpp"
25#endif
26
27namespace MueLu {
28
29// Copy object from one hierarchy to another calling AddNewLevel as appropriate.
30template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
31void HierarchyUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::CopyBetweenHierarchies(Hierarchy& fromHierarchy, Hierarchy& toHierarchy, const std::string fromLabel, const std::string toLabel, const std::string dataType) {
32 // add any necessary levels
33 for (int i = toHierarchy.GetNumLevels(); i < fromHierarchy.GetNumLevels(); i++)
34 toHierarchy.AddNewLevel();
35
36 for (int i = 0; i < fromHierarchy.GetNumLevels(); i++) {
37 RCP<Level> fromLevel = fromHierarchy.GetLevel(i);
38 RCP<Level> toLevel = toHierarchy.GetLevel(i);
39
40 TEUCHOS_TEST_FOR_EXCEPTION(dataType != "RCP<Matrix>" && dataType != "RCP<const Import>", Exceptions::InvalidArgument,
41 std::string("MueLu::Utils::CopyBetweenHierarchies: unknown data type(") + dataType + ")");
42 if (fromLevel->IsAvailable(fromLabel)) {
43 if (dataType == "RCP<Matrix>") {
44 // Normally, we should only do
45 // toLevel->Set(toLabel,fromLevel->Get<RCP<Matrix> >(fromLabel));
46 // The logic below is meant to handle a special case when we
47 // repartition a processor away, leaving behind a RCP<Operator> on
48 // on the level instead of an RCP<Matrix>
49
50 auto tempOp = fromLevel->Get<RCP<Operator>>(fromLabel);
51 auto tempMatrix = rcp_dynamic_cast<Matrix>(tempOp);
52 if (!tempMatrix.is_null())
53 toLevel->Set(toLabel, tempMatrix);
54 else
55 toLevel->Set(toLabel, tempOp);
56 }
57 if (dataType == "RCP<const Import>") {
58 toLevel->Set(toLabel, fromLevel->Get<RCP<const Import>>(fromLabel));
59 }
60 }
61 }
62}
63
64// Adds the following non-serializable data (A,P,R,Nullspace,Coordinates) from level-specific sublist nonSerialList,
65// calling AddNewLevel as appropriate.
66template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
68 typedef typename Xpetra::MultiVector<typename Teuchos::ScalarTraits<Scalar>::coordinateType,
70 realvaluedmultivector_type;
71
72 for (ParameterList::ConstIterator nonSerialEntry = nonSerialList.begin(); nonSerialEntry != nonSerialList.end(); nonSerialEntry++) {
73 const std::string& levelName = nonSerialEntry->first;
74 // Check for match of the form "level X" where X is a positive integer
75 if (nonSerialList.isSublist(levelName) && levelName.find("level ") == 0 && levelName.size() > 6) {
76 int levelID = strtol(levelName.substr(6).c_str(), 0, 0);
77 if (levelID > 0) {
78 // Do enough level adding so we can be sure to add the data to the right place
79 for (int i = H.GetNumLevels(); i <= levelID; i++)
80 H.AddNewLevel();
81 }
82 RCP<Level> level = H.GetLevel(levelID);
83
84 RCP<FactoryManager> M = Teuchos::rcp_dynamic_cast<FactoryManager>(HM.GetFactoryManager(levelID));
85 TEUCHOS_TEST_FOR_EXCEPTION(M.is_null(), Exceptions::InvalidArgument, "MueLu::Utils::AddNonSerializableDataToHierarchy: cannot get FactoryManager");
86
87 // Grab the level sublist & loop over parameters
88 const ParameterList& levelList = nonSerialList.sublist(levelName);
89 for (ParameterList::ConstIterator levelListEntry = levelList.begin(); levelListEntry != levelList.end(); levelListEntry++) {
90 const std::string& name = levelListEntry->first;
91 TEUCHOS_TEST_FOR_EXCEPTION(name != "A" && name != "P" && name != "R" && name != "K" && name != "M" && name != "Mdiag" &&
92 name != "D0" && name != "Dk_1" && name != "Dk_2" &&
93 name != "Mk_one" && name != "Mk_1_one" && name != "M1_beta" && name != "M1_alpha" &&
94 name != "invMk_1_invBeta" && name != "invMk_2_invAlpha" &&
95 name != "M1" && name != "Ms" && name != "M0inv" &&
96 name != "Pnodal" && name != "NodeMatrix" && name != "NodeAggMatrix" &&
97 name != "Nullspace" && name != "Coordinates" && name != "pcoarsen: element to node map" &&
98 name != "Node Comm" && name != "DualNodeID2PrimalNodeID" && name != "Primal interface DOF map" &&
99 name != "dropMap1" && name != "dropMap2" &&
102 std::string("MueLu::Utils::AddNonSerializableDataToHierarchy: parameter list contains unknown data type(") + name + ")");
103
104 // Get a valid communicator and lib
105 RCP<const Teuchos::Comm<int>> comm;
106 if (!level->GetComm().is_null())
107 comm = level->GetComm();
108 else if (level->IsAvailable("A")) {
109 RCP<Matrix> mat;
110 level->Get("A", mat);
111 comm = mat->getMap()->getComm();
112 } else {
113 RCP<Level> level0 = H.GetLevel(0);
114 if (!level0->GetComm().is_null())
115 comm = level0->GetComm();
116 else {
117 RCP<Matrix> mat;
118 level0->Get("A", mat);
119 comm = mat->getMap()->getComm();
120 }
121 }
122 Xpetra::UnderlyingLib lib = level->lib();
123
124 if (name == "A") {
125 RCP<Matrix> mat;
126 if (levelListEntry->second.isType<std::string>())
127 // We might also want to read maps here.
128 mat = Xpetra::IO<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Read(Teuchos::getValue<std::string>(levelListEntry->second), lib, comm);
129 else
130 mat = Teuchos::getValue<RCP<Matrix>>(levelListEntry->second);
131 level->Set(name, mat, NoFactory::get());
132 M->SetFactory(name, NoFactory::getRCP()); // TAW: not sure about this: be aware that this affects all levels
133 // However, A is accessible through NoFactory anyway, so it should
134 // be fine here.
135 } else if (name == "P" || name == "R" || name == "K" || name == "M") {
136 if (levelListEntry->second.isType<RCP<Operator>>()) {
137 RCP<Operator> mat;
138 mat = Teuchos::getValue<RCP<Operator>>(levelListEntry->second);
139
140 RCP<const FactoryBase> fact = M->GetFactory(name);
141 level->AddKeepFlag(name, fact.get(), MueLu::UserData);
142 level->Set(name, mat, fact.get());
143
144 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
145 level->Set(name, mat, NoFactory::get());
146 } else {
147 RCP<Matrix> mat;
148 if (levelListEntry->second.isType<std::string>())
149 // We might also want to read maps here.
150 mat = Xpetra::IO<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Read(Teuchos::getValue<std::string>(levelListEntry->second), lib, comm);
151 else
152 mat = Teuchos::getValue<RCP<Matrix>>(levelListEntry->second);
153
154 RCP<const FactoryBase> fact = M->GetFactory(name);
155 level->AddKeepFlag(name, fact.get(), MueLu::UserData);
156 level->Set(name, mat, fact.get());
157
158 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
159 level->Set(name, mat, NoFactory::get());
160 }
161 } else if (name == "D0" || name == "Dk_1" || name == "Dk_2" ||
162 name == "Mk_one" || name == "Mk_1_one" || name == "M1_beta" || name == "M1_alpha" ||
163 name == "invMk_1_invBeta" || name == "invMk_2_invAlpha" ||
164 name == "M1" || name == "Ms" || name == "M0inv" ||
165 name == "Pnodal" || name == "NodeMatrix" || name == "NodeAggMatrix") {
166 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
167 if (levelListEntry->second.isType<RCP<Operator>>())
168 level->Set(name, Teuchos::getValue<RCP<Operator>>(levelListEntry->second), NoFactory::get());
169 else
170 level->Set(name, Teuchos::getValue<RCP<Matrix>>(levelListEntry->second), NoFactory::get());
171 } else if (name == "Mdiag") {
172 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
173 level->Set(name, Teuchos::getValue<RCP<Vector>>(levelListEntry->second), NoFactory::get());
174 } else if (name == "Nullspace") {
175 RCP<MultiVector> vec;
176 if (levelListEntry->second.isType<std::string>()) {
177 TEUCHOS_ASSERT(level->IsAvailable("A"));
178 RCP<Matrix> mat;
179 level->Get("A", mat);
180 auto map = mat->getMap();
181 vec = Xpetra::IO<Scalar, LocalOrdinal, GlobalOrdinal, Node>::ReadMultiVector(Teuchos::getValue<std::string>(levelListEntry->second), map);
182 } else
183 vec = Teuchos::getValue<RCP<MultiVector>>(levelListEntry->second);
184 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
185 level->Set(name, vec, NoFactory::get());
186 // M->SetFactory(name, NoFactory::getRCP()); // TAW: generally it is a bad idea to overwrite the factory manager data here
187 // One should do this only in very special cases
188 } else if (name == "Material") {
189 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
190 level->Set(name, Teuchos::getValue<RCP<MultiVector>>(levelListEntry->second), NoFactory::get());
191 } else if (name == "Coordinates") // Scalar of Coordinates MV is always double
192 {
193 RCP<realvaluedmultivector_type> vec;
194 if (levelListEntry->second.isType<std::string>()) {
195 TEUCHOS_ASSERT(level->IsAvailable("A"));
196 RCP<Matrix> mat;
197 level->Get("A", mat);
198 size_t blkSize = mat->GetFixedBlockSize();
199 RCP<const Map> nodeMap = mat->getRowMap();
200 if (blkSize > 1) {
201 // Create a nodal map, as coordinates have not been expanded to a DOF map yet.
202 RCP<const Map> dofMap = mat->getRowMap();
203 GO indexBase = dofMap->getIndexBase();
204 size_t numLocalDOFs = dofMap->getLocalNumElements();
205 TEUCHOS_TEST_FOR_EXCEPTION(numLocalDOFs % blkSize, Exceptions::RuntimeError,
206 "HierarchyUtils: block size (" << blkSize << ") is incompatible with the number of local dofs in a row map (" << numLocalDOFs);
207 ArrayView<const GO> GIDs = dofMap->getLocalElementList();
208
209 Array<GO> nodeGIDs(numLocalDOFs / blkSize);
210 for (size_t i = 0; i < numLocalDOFs; i += blkSize)
211 nodeGIDs[i / blkSize] = (GIDs[i] - indexBase) / blkSize + indexBase;
212
213 Xpetra::global_size_t INVALID = Teuchos::OrdinalTraits<Xpetra::global_size_t>::invalid();
214 nodeMap = MapFactory::Build(dofMap->lib(), INVALID, nodeGIDs(), indexBase, dofMap->getComm());
215 }
216 vec = Xpetra::IO<typename Teuchos::ScalarTraits<Scalar>::coordinateType, LocalOrdinal, GlobalOrdinal, Node>::ReadMultiVector(Teuchos::getValue<std::string>(levelListEntry->second), nodeMap);
217 } else
218 vec = Teuchos::getValue<RCP<realvaluedmultivector_type>>(levelListEntry->second);
219 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
220 level->Set(name, vec, NoFactory::get());
221 // M->SetFactory(name, NoFactory::getRCP()); // TAW: generally it is a bad idea to overwrite the factory manager data here
222 } else if (name == "Node Comm") {
223 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
224 level->Set(name, Teuchos::getValue<RCP<const Teuchos::Comm<int>>>(levelListEntry->second), NoFactory::get());
225 } else if (name == "DualNodeID2PrimalNodeID") {
226 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
227 level->Set(name, Teuchos::getValue<RCP<std::map<LO, LO>>>(levelListEntry->second), NoFactory::get());
228 } else if (name == "Primal interface DOF map") {
229 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
230 level->Set(name, Teuchos::getValue<RCP<const Map>>(levelListEntry->second), NoFactory::get());
231 } else if (name == "dropMap1") {
232 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
233 level->Set(name, Teuchos::getValue<RCP<const Map>>(levelListEntry->second), NoFactory::get());
234 } else if (name == "dropMap2") {
235 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
236 level->Set(name, Teuchos::getValue<RCP<const Map>>(levelListEntry->second), NoFactory::get());
237 }
238#ifdef HAVE_MUELU_INTREPID2
239 else if (name == "pcoarsen: element to node map") {
240 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
241 level->Set(name, Teuchos::getValue<RCP<Kokkos::DynRankView<LocalOrdinal, typename Node::device_type>>>(levelListEntry->second), NoFactory::get());
242 }
243#endif
244 else
245#ifdef HAVE_MUELU_MATLAB
246 {
247 // Custom variable for Muemex
248 size_t typeNameStart = name.find_first_not_of(' ');
249 size_t typeNameEnd = name.find(' ', typeNameStart);
250 std::string typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
251 std::transform(typeName.begin(), typeName.end(), typeName.begin(), ::tolower);
252 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
253 if (typeName == "matrix")
254 level->Set(name, Teuchos::getValue<RCP<Matrix>>(levelListEntry->second), NoFactory::get());
255 else if (typeName == "multivector")
256 level->Set(name, Teuchos::getValue<RCP<MultiVector>>(levelListEntry->second), NoFactory::get());
257 else if (typeName == "map")
258 level->Set(name, Teuchos::getValue<RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>>(levelListEntry->second), NoFactory::get());
259 else if (typeName == "ordinalvector")
260 level->Set(name, Teuchos::getValue<RCP<Xpetra::Vector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>>>(levelListEntry->second), NoFactory::get());
261 else if (typeName == "scalar")
262 level->Set(name, Teuchos::getValue<Scalar>(levelListEntry->second), NoFactory::get());
263 else if (typeName == "double")
264 level->Set(name, Teuchos::getValue<double>(levelListEntry->second), NoFactory::get());
265 else if (typeName == "complex")
266 level->Set(name, Teuchos::getValue<std::complex<double>>(levelListEntry->second), NoFactory::get());
267 else if (typeName == "int")
268 level->Set(name, Teuchos::getValue<int>(levelListEntry->second), NoFactory::get());
269 else if (typeName == "string")
270 level->Set(name, Teuchos::getValue<std::string>(levelListEntry->second), NoFactory::get());
271 }
272#else
273 {
274 throw std::runtime_error("Invalid non-serializable data on list");
275 }
276#endif
277 }
278 } else if (nonSerialList.isSublist(levelName) && levelName.find("user data") != std::string::npos) {
279 // So far only put data on level 0
280 int levelID = 0;
281 RCP<Level> level = H.GetLevel(levelID);
282
283 RCP<FactoryManager> M = Teuchos::rcp_dynamic_cast<FactoryManager>(HM.GetFactoryManager(levelID));
284 TEUCHOS_TEST_FOR_EXCEPTION(M.is_null(), Exceptions::InvalidArgument, "MueLu::Utils::AddNonSerializableDataToHierarchy: cannot get FactoryManager");
285
286 // Grab the user data sublist & loop over parameters
287 const ParameterList& userList = nonSerialList.sublist(levelName);
288 for (ParameterList::ConstIterator userListEntry = userList.begin(); userListEntry != userList.end(); userListEntry++) {
289 const std::string& name = userListEntry->first;
290 TEUCHOS_TEST_FOR_EXCEPTION(name != "P" && name != "R" && name != "K" && name != "M" && name != "Mdiag" &&
291 name != "D0" && name != "Dk_1" && name != "Dk_2" &&
292 name != "Mk_one" && name != "Mk_1_one" && name != "M1_beta" && name != "M1_alpha" &&
293 name != "invMk_1_invBeta" && name != "invMk_2_invAlpha" &&
294 name != "M1" && name != "Ms" && name != "M0inv" &&
295 name != "NodeMatrix" &&
296 name != "Nullspace" && name != "Coordinates" && name != "Material" &&
297 name != "pcoarsen: element to node map" &&
298 name != "Node Comm" && name != "DualNodeID2PrimalNodeID" && name != "Primal interface DOF map" &&
299 name != "dropMap1" && name != "dropMap2" &&
300 name != "output stream" &&
303 std::string("MueLu::Utils::AddNonSerializableDataToHierarchy: user data parameter list contains unknown data type (") + name + ")");
304 if (name == "P" || name == "R" || name == "K" || name == "M" ||
305 name == "D0" || name == "Dk_1" || name == "Dk_2" ||
306 name == "Mk_one" || name == "Mk_1_one" || name == "M1_beta" || name == "M1_alpha" ||
307 name == "invMk_1_invBeta" || name == "invMk_2_invAlpha" ||
308 name == "M1" || name == "Ms" || name == "M0inv" ||
309 name == "NodeMatrix") {
310 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
311 level->Set(name, Teuchos::getValue<RCP<Matrix>>(userListEntry->second), NoFactory::get());
312 } else if (name == "Mdiag") {
313 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
314 level->Set(name, Teuchos::getValue<RCP<Vector>>(userListEntry->second), NoFactory::get());
315 } else if (name == "Nullspace") {
316 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
317 level->Set(name, Teuchos::getValue<RCP<MultiVector>>(userListEntry->second), NoFactory::get());
318 // M->SetFactory(name, NoFactory::getRCP()); // TAW: generally it is a bad idea to overwrite the factory manager data here
319 // One should do this only in very special cases
320 } else if (name == "Material") {
321 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
322 level->Set(name, Teuchos::getValue<RCP<MultiVector>>(userListEntry->second), NoFactory::get());
323 } else if (name == "Coordinates") { // Scalar of Coordinates MV is always double
324 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
325 level->Set(name, Teuchos::getValue<RCP<realvaluedmultivector_type>>(userListEntry->second), NoFactory::get());
326 } else if (name == "Node Comm") {
327 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
328 level->Set(name, Teuchos::getValue<RCP<const Teuchos::Comm<int>>>(userListEntry->second), NoFactory::get());
329 } else if (name == "DualNodeID2PrimalNodeID") {
330 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
331 level->Set(name, Teuchos::getValue<RCP<std::map<LO, LO>>>(userListEntry->second), NoFactory::get());
332 } else if (name == "Primal interface DOF map") {
333 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
334 level->Set(name, Teuchos::getValue<RCP<const Map>>(userListEntry->second), NoFactory::get());
335 } else if (name == "dropMap1") {
336 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
337 level->Set(name, Teuchos::getValue<RCP<const Map>>(userListEntry->second), NoFactory::get());
338 } else if (name == "dropMap2") {
339 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
340 level->Set(name, Teuchos::getValue<RCP<const Map>>(userListEntry->second), NoFactory::get());
341 }
342#ifdef HAVE_MUELU_INTREPID2
343 else if (name == "pcoarsen: element to node map") {
344 level->AddKeepFlag(name, NoFactory::get(), MueLu::UserData);
345 level->Set(name, Teuchos::getValue<RCP<Kokkos::DynRankView<LocalOrdinal, typename Node::device_type>>>(userListEntry->second), NoFactory::get());
346 }
347#endif
348 else if (name == "output stream") {
349 H.SetMueLuOStream(Teuchos::getValue<RCP<Teuchos::FancyOStream>>(userListEntry->second));
350 } else {
351 // Custom variable
352 size_t typeNameStart = name.find_first_not_of(' ');
353 size_t typeNameEnd = name.find(' ', typeNameStart);
354 std::string typeName = name.substr(typeNameStart, typeNameEnd - typeNameStart);
355 size_t varNameStart = name.find_first_not_of(' ', typeNameEnd);
356 std::string varName = name.substr(varNameStart, name.size());
357 std::transform(typeName.begin(), typeName.end(), typeName.begin(), ::tolower);
358 level->AddKeepFlag(varName, NoFactory::get(), MueLu::UserData);
359 if (typeName == "matrix")
360 level->Set(varName, Teuchos::getValue<RCP<Matrix>>(userListEntry->second), NoFactory::get());
361 else if (typeName == "multivector")
362 level->Set(varName, Teuchos::getValue<RCP<MultiVector>>(userListEntry->second), NoFactory::get());
363 else if (typeName == "vector")
364 level->Set(varName, Teuchos::getValue<RCP<Vector>>(userListEntry->second), NoFactory::get());
365 else if (typeName == "map")
366 level->Set(varName, Teuchos::getValue<RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>>(userListEntry->second), NoFactory::get());
367 else if (typeName == "ordinalvector")
368 level->Set(varName, Teuchos::getValue<RCP<Xpetra::Vector<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>>>(userListEntry->second), NoFactory::get());
369 else if (typeName == "scalar")
370 level->Set(varName, Teuchos::getValue<Scalar>(userListEntry->second), NoFactory::get());
371 else if (typeName == "double")
372 level->Set(varName, Teuchos::getValue<double>(userListEntry->second), NoFactory::get());
373 else if (typeName == "complex")
374 level->Set(varName, Teuchos::getValue<std::complex<double>>(userListEntry->second), NoFactory::get());
375 else if (typeName == "int")
376 level->Set(varName, Teuchos::getValue<int>(userListEntry->second), NoFactory::get());
377 else if (typeName == "string")
378 level->Set(varName, Teuchos::getValue<std::string>(userListEntry->second), NoFactory::get());
379 else if (typeName == "array<go>")
380 level->Set(varName, Teuchos::getValue<Array<GlobalOrdinal>>(userListEntry->second), NoFactory::get());
381 else if (typeName == "array<lo>")
382 level->Set(varName, Teuchos::getValue<Array<LocalOrdinal>>(userListEntry->second), NoFactory::get());
383 else if (typeName == "arrayrcp<lo>")
384 level->Set(varName, Teuchos::getValue<ArrayRCP<LocalOrdinal>>(userListEntry->second), NoFactory::get());
385 else if (typeName == "arrayrcp<go>")
386 level->Set(varName, Teuchos::getValue<ArrayRCP<GlobalOrdinal>>(userListEntry->second), NoFactory::get());
387 else
388 throw std::runtime_error("Invalid non-serializable data on list");
389 }
390 }
391 // level->print(std::cout, MueLu::Debug);
392 }
393 }
394}
395} // namespace MueLu
396
397#define MUELU_HIERARCHY_UTILS_SHORT
398#endif // MUELU_HIERARCHYHELPERS_DEF_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
Exception throws to report invalid user entry.
Exception throws to report errors in the internal logical of the program.
RCP< FactoryManagerBase > GetFactoryManager(int levelID) const
static void AddNonSerializableDataToHierarchy(HierarchyManager &HM, Hierarchy &H, const ParameterList &nonSerialList)
Add non-serializable data to Hierarchy.
static void CopyBetweenHierarchies(Hierarchy &fromHierarchy, Hierarchy &toHierarchy, const std::string fromLabel, const std::string toLabel, const std::string dataType)
Provides methods to build a multigrid hierarchy and apply multigrid cycles.
RCP< Level > & GetLevel(const int levelID=0)
Retrieve a certain level from hierarchy.
void AddNewLevel()
Add a new level at the end of the hierarchy.
static const RCP< const NoFactory > getRCP()
Static Get() functions.
static const NoFactory * get()
static void SetMueLuOStream(const Teuchos::RCP< Teuchos::FancyOStream > &mueluOStream)
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
@ UserData
User data are always kept. This flag is set automatically when Level::Set("data", data) is used....
bool IsParamValidVariable(const std::string &name)