47 #ifndef PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_Simple_DEF_HPP_
48 #define PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_Simple_DEF_HPP_
60 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
65 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
70 std::string defaultString =
71 "<ParameterList name=\"Input\">"
72 "<Parameter name=\"MueLu preconditioner\" type=\"string\" value=\"undefined\"/>"
73 "<Parameter name=\"Block 1: dofs per node\" type=\"int\" value=\"1\"/>"
74 "<Parameter name=\"Block 2: dofs per node\" type=\"int\" value=\"1\"/>"
75 "<Parameter name=\"Block 1: smoother\" type=\"string\" value=\"Symmetric Gauss-Seidel\"/>"
76 "<Parameter name=\"Block 1: level-of-fill\" type=\"int\" value=\"0\"/>"
77 "<Parameter name=\"Block 1: relaxation: sweeps\" type=\"int\" value=\"1\"/>"
78 "<Parameter name=\"Block 1: relaxation: damping factor\" type=\"double\" value=\"1.0\"/>"
79 "<Parameter name=\"Block 1: transfer smoothing\" type=\"bool\" value=\"true\"/>"
80 "<Parameter name=\"Block 2: smoother\" type=\"string\" value=\"Symmetric Gauss-Seidel\"/>"
81 "<Parameter name=\"Block 2: level-of-fill\" type=\"int\" value=\"0\"/>"
82 "<Parameter name=\"Block 2: relaxation: sweeps\" type=\"int\" value=\"1\"/>"
83 "<Parameter name=\"Block 2: relaxation: damping factor\" type=\"double\" value=\"1.0\"/>"
84 "<Parameter name=\"Block 2: transfer smoothing\" type=\"bool\" value=\"true\"/>"
85 "<Parameter name=\"Simple: damping factor\" type=\"double\" value=\"1.0\"/>"
86 "<Parameter name=\"max levels\" type=\"int\" value=\"5\"/>"
87 "<Parameter name=\"coarse: max size\" type=\"int\" value=\"25000\"/>"
88 "<Parameter name=\"verbosity\" type=\"string\" value=\"High\"/>"
99 std::string finalString =
101 "<ParameterList name=\"MueLu\">"
102 " <ParameterList name=\"Factories\">"
103 " <ParameterList name=\"mySubBlockAFactory1\">"
104 " <Parameter name=\"factory\" type=\"string\" value=\"SubBlockAFactory\"/>"
105 " <Parameter name=\"block row\" type=\"int\" value=\"0\"/>"
106 " <Parameter name=\"block col\" type=\"int\" value=\"0\"/>"
107 " <Parameter name=\"Range map: Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
108 " <Parameter name=\"Domain map: Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
111 " <ParameterList name=\"myAggFact1\">"
112 " <Parameter name=\"factory\" type=\"string\" value=\"UncoupledAggregationFactory\"/>"
113 " <Parameter name=\"aggregation: min agg size\" type=\"int\" value=\"5\"/>"
114 " <Parameter name=\"aggregation: max selected neighbors\" type=\"int\" value=\"1\"/>"
117 " <!-- tell the tentative prolongator that we have 2 DOFs per node on the coarse levels -->"
118 " <ParameterList name=\"myCoarseMap1\">"
119 " <Parameter name=\"factory\" type=\"string\" value=\"CoarseMapFactory\"/>"
120 " <Parameter name=\"Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
121 " <Parameter name=\"Strided block id\" type=\"int\" value=\"-1\"/>"
124 " <ParameterList name=\"myTentativePFact1\">"
125 " <Parameter name=\"factory\" type=\"string\" value=\"TentativePFactory\"/>"
126 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
127 " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
128 " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap1\"/>"
131 " <ParameterList name=\"myPFact1\">"
132 " <Parameter name=\"factory\" type=\"string\" value=\"PgPFactory\"/>"
133 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
134 " <Parameter name=\"P\" type=\"string\" value=\"myTentativePFact1\"/>"
137 " <ParameterList name=\"myRFact1\">"
138 " <Parameter name=\"factory\" type=\"string\" value=\"GenericRFactory\"/>"
139 " <Parameter name=\"P\" type=\"string\" value=\"myPFact1\"/>"
142 " <!-- We have to use Nullspace1 here. If \"Nullspace1\" is not set the"
143 " Factory creates the default null space containing of constant"
145 " <ParameterList name=\"myNspFact1\">"
146 " <Parameter name=\"factory\" type=\"string\" value=\"NullspaceFactory\"/>"
147 " <Parameter name=\"Fine level nullspace\" type=\"string\" value=\"Nullspace1\"/>"
148 " <Parameter name=\"Nullspace1\" type=\"string\" value=\"myTentativePFact1\"/>"
151 " <!-- BLOCK 2 (for submatrix A_{11}) PRESSURE PART -->"
152 " <ParameterList name=\"mySubBlockAFactory2\">"
153 " <Parameter name=\"factory\" type=\"string\" value=\"SubBlockAFactory\"/>"
154 " <Parameter name=\"block row\" type=\"int\" value=\"1\"/>"
155 " <Parameter name=\"block col\" type=\"int\" value=\"1\"/>"
156 " <Parameter name=\"Range map: Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
157 " <Parameter name=\"Domain map: Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
160 " <!-- tell the tentative prolongator that we have 2 DOFs per node on the coarse levels -->"
161 " <ParameterList name=\"myCoarseMap2\">"
162 " <Parameter name=\"factory\" type=\"string\" value=\"CoarseMapFactory\"/>"
163 " <Parameter name=\"Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
164 " <Parameter name=\"Strided block id\" type=\"int\" value=\"-1\"/>"
167 " <ParameterList name=\"myTentativePFact2\">"
168 " <Parameter name=\"factory\" type=\"string\" value=\"TentativePFactory\"/>"
169 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
170 " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
171 " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap2\"/>"
174 " <ParameterList name=\"myPFact2\">"
175 " <Parameter name=\"factory\" type=\"string\" value=\"SaPFactory\"/>"
176 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
177 " <Parameter name=\"P\" type=\"string\" value=\"myTentativePFact2\"/>"
180 " <ParameterList name=\"myRFact2\">"
181 " <Parameter name=\"factory\" type=\"string\" value=\"TransPFactory\"/>"
182 " <Parameter name=\"P\" type=\"string\" value=\"myPFact2\"/>"
185 " <ParameterList name=\"myNspFact2\">"
186 " <Parameter name=\"factory\" type=\"string\" value=\"NullspaceFactory\"/>"
187 " <Parameter name=\"Fine level nullspace\" type=\"string\" value=\"Nullspace2\"/>"
188 " <Parameter name=\"Nullspace2\" type=\"string\" value=\"myTentativePFact2\"/>"
191 " <!-- FACTORY MANAGERS -->"
193 " <!-- Multigrid setup for velocity block (A_{00}) -->"
194 " <ParameterList name=\"myFirstGroup\">"
195 " <Parameter name=\"group\" type=\"string\" value=\"FactoryManager\"/>"
196 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
197 " <Parameter name=\"P\" type=\"string\" value=\"myPFact1\"/>"
198 " <Parameter name=\"R\" type=\"string\" value=\"myRFact1\"/>"
199 " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
200 " <Parameter name=\"Nullspace\" type=\"string\" value=\"myNspFact1\"/>"
201 " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap1\"/>"
204 " <!-- Multigrid setup for pressure block (A_{11}) -->"
205 " <ParameterList name=\"mySecondGroup\">"
206 " <Parameter name=\"group\" type=\"string\" value=\"FactoryManager\"/>"
207 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
208 " <Parameter name=\"P\" type=\"string\" value=\"myPFact2\"/>"
209 " <Parameter name=\"R\" type=\"string\" value=\"myRFact2\"/>"
210 " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/><!-- reuse aggs from PRESSURE block! -->"
211 " <Parameter name=\"Nullspace\" type=\"string\" value=\"myNspFact2\"/>"
212 " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap2\"/>"
215 " <!-- BLOCK TRANSFER operators -->"
217 " <ParameterList name=\"myBlockedPFact\">"
218 " <Parameter name=\"factory\" type=\"string\" value=\"BlockedPFactory\"/>"
219 " <!-- factory manager for block 1 -->"
220 " <ParameterList name=\"block1\">"
221 " <Parameter name=\"group\" type=\"string\" value=\"myFirstGroup\"/>"
223 " <!-- factory manager for block 2 -->"
224 " <ParameterList name=\"block2\">"
225 " <Parameter name=\"group\" type=\"string\" value=\"mySecondGroup\"/>"
229 " <ParameterList name=\"myBlockedRFact\">"
230 " <Parameter name=\"factory\" type=\"string\" value=\"GenericRFactory\"/>"
231 " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
234 " <ParameterList name=\"myBlockedRAPFact\">"
235 " <Parameter name=\"factory\" type=\"string\" value=\"BlockedRAPFactory\"/>"
236 " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
237 " <Parameter name=\"R\" type=\"string\" value=\"myBlockedRFact\"/>"
240 " <!-- BLOCK SMOOTHERS -->"
241 " <ParameterList name=\"mySmooFact1\">"
242 " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
243 " <Parameter name=\"type\" type=\"string\" value=\"RELAXATION\"/>"
244 " <ParameterList name=\"ParameterList\">"
245 " <Parameter name=\"relaxation: type\" type=\"string\" value=\"XXXBlock 1: relaxation: typeYYY\"/>"
246 " <Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"XXXBlock 1: relaxation: sweepsYYY\"/>"
247 " <Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"XXXBlock 1: relaxation: damping factorYYY\"/>"
251 " <ParameterList name=\"mySmooILUFact1\">"
252 " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
253 " <Parameter name=\"type\" type=\"string\" value=\"ILU\"/>"
254 " <ParameterList name=\"ParameterList\">"
255 " <Parameter name=\"fact: level-of-fill\" type=\"int\" value=\"XXXBlock 1: level-of-fillYYY\"/>"
259 " <ParameterList name=\"mySmooDirectFact1\">"
260 " <Parameter name=\"factory\" type=\"string\" value=\"DirectSolver\"/>"
263 " <ParameterList name=\"mySmooFact2\">"
264 " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
265 " <Parameter name=\"type\" type=\"string\" value=\"RELAXATION\"/>"
266 " <ParameterList name=\"ParameterList\">"
267 " <Parameter name=\"relaxation: type\" type=\"string\" value=\"XXXBlock 2: relaxation: typeYYY\"/>"
268 " <Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"XXXBlock 2: relaxation: sweepsYYY\"/>"
269 " <Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"XXXBlock 2: relaxation: damping factorYYY\"/>"
273 " <ParameterList name=\"mySmooILUFact2\">"
274 " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
275 " <Parameter name=\"type\" type=\"string\" value=\"ILU\"/>"
276 " <ParameterList name=\"ParameterList\">"
277 " <Parameter name=\"fact: level-of-fill\" type=\"int\" value=\"XXXBlock 2: level-of-fillYYY\"/>"
281 " <ParameterList name=\"mySmooDirectFact2\">"
282 " <Parameter name=\"factory\" type=\"string\" value=\"DirectSolver\"/>"
285 " <ParameterList name=\"myNSSchurCompFact\">"
286 " <Parameter name=\"factory\" type=\"string\" value=\"SchurComplementFactory\"/>"
287 " <Parameter name=\"omega\" type=\"double\" value=\"1.0\"/>"
288 " <Parameter name=\"lumping\" type=\"bool\" value=\"false\"/>"
291 " <ParameterList name=\"myBlockSmoother\">"
292 " <Parameter name=\"factory\" type=\"string\" value=\"SimpleSmoother\"/>"
293 " <Parameter name=\"Sweeps\" type=\"int\" value=\"1\"/>"
294 " <Parameter name=\"Damping factor\" type=\"double\" value=\"XXXSimple: damping factorYYY\"/>"
295 " <!-- factory manager for block 1 -->"
296 " <ParameterList name=\"block1\">"
297 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
298 " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother1XYZ\"/>"
300 " <!-- factory manager for block 2 -->"
301 " <ParameterList name=\"block2\">"
302 " <Parameter name=\"A\" type=\"string\" value=\"myNSSchurCompFact\"/>"
303 " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother2XYZ\"/>"
308 " <!-- end Factories -->"
310 " <!-- Definition of the multigrid preconditioner -->"
311 " <ParameterList name=\"Hierarchy\">"
313 " <Parameter name=\"max levels\" type=\"int\" value=\"XXXmax levelsYYY\"/>"
314 " <Parameter name=\"coarse: max size\" type=\"int\" value=\"XXXcoarse: max sizeYYY\"/>"
315 " <Parameter name=\"verbosity\" type=\"string\" value=\"XXXverbosityYYY\"/>"
317 " <ParameterList name=\"AllLevel\">"
318 " <Parameter name=\"startLevel\" type=\"int\" value=\"0\"/>"
319 " <Parameter name=\"Smoother\" type=\"string\" value=\"myBlockSmoother\"/>"
320 " <Parameter name=\"CoarseSolver\" type=\"string\" value=\"myBlockSmoother\"/>"
321 " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
322 " <Parameter name=\"R\" type=\"string\" value=\"myBlockedRFact\"/>"
323 " <Parameter name=\"A\" type=\"string\" value=\"myBlockedRAPFact\"/>"
333 std::string smoother1 = inputParameters.
get<std::string>(
"Block 1: smoother");
334 if(smoother1 ==
"ILU") {
335 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooILUFact1");
336 }
else if (smoother1 ==
"Symmetric Gauss-Seidel" || smoother1 ==
"SGS") {
337 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Symmetric Gauss-Seidel");
338 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
339 }
else if (smoother1 ==
"Symmetric Gauss-Seidel" || smoother1 ==
"GS") {
340 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Gauss-Seidel");
341 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
342 }
else if (smoother1 ==
"Jacobi") {
343 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Jacobi");
344 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
345 }
else if (smoother1 ==
"Direct") {
346 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooDirectFact1");
348 this->GetOStream(
Errors) <<
"Invalid smoother type for block 1: " << smoother1 <<
". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
351 std::string smoother2 = inputParameters.
get<std::string>(
"Block 2: smoother");
352 if(smoother2 ==
"ILU") {
353 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooILUFact2");
354 }
else if (smoother2 ==
"Symmetric Gauss-Seidel" || smoother2 ==
"SGS") {
355 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Symmetric Gauss-Seidel");
356 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
357 }
else if (smoother2 ==
"Symmetric Gauss-Seidel" || smoother2 ==
"GS") {
358 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Gauss-Seidel");
359 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
360 }
else if (smoother2 ==
"Jacobi") {
361 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Jacobi");
362 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
363 }
else if (smoother2 ==
"Direct") {
364 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooDirectFact2");
366 this->GetOStream(
Errors) <<
"Invalid smoother type for block 2: " << smoother2 <<
". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
369 if(inputParameters.
get<
bool>(
"Block 1: transfer smoothing") ==
true) {
370 this->ReplaceString(finalString,
"XXXBlock 1: prolongatorYYY",
"myPFact1");
371 this->ReplaceString(finalString,
"XXXBlock 1: restrictor YYY",
"myRFact1");
373 this->ReplaceString(finalString,
"XXXBlock 1: prolongatorYYY",
"myTentativePFact1");
374 this->ReplaceString(finalString,
"XXXBlock 1: restrictor YYY",
"myTransPFact1");
376 if(inputParameters.
get<
bool>(
"Block 2: transfer smoothing") ==
true) {
377 this->ReplaceString(finalString,
"XXXBlock 2: prolongatorYYY",
"myPFact2");
378 this->ReplaceString(finalString,
"XXXBlock 2: restrictor YYY",
"myRFact2");
380 this->ReplaceString(finalString,
"XXXBlock 2: prolongatorYYY",
"myTentativePFact2");
381 this->ReplaceString(finalString,
"XXXBlock 2: restrictor YYY",
"myTransPFact2");
389 std::string par_name = inputParameters.
name(it);
390 std::stringstream ss;
391 ss <<
"XXX" << par_name <<
"YYY";
395 this->ReplaceString(finalString,
404 #endif // PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_Simple_DEF_HPP_
Teuchos::RCP< Teuchos::ParameterList > SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameter list for FacadeClass interpreter.
const std::string & name() const
FacadeSimple()
Constructor.
ConstIterator end() const
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
params_t::ConstIterator ConstIterator
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
ConstIterator begin() const
const ParameterEntry & entry(ConstIterator i) const
any & getAny(bool activeQry=true)
Exception throws to report errors in the internal logical of the program.
std::string toString(const T &t)