dynamic_cast
to get an object of concrete type (such as Epetra) and then give them to your favorite solver. With this method, you can use any solver compatible with the concrete vector/matrix type created by your run. In the following sections, we describe how to instantiate any of these solvers from an XML file, and how to write a solver specification in XML.
/* Read the parameters for the linear solver from an XML file */ ParameterXMLFileReader reader("../../examples-tutorial/bicgstab.xml"); ParameterList solverParams = reader.getParameters(); LinearSolver<double> linSolver = LinearSolverBuilder::createSolver(solverParams);
<Parameter name="Method" type="string" value="GMRES"/>
"string",
"int",
or "double".
The parameters for a solver should be included in a ParameterList object with name "Linear Solver". In XML, this is written as follows. <ParameterList name="Linear Solver">
<!-- solver parameters go here -->
</ParameterList>
Type
parameter. Don't confuse this with the choice of solver algorithm, the specification of which is done in a way that may vary from package to package (in both native TSF and Aztec solvers, it is done using the "Method" parameter). To use an Aztec solver, one would include <Parameter name="Type" type="string" value="Aztec"/>
<Parameter name="Type" type="string" value="TSF"/>
We now show two examples; the meaning of the parameters in each solver specification is described more fully in the sections on XML Specification of Native TSF Solvers and XML Specification of Aztec Solvers.
<ParameterList name="Linear Solver"> <Parameter name="Type" type="string" value="Aztec"/> <Parameter name="Method" type="string" value="GMRES"/> <Parameter name="Precond" type="string" value="Domain Decomposition"/> <Parameter name="Subdomain Solver" type="string" value="ILU"/> <Parameter name="Graph Fill" type="int" value="2"/> <Parameter name="Max Iterations" type="int" value="1000"/> <Parameter name="Tolerance" type="double" value="1e-6"/> </ParameterList>
<ParameterList name="Linear Solver"> <Parameter name="Type" type="string" value="TSF"/> <Parameter name="Method" type="string" value="BICGSTAB"/> <Parameter name="Graph Fill" type="int" value="1"/> <Parameter name="Max Iterations" type="int" value="800"/> <Parameter name="Precond" type="string" value="ILUK"/> <Parameter name="Tolerance" type="double" value="1e-12"/> <Parameter name="Verbosity" type="int" value="4"/> </ParameterList>
"Method"
"BICGSTAB", "GMRES"
"Precond"
"ILUK"
"Max Iterations"
"Graph Fill"
"Verbosity"
"Tolerance"
<Parameter name="Method" type="string" value="GMRES"/>
"Method"
"CG", "GMRES", "CGS", "TFQMR", "BICGSTAB", "Direct"
"Precond"
"None", "Jacobi", "Neumann Series", "Symmetric Gauss-Seidel", "Least-Squares Polynomial", "Domain Decomposition"
"Subdomain Solver"
"Approximate Sparse LU", "Saad ILUT", "ILU", "RILU", "Block ILU", "Incomplete Cholesky"
"Residual Scaling"
"Initial", "RHS", "Matrix", "Solution", "No Scaling"
"Verbosity"
"All", "Silent", "Warnings", "Final Residual"
"Overlap Type"
"Standard", "Symmetric"
"GMRES Orthogonalization"
"Classical Gram-Schmidt", "Modified Gram-Schmidt"
"Auxiliary Vector"
"Residual", "Random"
AZ_reorder "Reorder ILU" // whether to reorder before ILU factoring AZ_keep_info "Keep Factorization" // whether to preserve factorings between solves AZ_graph_fill "Graph Fill" // on-processor fill level for incomplete factorizations AZ_max_iter "Max Iterations" // max iterations for krylov solvers AZ_poly_ord "Polynomial Order" // order of polynomial precond AZ_kspace "Restart Size" // Size of Krylov subspace to be stored by GMRES AZ_overlap "Overlap" // off-processor fill level for incomplete factorizations
AZ_tol "Tolerance" // convergence tolerance (see section on scaling) AZ_drop "Drop Tolerance" // tolerance for discarding fill elements in an incomplete factorization AZ_ilut_fill "Fill Ratio" // maximum fill ratio allowed in an ILUT precond AZ_omega "Damping" // damping factor
AZ_solver "Method" AZ_cg "CG" AZ_gmres "GMRES" AZ_cgs "CGS" AZ_tfqmr "TFQMR" AZ_bicgstab "BICGSTAB" AZ_lu "Direct" AZ_precond "Precond" AZ_none "None" AZ_Jacobi "Jacobi" AZ_Neumann "Neumann Series" AZ_sym_GS "Symmetric Gauss-Seidel" AZ_ls "Least-Squares Polynomial" AZ_dom_decomp "Domain Decomposition" AZ_subdomain_solve "Subdomain Solver" AZ_lu "Approximate Sparse LU" AZ_ilut "Saad ILUT" AZ_ilu "ILU" AZ_rilu "RILU" AZ_bilu "Block ILU" AZ_icc "Incomplete Cholesky" AZ_reorder "Reorder ILU" AZ_keep_info "Keep Factorization" AZ_graph_fill "Graph Fill" AZ_max_iter "Max Iterations" AZ_poly_ord "Polynomial Order" AZ_kspace "Restart Size" AZ_overlap "Overlap" AZ_tol "Tolerance" AZ_drop "Drop Tolerance" AZ_ilut_fill "Fill Ratio" AZ_omega "Damping" AZ_conv "Residual Scaling" AZ_r0 "Initial" AZ_rhs "RHS" AZ_Anorm "Matrix" AZ_sol "Solution" AZ_noscaled "No Scaling" AZ_output "Verbosity" AZ_all "All" AZ_none "Silent" AZ_warnings "Warnings" AZ_last "Final Residual" AZ_type_overlap "Overlap Type" AZ_standard "Standard" AZ_symmetric "Symmetric" AZ_reorder "Reorder ILU" AZ_keep_info "Keep Factorization" AZ_orthog "GMRES Orthogonalization" AZ_classic "Classical Gram-Schmidt" AZ_modified "Modified Gram-Schmidt" AZ_aux_vec "Auxiliary Vector" AZ_resid "Residual" AZ_rand "Random" AZ_reorder "Reorder ILU" AZ_keep_info "Keep Factorization" AZ_graph_fill "Graph Fill" AZ_max_iter "Max Iterations" AZ_poly_ord "Polynomial Order" AZ_kspace "Restart Size" AZ_overlap "Overlap" AZ_tol "Tolerance" AZ_drop "Drop Tolerance" AZ_ilut_fill "Fill Ratio" AZ_omega "Damping"