Teko  Version of the Day
 All Classes Files Functions Variables Pages
Teko_InverseLibrary.cpp
1 /*
2 // @HEADER
3 //
4 // ***********************************************************************
5 //
6 // Teko: A package for block and physics based preconditioning
7 // Copyright 2010 Sandia Corporation
8 //
9 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
10 // the U.S. Government retains certain rights in this software.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Eric C. Cyr (eccyr@sandia.gov)
40 //
41 // ***********************************************************************
42 //
43 // @HEADER
44 
45 */
46 
47 #include "Teko_InverseLibrary.hpp"
48 
49 #include "Teko_SolveInverseFactory.hpp"
50 #include "Teko_PreconditionerInverseFactory.hpp"
51 #include "Teko_BlockPreconditionerFactory.hpp"
52 
53 #include "Teko_NeumannSeriesPreconditionerFactory.hpp"
54 #include "Teuchos_AbstractFactoryStd.hpp"
55 #include "Teko_Utilities.hpp"
56 
57 #include <algorithm>
58 
59 using Teuchos::RCP;
60 using Teuchos::rcp;
61 
62 namespace Teko {
63 
67 void addToStratimikosBuilder(const RCP<Stratimikos::DefaultLinearSolverBuilder>& builder) {
68  typedef Thyra::PreconditionerFactoryBase<double> PrecFactory;
69 
70  RCP<const Teuchos::ParameterList> parameters = builder->getValidParameters();
71 
72  if (!parameters->sublist("Preconditioner Types").isSublist("Neumann Series")) {
73  RCP<const Teuchos::AbstractFactory<Thyra::PreconditionerFactoryBase<double> > > factory;
74 
75  factory = Teuchos::abstractFactoryStd<PrecFactory,
76  Teko::NeumannSeriesPreconditionerFactory<double> >();
77  builder->setPreconditioningStrategyFactory(factory, "Neumann Series");
78  }
79 }
80 
81 InverseLibrary::InverseLibrary() {
82  Teko_DEBUG_SCOPE("InverseLibrary::InverseLibrary", 10);
83 
84  defaultBuilder_ = Teuchos::rcp(new Stratimikos::DefaultLinearSolverBuilder());
85  addToStratimikosBuilder(defaultBuilder_);
86 
87  // setup some valid Stratimikos parameters
89 
90  // set valid solve factory names
91  stratValidSolver_.push_back("Belos");
92  stratValidSolver_.push_back("Amesos");
93  stratValidSolver_.push_back("Amesos2");
94  stratValidSolver_.push_back("AztecOO");
95 
96  // set valid preconditioner factory name
97  stratValidPrecond_.push_back("ML");
98  stratValidPrecond_.push_back("Ifpack");
99  stratValidPrecond_.push_back("Neumann Series");
100  stratValidPrecond_.push_back("MueLu");
101  stratValidPrecond_.push_back("Ifpack2");
102 
103  // set valid Teko preconditioner factory names
105 
106  Teko_DEBUG_MSG_BEGIN(10) DEBUG_STREAM << "Loaded \"block\" preconditioners = ";
107  for (std::size_t i = 0; i < blockValidPrecond_.size(); i++)
108  DEBUG_STREAM << blockValidPrecond_[i] << ", ";
109  DEBUG_STREAM << std::endl;
110  Teko_DEBUG_MSG_END()
111 }
112 
113 InverseLibrary::InverseLibrary(const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder>& strat)
114  : defaultBuilder_(strat) {
115  Teko_DEBUG_SCOPE("InverseLibrary::InverseLibrary", 10);
116 
117  RCP<Teuchos::ParameterList> pl =
118  rcp(new Teuchos::ParameterList(*defaultBuilder_->getValidParameters()));
119  Teuchos::ParameterList lst(pl->sublist("Linear Solver Types"));
120  Teuchos::ParameterList pft(pl->sublist("Preconditioner Types"));
121 
122  Teuchos::ParameterList::ConstIterator itr;
123 
124  // set valid solve factory names
125  for (itr = lst.begin(); itr != lst.end(); ++itr) stratValidSolver_.push_back(itr->first);
126 
127  Teko_DEBUG_MSG_BEGIN(10) DEBUG_STREAM << "Loaded \"Stratimikos\" solvers = ";
128  for (std::size_t i = 0; i < stratValidSolver_.size(); i++)
129  DEBUG_STREAM << stratValidSolver_[i] << ", ";
130  DEBUG_STREAM << std::endl;
131  Teko_DEBUG_MSG_END()
132 
133  // set valid prec factory names
134  for (itr = pft.begin(); itr != pft.end(); ++itr) stratValidPrecond_.push_back(itr->first);
135 
136  Teko_DEBUG_MSG_BEGIN(10) DEBUG_STREAM << "Loaded \"Stratimikos\" preconditioners = ";
137  for (std::size_t i = 0; i < stratValidPrecond_.size(); i++)
138  DEBUG_STREAM << stratValidPrecond_[i] << ", ";
139  DEBUG_STREAM << std::endl;
140  Teko_DEBUG_MSG_END()
141 
142  // set valid Teko preconditioner factory names
143  PreconditionerFactory::getPreconditionerFactoryNames(blockValidPrecond_);
144 
145  Teko_DEBUG_MSG_BEGIN(10) DEBUG_STREAM << "Loaded \"block\" preconditioners = ";
146  for (std::size_t i = 0; i < blockValidPrecond_.size(); i++)
147  DEBUG_STREAM << blockValidPrecond_[i] << ", ";
148  DEBUG_STREAM << std::endl;
149  Teko_DEBUG_MSG_END()
150 }
151 
153 void InverseLibrary::addInverse(const std::string& label, const Teuchos::ParameterList& pl) {
154  // strip out the label
155  const std::string type = pl.get<std::string>("Type");
156 
157  // copy the parameter list so we can modify it
158  Teuchos::ParameterList settingsList;
159  settingsList.set(type, pl);
160  settingsList.sublist(type).remove("Type");
161 
162  // is this a Stratimikos preconditioner or solver
163  if (std::find(stratValidPrecond_.begin(), stratValidPrecond_.end(), type) !=
164  stratValidPrecond_.end()) {
165  // this is a Stratimikos preconditioner factory
166  addStratPrecond(label, type, settingsList);
167  } else if (std::find(stratValidSolver_.begin(), stratValidSolver_.end(), type) !=
168  stratValidSolver_.end()) {
169  // this is a Stratimikos preconditioner factory
170  addStratSolver(label, type, settingsList);
171  } else if (std::find(blockValidPrecond_.begin(), blockValidPrecond_.end(), type) !=
172  blockValidPrecond_.end()) {
173  // this is a Teko preconditioner factory
174  addBlockPrecond(label, type, settingsList);
175  } else {
176  Teuchos::FancyOStream& os = *Teko::getOutputStream();
177  os << "ERROR: Could not find inverse type \"" << type << "\" required by inverse name \""
178  << label << "\"" << std::endl;
179  TEUCHOS_ASSERT(false);
180  }
181 }
182 
184 void InverseLibrary::addStratSolver(const std::string& label, const std::string& type,
185  const Teuchos::ParameterList& pl) {
186  // add some additional parameters onto the list
187  RCP<Teuchos::ParameterList> stratList = rcp(new Teuchos::ParameterList());
188  stratList->set("Linear Solver Type", type);
189  stratList->set("Linear Solver Types", pl);
190  stratList->set("Preconditioner Type", "None");
191 
192  stratSolver_[label] = stratList;
193 }
194 
196 void InverseLibrary::addStratPrecond(const std::string& label, const std::string& type,
197  const Teuchos::ParameterList& pl) {
198  // add some additional parameters onto the list
199  RCP<Teuchos::ParameterList> stratList = rcp(new Teuchos::ParameterList());
200  stratList->set("Preconditioner Type", type);
201  stratList->set("Preconditioner Types", pl);
202 
203  stratPrecond_[label] = stratList;
204 }
205 
207 void InverseLibrary::addBlockPrecond(const std::string& label, const std::string& type,
208  const Teuchos::ParameterList& pl) {
209  // add some additional parameters onto the list
210  RCP<Teuchos::ParameterList> blockList = rcp(new Teuchos::ParameterList());
211  blockList->set("Preconditioner Type", type);
212  blockList->set("Preconditioner Settings", pl.sublist(type));
213 
214  // add the Teko preconditioner parameter list into the library
215  blockPrecond_[label] = blockList;
216 }
217 
225 Teuchos::RCP<const Teuchos::ParameterList> InverseLibrary::getParameterList(
226  const std::string& label) const {
227  std::map<std::string, RCP<const Teuchos::ParameterList> >::const_iterator itr;
228 
229  // check preconditioners
230  itr = stratPrecond_.find(label);
231  if (itr != stratPrecond_.end()) return itr->second;
232 
233  // check solvers
234  itr = stratSolver_.find(label);
235  if (itr != stratSolver_.end()) return itr->second;
236 
237  // check solvers
238  itr = blockPrecond_.find(label);
239  if (itr != blockPrecond_.end()) return itr->second;
240 
241  return Teuchos::null;
242 }
243 
245 Teuchos::RCP<InverseFactory> InverseLibrary::getInverseFactory(const std::string& label) const {
246  Teko_DEBUG_SCOPE("InverseLibrary::getInverseFactory", 10);
247 
248  std::map<std::string, RCP<const Teuchos::ParameterList> >::const_iterator itr;
249 
250  bool isStratSolver = false, isStratPrecond = false, isBlockPrecond = false;
251 
252  // is this a Stratimikos solver?
253  itr = stratPrecond_.find(label);
254  isStratPrecond = itr != stratPrecond_.end();
255 
256  // is this a Stratimikos preconditioner?
257  if (not isStratPrecond) {
258  itr = stratSolver_.find(label);
259  isStratSolver = itr != stratSolver_.end();
260  }
261 
262  // must be a "block" preconditioner
263  if (not(isStratSolver || isStratPrecond)) {
264  itr = blockPrecond_.find(label);
265  isBlockPrecond = itr != blockPrecond_.end();
266  }
267 
268  Teko_DEBUG_MSG("Inverse \"" << label << "\" is of type "
269  << "strat prec = " << isStratPrecond << ", "
270  << "strat solv = " << isStratSolver << ", "
271  << "block prec = " << isBlockPrecond,
272  3);
273 
274  // Must be one of Strat solver, strat preconditioner, block preconditioner
275  if (not(isStratSolver || isStratPrecond || isBlockPrecond)) {
276  RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream();
277 
278  *out << "InverseLibrary::getInverseFactory could not find \"" << label << "\" ... aborting\n";
279  *out << "Choose one of: " << std::endl;
280 
281  *out << " Stratimikos preconditioners = ";
282  for (itr = stratPrecond_.begin(); itr != stratPrecond_.end(); ++itr)
283  *out << " \"" << itr->first << "\"\n";
284  *out << std::endl;
285 
286  *out << " Stratimikos solvers = ";
287  for (itr = stratSolver_.begin(); itr != stratSolver_.end(); ++itr)
288  *out << " \"" << itr->first << "\"\n";
289  *out << std::endl;
290 
291  *out << " Block preconditioners = ";
292  for (itr = blockPrecond_.begin(); itr != blockPrecond_.end(); ++itr)
293  *out << " \"" << itr->first << "\"\n";
294  *out << std::endl;
295 
296  TEUCHOS_ASSERT(isStratSolver || isStratPrecond || isBlockPrecond);
297  }
298 
299  RCP<const Teuchos::ParameterList> pl = itr->second;
300 
301  // build inverse factory
302  if (isStratPrecond) {
303  // remove required parameters
304  RCP<Teuchos::ParameterList> plCopy = rcp(new Teuchos::ParameterList(*pl));
305  std::string type = plCopy->get<std::string>("Preconditioner Type");
306  RCP<Teuchos::ParameterList> xtraParams;
307  if (plCopy->sublist("Preconditioner Types").sublist(type).isParameter("Required Parameters")) {
308  xtraParams = rcp(new Teuchos::ParameterList(
309  plCopy->sublist("Preconditioner Types").sublist(type).sublist("Required Parameters")));
310  plCopy->sublist("Preconditioner Types").sublist(type).remove("Required Parameters");
311  }
312 
313  // print some debuggin info
314  Teko_DEBUG_MSG_BEGIN(10);
315  DEBUG_STREAM << "Printing parameter list: " << std::endl;
316  Teko_DEBUG_PUSHTAB();
317  plCopy->print(DEBUG_STREAM);
318  Teko_DEBUG_POPTAB();
319 
320  if (xtraParams != Teuchos::null) {
321  DEBUG_STREAM << "Printing extra parameters: " << std::endl;
322  Teko_DEBUG_PUSHTAB();
323  xtraParams->print(DEBUG_STREAM);
324  Teko_DEBUG_POPTAB();
325  }
326  Teko_DEBUG_MSG_END();
327 
328  // Stratimikos::DefaultLinearSolverBuilder strat;
329  // addToStratimikosBuilder(strat);
330  defaultBuilder_->setParameterList(plCopy);
331 
332  // try to build a preconditioner factory
333  RCP<Thyra::PreconditionerFactoryBase<double> > precFact =
334  defaultBuilder_->createPreconditioningStrategy(type);
335 
336  // string must map to a preconditioner
337  RCP<Teko::PreconditionerInverseFactory> precInvFact =
338  rcp(new PreconditionerInverseFactory(precFact, xtraParams, getRequestHandler()));
339  precInvFact->setupParameterListFromRequestHandler();
340  return precInvFact;
341  } else if (isStratSolver) {
342  RCP<Teuchos::ParameterList> solveList = rcp(new Teuchos::ParameterList(*pl));
343  std::string type = solveList->get<std::string>("Linear Solver Type");
344 
345  // get preconditioner name, remove "Use Preconditioner" parameter
346  Teuchos::ParameterList& solveSettings = solveList->sublist("Linear Solver Types").sublist(type);
347  std::string precKeyWord = "Use Preconditioner";
348  std::string precName = "None";
349  if (solveSettings.isParameter(precKeyWord)) {
350  precName = solveSettings.get<std::string>(precKeyWord);
351  solveSettings.remove(precKeyWord);
352  }
353 
354  // build Thyra preconditioner factory
355  RCP<Thyra::PreconditionerFactoryBase<double> > precFactory;
356  if (precName != "None") {
357  // we will manually set the preconditioner, so set this to null
358  solveList->set<std::string>("Preconditioner Type", "None");
359 
360  // build inverse that preconditioner corresponds to
361  RCP<PreconditionerInverseFactory> precInvFactory =
362  Teuchos::rcp_dynamic_cast<PreconditionerInverseFactory>(getInverseFactory(precName));
363 
364  // extract preconditioner factory from preconditioner _inverse_ factory
365  precFactory = precInvFactory->getPrecFactory();
366  }
367 
368  // Stratimikos::DefaultLinearSolverBuilder strat;
369  // addToStratimikosBuilder(strat);
370  defaultBuilder_->setParameterList(solveList);
371 
372  // try to build a solver factory
373  RCP<Thyra::LinearOpWithSolveFactoryBase<double> > solveFact =
374  defaultBuilder_->createLinearSolveStrategy(type);
375  if (precFactory != Teuchos::null) solveFact->setPreconditionerFactory(precFactory, precName);
376 
377  // if its around, build a InverseFactory
378  return rcp(new SolveInverseFactory(solveFact));
379  } else if (isBlockPrecond) {
380  try {
381  std::string type = pl->get<std::string>("Preconditioner Type");
382  const Teuchos::ParameterList& settings = pl->sublist("Preconditioner Settings");
383 
384  // build preconditioner factory from the string
385  RCP<PreconditionerFactory> precFact = PreconditionerFactory::buildPreconditionerFactory(
386  type, settings, Teuchos::rcpFromRef(*this));
387 
388  TEUCHOS_ASSERT(precFact != Teuchos::null);
389 
390  // return the inverse factory object
391  return rcp(new PreconditionerInverseFactory(precFact, getRequestHandler()));
392  } catch (std::exception& e) {
393  RCP<Teuchos::FancyOStream> out = Teko::getOutputStream();
394 
395  *out << "Teko: \"getInverseFactory\" failed, Parameter List =\n";
396  pl->print(*out);
397 
398  *out << "*** THROWN EXCEPTION ***\n";
399  *out << e.what() << std::endl;
400  *out << "************************\n";
401 
402  throw e;
403  }
404  }
405 
406  TEUCHOS_ASSERT(false);
407 }
408 
410 void InverseLibrary::PrintAvailableInverses(std::ostream& os) const {
411  std::map<std::string, Teuchos::RCP<const Teuchos::ParameterList> >::const_iterator itr;
412 
413  os << "Stratimikos Solvers: " << std::endl;
414  os << "********************************" << std::endl;
415  for (itr = stratSolver_.begin(); itr != stratSolver_.end(); ++itr) {
416  os << "name = \"" << itr->first << "\"" << std::endl;
417  itr->second->print(os);
418  os << std::endl;
419  }
420 
421  os << "Stratimikos Preconditioners: " << std::endl;
422  os << "********************************" << std::endl;
423  for (itr = stratPrecond_.begin(); itr != stratPrecond_.end(); ++itr) {
424  os << "name = \"" << itr->first << "\"" << std::endl;
425  itr->second->print(os);
426  os << std::endl;
427  }
428 
429  os << "Teko Preconditioners: " << std::endl;
430  os << "********************************" << std::endl;
431  for (itr = blockPrecond_.begin(); itr != blockPrecond_.end(); ++itr) {
432  os << "name = \"" << itr->first << "\"" << std::endl;
433  itr->second->print(os);
434  os << std::endl;
435  }
436 }
437 
447 RCP<InverseLibrary> InverseLibrary::buildFromParameterList(const Teuchos::ParameterList& pl,
448  bool useStratDefaults) {
449  // build from Stratimikos or allocate a new inverse library
450  RCP<InverseLibrary> invLib;
451  if (useStratDefaults)
452  invLib = InverseLibrary::buildFromStratimikos();
453  else
454  invLib = rcp(new InverseLibrary());
455 
456  // to convert the void* like entry
457  Teuchos::ParameterList* temp = 0;
458 
459  // loop over all entries in parameter list
460  Teuchos::ParameterList::ConstIterator itr;
461  for (itr = pl.begin(); itr != pl.end(); ++itr) {
462  // get current entry
463  std::string label = itr->first;
464  Teuchos::ParameterList& list = itr->second.getValue(temp);
465 
466  // add to library
467  invLib->addInverse(label, list);
468  }
469 
470  return invLib;
471 }
472 
483 RCP<InverseLibrary> InverseLibrary::buildFromParameterList(
484  const Teuchos::ParameterList& pl,
485  const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder>& strat) {
486  // if strat is set to null, use the defaults
487  if (strat == Teuchos::null) return buildFromParameterList(pl, true);
488 
489  // build from Stratimikos or allocate a new inverse library
490  RCP<InverseLibrary> invLib = InverseLibrary::buildFromStratimikos(strat);
491 
492  // to convert the void* like entry
493  Teuchos::ParameterList* temp = 0;
494 
495  // loop over all entries in parameter list
496  Teuchos::ParameterList::ConstIterator itr;
497  for (itr = pl.begin(); itr != pl.end(); ++itr) {
498  // get current entry
499  std::string label = itr->first;
500  Teuchos::ParameterList& list = itr->second.getValue(temp);
501 
502  // add to library
503  invLib->addInverse(label, list);
504  }
505 
506  return invLib;
507 }
508 
517 Teuchos::RCP<InverseLibrary> InverseLibrary::buildFromStratimikos() {
518  RCP<InverseLibrary> invLib = rcp(new InverseLibrary());
519 
520  // get default inveres in Stratimikos
521  RCP<Stratimikos::DefaultLinearSolverBuilder> strat = invLib->defaultBuilder_;
522  RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList(*strat->getValidParameters()));
523  Teuchos::ParameterList lst(pl->sublist("Linear Solver Types"));
524  Teuchos::ParameterList pft(pl->sublist("Preconditioner Types"));
525 
526  Teuchos::ParameterList::ConstIterator itr;
527  Teuchos::ParameterList* temp = 0;
528 
529  // loop over all entries in solver list
530  for (itr = lst.begin(); itr != lst.end(); ++itr) {
531  // get current entry
532  std::string label = itr->first;
533  Teuchos::ParameterList& list = itr->second.getValue(temp);
534  list.set("Type", label);
535 
536  // add to library
537  invLib->addInverse(label, list);
538  }
539 
540  // loop over all entries in preconditioner list
541  for (itr = pft.begin(); itr != pft.end(); ++itr) {
542  // get current entry
543  std::string label = itr->first;
544  Teuchos::ParameterList& list = itr->second.getValue(temp);
545  list.set("Type", label);
546 
547  // add to library
548  invLib->addInverse(label, list);
549  }
550 
551  return invLib;
552 }
553 
563 Teuchos::RCP<InverseLibrary> InverseLibrary::buildFromStratimikos(
564  const Stratimikos::DefaultLinearSolverBuilder& strat) {
565  RCP<InverseLibrary> invLib = rcp(new InverseLibrary());
566 
567  // get default inveres in Stratimikos
568  RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList(*strat.getValidParameters()));
569  Teuchos::ParameterList lst(pl->sublist("Linear Solver Types"));
570  Teuchos::ParameterList pft(pl->sublist("Preconditioner Types"));
571 
572  Teuchos::ParameterList::ConstIterator itr;
573  Teuchos::ParameterList* temp = 0;
574 
575  // loop over all entries in solver list
576  for (itr = lst.begin(); itr != lst.end(); ++itr) {
577  // get current entry
578  std::string label = itr->first;
579  Teuchos::ParameterList& list = itr->second.getValue(temp);
580  list.set("Type", label);
581 
582  // add to library
583  invLib->addInverse(label, list);
584  }
585 
586  // loop over all entries in preconditioner list
587  for (itr = pft.begin(); itr != pft.end(); ++itr) {
588  // get current entry
589  std::string label = itr->first;
590  Teuchos::ParameterList& list = itr->second.getValue(temp);
591  list.set("Type", label);
592 
593  // add to library
594  invLib->addInverse(label, list);
595  }
596 
597  return invLib;
598 }
599 
609 Teuchos::RCP<InverseLibrary> InverseLibrary::buildFromStratimikos(
610  const Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder>& strat) {
611  RCP<InverseLibrary> invLib = rcp(new InverseLibrary(strat));
612 
613  // get default inveres in Stratimikos
614  RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList(*strat->getValidParameters()));
615  Teuchos::ParameterList lst(pl->sublist("Linear Solver Types"));
616  Teuchos::ParameterList pft(pl->sublist("Preconditioner Types"));
617 
618  Teuchos::ParameterList::ConstIterator itr;
619  Teuchos::ParameterList* temp = 0;
620 
621  // loop over all entries in solver list
622  for (itr = lst.begin(); itr != lst.end(); ++itr) {
623  // get current entry
624  std::string label = itr->first;
625  Teuchos::ParameterList& list = itr->second.getValue(temp);
626  list.set("Type", label);
627 
628  // add to library
629  invLib->addInverse(label, list);
630  }
631 
632  // loop over all entries in preconditioner list
633  for (itr = pft.begin(); itr != pft.end(); ++itr) {
634  // get current entry
635  std::string label = itr->first;
636  Teuchos::ParameterList& list = itr->second.getValue(temp);
637  list.set("Type", label);
638 
639  // add to library
640  invLib->addInverse(label, list);
641  }
642 
643  return invLib;
644 }
645 
646 } // end namespace Teko
static void getPreconditionerFactoryNames(std::vector< std::string > &names)
Get the names of the block preconditioner factories.
static Teuchos::RCP< PreconditionerFactory > buildPreconditionerFactory(const std::string &name, const Teuchos::ParameterList &settings, const Teuchos::RCP< const InverseLibrary > &invLib=Teuchos::null)
Builder function for creating preconditioner factories (yes this is a factory factory).