MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_FacadeSimple_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 // Tobias Wiesner (tawiesn@sandia.gov)
43 //
44 // ***********************************************************************
45 //
46 // @HEADER
47 #ifndef PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_Simple_DEF_HPP_
48 #define PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_Simple_DEF_HPP_
49 
52 
53 #include "MueLu_Exceptions.hpp"
54 
56 
57 namespace MueLu {
58 
59 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
61 }
62 
63 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
65  // obtain ParameterList with default input parameters for this facade class
66  // Note all parameters are of type string (we use it for string replacement)
67  std::string defaultString =
68  "<ParameterList name=\"Input\">"
69  "<Parameter name=\"MueLu preconditioner\" type=\"string\" value=\"undefined\"/>"
70  "<Parameter name=\"Block 1: dofs per node\" type=\"int\" value=\"1\"/>"
71  "<Parameter name=\"Block 2: dofs per node\" type=\"int\" value=\"1\"/>"
72  "<Parameter name=\"Block 1: smoother\" type=\"string\" value=\"Symmetric Gauss-Seidel\"/>"
73  "<Parameter name=\"Block 1: level-of-fill\" type=\"int\" value=\"0\"/>"
74  "<Parameter name=\"Block 1: relaxation: sweeps\" type=\"int\" value=\"1\"/>"
75  "<Parameter name=\"Block 1: relaxation: damping factor\" type=\"double\" value=\"1.0\"/>"
76  "<Parameter name=\"Block 1: transfer smoothing\" type=\"bool\" value=\"true\"/>"
77  "<Parameter name=\"Block 2: smoother\" type=\"string\" value=\"Symmetric Gauss-Seidel\"/>"
78  "<Parameter name=\"Block 2: level-of-fill\" type=\"int\" value=\"0\"/>"
79  "<Parameter name=\"Block 2: relaxation: sweeps\" type=\"int\" value=\"1\"/>"
80  "<Parameter name=\"Block 2: relaxation: damping factor\" type=\"double\" value=\"1.0\"/>"
81  "<Parameter name=\"Block 2: transfer smoothing\" type=\"bool\" value=\"true\"/>"
82  "<Parameter name=\"Simple: damping factor\" type=\"double\" value=\"1.0\"/>"
83  "<Parameter name=\"max levels\" type=\"int\" value=\"5\"/>"
84  "<Parameter name=\"coarse: max size\" type=\"int\" value=\"25000\"/>"
85  "<Parameter name=\"verbosity\" type=\"string\" value=\"High\"/>"
86  "</ParameterList>";
87  Teuchos::RCP<ParameterList> defaultList = Teuchos::getParametersFromXmlString(defaultString);
88  // validate user input parameters (and set defaults if necessary)
89  Teuchos::ParameterList inputParameters = paramList;
90  inputParameters.validateParametersAndSetDefaults(*defaultList);
91  TEUCHOS_TEST_FOR_EXCEPTION(inputParameters.get<std::string>("MueLu preconditioner") == "undefined", MueLu::Exceptions::RuntimeError, "FacadeSimple: undefined MueLu preconditioner. Set the \"MueLu preconditioner\" parameter correctly in your input file.");
92 
93  // create copy of template string which is updated with in-place string replacements
94  // template string for preconditioner layout (factory based parameters)
95  std::string finalString =
96 
97  "<ParameterList name=\"MueLu\">"
98  " <ParameterList name=\"Factories\">"
99  " <ParameterList name=\"mySubBlockAFactory1\">"
100  " <Parameter name=\"factory\" type=\"string\" value=\"SubBlockAFactory\"/>"
101  " <Parameter name=\"block row\" type=\"int\" value=\"0\"/>"
102  " <Parameter name=\"block col\" type=\"int\" value=\"0\"/>"
103  " <Parameter name=\"Range map: Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
104  " <Parameter name=\"Domain map: Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
105  " </ParameterList>"
106  ""
107  " <ParameterList name=\"myAggFact1\">"
108  " <Parameter name=\"factory\" type=\"string\" value=\"UncoupledAggregationFactory\"/>"
109  " <Parameter name=\"aggregation: min agg size\" type=\"int\" value=\"5\"/>"
110  " <Parameter name=\"aggregation: max selected neighbors\" type=\"int\" value=\"1\"/>"
111  " </ParameterList>"
112  ""
113  " <!-- tell the tentative prolongator that we have 2 DOFs per node on the coarse levels -->"
114  " <ParameterList name=\"myCoarseMap1\">"
115  " <Parameter name=\"factory\" type=\"string\" value=\"CoarseMapFactory\"/>"
116  " <Parameter name=\"Striding info\" type=\"string\" value=\"{ XXXBlock 1: dofs per nodeYYY }\"/>"
117  " <Parameter name=\"Strided block id\" type=\"int\" value=\"-1\"/>"
118  " </ParameterList>"
119  ""
120  " <ParameterList name=\"myTentativePFact1\">"
121  " <Parameter name=\"factory\" type=\"string\" value=\"TentativePFactory\"/>"
122  " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
123  " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
124  " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap1\"/>"
125  " </ParameterList>"
126  ""
127  " <ParameterList name=\"myPFact1\">"
128  " <Parameter name=\"factory\" type=\"string\" value=\"PgPFactory\"/>"
129  " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
130  " <Parameter name=\"P\" type=\"string\" value=\"myTentativePFact1\"/>"
131  " </ParameterList>"
132  ""
133  " <ParameterList name=\"myRFact1\">"
134  " <Parameter name=\"factory\" type=\"string\" value=\"GenericRFactory\"/>"
135  " <Parameter name=\"P\" type=\"string\" value=\"myPFact1\"/>"
136  " </ParameterList>"
137  ""
138  " <!-- We have to use Nullspace1 here. If \"Nullspace1\" is not set the"
139  " Factory creates the default null space containing of constant"
140  " vectors -->"
141  " <ParameterList name=\"myNspFact1\">"
142  " <Parameter name=\"factory\" type=\"string\" value=\"NullspaceFactory\"/>"
143  " <Parameter name=\"Fine level nullspace\" type=\"string\" value=\"Nullspace1\"/>"
144  " <Parameter name=\"Nullspace1\" type=\"string\" value=\"myTentativePFact1\"/>"
145  " </ParameterList>"
146  ""
147  " <!-- BLOCK 2 (for submatrix A_{11}) PRESSURE PART -->"
148  " <ParameterList name=\"mySubBlockAFactory2\">"
149  " <Parameter name=\"factory\" type=\"string\" value=\"SubBlockAFactory\"/>"
150  " <Parameter name=\"block row\" type=\"int\" value=\"1\"/>"
151  " <Parameter name=\"block col\" type=\"int\" value=\"1\"/>"
152  " <Parameter name=\"Range map: Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
153  " <Parameter name=\"Domain map: Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
154  " </ParameterList>"
155  ""
156  " <!-- tell the tentative prolongator that we have 2 DOFs per node on the coarse levels -->"
157  " <ParameterList name=\"myCoarseMap2\">"
158  " <Parameter name=\"factory\" type=\"string\" value=\"CoarseMapFactory\"/>"
159  " <Parameter name=\"Striding info\" type=\"string\" value=\"{ XXXBlock 2: dofs per nodeYYY }\"/>"
160  " <Parameter name=\"Strided block id\" type=\"int\" value=\"-1\"/>"
161  " </ParameterList>"
162  ""
163  " <ParameterList name=\"myTentativePFact2\">"
164  " <Parameter name=\"factory\" type=\"string\" value=\"TentativePFactory\"/>"
165  " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
166  " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
167  " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap2\"/>"
168  " </ParameterList>"
169  ""
170  " <ParameterList name=\"myPFact2\">"
171  " <Parameter name=\"factory\" type=\"string\" value=\"SaPFactory\"/>"
172  " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
173  " <Parameter name=\"P\" type=\"string\" value=\"myTentativePFact2\"/>"
174  " </ParameterList>"
175  ""
176  " <ParameterList name=\"myRFact2\">"
177  " <Parameter name=\"factory\" type=\"string\" value=\"TransPFactory\"/>"
178  " <Parameter name=\"P\" type=\"string\" value=\"myPFact2\"/>"
179  " </ParameterList>"
180  ""
181  " <ParameterList name=\"myNspFact2\">"
182  " <Parameter name=\"factory\" type=\"string\" value=\"NullspaceFactory\"/>"
183  " <Parameter name=\"Fine level nullspace\" type=\"string\" value=\"Nullspace2\"/>"
184  " <Parameter name=\"Nullspace2\" type=\"string\" value=\"myTentativePFact2\"/>"
185  " </ParameterList>"
186  ""
187  " <!-- FACTORY MANAGERS -->"
188  ""
189  " <!-- Multigrid setup for velocity block (A_{00}) -->"
190  " <ParameterList name=\"myFirstGroup\">"
191  " <Parameter name=\"group\" type=\"string\" value=\"FactoryManager\"/>"
192  " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
193  " <Parameter name=\"P\" type=\"string\" value=\"myPFact1\"/>"
194  " <Parameter name=\"R\" type=\"string\" value=\"myRFact1\"/>"
195  " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/>"
196  " <Parameter name=\"Nullspace\" type=\"string\" value=\"myNspFact1\"/>"
197  " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap1\"/>"
198  " </ParameterList>"
199  ""
200  " <!-- Multigrid setup for pressure block (A_{11}) -->"
201  " <ParameterList name=\"mySecondGroup\">"
202  " <Parameter name=\"group\" type=\"string\" value=\"FactoryManager\"/>"
203  " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory2\"/>"
204  " <Parameter name=\"P\" type=\"string\" value=\"myPFact2\"/>"
205  " <Parameter name=\"R\" type=\"string\" value=\"myRFact2\"/>"
206  " <Parameter name=\"Aggregates\" type=\"string\" value=\"myAggFact1\"/><!-- reuse aggs from PRESSURE block! -->"
207  " <Parameter name=\"Nullspace\" type=\"string\" value=\"myNspFact2\"/>"
208  " <Parameter name=\"CoarseMap\" type=\"string\" value=\"myCoarseMap2\"/>"
209  " </ParameterList>"
210  ""
211  " <!-- BLOCK TRANSFER operators -->"
212  ""
213  " <ParameterList name=\"myBlockedPFact\">"
214  " <Parameter name=\"factory\" type=\"string\" value=\"BlockedPFactory\"/>"
215  " <!-- factory manager for block 1 -->"
216  " <ParameterList name=\"block1\">"
217  " <Parameter name=\"group\" type=\"string\" value=\"myFirstGroup\"/>"
218  " </ParameterList>"
219  " <!-- factory manager for block 2 -->"
220  " <ParameterList name=\"block2\">"
221  " <Parameter name=\"group\" type=\"string\" value=\"mySecondGroup\"/>"
222  " </ParameterList>"
223  " </ParameterList>"
224  ""
225  " <ParameterList name=\"myBlockedRFact\">"
226  " <Parameter name=\"factory\" type=\"string\" value=\"GenericRFactory\"/>"
227  " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
228  " </ParameterList>"
229  ""
230  " <ParameterList name=\"myBlockedRAPFact\">"
231  " <Parameter name=\"factory\" type=\"string\" value=\"BlockedRAPFactory\"/>"
232  " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
233  " <Parameter name=\"R\" type=\"string\" value=\"myBlockedRFact\"/>"
234  " </ParameterList>"
235  ""
236  " <!-- BLOCK SMOOTHERS -->"
237  " <ParameterList name=\"mySmooFact1\">"
238  " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
239  " <Parameter name=\"type\" type=\"string\" value=\"RELAXATION\"/>"
240  " <ParameterList name=\"ParameterList\">"
241  " <Parameter name=\"relaxation: type\" type=\"string\" value=\"XXXBlock 1: relaxation: typeYYY\"/>"
242  " <Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"XXXBlock 1: relaxation: sweepsYYY\"/>"
243  " <Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"XXXBlock 1: relaxation: damping factorYYY\"/>"
244  " </ParameterList>"
245  " </ParameterList>"
246  ""
247  " <ParameterList name=\"mySmooILUFact1\">"
248  " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
249  " <Parameter name=\"type\" type=\"string\" value=\"ILU\"/>"
250  " <ParameterList name=\"ParameterList\">"
251  " <Parameter name=\"fact: level-of-fill\" type=\"int\" value=\"XXXBlock 1: level-of-fillYYY\"/>"
252  " </ParameterList>"
253  " </ParameterList>"
254  ""
255  " <ParameterList name=\"mySmooDirectFact1\">"
256  " <Parameter name=\"factory\" type=\"string\" value=\"DirectSolver\"/>"
257  " </ParameterList>"
258  ""
259  " <ParameterList name=\"mySmooFact2\">"
260  " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
261  " <Parameter name=\"type\" type=\"string\" value=\"RELAXATION\"/>"
262  " <ParameterList name=\"ParameterList\">"
263  " <Parameter name=\"relaxation: type\" type=\"string\" value=\"XXXBlock 2: relaxation: typeYYY\"/>"
264  " <Parameter name=\"relaxation: sweeps\" type=\"int\" value=\"XXXBlock 2: relaxation: sweepsYYY\"/>"
265  " <Parameter name=\"relaxation: damping factor\" type=\"double\" value=\"XXXBlock 2: relaxation: damping factorYYY\"/>"
266  " </ParameterList>"
267  " </ParameterList>"
268  ""
269  " <ParameterList name=\"mySmooILUFact2\">"
270  " <Parameter name=\"factory\" type=\"string\" value=\"TrilinosSmoother\"/>"
271  " <Parameter name=\"type\" type=\"string\" value=\"ILU\"/>"
272  " <ParameterList name=\"ParameterList\">"
273  " <Parameter name=\"fact: level-of-fill\" type=\"int\" value=\"XXXBlock 2: level-of-fillYYY\"/>"
274  " </ParameterList>"
275  " </ParameterList>"
276  ""
277  " <ParameterList name=\"mySmooDirectFact2\">"
278  " <Parameter name=\"factory\" type=\"string\" value=\"DirectSolver\"/>"
279  " </ParameterList>"
280  ""
281  " <ParameterList name=\"myNSSchurCompFact\">"
282  " <Parameter name=\"factory\" type=\"string\" value=\"SchurComplementFactory\"/>"
283  " <Parameter name=\"omega\" type=\"double\" value=\"1.0\"/>"
284  " <Parameter name=\"lumping\" type=\"bool\" value=\"false\"/>"
285  " </ParameterList>"
286  ""
287  " <ParameterList name=\"myBlockSmoother\">"
288  " <Parameter name=\"factory\" type=\"string\" value=\"SimpleSmoother\"/>"
289  " <Parameter name=\"Sweeps\" type=\"int\" value=\"1\"/>"
290  " <Parameter name=\"Damping factor\" type=\"double\" value=\"XXXSimple: damping factorYYY\"/>"
291  " <!-- factory manager for block 1 -->"
292  " <ParameterList name=\"block1\">"
293  " <Parameter name=\"A\" type=\"string\" value=\"mySubBlockAFactory1\"/>"
294  " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother1XYZ\"/>"
295  " </ParameterList>"
296  " <!-- factory manager for block 2 -->"
297  " <ParameterList name=\"block2\">"
298  " <Parameter name=\"A\" type=\"string\" value=\"myNSSchurCompFact\"/>"
299  " <Parameter name=\"Smoother\" type=\"string\" value=\"XYZSmoother2XYZ\"/>"
300  " </ParameterList>"
301  " </ParameterList>"
302  ""
303  " </ParameterList>"
304  " <!-- end Factories -->"
305  ""
306  " <!-- Definition of the multigrid preconditioner -->"
307  " <ParameterList name=\"Hierarchy\">"
308  ""
309  " <Parameter name=\"max levels\" type=\"int\" value=\"XXXmax levelsYYY\"/>"
310  " <Parameter name=\"coarse: max size\" type=\"int\" value=\"XXXcoarse: max sizeYYY\"/>"
311  " <Parameter name=\"verbosity\" type=\"string\" value=\"XXXverbosityYYY\"/>"
312  ""
313  " <ParameterList name=\"AllLevel\">"
314  " <Parameter name=\"startLevel\" type=\"int\" value=\"0\"/>"
315  " <Parameter name=\"Smoother\" type=\"string\" value=\"myBlockSmoother\"/>"
316  " <Parameter name=\"CoarseSolver\" type=\"string\" value=\"myBlockSmoother\"/>"
317  " <Parameter name=\"P\" type=\"string\" value=\"myBlockedPFact\"/>"
318  " <Parameter name=\"R\" type=\"string\" value=\"myBlockedRFact\"/>"
319  " <Parameter name=\"A\" type=\"string\" value=\"myBlockedRAPFact\"/>"
320  " </ParameterList>"
321  ""
322  " </ParameterList>"
323  "</ParameterList>";
324 
325  // logical code for more complicated distinctions
326 
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");
341  } else {
342  this->GetOStream(Errors) << "Invalid smoother type for block 1: " << smoother1 << ". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
343  }
344 
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", "Jacobi");
356  this->ReplaceString(finalString, "XYZSmoother2XYZ", "mySmooFact2");
357  } else if (smoother2 == "Direct") {
358  this->ReplaceString(finalString, "XYZSmoother2XYZ", "mySmooDirectFact2");
359  } else {
360  this->GetOStream(Errors) << "Invalid smoother type for block 2: " << smoother2 << ". Valid options are: \"SGS\", \"GS\", \"Jacobi\", \"ILU\" or \"Direct\"." << std::endl;
361  }
362 
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");
366  } else {
367  this->ReplaceString(finalString, "XXXBlock 1: prolongatorYYY", "myTentativePFact1");
368  this->ReplaceString(finalString, "XXXBlock 1: restrictor YYY", "myTransPFact1");
369  }
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");
373  } else {
374  this->ReplaceString(finalString, "XXXBlock 2: prolongatorYYY", "myTentativePFact2");
375  this->ReplaceString(finalString, "XXXBlock 2: restrictor YYY", "myTransPFact2");
376  }
377 
378  // end logical code
379 
380  // loop over all input parameters
381  for (Teuchos::ParameterList::ConstIterator it = inputParameters.begin(); it != inputParameters.end(); it++) {
382  // form replacement string
383  std::string par_name = inputParameters.name(it);
384  std::stringstream ss;
385  ss << "XXX" << par_name << "YYY";
386 
387  // update final string with parameters
388  Teuchos::ParameterEntry par_entry = inputParameters.entry(it);
389  this->ReplaceString(finalString,
390  ss.str(), Teuchos::toString(par_entry.getAny()));
391  }
392 
393  Teuchos::RCP<ParameterList> ret = Teuchos::getParametersFromXmlString(finalString);
394  return ret;
395 }
396 
397 } // end namespace MueLu
398 #endif // PACKAGES_MUELU_SRC_INTERFACE_FACADECLASSES_Simple_DEF_HPP_
Teuchos::RCP< Teuchos::ParameterList > SetParameterList(const Teuchos::ParameterList &paramList)
Set parameter list for FacadeClass interpreter.
const std::string & name() const
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)