TSFPreconditioner.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 /* ***********************************************************************
00003 // 
00004 //           TSFExtended: Trilinos Solver Framework Extended
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 TSFPRECONDITIONER_HPP
00030 #define TSFPRECONDITIONER_HPP
00031 
00032 #include "SundanceDefs.hpp"
00033 #include "SundanceHandle.hpp"
00034 #include "TSFPreconditionerBase.hpp"
00035 
00036 namespace TSFExtended
00037 {
00038   /**
00039    * 
00040    */
00041   template <class Scalar> 
00042   class Preconditioner : public Sundance::Handle<PreconditionerBase<Scalar> >
00043   {
00044   public:
00045     /* Boilerplate ctors */
00046     HANDLE_CTORS(Preconditioner, PreconditionerBase<Scalar>);
00047 
00048     /** Change the value of a double parameter */
00049     void changeParameter(const std::string& name, const double& value);
00050 
00051     /** Change the value of an integer parameter */
00052     void changeParameter(const std::string& name, int value);
00053 
00054     
00055     
00056     /** Left preconditioner */
00057     LinearOperator<Scalar> left() const ;
00058     
00059     /** Right preconditioner */
00060     LinearOperator<Scalar> right() const ;
00061     
00062     /** return true if this preconditioner has both left and
00063      * right components. */
00064     bool isTwoSided() const {return hasLeft() && hasRight();}
00065     
00066     /** return true if this preconditioner has a nontrivial left component */
00067     bool hasLeft() const ;
00068     
00069     /** return true if this preconditioner has
00070      * a nontrivial right component */
00071     bool hasRight() const ;
00072     
00073     /** return true if this preconditioner has neither left nor
00074      * right operators defined */
00075     bool isIdentity() const {return !hasLeft() && !hasRight();}
00076   };
00077 
00078   
00079 
00080   template <class Scalar> inline 
00081   LinearOperator<Scalar> Preconditioner<Scalar>::left() const 
00082   {
00083     TEST_FOR_EXCEPTION(this->ptr().get()==0, std::runtime_error,
00084                        "null pointer in Preconditioner<Scalar>::left()");
00085     return this->ptr()->left();
00086   }
00087 
00088   template <class Scalar> inline 
00089   LinearOperator<Scalar> Preconditioner<Scalar>::right() const 
00090   {
00091     TEST_FOR_EXCEPTION(this->ptr().get()==0, std::runtime_error,
00092                        "null pointer in Preconditioner<Scalar>::right()");
00093     return this->ptr()->right();
00094   }
00095 
00096   template <class Scalar> inline
00097   bool Preconditioner<Scalar>::hasLeft() const 
00098   {
00099     return (this->ptr().get()!=0 && this->ptr()->hasLeft());
00100   }
00101 
00102   template <class Scalar> inline
00103   bool Preconditioner<Scalar>::hasRight() const 
00104   {
00105     return (this->ptr().get()!=0 && this->ptr()->hasRight());
00106   }
00107 
00108   
00109 }
00110 
00111 #endif

Site Contact