10 #ifndef PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_BGS2x2_DEF_HPP_
11 #define PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_BGS2x2_DEF_HPP_
22 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
26 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
30 std::string defaultString =
31 "<ParameterList name=\"Input\">"
32 "<Parameter name=\"MueLu preconditioner\" type=\"string\" value=\"undefined\"/>"
33 "<Parameter name=\"Block 1: dofs per node\" type=\"int\" value=\"1\"/>"
34 "<Parameter name=\"Block 2: dofs per node\" type=\"int\" value=\"1\"/>"
35 "<Parameter name=\"Block 1: smoother\" type=\"string\" value=\"Symmetric Gauss-Seidel\"/>"
36 "<Parameter name=\"Block 1: level-of-fill\" type=\"int\" value=\"0\"/>"
37 "<Parameter name=\"Block 1: relaxation: sweeps\" type=\"int\" value=\"1\"/>"
38 "<Parameter name=\"Block 1: relaxation: damping factor\" type=\"double\" value=\"1.0\"/>"
39 "<Parameter name=\"Block 1: transfer smoothing\" type=\"bool\" value=\"true\"/>"
40 "<Parameter name=\"Block 2: smoother\" type=\"string\" value=\"Symmetric Gauss-Seidel\"/>"
41 "<Parameter name=\"Block 2: level-of-fill\" type=\"int\" value=\"0\"/>"
42 "<Parameter name=\"Block 2: relaxation: sweeps\" type=\"int\" value=\"1\"/>"
43 "<Parameter name=\"Block 2: relaxation: damping factor\" type=\"double\" value=\"1.0\"/>"
44 "<Parameter name=\"Block 2: transfer smoothing\" type=\"bool\" value=\"true\"/>"
45 "<Parameter name=\"BGS: damping factor\" type=\"double\" value=\"1.0\"/>"
46 "<Parameter name=\"max levels\" type=\"int\" value=\"5\"/>"
47 "<Parameter name=\"coarse: max size\" type=\"int\" value=\"25000\"/>"
48 "<Parameter name=\"verbosity\" type=\"string\" value=\"High\"/>"
58 std::string finalString =
60 "<ParameterList name=\"MueLu\">"
61 " <ParameterList name=\"Factories\">"
62 " <ParameterList name=\"mySubBlockAFactory1\">"
63 " <Parameter name=\"factory\" type=\"string\" value=\"SubBlockAFactory\"/>"
64 " <Parameter name=\"block row\" type=\"int\" value=\"0\"/>"
65 " <Parameter name=\"block col\" type=\"int\" value=\"0\"/>"
66 " <Parameter name=\"Range map: Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
67 " <Parameter name=\"Domain map: Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
70 " <ParameterList name=\"myAggFact1\">"
71 " <Parameter name=\"factory\" type=\"string\" value=\"UncoupledAggregationFactory\"/>"
72 " <Parameter name=\"aggregation: min agg size\" type=\"int\" value=\"5\"/>"
73 " <Parameter name=\"aggregation: max selected neighbors\" type=\"int\" value=\"1\"/>"
76 " <!-- tell the tentative prolongator that we have 2 DOFs per node on the coarse levels -->"
77 " <ParameterList name=\"myCoarseMap1\">"
78 " <Parameter name=\"factory\" type=\"string\" value=\"CoarseMapFactory\"/>"
79 " <Parameter name=\"Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
80 " <Parameter name=\"Strided block id\" type=\"int\" value=\"-1\"/>"
83 " <ParameterList name=\"myTentativePFact1\">"
84 " <Parameter name=\"factory\" type=\"string\" value=\"TentativePFactory\"/>"
85 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
86 " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
87 " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap1\"/>"
90 " <ParameterList name=\"myPFact1\">"
91 " <Parameter name=\"factory\" type=\"string\" value=\"PgPFactory\"/>"
92 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
93 " <Parameter name=\"P\" type=\"string\" value=\"myTentativePFact1\"/>"
96 " <ParameterList name=\"myRFact1\">"
97 " <Parameter name=\"factory\" type=\"string\" value=\"GenericRFactory\"/>"
98 " <Parameter name=\"P\" type=\"string\" value=\"myPFact1\"/>"
101 " <!-- We have to use Nullspace1 here. If \"Nullspace1\" is not set the"
102 " Factory creates the default null space containing of constant"
104 " <ParameterList name=\"myNspFact1\">"
105 " <Parameter name=\"factory\" type=\"string\" value=\"NullspaceFactory\"/>"
106 " <Parameter name=\"Fine level nullspace\" type=\"string\" value=\"Nullspace1\"/>"
107 " <Parameter name=\"Nullspace1\" type=\"string\" value=\"myTentativePFact1\"/>"
110 " <!-- BLOCK 2 (for submatrix A_{11}) PRESSURE PART -->"
111 " <ParameterList name=\"mySubBlockAFactory2\">"
112 " <Parameter name=\"factory\" type=\"string\" value=\"SubBlockAFactory\"/>"
113 " <Parameter name=\"block row\" type=\"int\" value=\"1\"/>"
114 " <Parameter name=\"block col\" type=\"int\" value=\"1\"/>"
115 " <Parameter name=\"Range map: Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
116 " <Parameter name=\"Domain map: Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
119 " <!-- tell the tentative prolongator that we have 2 DOFs per node on the coarse levels -->"
120 " <ParameterList name=\"myCoarseMap2\">"
121 " <Parameter name=\"factory\" type=\"string\" value=\"CoarseMapFactory\"/>"
122 " <Parameter name=\"Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
123 " <Parameter name=\"Strided block id\" type=\"int\" value=\"-1\"/>"
126 " <ParameterList name=\"myTentativePFact2\">"
127 " <Parameter name=\"factory\" type=\"string\" value=\"TentativePFactory\"/>"
128 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
129 " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
130 " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap2\"/>"
133 " <ParameterList name=\"myPFact2\">"
134 " <Parameter name=\"factory\" type=\"string\" value=\"SaPFactory\"/>"
135 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
136 " <Parameter name=\"P\" type=\"string\" value=\"myTentativePFact2\"/>"
139 " <ParameterList name=\"myRFact2\">"
140 " <Parameter name=\"factory\" type=\"string\" value=\"TransPFactory\"/>"
141 " <Parameter name=\"P\" type=\"string\" value=\"myPFact2\"/>"
144 " <ParameterList name=\"myNspFact2\">"
145 " <Parameter name=\"factory\" type=\"string\" value=\"NullspaceFactory\"/>"
146 " <Parameter name=\"Fine level nullspace\" type=\"string\" value=\"Nullspace2\"/>"
147 " <Parameter name=\"Nullspace2\" type=\"string\" value=\"myTentativePFact2\"/>"
150 " <!-- FACTORY MANAGERS -->"
152 " <!-- Multigrid setup for velocity block (A_{00}) -->"
153 " <ParameterList name=\"myFirstGroup\">"
154 " <Parameter name=\"group\" type=\"string\" value=\"FactoryManager\"/>"
155 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
156 " <Parameter name=\"P\" type=\"string\" value=\"myPFact1\"/>"
157 " <Parameter name=\"R\" type=\"string\" value=\"myRFact1\"/>"
158 " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
159 " <Parameter name=\"Nullspace\" type=\"string\" value=\"myNspFact1\"/>"
160 " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap1\"/>"
163 " <!-- Multigrid setup for pressure block (A_{11}) -->"
164 " <ParameterList name=\"mySecondGroup\">"
165 " <Parameter name=\"group\" type=\"string\" value=\"FactoryManager\"/>"
166 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
167 " <Parameter name=\"P\" type=\"string\" value=\"myPFact2\"/>"
168 " <Parameter name=\"R\" type=\"string\" value=\"myRFact2\"/>"
169 " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/><!-- reuse aggs from PRESSURE block! -->"
170 " <Parameter name=\"Nullspace\" type=\"string\" value=\"myNspFact2\"/>"
171 " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap2\"/>"
174 " <!-- BLOCK TRANSFER operators -->"
176 " <ParameterList name=\"myBlockedPFact\">"
177 " <Parameter name=\"factory\" type=\"string\" value=\"BlockedPFactory\"/>"
178 " <!-- factory manager for block 1 -->"
179 " <ParameterList name=\"block1\">"
180 " <Parameter name=\"group\" type=\"string\" value=\"myFirstGroup\"/>"
182 " <!-- factory manager for block 2 -->"
183 " <ParameterList name=\"block2\">"
184 " <Parameter name=\"group\" type=\"string\" value=\"mySecondGroup\"/>"
188 " <ParameterList name=\"myBlockedRFact\">"
189 " <Parameter name=\"factory\" type=\"string\" value=\"GenericRFactory\"/>"
190 " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
193 " <ParameterList name=\"myBlockedRAPFact\">"
194 " <Parameter name=\"factory\" type=\"string\" value=\"BlockedRAPFactory\"/>"
195 " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
196 " <Parameter name=\"R\" type=\"string\" value=\"myBlockedRFact\"/>"
199 " <!-- BLOCK SMOOTHERS -->"
200 " <ParameterList name=\"mySmooFact1\">"
201 " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
202 " <Parameter name=\"type\" type=\"string\" value=\"RELAXATION\"/>"
203 " <ParameterList name=\"ParameterList\">"
204 " <Parameter name=\"relaxation: type\" type=\"string\" value=\"XXXBlock 1: relaxation: typeYYY\"/>"
205 " <Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"XXXBlock 1: relaxation: sweepsYYY\"/>"
206 " <Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"XXXBlock 1: relaxation: damping factorYYY\"/>"
210 " <ParameterList name=\"mySmooILUFact1\">"
211 " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
212 " <Parameter name=\"type\" type=\"string\" value=\"ILU\"/>"
213 " <ParameterList name=\"ParameterList\">"
214 " <Parameter name=\"fact: level-of-fill\" type=\"int\" value=\"XXXBlock 1: level-of-fillYYY\"/>"
218 " <ParameterList name=\"mySmooDirectFact1\">"
219 " <Parameter name=\"factory\" type=\"string\" value=\"DirectSolver\"/>"
222 " <ParameterList name=\"mySmooFact2\">"
223 " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
224 " <Parameter name=\"type\" type=\"string\" value=\"RELAXATION\"/>"
225 " <ParameterList name=\"ParameterList\">"
226 " <Parameter name=\"relaxation: type\" type=\"string\" value=\"XXXBlock 2: relaxation: typeYYY\"/>"
227 " <Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"XXXBlock 2: relaxation: sweepsYYY\"/>"
228 " <Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"XXXBlock 2: relaxation: damping factorYYY\"/>"
232 " <ParameterList name=\"mySmooILUFact2\">"
233 " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
234 " <Parameter name=\"type\" type=\"string\" value=\"ILU\"/>"
235 " <ParameterList name=\"ParameterList\">"
236 " <Parameter name=\"fact: level-of-fill\" type=\"int\" value=\"XXXBlock 2: level-of-fillYYY\"/>"
240 " <ParameterList name=\"mySmooDirectFact2\">"
241 " <Parameter name=\"factory\" type=\"string\" value=\"DirectSolver\"/>"
244 " <ParameterList name=\"myBlockSmoother\">"
245 " <Parameter name=\"factory\" type=\"string\" value=\"BlockedGaussSeidelSmoother\"/>"
246 " <Parameter name=\"Sweeps\" type=\"int\" value=\"1\"/>"
247 " <Parameter name=\"Damping factor\" type=\"double\" value=\"XXXBGS: damping factorYYY\"/>"
248 " <!-- factory manager for block 1 -->"
249 " <ParameterList name=\"block1\">"
250 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
251 " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother1XYZ\"/>"
253 " <!-- factory manager for block 2 -->"
254 " <ParameterList name=\"block2\">"
255 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
256 " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother2XYZ\"/>"
261 " <!-- end Factories -->"
263 " <!-- Definition of the multigrid preconditioner -->"
264 " <ParameterList name=\"Hierarchy\">"
266 " <Parameter name=\"max levels\" type=\"int\" value=\"XXXmax levelsYYY\"/>"
267 " <Parameter name=\"coarse: max size\" type=\"int\" value=\"XXXcoarse: max sizeYYY\"/>"
268 " <Parameter name=\"verbosity\" type=\"string\" value=\"XXXverbosityYYY\"/>"
270 " <ParameterList name=\"AllLevel\">"
271 " <Parameter name=\"startLevel\" type=\"int\" value=\"0\"/>"
272 " <Parameter name=\"Smoother\" type=\"string\" value=\"myBlockSmoother\"/>"
273 " <Parameter name=\"CoarseSolver\" type=\"string\" value=\"myBlockSmoother\"/>"
274 " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
275 " <Parameter name=\"R\" type=\"string\" value=\"myBlockedRFact\"/>"
276 " <Parameter name=\"A\" type=\"string\" value=\"myBlockedRAPFact\"/>"
284 std::string smoother1 = inputParameters.
get<std::string>(
"Block 1: smoother");
285 if (smoother1 ==
"ILU") {
286 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooILUFact1");
287 }
else if (smoother1 ==
"Symmetric Gauss-Seidel" || smoother1 ==
"SGS") {
288 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Symmetric Gauss-Seidel");
289 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
290 }
else if (smoother1 ==
"Symmetric Gauss-Seidel" || smoother1 ==
"GS") {
291 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Gauss-Seidel");
292 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
293 }
else if (smoother1 ==
"Jacobi") {
294 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Jacobi");
295 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
296 }
else if (smoother1 ==
"Direct") {
297 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooDirectFact1");
299 this->GetOStream(
Errors) <<
"Invalid smoother type for block 1: " << smoother1 <<
". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
302 std::string smoother2 = inputParameters.
get<std::string>(
"Block 2: smoother");
303 if (smoother2 ==
"ILU") {
304 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooILUFact2");
305 }
else if (smoother2 ==
"Symmetric Gauss-Seidel" || smoother2 ==
"SGS") {
306 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Symmetric Gauss-Seidel");
307 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
308 }
else if (smoother2 ==
"Symmetric Gauss-Seidel" || smoother2 ==
"GS") {
309 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Gauss-Seidel");
310 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
311 }
else if (smoother2 ==
"Jacobi") {
312 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Gauss-Seidel");
313 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
314 }
else if (smoother2 ==
"Direct") {
315 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooDirectFact2");
317 this->GetOStream(
Errors) <<
"Invalid smoother type for block 2: " << smoother2 <<
". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
320 if (inputParameters.
get<
bool>(
"Block 1: transfer smoothing") ==
true) {
321 this->ReplaceString(finalString,
"XXXBlock 1: prolongatorYYY",
"myPFact1");
322 this->ReplaceString(finalString,
"XXXBlock 1: restrictor YYY",
"myRFact1");
324 this->ReplaceString(finalString,
"XXXBlock 1: prolongatorYYY",
"myTentativePFact1");
325 this->ReplaceString(finalString,
"XXXBlock 1: restrictor YYY",
"myTransPFact1");
327 if (inputParameters.
get<
bool>(
"Block 2: transfer smoothing") ==
true) {
328 this->ReplaceString(finalString,
"XXXBlock 2: prolongatorYYY",
"myPFact2");
329 this->ReplaceString(finalString,
"XXXBlock 2: restrictor YYY",
"myRFact2");
331 this->ReplaceString(finalString,
"XXXBlock 2: prolongatorYYY",
"myTentativePFact2");
332 this->ReplaceString(finalString,
"XXXBlock 2: restrictor YYY",
"myTransPFact2");
340 std::string par_name = inputParameters.
name(it);
341 std::stringstream ss;
342 ss <<
"XXX" << par_name <<
"YYY";
346 this->ReplaceString(finalString,
355 #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)