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::RCP<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.

Alternatively, users can build a set of status tests from a Teuchos::ParameterList by using the NOX::StatusTest::Factory object. See NOX::StatusTest::Factory for parameter list arguments and examples.

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::RCP<NOX::StatusTest::NormF> statusTestNormF = Teuchos::rcp(new NOX::StatusTest::NormF(1.0e-4)); Teuchos::RCP<NOX::StatusTest::MaxIters> statusTestMaxIters = Teuchos::rcp(new NOX::StatusTest::MaxIters(20)); Teuchos::RCP<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::RCP<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 Teuchos::RCP<NOX::Solver::Generic> solver = NOX::Solver::buildSolver(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 Wed May 12 21:26:21 2010 for NOX by 1.4.7