NOX
Development
|
This page describes how to write the main file for using NOX's Epetra implementation of the Group and Vector.
This example can be found in Trilinos/packages/nox/test/epetra/1Dfem/1Dfem.C
Begin by including the NOX library header files and any other headers needed by your application:
For convenience define the following:
Begin by initializing MPI (if building a parallel version) and create the Epetra communicator for MPI. In this case autoconf defines the flag HAVE_MPI if we are building a parallel version.
Setup some initial values.
Create your object that derives from NOX::Epetra::Interface::Required so that nox has access to the set of nonlinear equations to solve.
Grab the initial guess vector and initialize it and the interface object.
Create a parameter list and choose the options for the NOX solver. Note that the linear solver parameters in teh "Linear Solver" sublist are dependent upon what NOX::Epetra::LinearSystem object you are using. Currently NOX only comes with one concrete linear system implementation: NOX::EpetraLinearSystemAztecOO.
Optionally the user can define methods that will be called before and after each nonlineaer iteration and before and after each nonlinear solve. This is done by creating an object derived from NOX::Abstract::PrePostOperator.
Set the status test check option.
Create a Jacobian-Free Newton-Krylov method by using a NOX::Epetra::MatrixFree operator for the Jacobian.
Create a Finite Difference operator to estimate the Jacobian matrix for preconditioning.
Create a linear system derived from NOX::Epetra::LinearSystem. NOX comes with a concrete implementation of the linear system class that uses AztecOO as the linear solver called NOX::Epetra::LinearSystemAztecOO. In this case we will use the constructor that specifies the Jacobian operator and a preconditioner matrix to be used with an internally constructed AztecOO preconditioner.
Create the group using the linear system.
Create the status tests to determine how to terminate the nonlinear solve.
Create the solver and solve the problem
Get the underlying solution vector in terms of an Epetra_Vector and do whatever you want with it.
Exit simulation.