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 namespace Thyra {
00035 
00036 // Overridden from EpetraOperatorViewExtractorBase
00037 
00038 bool EpetraOperatorViewExtractorStd::isCompatible( const LinearOpBase<double> &fwdOp ) const
00039 {
00040   double                     wrappedScalar = 0.0;
00041   ETransp                    wrappedTransp = NOTRANS;
00042   const LinearOpBase<double> *wrappedFwdOp = NULL;
00043   ::Thyra::unwrap(fwdOp,&wrappedScalar,&wrappedTransp,&wrappedFwdOp);
00044   const EpetraLinearOpBase *eFwdOp = NULL;
00045   if( ! (eFwdOp = dynamic_cast<const EpetraLinearOpBase*>(wrappedFwdOp)) )
00046     return false;
00047   return true;
00048 }
00049 
00050 void EpetraOperatorViewExtractorStd::getEpetraOpView(
00051   const Teuchos::RefCountPtr<LinearOpBase<double> >   &fwdOp
00052   ,Teuchos::RefCountPtr<Epetra_Operator>              *epetraOp
00053   ,ETransp                                            *epetraOpTransp
00054   ,EApplyEpetraOpAs                                   *epetraOpApplyAs
00055   ,EAdjointEpetraOp                                   *epetraOpAdjointSupport
00056   ,double                                             *epetraOpScalar
00057   ) const
00058 {
00059   TEST_FOR_EXCEPT(true);
00060   // ToDo: Implement once this is needed by just copying what is below and
00061   // removing the 'const' in the right places!
00062 }
00063 
00064 void EpetraOperatorViewExtractorStd::getEpetraOpView(
00065   const Teuchos::RefCountPtr<const LinearOpBase<double> >   &fwdOp
00066   ,Teuchos::RefCountPtr<const Epetra_Operator>              *epetraOp
00067   ,ETransp                                                  *epetraOpTransp
00068   ,EApplyEpetraOpAs                                         *epetraOpApplyAs
00069   ,EAdjointEpetraOp                                         *epetraOpAdjointSupport
00070   ,double                                                   *epetraOpScalar
00071   ) const
00072 {
00073 #ifdef TEUCHOS_DEBUG
00074   TEST_FOR_EXCEPT(epetraOp==NULL);
00075   TEST_FOR_EXCEPT(epetraOpTransp==NULL);
00076   TEST_FOR_EXCEPT(epetraOpApplyAs==NULL);
00077   TEST_FOR_EXCEPT(epetraOpAdjointSupport==NULL);
00078 #endif // TEUCHOS_DEBUG
00079   double                                              wrappedFwdOpScalar = 0.0;
00080   ETransp                                             wrappedFwdOpTransp = NOTRANS;
00081   Teuchos::RefCountPtr<const LinearOpBase<double> >   wrappedFwdOp; 
00082   unwrap(fwdOp,&wrappedFwdOpScalar,&wrappedFwdOpTransp,&wrappedFwdOp);
00083   Teuchos::RefCountPtr<const EpetraLinearOpBase>
00084     epetraFwdOp = Teuchos::rcp_dynamic_cast<const EpetraLinearOpBase>(wrappedFwdOp,true);
00085   ETransp epetra_epetraOpTransp;
00086   epetraFwdOp->getEpetraOpView(epetraOp,&epetra_epetraOpTransp,epetraOpApplyAs,epetraOpAdjointSupport);
00087   *epetraOpTransp = trans_trans(real_trans(epetra_epetraOpTransp),wrappedFwdOpTransp);
00088   *epetraOpScalar = wrappedFwdOpScalar;
00089 }
00090 
00091 } // namespace Thyra

Generated on Thu Sep 18 12:37:48 2008 for Epetra to Thyra Adapter Software by doxygen 1.3.9.1