47 #ifndef PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_BGS2x2_DEF_HPP_
48 #define PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_BGS2x2_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=\"BGS: 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=\"myBlockSmoother\">"
286 " <Parameter name=\"factory\" type=\"string\" value=\"BlockedGaussSeidelSmoother\"/>"
287 " <Parameter name=\"Sweeps\" type=\"int\" value=\"1\"/>"
288 " <Parameter name=\"Damping factor\" type=\"double\" value=\"XXXBGS: damping factorYYY\"/>"
289 " <!-- factory manager for block 1 -->"
290 " <ParameterList name=\"block1\">"
291 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
292 " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother1XYZ\"/>"
294 " <!-- factory manager for block 2 -->"
295 " <ParameterList name=\"block2\">"
296 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
297 " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother2XYZ\"/>"
302 " <!-- end Factories -->"
304 " <!-- Definition of the multigrid preconditioner -->"
305 " <ParameterList name=\"Hierarchy\">"
307 " <Parameter name=\"max levels\" type=\"int\" value=\"XXXmax levelsYYY\"/>"
308 " <Parameter name=\"coarse: max size\" type=\"int\" value=\"XXXcoarse: max sizeYYY\"/>"
309 " <Parameter name=\"verbosity\" type=\"string\" value=\"XXXverbosityYYY\"/>"
311 " <ParameterList name=\"AllLevel\">"
312 " <Parameter name=\"startLevel\" type=\"int\" value=\"0\"/>"
313 " <Parameter name=\"Smoother\" type=\"string\" value=\"myBlockSmoother\"/>"
314 " <Parameter name=\"CoarseSolver\" type=\"string\" value=\"myBlockSmoother\"/>"
315 " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
316 " <Parameter name=\"R\" type=\"string\" value=\"myBlockedRFact\"/>"
317 " <Parameter name=\"A\" type=\"string\" value=\"myBlockedRAPFact\"/>"
327 std::string smoother1 = inputParameters.
get<std::string>(
"Block 1: smoother");
328 if(smoother1 ==
"ILU") {
329 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooILUFact1");
330 }
else if (smoother1 ==
"Symmetric Gauss-Seidel" || smoother1 ==
"SGS") {
331 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Symmetric Gauss-Seidel");
332 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
333 }
else if (smoother1 ==
"Symmetric Gauss-Seidel" || smoother1 ==
"GS") {
334 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Gauss-Seidel");
335 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
336 }
else if (smoother1 ==
"Jacobi") {
337 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Jacobi");
338 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
339 }
else if (smoother1 ==
"Direct") {
340 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooDirectFact1");
342 this->GetOStream(
Errors) <<
"Invalid smoother type for block 1: " << smoother1 <<
". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
345 std::string smoother2 = inputParameters.
get<std::string>(
"Block 2: smoother");
346 if(smoother2 ==
"ILU") {
347 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooILUFact2");
348 }
else if (smoother2 ==
"Symmetric Gauss-Seidel" || smoother2 ==
"SGS") {
349 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Symmetric Gauss-Seidel");
350 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
351 }
else if (smoother2 ==
"Symmetric Gauss-Seidel" || smoother2 ==
"GS") {
352 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Gauss-Seidel");
353 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
354 }
else if (smoother2 ==
"Jacobi") {
355 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Gauss-Seidel");
356 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
357 }
else if (smoother2 ==
"Direct") {
358 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooDirectFact2");
360 this->GetOStream(
Errors) <<
"Invalid smoother type for block 2: " << smoother2 <<
". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
363 if(inputParameters.
get<
bool>(
"Block 1: transfer smoothing") ==
true) {
364 this->ReplaceString(finalString,
"XXXBlock 1: prolongatorYYY",
"myPFact1");
365 this->ReplaceString(finalString,
"XXXBlock 1: restrictor YYY",
"myRFact1");
367 this->ReplaceString(finalString,
"XXXBlock 1: prolongatorYYY",
"myTentativePFact1");
368 this->ReplaceString(finalString,
"XXXBlock 1: restrictor YYY",
"myTransPFact1");
370 if(inputParameters.
get<
bool>(
"Block 2: transfer smoothing") ==
true) {
371 this->ReplaceString(finalString,
"XXXBlock 2: prolongatorYYY",
"myPFact2");
372 this->ReplaceString(finalString,
"XXXBlock 2: restrictor YYY",
"myRFact2");
374 this->ReplaceString(finalString,
"XXXBlock 2: prolongatorYYY",
"myTentativePFact2");
375 this->ReplaceString(finalString,
"XXXBlock 2: restrictor YYY",
"myTransPFact2");
383 std::string par_name = inputParameters.
name(it);
384 std::stringstream ss;
385 ss <<
"XXX" << par_name <<
"YYY";
389 this->ReplaceString(finalString,
398 #endif // PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_BGS2x2_DEF_HPP_
const std::string & name() const
ConstIterator end() const
FacadeBGS2x2()
Constructor.
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)
Teuchos::RCP< Teuchos::ParameterList > SetParameterList(const Teuchos::ParameterList ¶mList)
Set parameter list for FacadeClass interpreter.
Exception throws to report errors in the internal logical of the program.
std::string toString(const T &t)