Exemplo n.º 1
0
int main(int argc, char *argv[])
{
  // Initialize MPI
  Teuchos::GlobalMPISession mpiSession(&argc,&argv);

  // Get the number of elements from the command line
  int NumGlobalNodes = 100 + 1;

#ifdef DO_XYZT
  // MPI MANIPULATION FOR XYZT PROBLEMS
  int spatialProcs = 1; // default
  if (argc>2) { spatialProcs = atoi(argv[2]);}
  int numTimeSteps= 1; // default
  if (argc>3) { numTimeSteps = atoi(argv[3]);}

  Teuchos::RCP<EpetraExt::MultiMpiComm> globalComm = 
    Teuchos::rcp(new EpetraExt::MultiMpiComm(MPI_COMM_WORLD, spatialProcs, numTimeSteps));
  Epetra_Comm& Comm = globalComm->SubDomainComm();

#else
  // Create a communicator for Epetra objects
#ifdef HAVE_MPI
  Epetra_MpiComm Comm( MPI_COMM_WORLD );
#else
  Epetra_SerialComm Comm();
#endif

#endif

  // Create and reset the Timer
  Epetra_Time myTimer(Comm);
  double startWallTime = myTimer.WallTime();

  // Get the process ID and the total number of processors
  int MyPID = Comm.MyPID();
  int NumProc = Comm.NumProc();

  // The number of unknowns must be at least equal to the 
  // number of processors.
  if (NumGlobalNodes < NumProc) {
    std::cout << "numGlobalNodes = " << NumGlobalNodes 
	 << " cannot be < number of processors = " << NumProc << std::endl;
    exit(1);
  }

  // Create the Brusselator problem class.  This creates all required
  // Epetra objects for the problem and allows calls to the 
  // function (F) and Jacobian evaluation routines.
  Brusselator::OverlapType OType = Brusselator::ELEMENTS;
  Brusselator Problem(NumGlobalNodes, Comm, OType);
  double dt = 0.5;

  // Get the vector from the Problem
  Epetra_Vector& soln = Problem.getSolution();
  Epetra_Vector& initCond = soln;

  // Begin Nonlinear Solver ************************************

  // Create the top level parameter list

  Teuchos::RCP<Teuchos::ParameterList> paramList =
       Teuchos::rcp(new Teuchos::ParameterList);

  // Create LOCA sublist
  Teuchos::ParameterList& locaParamsList = paramList->sublist("LOCA");

  // Create the stepper sublist and set the stepper parameters
  Teuchos::ParameterList& locaStepperList = locaParamsList.sublist("Stepper");
  locaStepperList.set("Continuation Method", "Natural");
  //locaStepperList.set("Continuation Method", "Arc Length");
  //locaStepperList.set("Continuation Method", "Householder Arc Length");
  locaStepperList.set("Continuation Parameter", "alpha");
  locaStepperList.set("Initial Value", 0.6);
  locaStepperList.set("Max Value", 100.0);
  locaStepperList.set("Min Value", 0.05);
#ifdef DO_XYZT
  locaStepperList.set("Max Steps", 7);
#else
  locaStepperList.set("Max Steps", 0);// must be 0 so just a nonlinear solver
#endif
  locaStepperList.set("Max Nonlinear Iterations", 15);
  locaStepperList.set("Enable Arc Length Scaling", true);
  locaStepperList.set("Goal Arc Length Parameter Contribution", 0.5);
  locaStepperList.set("Max Arc Length Parameter Contribution", 0.7);
  locaStepperList.set("Initial Scale Factor", 1.0);
  locaStepperList.set("Min Scale Factor", 1.0e-8);
  locaStepperList.set("Enable Tangent Factor Step Size Scaling",false);
  locaStepperList.set("Min Tangent Factor", 0.8);
  locaStepperList.set("Tangent Factor Exponent",1.5);

  // Create step size sublist
  Teuchos::ParameterList& stepSizeList = locaParamsList.sublist("Step Size");
  stepSizeList.set("Method", "Constant");
 // stepSizeList.set("Method", "Adaptive");
  stepSizeList.set("Initial Step Size", -0.1);
  stepSizeList.set("Min Step Size", 1.0e-3);
  stepSizeList.set("Max Step Size", 2000.0);
  stepSizeList.set("Aggressiveness", 0.1);
  stepSizeList.set("Failed Step Reduction Factor", 0.5);
  stepSizeList.set("Successful Step Increase Factor", 1.00); // for constant

  // Create predictor sublist
  Teuchos::ParameterList& predictorList = locaParamsList.sublist("Predictor");
  //predictorList.set("Method", "Constant");
  //predictorList.set("Method", "Tangent");
  predictorList.set("Method", "Secant");

  // Create bifurcation sublist
    Teuchos::ParameterList& bifurcationList = 
      locaParamsList.sublist("Bifurcation");
    bifurcationList.set("Type", "None");

  // Create Anasazi Eigensolver sublist (needs --with-loca-anasazi)
  locaStepperList.set("Compute Eigenvalues",false);
#ifdef HAVE_LOCA_ANASAZI
  Teuchos::ParameterList& aList = locaStepperList.sublist("Eigensolver");
  aList.set("Method", "Anasazi");
  aList.set("Block Size", 1);
  aList.set("Num Blocks", 10);
  aList.set("Num Eigenvalues", 3);
  aList.set("Convergence Tolerance", 2.0e-7);
  aList.set("Convergence Check", 1);
  aList.set("Maximum Restarts",2);
  aList.set("Step Size",1);
  aList.set("Verbosity",
	    Anasazi::Errors + 
	    Anasazi::Warnings +
	    Anasazi::FinalSummary);
#endif

  // Create the "Solver" parameters sublist to be used with NOX Solvers
  Teuchos::ParameterList& nlParams = paramList->sublist("NOX");
  // Set the nonlinear solver method
  nlParams.set("Nonlinear Solver", "Line Search Based");
  //nlParams.set("Nonlinear Solver", "Trust Region Based");

  // Set the printing parameters in the "Printing" sublist
  Teuchos::ParameterList& printParams = nlParams.sublist("Printing");
  printParams.set("MyPID", MyPID); 
  printParams.set("Output Precision", 3);
  printParams.set("Output Processor", 0);
  printParams.set("Output Information", 
			   NOX::Utils::OuterIteration + 
			   NOX::Utils::OuterIterationStatusTest + 
			   NOX::Utils::InnerIteration +
			   NOX::Utils::Parameters + 
			   NOX::Utils::Details + 
			   NOX::Utils::Warning + 
			   NOX::Utils::StepperIteration +
			   NOX::Utils::StepperDetails);

  // Sublist for line search 
  Teuchos::ParameterList& searchParams = nlParams.sublist("Line Search");
  searchParams.set("Method", "Full Step");
  //searchParams.set("Method", "Interval Halving");
  //searchParams.set("Method", "Polynomial");
  //searchParams.set("Method", "NonlinearCG");
  //searchParams.set("Method", "Quadratic");
  //searchParams.set("Method", "More'-Thuente");

  // Sublist for direction
  Teuchos::ParameterList& dirParams = nlParams.sublist("Direction");
  dirParams.set("Method", "Newton");
  Teuchos::ParameterList& newtonParams = dirParams.sublist("Newton");
    newtonParams.set("Forcing Term Method", "Constant");
    //newtonParams.set("Forcing Term Method", "Type 1");
    //newtonParams.set("Forcing Term Method", "Type 2");
    //newtonParams.set("Forcing Term Minimum Tolerance", 1.0e-4);
    //newtonParams.set("Forcing Term Maximum Tolerance", 0.1);
  //dirParams.set("Method", "Steepest Descent");
  //Teuchos::ParameterList& sdParams = dirParams.sublist("Steepest Descent");
    //sdParams.set("Scaling Type", "None");
    //sdParams.set("Scaling Type", "2-Norm");
    //sdParams.set("Scaling Type", "Quadratic Model Min");
  //dirParams.set("Method", "NonlinearCG");
  //Teuchos::ParameterList& nlcgParams = dirParams.sublist("Nonlinear CG");
    //nlcgParams.set("Restart Frequency", 2000);
    //nlcgParams.set("Precondition", "On");
    //nlcgParams.set("Orthogonalize", "Polak-Ribiere");
    //nlcgParams.set("Orthogonalize", "Fletcher-Reeves");

  // Sublist for linear solver for the Newton method
  Teuchos::ParameterList& lsParams = newtonParams.sublist("Linear Solver");
  lsParams.set("Aztec Solver", "GMRES");  
  lsParams.set("Max Iterations", 800);  
  lsParams.set("Tolerance", 1e-6);
  lsParams.set("Output Frequency", 50);    
#ifdef DO_XYZT_PREC
  lsParams.set("Preconditioner", "User Defined"); 
#else
  lsParams.set("Preconditioner", "Ifpack"); 
  //lsParams.set("Preconditioner", "AztecOO"); 
  //lsParams.set("Aztec Preconditioner", "ilu"); 
  //lsParams.set("Overlap", 2);  
  //lsParams.set("Graph Fill", 2); 
  //lsParams.set("Aztec Preconditioner", "ilut"); 
  //lsParams.set("Overlap", 2);   
  //lsParams.set("Fill Factor", 2);   
  //lsParams.set("Drop Tolerance", 1.0e-12);   
  //lsParams.set("Aztec Preconditioner", "Polynomial"); 
  //lsParams.set("Polynomial Order", 6); 
#endif

  // Create the interface between the test problem and the nonlinear solver
  Teuchos::RCP<Problem_Interface> interface = 
    Teuchos::rcp(new Problem_Interface(Problem));

  // Create the Epetra_RowMatrixfor the Jacobian/Preconditioner
  Teuchos::RCP<Epetra_RowMatrix> A = 
    Teuchos::rcp(&Problem.getJacobian(),false);

#ifdef DO_XYZT
  Epetra_MultiVector initGuess(soln.Map(), globalComm->NumTimeStepsOnDomain());
  for (int i=0; i<globalComm->NumTimeStepsOnDomain(); i++) *(initGuess(i)) = soln;

#ifdef DO_XYZT_PREC
  // Sublist for linear solver of the preconditioner
  Teuchos::RCP<Teuchos::ParameterList> precLSParams =
       Teuchos::rcp(new Teuchos::ParameterList(lsParams));
  precLSParams->set("Aztec Solver", "GMRES");  
  precLSParams->set("Preconditioner", "Ifpack");  
  //precLSParams->set("Preconditioner", "AztecOO");  
  precLSParams->set("Max Iterations", 800);  
  precLSParams->set("Tolerance", 1e-6);
  precLSParams->set("Output Frequency", 50);    
  //precLSParams->set("XYZTPreconditioner", "None"); 
  precLSParams->set("XYZTPreconditioner", "Global"); 
  //precLSParams->set("XYZTPreconditioner", "Sequential"); 
  //precLSParams->set("XYZTPreconditioner", "Parallel"); 
  //precLSParams->set("XYZTPreconditioner", "Parareal"); 
  //precLSParams->set("XYZTPreconditioner", "BlockDiagonal"); 

  Teuchos::RCP<Teuchos::ParameterList> precPrintParams =
       Teuchos::rcp(new Teuchos::ParameterList(printParams));
  precPrintParams->set("MyPID", MyPID); 
  precPrintParams->set("Output Precision", 3);
  precPrintParams->set("Output Processor", 0);
  precPrintParams->set("Output Information", 
			NOX::Utils::OuterIteration + 
			NOX::Utils::OuterIterationStatusTest + 
			NOX::Utils::InnerIteration +
			NOX::Utils::Parameters + 
			NOX::Utils::Details + 
			NOX::Utils::Warning);

  Teuchos::RCP<LOCA::Epetra::Interface::xyzt> ixyzt = 
    Teuchos::rcp(new LOCA::Epetra::Interface::xyzt(interface, 
						   initGuess, A,
						   globalComm, 
                                                   initCond, dt,
						   precPrintParams.get(), precLSParams.get()));

  Teuchos::RCP<Epetra_RowMatrix> Axyzt =
     Teuchos::rcp(&(ixyzt->getJacobian()),false);
  Epetra_Vector& solnxyzt = ixyzt->getSolution();
  Teuchos::RCP<Epetra_Operator> Mxyzt = 
     Teuchos::rcp(&(ixyzt->getPreconditioner()),false);

  Teuchos::RCP<LOCA::Epetra::Interface::Required> iReq = ixyzt;

  // Create the Linear System
  Teuchos::RCP<NOX::Epetra::Interface::Jacobian> iJac = ixyzt;
  Teuchos::RCP<NOX::Epetra::Interface::Preconditioner> iPrec = 
    Teuchos::rcp(&(ixyzt->getPreconditioner()),false);
  Teuchos::RCP<NOX::Epetra::LinearSystemAztecOO> linSys =
    Teuchos::rcp(new NOX::Epetra::LinearSystemAztecOO(printParams, lsParams,
						      iJac, Axyzt, iPrec, Mxyzt, 
						      solnxyzt));
#else
  Teuchos::RCP<LOCA::Epetra::Interface::xyzt> ixyzt = 
    Teuchos::rcp(new LOCA::Epetra::Interface::xyzt(interface, 
						   initGuess, A,
                                                   initCond, dt,
						   globalComm));

  Teuchos::RCP<Epetra_RowMatrix> Axyzt =
     Teuchos::rcp(&(ixyzt->getJacobian()),false);
  Epetra_Vector& solnxyzt = ixyzt->getSolution();

  Teuchos::RCP<LOCA::Epetra::Interface::Required> iReq = ixyzt;

  // Create the Linear System
  Teuchos::RCP<NOX::Epetra::Interface::Jacobian> iJac = ixyzt;
  Teuchos::RCP<NOX::Epetra::LinearSystemAztecOO> linSys =
    Teuchos::rcp(new NOX::Epetra::LinearSystemAztecOO(printParams, lsParams,
						      iReq, iJac, Axyzt, 
						      solnxyzt));
#endif
  NOX::Epetra::Vector initialGuess(solnxyzt);
#else
  // Use an Epetra Scaling object if desired
  Teuchos::RCP<Epetra_Vector> scaleVec = 
    Teuchos::rcp(new Epetra_Vector(soln));
  NOX::Epetra::Scaling scaling;
  scaling.addRowSumScaling(NOX::Epetra::Scaling::Left, scaleVec);

  Teuchos::RCP<LOCA::Epetra::Interface::Required> iReq = interface;

  // Create the Linear System
  Teuchos::RCP<NOX::Epetra::Interface::Jacobian> iJac = interface;
  Teuchos::RCP<NOX::Epetra::LinearSystemAztecOO> linSys = 
    Teuchos::rcp(new NOX::Epetra::LinearSystemAztecOO(printParams, lsParams,
						      iReq, iJac, A, soln));
		                                      //&scaling);

  // Create the Group
  NOX::Epetra::Vector initialGuess(Teuchos::rcp(&soln,false), 
				   NOX::Epetra::Vector::CreateView,
				   NOX::DeepCopy);
#endif

  // Create and initialize the parameter vector
  LOCA::ParameterVector pVector;
  pVector.addParameter("alpha",0.6);
  pVector.addParameter("beta",2.0);

  // Create Epetra factory
  Teuchos::RCP<LOCA::Abstract::Factory> epetraFactory =
    Teuchos::rcp(new LOCA::Epetra::Factory);

  // Create global data object
  Teuchos::RCP<LOCA::GlobalData> globalData = 
    LOCA::createGlobalData(paramList, epetraFactory);

  Teuchos::RCP<LOCA::Epetra::Group> grp =
    Teuchos::rcp(new LOCA::Epetra::Group(globalData, printParams,
                 iReq, initialGuess, linSys, pVector));

  grp->computeF();

  // Create the convergence tests
  Teuchos::RCP<NOX::StatusTest::NormF> absresid = 
    Teuchos::rcp(new NOX::StatusTest::NormF(1.0e-8, 
					    NOX::StatusTest::NormF::Unscaled));
  //NOX::StatusTest::NormF relresid(*grp.get(), 1.0e-2);
  //NOX::StatusTest::NormUpdate update(1.0e-5);
  //NOX::StatusTest::NormWRMS wrms(1.0e-2, 1.0e-8);
  //NOX::StatusTest::Combo converged(NOX::StatusTest::Combo::AND);
  //converged.addStatusTest(absresid);
  //converged.addStatusTest(relresid);
  //converged.addStatusTest(wrms);
  //converged.addStatusTest(update);
  Teuchos::RCP<NOX::StatusTest::MaxIters> maxiters = 
    Teuchos::rcp(new NOX::StatusTest::MaxIters(50));
  Teuchos::RCP<NOX::StatusTest::Combo> combo =
    Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::OR));
  combo->addStatusTest(absresid);
  combo->addStatusTest(maxiters);

  // Create the method
  //NOX::Solver::Manager solver(grp, combo, nlParams);
  LOCA::Stepper stepper(globalData, grp, combo, paramList);

  // Initialize time integration parameters
#ifdef DO_XYZT
  int maxTimeSteps = 1; // No longer need a time integration loop
#else
  int maxTimeSteps = 2;
#endif
  int timeStep = 0;
  double time = 0.;
  
  // Time integration loop
  while(timeStep < maxTimeSteps) {

    timeStep++;
    time += dt;
  
    globalData->locaUtils->out() 
      << "Time Step: " << timeStep << ",\tTime: " << time << std::endl;
  
//    NOX::StatusTest::StatusType status = solver.solve();
    LOCA::Abstract::Iterator::IteratorStatus status = stepper.run();

    if (status == LOCA::Abstract::Iterator::Finished)
      globalData->locaUtils->out() << "All tests passed" << std::endl;
    else
       globalData->locaUtils->out() << "Stepper failed to converge!" << std::endl;


    // Get the Epetra_Vector with the final solution from the solver
    const LOCA::Epetra::Group& finalGroup = 
      dynamic_cast<const LOCA::Epetra::Group&>(*(stepper.getSolutionGroup()));
    const Epetra_Vector& finalSolution = 
      (dynamic_cast<const NOX::Epetra::Vector&>(finalGroup.getX())).getEpetraVector();

    // End Nonlinear Solver **************************************

#ifndef DO_XYZT

    //Problem.reset(finalSolution);
    grp->setX(finalSolution);
    stepper.reset(globalData, grp, combo, paramList);
    grp->computeF();
#endif

  } // end time step while loop

  // Output the parameter list
  if (globalData->locaUtils->isPrintType(NOX::Utils::Parameters)) {
      globalData->locaUtils->out() 
	<< std::endl << "Final Parameters" << std::endl
	<< "****************" << std::endl;
      stepper.getList()->print(globalData->locaUtils->out());
      globalData->locaUtils->out() << std::endl;
    }

  // Output timing info
  globalData->locaUtils->out() << "\nTimings :\n\tWallTime --> " << 
    myTimer.WallTime() - startWallTime << " sec."
	      << "\n\tElapsedTime --> " << myTimer.ElapsedTime() 
	      << " sec." << std::endl << std::endl;

  LOCA::destroyGlobalData(globalData);

return 0 ;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
  int ierr = 0;
  int MyPID = 0;
  double alpha = 0.25;
  double beta = 1.5;
  double D1 = 1.0/40.0;
  double D2 = 1.0/40.0;
  int maxNewtonIters = 10;

  try {

    // Initialize MPI
#ifdef HAVE_MPI
    MPI_Init(&argc,&argv);
#endif

    // Create a communicator for Epetra objects
#ifdef HAVE_MPI
    Epetra_MpiComm Comm( MPI_COMM_WORLD );
#else
    Epetra_SerialComm Comm;
#endif

    // Get the process ID and the total number of processors
    MyPID = Comm.MyPID();
    int NumProc = Comm.NumProc();

    // Check for verbose output
    bool verbose = false;
    if (argc>1) 
      if (argv[1][0]=='-' && argv[1][1]=='v') 
	verbose = true;

    // Get the number of elements from the command line
    int NumGlobalNodes = 0;
    if ((argc > 2) && (verbose))
      NumGlobalNodes = atoi(argv[2]) + 1;
    else if ((argc > 1) && (!verbose))
      NumGlobalNodes = atoi(argv[1]) + 1;
    else 
      NumGlobalNodes = 101;

    // The number of unknowns must be at least equal to the 
    // number of processors.
    if (NumGlobalNodes < NumProc) {
      std::cout << "numGlobalNodes = " << NumGlobalNodes 
		<< " cannot be < number of processors = " << NumProc 
		<< std::endl;
      exit(1);
    }

    // Create the Brusselator problem class.  This creates all required
    // Epetra objects for the problem and allows calls to the 
    // function (F) and Jacobian evaluation routines.
    Brusselator Problem(NumGlobalNodes, Comm);

    // Get the vector from the Problem
    Epetra_Vector& soln = Problem.getSolution();

    // Begin LOCA Solver ************************************

    // Create the top level parameter list

    Teuchos::RCP<Teuchos::ParameterList> paramList =
      Teuchos::rcp(new Teuchos::ParameterList);

    // Create LOCA sublist
    Teuchos::ParameterList& locaParamsList = paramList->sublist("LOCA");

    // Create the stepper sublist and set the stepper parameters
    Teuchos::ParameterList& stepperList = locaParamsList.sublist("Stepper");
    stepperList.set("Bordered Solver Method", "Householder");
    stepperList.set("Continuation Parameter", "beta");
    stepperList.set("Initial Value", beta);
    stepperList.set("Max Value", 1.6);
    stepperList.set("Min Value", 0.0);
    stepperList.set("Max Steps", 100);
    stepperList.set("Max Nonlinear Iterations", maxNewtonIters);

#ifdef HAVE_LOCA_ANASAZI
    // Create Anasazi Eigensolver sublist (needs --with-loca-anasazi)
    stepperList.set("Compute Eigenvalues",true);
    Teuchos::ParameterList& aList = stepperList.sublist("Eigensolver");
    aList.set("Method", "Anasazi");
    if (!verbose)
      aList.set("Verbosity", Anasazi::Errors);
    aList.set("Block Size", 1);        // Size of blocks
    aList.set("Num Blocks", 50);       // Size of Arnoldi factorization
    aList.set("Num Eigenvalues", 3);   // Number of eigenvalues
    aList.set("Convergence Tolerance", 1.0e-7);          // Tolerance
    aList.set("Step Size", 1);         // How often to check convergence
    aList.set("Maximum Restarts",1);   // Maximum number of restarts
    aList.set("Operator", "Cayley");
    aList.set("Cayley Pole", 0.1);
    aList.set("Cayley Zero", -0.1);
    aList.set("Sorting Order", "CA");
#else
    stepperList.set("Compute Eigenvalues",false);
#endif

    // Create predictor sublist
    Teuchos::ParameterList& predictorList = 
      locaParamsList.sublist("Predictor");
    predictorList.set("Method", "Constant");

    // Create step size sublist
    Teuchos::ParameterList& stepSizeList = locaParamsList.sublist("Step Size");
    stepSizeList.set("Initial Step Size", 0.01);
    stepSizeList.set("Min Step Size", 1.0e-3);
    stepSizeList.set("Max Step Size", 0.01);
    stepSizeList.set("Aggressiveness", 0.1);

    // Create the "Solver" parameters sublist to be used with NOX Solvers
    Teuchos::ParameterList& nlParams = paramList->sublist("NOX");

    // Set the printing parameters in the "Printing" sublist
    Teuchos::ParameterList& printParams = nlParams.sublist("Printing");
    printParams.set("MyPID", MyPID); 
    printParams.set("Output Precision", 3);
    printParams.set("Output Processor", 0);
     if (verbose)
      printParams.set("Output Information", 
		      NOX::Utils::OuterIteration + 
		      NOX::Utils::OuterIterationStatusTest + 
		      NOX::Utils::InnerIteration +
		      NOX::Utils::Details + 
		      NOX::Utils::Warning +
		      NOX::Utils::TestDetails + 
		      NOX::Utils::Error + 
		      NOX::Utils::StepperIteration +
		      NOX::Utils::StepperDetails +
		      NOX::Utils::StepperParameters);
     else
       printParams.set("Output Information", NOX::Utils::Error);

    // Sublist for "Linear Solver"
    Teuchos::ParameterList& dirParams = nlParams.sublist("Direction");
    Teuchos::ParameterList& newtonParams = dirParams.sublist("Newton");
    Teuchos::ParameterList& lsParams = newtonParams.sublist("Linear Solver");
    lsParams.set("Aztec Solver", "GMRES");  
    lsParams.set("Max Iterations", 800);  
    lsParams.set("Tolerance", 1e-6);
    lsParams.set("Output Frequency", 50);    
    lsParams.set("Preconditioner", "Ifpack"); 

    // Create the interface between the test problem and the nonlinear solver
    Teuchos::RCP<Problem_Interface> interface = 
      Teuchos::rcp(new Problem_Interface(Problem));

    // Create the Epetra_RowMatrixfor the Jacobian/Preconditioner
    Teuchos::RCP<Epetra_RowMatrix> A = 
      Teuchos::rcp(&Problem.getJacobian(),false);


    // Use an Epetra Scaling object if desired
    Teuchos::RCP<Epetra_Vector> scaleVec = 
      Teuchos::rcp(new Epetra_Vector(soln));
    NOX::Epetra::Scaling scaling;
    scaling.addRowSumScaling(NOX::Epetra::Scaling::Left, scaleVec);

    Teuchos::RCP<LOCA::Epetra::Interface::Required> iReq = interface;

    // Create the Linear System
    Teuchos::RCP<NOX::Epetra::Interface::Jacobian> iJac = interface;
    Teuchos::RCP<NOX::Epetra::LinearSystemAztecOO> linSys = 
      Teuchos::rcp(new NOX::Epetra::LinearSystemAztecOO(printParams, lsParams,
							iReq, iJac, A, soln));
                                                        //&scaling);
    Teuchos::RCP<NOX::Epetra::LinearSystemAztecOO> shiftedLinSys = 
      Teuchos::rcp(new NOX::Epetra::LinearSystemAztecOO(printParams, lsParams,
							iReq, iJac, A, soln));

    // Create initial guess
    NOX::Epetra::Vector initialGuess(Teuchos::rcp(&soln,false), 
				     NOX::Epetra::Vector::CreateView,
				     NOX::DeepCopy);

    // Create and initialize the parameter vector
    LOCA::ParameterVector pVector;
    pVector.addParameter("alpha",alpha);
    pVector.addParameter("beta",beta);
    pVector.addParameter("D1",D1);
    pVector.addParameter("D2",D2);

    // Create Epetra factory
    Teuchos::RCP<LOCA::Abstract::Factory> epetraFactory =
      Teuchos::rcp(new LOCA::Epetra::Factory);

    // Create global data object
    Teuchos::RCP<LOCA::GlobalData> globalData = 
      LOCA::createGlobalData(paramList, epetraFactory);

    // Create the Group
    Teuchos::RCP<LOCA::Epetra::Interface::TimeDependent> iTime = interface;
    Teuchos::RCP<LOCA::Epetra::Group> grp =
      Teuchos::rcp(new LOCA::Epetra::Group(globalData, printParams,
					   iTime, initialGuess, linSys, 
					   shiftedLinSys, pVector));

    grp->computeF();

    // Create the convergence tests
    Teuchos::RCP<NOX::StatusTest::NormF> absresid = 
      Teuchos::rcp(new NOX::StatusTest::NormF(1.0e-8, 
					   NOX::StatusTest::NormF::Unscaled));
    Teuchos::RCP<NOX::StatusTest::MaxIters> maxiters = 
      Teuchos::rcp(new NOX::StatusTest::MaxIters(maxNewtonIters));
    Teuchos::RCP<NOX::StatusTest::Combo> combo =
      Teuchos::rcp(new NOX::StatusTest::Combo(NOX::StatusTest::Combo::OR));
    combo->addStatusTest(absresid);
    combo->addStatusTest(maxiters);

    // Create stepper
    LOCA::Stepper stepper(globalData, grp, combo, paramList);

    LOCA::Abstract::Iterator::IteratorStatus status = stepper.run();

    if (status != LOCA::Abstract::Iterator::Finished) {
      ierr = 1;
      if (globalData->locaUtils->isPrintType(NOX::Utils::Error))
	globalData->locaUtils->out() 
	  << "Stepper failed to converge!" << std::endl;
    }

    // Get the final solution from the stepper
    Teuchos::RCP<const LOCA::Epetra::Group> finalGroup = 
      Teuchos::rcp_dynamic_cast<const LOCA::Epetra::Group>(stepper.getSolutionGroup());
    const NOX::Epetra::Vector& finalSolution = 
      dynamic_cast<const NOX::Epetra::Vector&>(finalGroup->getX());

    // Output the parameter list
    if (globalData->locaUtils->isPrintType(NOX::Utils::StepperParameters)) {
      globalData->locaUtils->out() 
	<< std::endl << "Final Parameters" << std::endl
	<< "****************" << std::endl;
      stepper.getList()->print(globalData->locaUtils->out());
      globalData->locaUtils->out() << std::endl;
    }

    // Check some statistics on the solution
    NOX::TestCompare testCompare(globalData->locaUtils->out(), 
				 *(globalData->locaUtils));
  
    if (globalData->locaUtils->isPrintType(NOX::Utils::TestDetails))
      globalData->locaUtils->out() 
	<< std::endl 
	<< "***** Checking solution statistics *****" 
	<< std::endl;

    // Check number of continuation steps
    int numSteps = stepper.getStepNumber();
    int numSteps_expected = 11;
    ierr += testCompare.testValue(numSteps, numSteps_expected, 0.0,
				  "number of continuation steps",
				  NOX::TestCompare::Absolute);

    // Check number of failed steps
    int numFailedSteps = stepper.getNumFailedSteps();
    int numFailedSteps_expected = 0;
    ierr += testCompare.testValue(numFailedSteps, numFailedSteps_expected, 0.0,
				  "number of failed continuation steps",
				  NOX::TestCompare::Absolute);

    // Check final value of continuation parameter
    double beta_final = finalGroup->getParam("beta");
    double beta_expected = 1.6;
    ierr += testCompare.testValue(beta_final, beta_expected, 1.0e-14,
				  "final value of continuation parameter", 
				  NOX::TestCompare::Relative);

    // Check final of solution
    NOX::Epetra::Vector final_x_expected(finalSolution);
    int n = final_x_expected.getEpetraVector().MyLength()/2;
    for (int i=0; i<n; i++) {
      final_x_expected.getEpetraVector()[2*i] = alpha;
      final_x_expected.getEpetraVector()[2*i+1] = beta_final/alpha;
    }
    ierr += testCompare.testVector(finalSolution, final_x_expected, 
				   1.0e-6, 1.0e-6,
				   "value of final solution");

    LOCA::destroyGlobalData(globalData);
  }
  catch (std::exception& e) {
    std::cout << e.what() << std::endl;
    ierr = 1;
  }
  catch (const char *s) {
    std::cout << s << std::endl;
    ierr = 1;
  }
  catch (...) {
    std::cout << "Caught unknown exception!" << std::endl;
    ierr = 1;
  }

  if (MyPID == 0) {
    if (ierr == 0)
      std::cout << "All tests passed!" << std::endl;
    else
      std::cout << ierr << " test(s) failed!" << std::endl;
  }

#ifdef HAVE_MPI
  MPI_Finalize() ;
#endif

return ierr;
}