Step 3: Call NOX from your code

A small example based on the NOX::LAPACK Vector and Group is included with NOX; see Rosenbrock.C.

There are four steps to calling the solver.

Step A: Set up a Group object containing the initial guess.

The first step is to somehow construct an object deriving from the Abstract::Group which contains the initial guess as its x-vector. See Step 2: Create concrete implementations of the NOX::Abstract classes for more details.

// Construct an object that derives from the abstract Group object. Here
// we call it the ExampleGroup. It should contain the initial guess.
ExampleGroup grp;

Step B: Construct the status tests

The NOX::StatusTest objects are used to test for convergence or failure. For example...

These and other status tests can be combined using the NOX::StatusTest::Combo object. It takes an arbitrary number of status tests and either AND's or OR's them together.

Finally, the user can create their own status tests, so long as they derive from NOX::StatusTest::Generic.

Here is some sample code.

  // Set up the status tests
  NOX::StatusTest::NormF statusTestA(grp, 1.0e-4);
  NOX::StatusTest::MaxIters statusTestB(20);
  NOX::StatusTest::Combo statusTestsCombo(NOX::StatusTest::Combo::OR, statusTestA, statusTestB);

Step C: Set the solver parameters

Next, we set up a parameter list containing the information on what types of solvers and so forth should be used.

// Create the list of solver parameters
NOX::Parameter::List solverParameters;

// Set the solver (this is the default)
solverParameters.setParameter("Nonlinear Solver", "Line Search Based");

// Create the line search parameters sublist
NOX::Parameter::List& lineSearchParameters = solverParameters.sublist("Line Search");

// Set the line search method
lineSearchParameters.setParameter("Method","More'-Thuente");

For a full list of parameters; see NOX Parameter Reference Page.

Step D: Construct the solver and solve

The last step is to create the solver, passing in the group with the initial guess, the status tests, and the solver parameters.

// Create the solver
NOX::Solver::Manager solver(grp, statusTestsCombo, solverParameters);

// Solve the nonlinear system
NOX::StatusTest::StatusType status = solver.solve();

// Print the answer
cout << "\n" << "-- Parameter List From Solver --" << "\n";
solver.getParameterList().print(cout);

// Get the answer
grp = solver.getSolutionGroup();

// Print the answer
cout << "\n" << "-- Final Solution From Solver --" << "\n";
grp.print();

If you have problems...

If you have problems configuring and compiling NOX, please report them using Bugzilla; see Reporting Bugs and Making Enhancement Requests for more information.

Moving on...

Go on to Step 4: Link your code to NOX.
Generated on Thu Sep 18 12:43:29 2008 for NOX by doxygen 1.3.9.1