Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_EpetraOperatorViewExtractorStd.cpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Thyra_EpetraOperatorViewExtractorStd.hpp"
11 #include "Thyra_EpetraLinearOpBase.hpp"
12 #include "Thyra_ScaledAdjointLinearOpBase.hpp"
13 
14 class Epetra_Operator;
15 
16 
17 namespace Thyra {
18 
19 
20 // Overridden from EpetraOperatorViewExtractorBase
21 
22 
24 {
25  double wrappedScalar = 0.0;
26  EOpTransp wrappedTransp = NOTRANS;
27  const LinearOpBase<double> *wrappedFwdOp = NULL;
28  ::Thyra::unwrap(fwdOp, &wrappedScalar, &wrappedTransp, &wrappedFwdOp);
29  const EpetraLinearOpBase *eFwdOp =
30  dynamic_cast<const EpetraLinearOpBase*>(wrappedFwdOp);
31  if (!eFwdOp) {
32  return false;
33  }
34  return true;
35 }
36 
37 
39  const RCP<LinearOpBase<double> > &/* fwdOp */,
40  const Ptr<RCP<Epetra_Operator> > &/* epetraOp */,
41  const Ptr<EOpTransp> &/* epetraOpTransp */,
42  const Ptr<EApplyEpetraOpAs> &/* epetraOpApplyAs */,
43  const Ptr<EAdjointEpetraOp> &/* epetraOpAdjointSupport */,
44  const Ptr<double> &/* epetraOpScalar */
45  ) const
46 {
48  // ToDo: Implement once this is needed by just copying what is below and
49  // removing the 'const' in the right places!
50 }
51 
52 
54  const RCP<const LinearOpBase<double> > &fwdOp,
55  const Ptr<RCP<const Epetra_Operator> > &epetraOp,
56  const Ptr<EOpTransp> &epetraOpTransp,
57  const Ptr<EApplyEpetraOpAs> &epetraOpApplyAs,
58  const Ptr<EAdjointEpetraOp> &epetraOpAdjointSupport,
59  const Ptr<double> &epetraOpScalar
60  ) const
61 {
62  using Teuchos::outArg;
63  double wrappedFwdOpScalar = 0.0;
64  EOpTransp wrappedFwdOpTransp = NOTRANS;
66  unwrap(fwdOp,&wrappedFwdOpScalar, &wrappedFwdOpTransp, &wrappedFwdOp);
68  Teuchos::rcp_dynamic_cast<const EpetraLinearOpBase>(wrappedFwdOp,true);
69  EOpTransp epetra_epetraOpTransp;
70  epetraFwdOp->getEpetraOpView(epetraOp, outArg(epetra_epetraOpTransp),
71  epetraOpApplyAs, epetraOpAdjointSupport);
72  *epetraOpTransp = trans_trans(real_trans(epetra_epetraOpTransp), wrappedFwdOpTransp);
73  *epetraOpScalar = wrappedFwdOpScalar;
74 }
75 
76 
77 // ToDo: Refactor unwrap(...) to not use raw pointers!
78 
79 
80 } // namespace Thyra
void getEpetraOpView(const RCP< const LinearOpBase< double > > &fwdOp, const Ptr< RCP< const Epetra_Operator > > &epetraOp, const Ptr< EOpTransp > &epetraOpTransp, const Ptr< EApplyEpetraOpAs > &epetraOpApplyAs, const Ptr< EAdjointEpetraOp > &epetraOpAdjointSupport, const Ptr< double > &epetraOpScalar) const
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
void unwrap(const LinearOpBase< Scalar > &Op, Scalar *scalar, EOpTransp *transp, const LinearOpBase< Scalar > **origOp)
Extract the overallScalar, overallTransp and const origOp from a const LinearOpBase object...
bool isCompatible(const LinearOpBase< double > &fwdOp) const
Use the non-transposed operator.
Abstract base class for all LinearOpBase objects that can return an Epetra_Operator view of themselve...
EOpTransp real_trans(EOpTransp transp)
Return NOTRANS or TRANS for real scalar valued operators and this also is used for determining struct...
EOpTransp trans_trans(EOpTransp trans1, EOpTransp trans2)
Combine two transpose arguments.
void getNonconstEpetraOpView(const RCP< LinearOpBase< double > > &fwdOp, const Ptr< RCP< Epetra_Operator > > &epetraOp, const Ptr< EOpTransp > &epetraOpTransp, const Ptr< EApplyEpetraOpAs > &epetraOpApplyAs, const Ptr< EAdjointEpetraOp > &epetraOpAdjointSupport, const Ptr< double > &epetraOpScalar) const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)