Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_EpetraOperatorViewExtractorStd.cpp
Go to the documentation of this file.
00001 // ***********************************************************************
00002 // 
00003 //               Thyra: Trilinos Solver Framework Core
00004 //                 Copyright (2004) Sandia Corporation
00005 // 
00006 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00007 // license for use of this work by or on behalf of the U.S. Government.
00008 // 
00009 // This library is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU Lesser General Public License as
00011 // published by the Free Software Foundation; either version 2.1 of the
00012 // License, or (at your option) any later version.
00013 //  
00014 // This library is distributed in the hope that it will be useful, but
00015 // WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 //  
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022 // USA
00023 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00024 // 
00025 // ***********************************************************************
00026 // @HEADER
00027 
00028 #include "Thyra_EpetraOperatorViewExtractorStd.hpp"
00029 #include "Thyra_EpetraLinearOpBase.hpp"
00030 #include "Thyra_ScaledAdjointLinearOpBase.hpp"
00031 
00032 class Epetra_Operator;
00033 
00034 
00035 namespace Thyra {
00036 
00037 
00038 // Overridden from EpetraOperatorViewExtractorBase
00039 
00040 
00041 bool EpetraOperatorViewExtractorStd::isCompatible( const LinearOpBase<double> &fwdOp ) const
00042 {
00043   double wrappedScalar = 0.0;
00044   EOpTransp wrappedTransp = NOTRANS;
00045   const LinearOpBase<double> *wrappedFwdOp = NULL;
00046   ::Thyra::unwrap(fwdOp, &wrappedScalar, &wrappedTransp, &wrappedFwdOp);
00047   const EpetraLinearOpBase *eFwdOp = NULL;
00048   if( !(eFwdOp = dynamic_cast<const EpetraLinearOpBase*>(wrappedFwdOp)) )
00049     return false;
00050   return true;
00051 }
00052 
00053 
00054 void EpetraOperatorViewExtractorStd::getNonconstEpetraOpView(
00055   const RCP<LinearOpBase<double> > &fwdOp,
00056   const Ptr<RCP<Epetra_Operator> > &epetraOp,
00057   const Ptr<EOpTransp> &epetraOpTransp,
00058   const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
00059   const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport,
00060     const Ptr<double> &epetraOpScalar
00061   ) const
00062 {
00063   TEST_FOR_EXCEPT(true);
00064   // ToDo: Implement once this is needed by just copying what is below and
00065   // removing the 'const' in the right places!
00066 }
00067 
00068 
00069 void EpetraOperatorViewExtractorStd::getEpetraOpView(
00070   const RCP<const LinearOpBase<double> > &fwdOp,
00071   const Ptr<RCP<const Epetra_Operator> > &epetraOp,
00072   const Ptr<EOpTransp> &epetraOpTransp,
00073   const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
00074   const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport,
00075     const Ptr<double> &epetraOpScalar
00076   ) const
00077 {
00078   using Teuchos::outArg;
00079   double wrappedFwdOpScalar = 0.0;
00080   EOpTransp wrappedFwdOpTransp = NOTRANS;
00081   Teuchos::RCP<const LinearOpBase<double> > wrappedFwdOp; 
00082   unwrap(fwdOp,&wrappedFwdOpScalar, &wrappedFwdOpTransp, &wrappedFwdOp);
00083   Teuchos::RCP<const EpetraLinearOpBase> epetraFwdOp =
00084     Teuchos::rcp_dynamic_cast<const EpetraLinearOpBase>(wrappedFwdOp,true);
00085   EOpTransp epetra_epetraOpTransp;
00086   epetraFwdOp->getEpetraOpView(epetraOp, outArg(epetra_epetraOpTransp),
00087     epetraOpApplyAs, epetraOpAdjointSupport);
00088   *epetraOpTransp = trans_trans(real_trans(epetra_epetraOpTransp), wrappedFwdOpTransp);
00089   *epetraOpScalar = wrappedFwdOpScalar;
00090 }
00091 
00092 
00093 // ToDo: Refactor unwrap(...) to not use raw pointers!
00094 
00095 
00096 } // namespace Thyra
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines