|
Stratimikos Package Browser (Single Doxygen Collection)
Version of the Day
|
Simple example program for how the Stratimikos::DefaultLinearSolverBuilder class is used to take a parameter list (e.g. read from a file) and use it so solve a linear system read in as Epetra objects from a file.
Outline
Example program source (with line numbers)
Command-line options for the driver program
Teuchos::GlobalMPISession::GlobalMPISession(): started serial run
Echoing the command-line:
/home/rabartl/PROJECTS/Trilinos.base/BUILDS/CMAKE/SERIAL_DEBUG/packages/stratimikos/example/Stratimikos_simple_stratimikos_example.exe --echo-command-line --help
Usage: /home/rabartl/PROJECTS/Trilinos.base/BUILDS/CMAKE/SERIAL_DEBUG/packages/stratimikos/example/Stratimikos_simple_stratimikos_example.exe [options]
options:
--help Prints this help message
--pause-for-debugging Pauses for user input to allow attaching a debugger
--echo-command-line Echo the command-line but continue as normal
--linear-solver-params-file string Name of an XML file containing parameters for linear solver options to be appended first.
(default: --linear-solver-params-file="")
--extra-linear-solver-params string An XML string containing linear solver parameters to be appended second.
(default: --extra-linear-solver-params="")
--linear-solver-params-used-file string Name of an XML file that can be written with the parameter list after it has been used on completion of this program.
(default: --linear-solver-params-used-file="")
--matrix-file string Defines the matrix and perhaps the RHS and LHS for a linear system to be solved.
(default: --matrix-file="")
--tol double Tolerance to check against the scaled residual norm.
(default: --tol=1e-05)
--only-print-options bool Only print options and stop or continue on
--continue-after-printing-options (default: --continue-after-printing-options)
--print-xml-format bool Print the valid options in XML format or in readable format.
--print-readable-format (default: --print-readable-format)
--show-doc bool Print the valid options with or without documentation.
--hide-doc (default: --show-doc)
DETAILED DOCUMENTATION:
Simple example for the use of the Stratimikos facade Stratimikos::DefaultLinearSolverBuilder.
To print out just the valid options use --matrix-file="" --only-print-options with --print-xml-format or --print-readable-format.
To solve a linear system from a system read from a file use --matrix-file="SomeFile.mtx" with options read from an XML file using --linear-solver-params-file="SomeFile.xml"
Here is an example input XML file, called amesos.klu.xml, that specifies that the KLU solver from Amesos be used to solve the linear system:
<ParameterList>
<Parameter isUsed="true" name="Linear Solver Type" type="string" value="Amesos"/>
<ParameterList name="Linear Solver Types">
<ParameterList name="Amesos">
<ParameterList name="Amesos Settings"/>
<Parameter name="Solver Type" type="string" value="Klu"/>
</ParameterList>
</ParameterList>
<Parameter name="Preconditioner Type" type="string" value="None"/>
</ParameterList>
Sample output looks like when using the above amesos.klu.xml file as input with a test system:
Teuchos::GlobalMPISession::GlobalMPISession(): started serial run Echoing the command-line: /home/rabartl/PROJECTS/Trilinos.base/BUILDS/CMAKE/SERIAL_DEBUG/packages/stratimikos/example/Stratimikos_simple_stratimikos_example.exe --echo-command-line --matrix-file=FourByFour.mtx --linear-solver-params-file=amesos.klu.xml Reading linear system in Epetra format from the file 'FourByFour.mtx' ... Printing statistics of the Epetra linear system ... Epetra_CrsMatrix epetra_A of dimension 4 x 4 ||epetraA||inf = 1.643 ||epetra_b||2 = 1.52593 ||epetra_x||2 = 0 Reading parameters from XML file "amesos.klu.xml" ... Solving block system using Amesos solver Amesos_Klu ... Total solve time = 0 sec Solve status: solveStatus = SOLVE_STATUS_CONVERGED achievedTol = unknownTolerance() message: Solver Amesos_Klu converged! extraParameters: NONE Solution ||epetra_x||2 = 1.24984 Testing the solution error ||b-A*x||/||b|| computed through the Epetra objects ... ||b-A*x||/||b|| = 1.11022e-16/1.52593 = 7.27571e-17 < tol = 1e-05 ? passed Congratulations! All of the tests checked out!
Example program source (without line numbers)
Here is the main driver program itself without line numbers:
1.8.16