44 #include "Thyra_DetachedSpmdVectorView.hpp"
45 #include "Thyra_DefaultProductVector.hpp"
46 #include "Thyra_ProductVectorSpaceBase.hpp"
47 #include "Thyra_SpmdVectorBase.hpp"
51 # include "Epetra_MpiComm.h"
53 #include "Epetra_SerialComm.h"
54 #include "Epetra_Vector.h"
69 const RCP<
const LinearOpBase<double> > &thyraOp
71 : useTranspose_(false),
73 range_(thyraOp->range()),
74 domain_(thyraOp->domain()),
75 comm_(getEpetraComm(*thyraOp)),
78 label_(thyraOp->description())
83 const Ptr<VectorBase<double> > &thyraVec)
const
86 using Teuchos::rcpFromPtr;
87 using Teuchos::rcp_dynamic_cast;
89 const int numVecs = x.NumVectors();
92 "epetraToThyra does not work with MV dimension != 1");
95 castOrCreateNonconstProductVectorBase(rcpFromPtr(thyraVec));
103 const int numBlocks = prodThyraVec->productSpace()->numBlocks();
104 for (
int b = 0; b < numBlocks; ++b) {
107 rcp_dynamic_cast<
const SpmdVectorSpaceBase<double> >(vec_b->space(),
true);
108 DetachedSpmdVectorView<double> view(vec_b);
109 const ArrayRCP<double> thyraData = view.sv().values();
110 const int localNumElems = spmd_vs_b->localSubDim();
111 for (
int i=0; i < localNumElems; ++i) {
112 thyraData[i] = epetraData[i+offset];
114 offset += localNumElems;
121 const VectorBase<double>& thyraVec, Epetra_MultiVector& x)
const
124 using Teuchos::rcpFromRef;
125 using Teuchos::rcp_dynamic_cast;
127 const int numVecs = x.NumVectors();
130 "epetraToThyra does not work with MV dimension != 1");
133 castOrCreateProductVectorBase(rcpFromRef(thyraVec));
139 const int numBlocks = prodThyraVec->productSpace()->numBlocks();
140 for (
int b = 0; b < numBlocks; ++b) {
143 rcp_dynamic_cast<
const SpmdVectorSpaceBase<double> >(vec_b->space(),
true);
144 ConstDetachedSpmdVectorView<double> view(vec_b);
145 const ArrayRCP<const double> thyraData = view.sv().values();
146 const int localNumElems = spmd_vs_b->localSubDim();
147 for (
int i=0; i < localNumElems; ++i) {
148 epetraData[i+offset] = thyraData[i];
150 offset += localNumElems;
160 Epetra_MultiVector& Y)
const
182 Epetra_MultiVector& )
const
185 "EpetraOperatorWrapper::ApplyInverse not implemented");
193 "EpetraOperatorWrapper::NormInf not implemated");
206 using Teuchos::rcp_dynamic_cast;
209 using Teuchos::MpiComm;
215 rcp_dynamic_cast<
const ProductVectorSpaceBase<double> >(vs);
218 vs = prod_vs->getBlock(0);
221 rcp_dynamic_cast<
const SpmdVectorSpaceBase<double> >(vs,
true);
232 Thyra::makeEpetraWrapper(
const RCP<
const LinearOpBase<double> > &thyraOp)
void copyEpetraIntoThyra(const Epetra_MultiVector &x, const Ptr< VectorBase< double > > &thyraVec) const
EpetraOperatorWrapper(const RCP< const LinearOpBase< double > > &thyraOp)
RCP< const Epetra_Map > get_Epetra_Map(const VectorSpaceBase< double > &vs, const RCP< const Epetra_Comm > &comm)
Get (or create) an Epetra_Map object given an VectorSpaceBase object an optionally an extra Epetra_Co...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static RCP< const Epetra_Comm > getEpetraComm(const LinearOpBase< double > &thyraOp)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< const EpetraLinearOp > epetraLinearOp(const RCP< const Epetra_Operator > &op, EOpTransp opTrans=NOTRANS, EApplyEpetraOpAs applyAs=EPETRA_OP_APPLY_APPLY, EAdjointEpetraOp adjointSupport=EPETRA_OP_ADJOINT_SUPPORTED, const RCP< const VectorSpaceBase< double > > &range=Teuchos::null, const RCP< const VectorSpaceBase< double > > &domain=Teuchos::null)
Dynamically allocate a nonconst EpetraLinearOp to wrap a const Epetra_Operator object.
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
RCP< const VectorSpaceBase< double > > range_
RCP< const VectorSpaceBase< double > > domain_
RCP< const Epetra_Comm > get_Epetra_Comm(const Teuchos::Comm< Ordinal > &comm)
Get (or create) and Epetra_Comm given a Teuchos::Comm object.
void copyThyraIntoEpetra(const VectorBase< double > &thyraVec, Epetra_MultiVector &x) const
bool nonnull(const boost::shared_ptr< T > &p)
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
RCP< const LinearOpBase< double > > thyraOp_
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)