There are four steps to calling the solver.

// Construct an object that derives from the abstract Group object. Here // we call it the ExampleGroup. It should contain the initial guess. Teuchos::RefCountPtr<UserConcreteGroup> grp = Teuchos::rcp(new UserConcreteGroup);

Note that the group is not handled as a raw pointer, but is wrapped in a reference counter smart pointer (RCP). RCPs enforce strict memory management in NOX and LOCA and can prevent many errors that users have encountered with objects going out of scope. We use the RCP implementation in the Trilinos package Teuchos. For information on the use of smart pointers, see Teuchos Reference Counted Pointer Beginners Guide.

- The NOX::StatusTest::MaxIters test is used to control the maximum number of iterations that the nonlinear solver is allowed to take.

- The NOX::StatusTest::NormF test checks the size of . This check can be done based on relative or absolute norms, scaled by , and more. See the description for more details.

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 Teuchos::RefCountPtr<NOX::StatusTest::NormF> statusTestNormF = Teuchos::rcp(new NOX::StatusTest::NormF(1.0e-4)); Teuchos::RefCountPtr<NOX::StatusTest::MaxIters> statusTestMaxIters = Teuchos::rcp(new NOX::StatusTest::MaxIters(20)); Teuchos::RefCountPtr<NOX::StatusTest::Combo> statusTestsCombo = Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::OR, statusTestNormF, statusTestMaxIters));

This test uses an OR combination, meaning that either test registered with the Combo test can trigger termination. The first test requires that the norm of the residual is less that 1.0e-4. If met, NOX will terminate returning a "Converged" result. The second test will trigger NOX to terminate if a maximum number of iterations is reached and return a "Failed" result.

// Create the list of solver parameters Teuchos::RefCountPtr<Teuchos::ParameterList> solverParametersPtr = Teuchos::rcp(new Teuchos::ParameterList); // Select the solver (this is the default) solverParametersPtr->set("Nonlinear Solver", "Line Search Based"); // Create the line search parameters sublist Teuchos::ParameterList& lineSearchParameters = solverParametersPtr->sublist("Line Search"); // Set the line search method lineSearchParameters.set("Method","More'-Thuente");

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

// Create the solver NOX::Solver::Manager solver(grp, statusTestsCombo, solverParametersPtr); // Solve the nonlinear system NOX::StatusTest::StatusType status = solver.solve(); // Print the parameter list cout << "\n" << "-- Parameter List From Solver --" << "\n"; solver.getList().print(cout); // Get the answer grp = solver.getSolutionGroup(); // Print the answer cout << "\n" << "-- Final Solution From Solver --" << "\n"; grp.printSolution();

Generated on Thu Sep 18 12:38:28 2008 for NOX by 1.3.9.1