10 #ifndef PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_Simple_DEF_HPP_
11 #define PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_Simple_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=\"Simple: 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=\"myNSSchurCompFact\">"
245 " <Parameter name=\"factory\" type=\"string\" value=\"SchurComplementFactory\"/>"
246 " <Parameter name=\"omega\" type=\"double\" value=\"1.0\"/>"
247 " <Parameter name=\"lumping\" type=\"bool\" value=\"false\"/>"
250 " <ParameterList name=\"myBlockSmoother\">"
251 " <Parameter name=\"factory\" type=\"string\" value=\"SimpleSmoother\"/>"
252 " <Parameter name=\"Sweeps\" type=\"int\" value=\"1\"/>"
253 " <Parameter name=\"Damping factor\" type=\"double\" value=\"XXXSimple: damping factorYYY\"/>"
254 " <!-- factory manager for block 1 -->"
255 " <ParameterList name=\"block1\">"
256 " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
257 " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother1XYZ\"/>"
259 " <!-- factory manager for block 2 -->"
260 " <ParameterList name=\"block2\">"
261 " <Parameter name=\"A\" type=\"string\" value=\"myNSSchurCompFact\"/>"
262 " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother2XYZ\"/>"
267 " <!-- end Factories -->"
269 " <!-- Definition of the multigrid preconditioner -->"
270 " <ParameterList name=\"Hierarchy\">"
272 " <Parameter name=\"max levels\" type=\"int\" value=\"XXXmax levelsYYY\"/>"
273 " <Parameter name=\"coarse: max size\" type=\"int\" value=\"XXXcoarse: max sizeYYY\"/>"
274 " <Parameter name=\"verbosity\" type=\"string\" value=\"XXXverbosityYYY\"/>"
276 " <ParameterList name=\"AllLevel\">"
277 " <Parameter name=\"startLevel\" type=\"int\" value=\"0\"/>"
278 " <Parameter name=\"Smoother\" type=\"string\" value=\"myBlockSmoother\"/>"
279 " <Parameter name=\"CoarseSolver\" type=\"string\" value=\"myBlockSmoother\"/>"
280 " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
281 " <Parameter name=\"R\" type=\"string\" value=\"myBlockedRFact\"/>"
282 " <Parameter name=\"A\" type=\"string\" value=\"myBlockedRAPFact\"/>"
290 std::string smoother1 = inputParameters.
get<std::string>(
"Block 1: smoother");
291 if (smoother1 ==
"ILU") {
292 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooILUFact1");
293 }
else if (smoother1 ==
"Symmetric Gauss-Seidel" || smoother1 ==
"SGS") {
294 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Symmetric Gauss-Seidel");
295 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
296 }
else if (smoother1 ==
"Symmetric Gauss-Seidel" || smoother1 ==
"GS") {
297 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Gauss-Seidel");
298 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
299 }
else if (smoother1 ==
"Jacobi") {
300 this->ReplaceString(finalString,
"XXXBlock 1: relaxation: typeYYY",
"Jacobi");
301 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooFact1");
302 }
else if (smoother1 ==
"Direct") {
303 this->ReplaceString(finalString,
"XYZSmoother1XYZ",
"mySmooDirectFact1");
305 this->GetOStream(
Errors) <<
"Invalid smoother type for block 1: " << smoother1 <<
". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
308 std::string smoother2 = inputParameters.
get<std::string>(
"Block 2: smoother");
309 if (smoother2 ==
"ILU") {
310 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooILUFact2");
311 }
else if (smoother2 ==
"Symmetric Gauss-Seidel" || smoother2 ==
"SGS") {
312 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Symmetric Gauss-Seidel");
313 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
314 }
else if (smoother2 ==
"Symmetric Gauss-Seidel" || smoother2 ==
"GS") {
315 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Gauss-Seidel");
316 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
317 }
else if (smoother2 ==
"Jacobi") {
318 this->ReplaceString(finalString,
"XXXBlock 2: relaxation: typeYYY",
"Jacobi");
319 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooFact2");
320 }
else if (smoother2 ==
"Direct") {
321 this->ReplaceString(finalString,
"XYZSmoother2XYZ",
"mySmooDirectFact2");
323 this->GetOStream(
Errors) <<
"Invalid smoother type for block 2: " << smoother2 <<
". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
326 if (inputParameters.
get<
bool>(
"Block 1: transfer smoothing") ==
true) {
327 this->ReplaceString(finalString,
"XXXBlock 1: prolongatorYYY",
"myPFact1");
328 this->ReplaceString(finalString,
"XXXBlock 1: restrictor YYY",
"myRFact1");
330 this->ReplaceString(finalString,
"XXXBlock 1: prolongatorYYY",
"myTentativePFact1");
331 this->ReplaceString(finalString,
"XXXBlock 1: restrictor YYY",
"myTransPFact1");
333 if (inputParameters.
get<
bool>(
"Block 2: transfer smoothing") ==
true) {
334 this->ReplaceString(finalString,
"XXXBlock 2: prolongatorYYY",
"myPFact2");
335 this->ReplaceString(finalString,
"XXXBlock 2: restrictor YYY",
"myRFact2");
337 this->ReplaceString(finalString,
"XXXBlock 2: prolongatorYYY",
"myTentativePFact2");
338 this->ReplaceString(finalString,
"XXXBlock 2: restrictor YYY",
"myTransPFact2");
346 std::string par_name = inputParameters.
name(it);
347 std::stringstream ss;
348 ss <<
"XXX" << par_name <<
"YYY";
352 this->ReplaceString(finalString,
361 #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)