TSFOpWithBackwardsCompatibleApply.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 TSFOPWITHBACKWARDSCOMPATIBLEAPPLY_HPP
00030 #define TSFOPWITHBACKWARDSCOMPATIBLEAPPLY_HPP
00031 
00032 #include "Thyra_VectorBase.hpp"
00033 #include "Thyra_MultiVectorBase.hpp"
00034 #include "Thyra_AssertOp.hpp"
00035 #include "Thyra_DefaultColumnwiseMultiVector.hpp"
00036 #include "Teuchos_TestForException.hpp"
00037 #include "SundanceObjectWithVerbosity.hpp"
00038 #include "SundanceNamedObject.hpp"
00039 #include "SundanceOut.hpp"
00040 
00041 namespace TSFExtended
00042 {
00043 using namespace Teuchos;
00044 using namespace Thyra;
00045 using namespace Sundance;
00046 
00047 /** */
00048 template <class Scalar>
00049 class OpWithBackwardsCompatibleApply :
00050     public LinearOpBase<Scalar>,
00051     public DefaultObjectWithVerbosity
00052 {
00053 public:
00054 
00055   /** \brief . */
00056   bool opSupportedImpl(Thyra::EOpTransp M_trans) const
00057     {
00058       return (M_trans == Thyra::NOTRANS);
00059     }
00060 
00061   /** Thyra apply method */
00062   virtual void applyImpl(
00063     const Thyra::EOpTransp M_trans,
00064     const Thyra::MultiVectorBase<Scalar>    &X,
00065     const Ptr<Thyra::MultiVectorBase<Scalar> > &Y,
00066     const Scalar alpha,
00067     const Scalar beta
00068     ) const 
00069     {
00070       generalApply(M_trans, X, &*Y, alpha, beta);
00071     }
00072 
00073   /**
00074    * generalApply() applies either the operator or the transpose
00075    * according to the value of the transpose flag. This method is
00076    * backwards compatible with TSFCore-based code.
00077    */
00078   virtual void generalApply(const Thyra::EOpTransp M_trans,
00079     const Thyra::MultiVectorBase<Scalar>    &x,
00080     Thyra::MultiVectorBase<Scalar>          *y,
00081     const Scalar            alpha,
00082     const Scalar            beta) const 
00083     {
00084 
00085       using Teuchos::dyn_cast;
00086 
00087       THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES(
00088         "OpWithBackwardsCompatibleApply<Scalar>::applyImpl(...)",
00089         *this, M_trans, x, y );
00090 
00091 /*
00092       const Thyra::DefaultColumnwiseMultiVector<Scalar> &xVec =
00093         dyn_cast<const Thyra::DefaultColumnwiseMultiVector<Scalar> >(x);
00094       
00095       Thyra::DefaultColumnwiseMultiVector<Scalar> &yVec = 
00096         dyn_cast<Thyra::DefaultColumnwiseMultiVector<Scalar> >(*y);
00097 */
00098       
00099       int nXCols = x.domain()->dim();
00100       
00101       for (int i=0; i < nXCols; i++)
00102       {
00103         generalApply(M_trans, *x.col(i), &*y->col(i), alpha, beta);
00104         //generalApply(M_trans, *xVec.col(i), &*yVec.col(i), alpha, beta);
00105       }
00106     }
00107 
00108 /**
00109  *
00110  */
00111   virtual void generalApply(const Thyra::EOpTransp M_trans,
00112     const Thyra::VectorBase<Scalar>    &x,
00113     Thyra::VectorBase<Scalar>* y,
00114     const Scalar alpha = Teuchos::ScalarTraits<Scalar>::one(),
00115     const Scalar beta  = Teuchos::ScalarTraits<Scalar>::zero()) const = 0 ;
00116 };
00117 
00118 }
00119 
00120 #endif

Site Contact