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_LinearOpWithSolveBase.hpp"
00033 #include "Thyra_ModelEvaluator.hpp"
00034 #include "Teuchos_Describable.hpp"
00035 #include "Teuchos_VerboseObject.hpp"
00036 #include "Teuchos_ParameterListAcceptor.hpp"
00037 
00038 
00039 namespace Thyra {
00040 
00041 
00061 template <class Scalar>
00062 class NonlinearSolverBase
00063   : virtual public Teuchos::Describable
00064   , virtual public Teuchos::VerboseObject<NonlinearSolverBase<Scalar> >
00065   , virtual public Teuchos::ParameterListAcceptor
00066 {
00067 public:
00068   
00071 
00079   virtual void setModel(
00080     const RCP<const ModelEvaluator<Scalar> > &model
00081     ) = 0;
00082   
00084   virtual RCP<const ModelEvaluator<Scalar> > getModel() const = 0;
00085   
00105   virtual SolveStatus<Scalar> solve(
00106     VectorBase<Scalar> *x,
00107     const SolveCriteria<Scalar> *solveCriteria = NULL,
00108     VectorBase<Scalar> *delta = NULL
00109     ) = 0;
00110   
00112   
00115 
00120   virtual bool supportsCloning() const;
00121 
00142   virtual RCP<NonlinearSolverBase<Scalar> > cloneNonlinearSolver() const;
00143   
00149   virtual RCP<const VectorBase<Scalar> > get_current_x() const;
00150 
00156   virtual bool is_W_current() const;
00157 
00173   virtual RCP<LinearOpWithSolveBase<Scalar> >
00174   get_nonconst_W( const bool forceUpToDate = false );
00175 
00183   virtual RCP<const LinearOpWithSolveBase<Scalar> > get_W() const;
00184 
00194   virtual void set_W_is_current(bool W_is_current);
00195 
00197 
00198 private:
00199   
00200   // Not defined and not to be called
00201   NonlinearSolverBase<Scalar>&
00202   operator=(const NonlinearSolverBase<Scalar>&);
00203 
00204 };
00205 
00206 
00211 template <class Scalar>
00212 const SolveStatus<Scalar> solve(
00213   NonlinearSolverBase<Scalar> &nonlinearSolver,
00214     VectorBase<Scalar> *x,
00215     const SolveCriteria<Scalar> *solveCriteria = NULL,
00216     VectorBase<Scalar> *delta = NULL
00217     )
00218 {
00219   return nonlinearSolver.solve(x,solveCriteria,delta);
00220 }
00221 
00222 
00223 // ///////////////////////////////
00224 // Implementations
00225 
00226 template <class Scalar>
00227 bool NonlinearSolverBase<Scalar>::supportsCloning() const
00228 {
00229   return false;
00230 }
00231 
00232 template <class Scalar>
00233 RCP<NonlinearSolverBase<Scalar> >
00234 NonlinearSolverBase<Scalar>::cloneNonlinearSolver() const
00235 {
00236   return Teuchos::null;
00237 }
00238 
00239 template <class Scalar>
00240 RCP<const VectorBase<Scalar> >
00241 NonlinearSolverBase<Scalar>::get_current_x() const
00242 {
00243   return Teuchos::null;
00244 }
00245 
00246 template <class Scalar>
00247 bool NonlinearSolverBase<Scalar>::is_W_current() const
00248 {
00249   return false;
00250 }
00251 
00252 template <class Scalar>
00253 RCP<LinearOpWithSolveBase<Scalar> >
00254 NonlinearSolverBase<Scalar>::get_nonconst_W(const bool forceUpToDate)
00255 {
00256   return Teuchos::null;
00257 }
00258 
00259 template <class Scalar>
00260 RCP<const LinearOpWithSolveBase<Scalar> >
00261 NonlinearSolverBase<Scalar>::get_W() const
00262 {
00263   return Teuchos::null;
00264 }
00265 
00266 template <class Scalar>
00267 void NonlinearSolverBase<Scalar>::set_W_is_current(bool W_is_current)
00268 {
00269   TEST_FOR_EXCEPTION(
00270     true, std::logic_error,
00271     "Error, the subclass object described as " << this->description() << " did not"
00272     " override this function!"
00273     );
00274 }
00275 
00276 
00277 } // namespace Thyra
00278 
00279 
00280 #endif // THYRA_NONLINEAR_SOLVER_BASE_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:00:20 2011 for Thyra by  doxygen 1.6.3