NOX_TSF_StatusTestBuilder.C
Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
00003 
00004 //@HEADER
00005 // ************************************************************************
00006 // 
00007 //            NOX: An Object-Oriented Nonlinear Solver Package
00008 //                 Copyright (2002) Sandia Corporation
00009 // 
00010 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00011 // license for use of this work by or on behalf of the U.S. Government.
00012 // 
00013 // This library is free software; you can redistribute it and/or modify
00014 // it under the terms of the GNU Lesser General Public License as
00015 // published by the Free Software Foundation; either version 2.1 of the
00016 // License, or (at your option) any later version.
00017 //  
00018 // This library is distributed in the hope that it will be useful, but
00019 // WITHOUT ANY WARRANTY; without even the implied warranty of
00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021 // Lesser General Public License for more details.
00022 //                                                                                 
00023 // You should have received a copy of the GNU Lesser General Public
00024 // License along with this library; if not, write to the Free Software
00025 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00026 // USA                                                                                
00027 // Questions? Contact Tammy Kolda (tgkolda@sandia.gov) or Roger Pawlowski
00028 // (rppawlo@sandia.gov), Sandia National Laboratories.
00029 // 
00030 // ************************************************************************
00031 //@HEADER
00032 
00033 #include "NOX_TSF_StatusTestBuilder.H"         
00034 #include "NOX_StatusTest_NormF.H"         
00035 #include "NOX_StatusTest_NormUpdate.H"         
00036 #include "NOX_StatusTest_SafeCombo.H"         
00037 #include "NOX_StatusTest_MaxIters.H"         
00038 #include "Teuchos_TestForException.hpp"   
00039 
00040 using namespace NOX;
00041 using namespace NOX::TSF;
00042 using namespace Teuchos;
00043 
00044 RCP<StatusTest::Generic> 
00045 StatusTestBuilder::makeStatusTest(const ParameterList& params)
00046 {
00047   TEST_FOR_EXCEPTION(!params.isSublist("Status Test"), runtime_error,
00048                      "did not find Status Test sublist in " << params);
00049 
00050   ParameterList testSublist = params.sublist("Status Test");
00051 
00052   double fTol = 1.0e-15;
00053   double dxTol = 1.0e-15;
00054   int maxiters = 20;
00055   if (testSublist.isParameter("Tolerance"))
00056     {
00057       fTol = getParameter<double>(testSublist, "Tolerance");
00058     }
00059   if (testSublist.isParameter("Residual Tolerance"))
00060     {
00061       fTol = getParameter<double>(testSublist, "Residual Tolerance");
00062     }
00063   if (testSublist.isParameter("Step Tolerance"))
00064     {
00065       dxTol = getParameter<double>(testSublist, "Step Tolerance");
00066     }
00067   if (testSublist.isParameter("Max Iterations"))
00068     {
00069       maxiters = getParameter<int>(testSublist, "Max Iterations");
00070     }
00071 
00072   RCP<StatusTest::Generic> A = rcp(new StatusTest::NormF(fTol));
00073   RCP<StatusTest::Generic> B = rcp(new StatusTest::MaxIters(maxiters));
00074   RCP<StatusTest::Generic> C = rcp(new StatusTest::NormUpdate(dxTol));
00075   RCP<StatusTest::Generic> AB 
00076     = rcp(new StatusTest::SafeCombo(StatusTest::SafeCombo::OR, A, B));
00077   RCP<StatusTest::Generic> ABC 
00078     = rcp(new StatusTest::SafeCombo(StatusTest::SafeCombo::OR, AB, C));
00079   
00080   return ABC;
00081 }
00082 
00083 
00084 

Site Contact