Thyra_NonlinearSolverBase.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef THYRA_NONLINEAR_SOLVER_BASE_HPP
00030 #define THYRA_NONLINEAR_SOLVER_BASE_HPP
00031 
00032 #include "Thyra_LinearOpWithSolveBaseDecl.hpp"
00033 #include "Thyra_ModelEvaluator.hpp"
00034 #include "Teuchos_Describable.hpp"
00035 #include "Teuchos_VerboseObject.hpp"
00036 #include "Teuchos_ParameterListAcceptor.hpp"
00037 
00038 namespace Thyra {
00039 
00058 template <class Scalar>
00059 class NonlinearSolverBase
00060   : virtual public Teuchos::Describable
00061   , virtual public Teuchos::VerboseObject<NonlinearSolverBase<Scalar> >
00062   , virtual public Teuchos::ParameterListAcceptor
00063 {
00064 public:
00065   
00068 
00076   virtual void setModel(
00077     const RCP<const ModelEvaluator<Scalar> > &model
00078     ) = 0;
00079   
00081   virtual RCP<const ModelEvaluator<Scalar> > getModel() const = 0;
00082   
00102   virtual SolveStatus<Scalar> solve(
00103     VectorBase<Scalar> *x,
00104     const SolveCriteria<Scalar> *solveCriteria = NULL,
00105     VectorBase<Scalar> *delta = NULL
00106     ) = 0;
00107   
00109   
00112 
00117   virtual bool supportsCloning() const;
00118 
00139   virtual RCP<NonlinearSolverBase<Scalar> > cloneNonlinearSolver() const;
00140   
00146   virtual RCP<const VectorBase<Scalar> > get_current_x() const;
00147 
00153   virtual bool is_W_current() const;
00154 
00170   virtual RCP<LinearOpWithSolveBase<Scalar> >
00171   get_nonconst_W( const bool forceUpToDate = false );
00172 
00180   virtual RCP<const LinearOpWithSolveBase<Scalar> > get_W() const;
00181 
00191   virtual void set_W_is_current(bool W_is_current);
00192 
00194 
00195 };
00196 
00197 
00202 template <class Scalar>
00203 const SolveStatus<Scalar> solve(
00204   NonlinearSolverBase<Scalar> &nonlinearSolver,
00205     VectorBase<Scalar> *x,
00206     const SolveCriteria<Scalar> *solveCriteria = NULL,
00207     VectorBase<Scalar> *delta = NULL
00208     )
00209 {
00210   return nonlinearSolver.solve(x,solveCriteria,delta);
00211 }
00212 
00213 
00214 // ///////////////////////////////
00215 // Implementations
00216 
00217 template <class Scalar>
00218 bool NonlinearSolverBase<Scalar>::supportsCloning() const
00219 {
00220   return false;
00221 }
00222 
00223 template <class Scalar>
00224 RCP<NonlinearSolverBase<Scalar> >
00225 NonlinearSolverBase<Scalar>::cloneNonlinearSolver() const
00226 {
00227   return Teuchos::null;
00228 }
00229 
00230 template <class Scalar>
00231 RCP<const VectorBase<Scalar> >
00232 NonlinearSolverBase<Scalar>::get_current_x() const
00233 {
00234   return Teuchos::null;
00235 }
00236 
00237 template <class Scalar>
00238 bool NonlinearSolverBase<Scalar>::is_W_current() const
00239 {
00240   return false;
00241 }
00242 
00243 template <class Scalar>
00244 RCP<LinearOpWithSolveBase<Scalar> >
00245 NonlinearSolverBase<Scalar>::get_nonconst_W(const bool forceUpToDate)
00246 {
00247   return Teuchos::null;
00248 }
00249 
00250 template <class Scalar>
00251 RCP<const LinearOpWithSolveBase<Scalar> >
00252 NonlinearSolverBase<Scalar>::get_W() const
00253 {
00254   return Teuchos::null;
00255 }
00256 
00257 template <class Scalar>
00258 void NonlinearSolverBase<Scalar>::set_W_is_current(bool W_is_current)
00259 {
00260   TEST_FOR_EXCEPTION(
00261     true, std::logic_error,
00262     "Error, the subclass object described as " << this->description() << " did not"
00263     " override this function!"
00264     );
00265 }
00266 
00267 } // namespace Thyra
00268 
00269 #endif // THYRA_NONLINEAR_SOLVER_BASE_HPP

Generated on Wed May 12 21:26:50 2010 for Thyra ANA Nonlinear Solver Interfaces by  doxygen 1.4.7