10#include "AztecOOParameterList.hpp" 
   11#include "Teuchos_StandardParameterEntryValidators.hpp" 
   12#include "Teuchos_ValidatorXMLConverterDB.hpp" 
   13#include "Teuchos_StandardValidatorXMLConverters.hpp" 
   23const std::string AztecSolver_name = 
"Aztec Solver";
 
   25const std::string AztecPreconditioner_name = 
"Aztec Preconditioner";
 
   27enum EAztecPreconditioner {
 
   28  AZTEC_PREC_NONE, AZTEC_PREC_ILU, AZTEC_PREC_ILUT, AZTEC_PREC_JACOBI,
 
   29  AZTEC_PREC_SYMMGS, AZTEC_PREC_POLY, AZTEC_PREC_LSPOLY
 
   33inline std::istream& operator>>(std::istream& is, EAztecPreconditioner& prec){
 
   36  prec = (EAztecPreconditioner)intval;
 
   40const std::string Overlap_name = 
"Overlap";
 
   42const std::string GraphFill_name = 
"Graph Fill";
 
   44const std::string DropTolerance_name = 
"Drop Tolerance";
 
   46const std::string FillFactor_name = 
"Fill Factor";
 
   48const std::string Steps_name = 
"Steps";
 
   50const std::string PolynomialOrder_name = 
"Polynomial Order";
 
   52const std::string RCMReordering_name = 
"RCM Reordering";
 
   54const std::string Orthogonalization_name = 
"Orthogonalization";
 
   56const std::string SizeOfKrylovSubspace_name = 
"Size of Krylov Subspace";
 
   58const std::string ConvergenceTest_name = 
"Convergence Test";
 
   60const std::string IllConditioningThreshold_name = 
"Ill-Conditioning Threshold";
 
   62const std::string OutputFrequency_name = 
"Output Frequency";
 
   64Teuchos::RCP<Teuchos::ParameterList>  validAztecOOParams;
 
   68void setAztecOOParameters(
 
   69  Teuchos::ParameterList  *pl
 
   73  using Teuchos::getIntegralValue;
 
   74  using Teuchos::getParameter;
 
   75  TEUCHOS_TEST_FOR_EXCEPT(pl==NULL);
 
   76  TEUCHOS_TEST_FOR_EXCEPT(solver==NULL);
 
   79  pl->validateParametersAndSetDefaults(*getValidAztecOOParameters());
 
   83    ,getIntegralValue<int>(*pl,AztecSolver_name)
 
   87    getIntegralValue<EAztecPreconditioner>(
 
   88      *pl,AztecPreconditioner_name
 
   96      pl->set(AztecPreconditioner_name, 
"none");
 
  100      solver->
SetAztecOption(AZ_overlap,getParameter<int>(*pl,Overlap_name));
 
  102      solver->
SetAztecOption(AZ_graph_fill,getParameter<int>(*pl,GraphFill_name));
 
  103      pl->set(AztecPreconditioner_name, 
"ilu");
 
  105    case AZTEC_PREC_ILUT:
 
  107      solver->
SetAztecOption(AZ_overlap,getParameter<int>(*pl,Overlap_name));
 
  109      solver->
SetAztecParam(AZ_drop,getParameter<double>(*pl,DropTolerance_name));
 
  110      solver->
SetAztecParam(AZ_ilut_fill,getParameter<double>(*pl,FillFactor_name));
 
  111      pl->set(AztecPreconditioner_name, 
"ilut");
 
  113    case AZTEC_PREC_JACOBI:
 
  115      solver->
SetAztecOption(AZ_poly_ord,getParameter<int>(*pl,Steps_name));
 
  116      pl->set(AztecPreconditioner_name, 
"Jacobi");
 
  118    case AZTEC_PREC_SYMMGS:
 
  120      solver->
SetAztecOption(AZ_poly_ord,getParameter<int>(*pl,Steps_name));
 
  121      pl->set(AztecPreconditioner_name, 
"Symmetric Gauss-Seidel");
 
  123    case AZTEC_PREC_POLY:
 
  125      solver->
SetAztecOption(AZ_poly_ord,getParameter<int>(*pl,PolynomialOrder_name));
 
  126      pl->set(AztecPreconditioner_name, 
"Polynomial");
 
  128    case AZTEC_PREC_LSPOLY:
 
  130      solver->
SetAztecOption(AZ_poly_ord,getParameter<int>(*pl,PolynomialOrder_name));
 
  131      pl->set(AztecPreconditioner_name, 
"Least-squares Polynomial");
 
  134      TEUCHOS_TEST_FOR_EXCEPT(
true); 
 
  139    ,getIntegralValue<int>(*pl,RCMReordering_name)
 
  144    ,getIntegralValue<int>(*pl,Orthogonalization_name)
 
  147  solver->
SetAztecOption(AZ_kspace,getParameter<int>(*pl,SizeOfKrylovSubspace_name));
 
  151    ,getIntegralValue<int>(*pl,ConvergenceTest_name)
 
  155    AZ_ill_cond_thresh, getParameter<double>(*pl,IllConditioningThreshold_name)
 
  159    AZ_output, getParameter<int>(*pl,OutputFrequency_name)
 
  163  pl->validateParameters(*getValidAztecOOParameters());
 
  167Teuchos::RCP<const Teuchos::ParameterList>
 
  168getValidAztecOOParameters()
 
  179  using Teuchos::tuple;
 
  180  using Teuchos::setStringToIntegralParameter;
 
  181  using Teuchos::setIntParameter;
 
  182  using Teuchos::setDoubleParameter;
 
  183  using Teuchos::ParameterList;
 
  190  Teuchos::ValidatorXMLConverterDB::addConverter(
 
  191    Teuchos::DummyObjectGetter<
 
  192      Teuchos::StringToIntegralParameterEntryValidator<EAztecPreconditioner> 
 
  194    Teuchos::DummyObjectGetter<Teuchos::StringToIntegralValidatorXMLConverter<
 
  195      EAztecPreconditioner> >::getDummyObject());
 
  197  RCP<ParameterList> pl = validAztecOOParams;
 
  198  if(pl.get()) 
return pl;
 
  199  pl = validAztecOOParams = rcp(
new ParameterList());
 
  201  setStringToIntegralParameter<int>(
 
  202    AztecSolver_name, 
"GMRES",
 
  203    "Type of linear solver algorithm to use.",
 
  204    tuple<std::string>(
"CG",
"GMRES",
"CGS",
"TFQMR",
"BiCGStab",
"LU",
"GMRESR",
"FixedPoint"),
 
  205    tuple<int>(AZ_cg,AZ_gmres,AZ_cgs,AZ_tfqmr,AZ_bicgstab,AZ_lu,AZ_GMRESR,AZ_fixed_pt),
 
  208  setStringToIntegralParameter<EAztecPreconditioner>(
 
  209    AztecPreconditioner_name, 
"ilu",
 
  210    "Type of internal preconditioner to use.\n" 
  211    "Note! this preconditioner will only be used if the input operator\n" 
  212    "supports the Epetra_RowMatrix interface and the client does not pass\n" 
  213    "in an external preconditioner!",
 
  215      "none",
"ilu",
"ilut",
"Jacobi",
 
  216      "Symmetric Gauss-Seidel",
"Polynomial",
"Least-squares Polynomial" 
  218    tuple<EAztecPreconditioner>(
 
  219      AZTEC_PREC_NONE,AZTEC_PREC_ILU,AZTEC_PREC_ILUT,AZTEC_PREC_JACOBI,
 
  220      AZTEC_PREC_SYMMGS,AZTEC_PREC_POLY,AZTEC_PREC_LSPOLY
 
  226    "The amount of overlap used for the internal \"ilu\" and \"ilut\" preconditioners.",
 
  231    "The amount of fill allowed for the internal \"ilu\" preconditioner.",
 
  235    DropTolerance_name, 0.0,
 
  236    "The tolerance below which an entry from the factors of an internal \"ilut\"\n" 
  237    "preconditioner will be dropped.",
 
  241    FillFactor_name, 1.0,
 
  242    "The amount of fill allowed for an internal \"ilut\" preconditioner.",
 
  247    "Number of steps taken for the \"Jacobi\" or the \"Symmetric Gauss-Seidel\"\n" 
  248    "internal preconditioners for each preconditioner application.",
 
  252    PolynomialOrder_name, 3,
 
  253    "The order for of the polynomials used for the \"Polynomial\" and\n" 
  254    "\"Least-squares Polynomial\" internal preconditioners.",
 
  257  setStringToIntegralParameter<int>(
 
  258    RCMReordering_name, 
"Disabled",
 
  259    "Determines if RCM reordering is used with the internal\n" 
  260    "\"ilu\" or \"ilut\" preconditioners.",
 
  261    tuple<std::string>(
"Enabled",
"Disabled"),
 
  265  setStringToIntegralParameter<int>(
 
  266    Orthogonalization_name, 
"Classical",
 
  267    "The type of orthogonalization to use with the \"GMRES\" solver.",
 
  268    tuple<std::string>(
"Classical",
"Modified"),
 
  269    tuple<int>(AZ_classic,AZ_modified),
 
  273    SizeOfKrylovSubspace_name, 300,
 
  274    "The maximum size of the Krylov subspace used with \"GMRES\" before\n" 
  275    "a restart is performed.",
 
  278  setStringToIntegralParameter<int>(
 
  279    ConvergenceTest_name, 
"r0", 
 
  280    "The convergence test to use for terminating the iterative solver.",
 
  281    tuple<std::string>(
"r0",
"rhs",
"Anorm",
"no scaling",
"sol"),
 
  282    tuple<int>(AZ_r0,AZ_rhs,AZ_Anorm,AZ_noscaled,AZ_sol),
 
  286    IllConditioningThreshold_name, 1e+11,
 
  287    "The threshold tolerance above which a system is considered\n" 
  292    OutputFrequency_name, 0, 
 
  293    "The number of iterations between each output of the solver's progress.",
 
int SetAztecParam(int param, double value)
int SetAztecOption(int option, int value)