42 #ifndef THYRA_TPETRA_THYRA_WRAPPERS_HPP
43 #define THYRA_TPETRA_THYRA_WRAPPERS_HPP
46 #include "Thyra_TpetraThyraWrappers.hpp"
47 #include "Thyra_TpetraVectorSpace.hpp"
48 #include "Thyra_TpetraVector.hpp"
49 #include "Thyra_TpetraMultiVector.hpp"
50 #include "Thyra_TpetraLinearOp.hpp"
56 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
58 getOrCreateTpetraVectorSpace(
59 const RCP<
const VectorSpaceBase<Scalar> > space,
60 const RCP<
const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > &tpetraMap
63 using Teuchos::rcp_dynamic_cast;
64 typedef TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> TpetraVectorSpace_t;
65 RCP<const TpetraVectorSpace_t> tpetraSpace;
67 tpetraSpace = rcp_dynamic_cast<
const TpetraVectorSpace_t>(space,
true);
70 tpetraSpace = tpetraVectorSpace<Scalar>(tpetraMap);
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
78 getOrCreateLocallyReplicatedTpetraVectorSpace(
79 const RCP<
const VectorSpaceBase<Scalar> > space,
84 using Teuchos::rcp_dynamic_cast;
85 typedef TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> TpetraVectorSpace_t;
86 RCP<const TpetraVectorSpace_t> tpetraSpace;
88 tpetraSpace = rcp_dynamic_cast<
const TpetraVectorSpace_t>(space,
true);
91 tpetraSpace = tpetraVectorSpace<Scalar>(
92 Tpetra::createLocalMapWithNode<LocalOrdinal,GlobalOrdinal,Node>(
103 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 const RCP<
const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > &tpetraMap
109 return tpetraVectorSpace<Scalar>(tpetraMap);
113 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
116 const RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector_in,
117 const RCP<
const VectorSpaceBase<Scalar> > space_in
121 getOrCreateTpetraVectorSpace(space_in, tpetraVector_in->getMap()),
127 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130 const RCP<
const Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector_in,
131 const RCP<
const VectorSpaceBase<Scalar> > space
135 getOrCreateTpetraVectorSpace(space, tpetraVector_in->getMap()),
141 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144 const RCP<Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraMultiVector_in,
145 const RCP<
const VectorSpaceBase<Scalar> > rangeSpace,
146 const RCP<
const VectorSpaceBase<Scalar> > domainSpace
150 getOrCreateTpetraVectorSpace(rangeSpace, tpetraMultiVector_in->getMap()),
151 getOrCreateLocallyReplicatedTpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
152 domainSpace, tpetraMultiVector_in->getMap()->getComm(),
153 tpetraMultiVector_in->getNumVectors()
160 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
163 const RCP<
const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraMultiVector_in,
164 const RCP<
const VectorSpaceBase<Scalar> > rangeSpace,
165 const RCP<
const VectorSpaceBase<Scalar> > domainSpace
169 getOrCreateTpetraVectorSpace(rangeSpace, tpetraMultiVector_in->getMap()),
170 getOrCreateLocallyReplicatedTpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
171 domainSpace, tpetraMultiVector_in->getMap()->getComm(),
172 tpetraMultiVector_in->getNumVectors()
179 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
182 const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator_in,
183 const RCP<
const VectorSpaceBase<Scalar> > rangeSpace,
184 const RCP<
const VectorSpaceBase<Scalar> > domainSpace
187 return tpetraLinearOp<Scalar,LocalOrdinal,GlobalOrdinal,Node>(
188 getOrCreateTpetraVectorSpace(rangeSpace, tpetraOperator_in->getRangeMap()),
189 getOrCreateTpetraVectorSpace(domainSpace, tpetraOperator_in->getDomainMap()),
195 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
198 const RCP<
const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator_in,
199 const RCP<
const VectorSpaceBase<Scalar> > rangeSpace,
200 const RCP<
const VectorSpaceBase<Scalar> > domainSpace
203 return constTpetraLinearOp<Scalar,LocalOrdinal,GlobalOrdinal,Node>(
204 getOrCreateTpetraVectorSpace(rangeSpace, tpetraOperator_in->getRangeMap()),
205 getOrCreateTpetraVectorSpace(domainSpace, tpetraOperator_in->getDomainMap()),
213 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
214 RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
219 return Teuchos::rcp_dynamic_cast<
const TpetraVectorSpace_t>(vs,
true)->getTpetraMap();
223 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
229 return Teuchos::rcp_dynamic_cast<TpetraVector_t>(v,
true)->getTpetraVector();
233 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
239 return Teuchos::rcp_dynamic_cast<
const TpetraVector_t>(v,
true)->getConstTpetraVector();
243 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
253 using Teuchos::rcp_dynamic_cast;
256 ThyraTpetraMultiVector_t;
258 rcp_dynamic_cast<ThyraTpetraMultiVector_t>(mv);
260 return tmv->getTpetraMultiVector();
266 rcp_dynamic_cast<ThyraTpetraVector_t>(mv);
268 return tv->getTpetraVector();
272 "Error, the input mv = " << mv->description() <<
" does not support the"
273 " Thyra::TpetraMultiVector or the Thyra::TpetraVector interfaces!");
280 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
290 using Teuchos::rcp_dynamic_cast;
293 ThyraTpetraMultiVector_t;
295 rcp_dynamic_cast<
const ThyraTpetraMultiVector_t>(mv);
297 return tmv->getConstTpetraMultiVector();
303 rcp_dynamic_cast<
const ThyraTpetraVector_t>(mv);
305 return tv->getConstTpetraVector();
309 "Error, the input mv = " << mv->description() <<
" does not support the"
310 " Thyra::TpetraMultiVector or the Thyra::TpetraVector interfaces!");
317 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
323 return Teuchos::rcp_dynamic_cast<TpetraLinearOp_t>(op,
true)->getTpetraOperator();
327 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
333 return Teuchos::rcp_dynamic_cast<
const TpetraLinearOp_t>(op,
true)->getConstTpetraOperator();
340 #endif // THYRA_TPETRA_THYRA_WRAPPERS_HPP
Concrete implementation of Thyra::MultiVector in terms of Tpetra::MultiVector.
Concrete implementation of an SPMD vector space for Tpetra.
RCP< MultiVectorBase< Scalar > > createMultiVector(const RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraMultiVector, const RCP< const VectorSpaceBase< Scalar > > rangeSpace=Teuchos::null, const RCP< const VectorSpaceBase< Scalar > > domainSpace=Teuchos::null)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
RCP< const MultiVectorBase< Scalar > > createConstMultiVector(const RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraMultiVector, const RCP< const VectorSpaceBase< Scalar > > rangeSpace=Teuchos::null, const RCP< const VectorSpaceBase< Scalar > > domainSpace=Teuchos::null)
RCP< const VectorBase< Scalar > > createConstVector(const RCP< const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVector, const RCP< const VectorSpaceBase< Scalar > > space=Teuchos::null)
Abstract interface for objects that represent a space for vectors.
RCP< TpetraMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraMultiVector(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const ScalarProdVectorSpaceBase< Scalar > > &domainSpace, const RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraMultiVector)
Nonmember constructor for TpetraMultiVector.
RCP< const LinearOpBase< Scalar > > createConstLinearOp(const RCP< const Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraOperator, const RCP< const VectorSpaceBase< Scalar > > rangeSpace=Teuchos::null, const RCP< const VectorSpaceBase< Scalar > > domainSpace=Teuchos::null)
Interface for a collection of column vectors called a multi-vector.
RCP< const TpetraMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > constTpetraMultiVector(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const ScalarProdVectorSpaceBase< Scalar > > &domainSpace, const RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraMultiVector)
Nonmember constructor for TpetraMultiVector.
RCP< VectorBase< Scalar > > createVector(const RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVector, const RCP< const VectorSpaceBase< Scalar > > space=Teuchos::null)
Abstract interface for finite-dimensional dense vectors.
RCP< const VectorSpaceBase< Scalar > > createVectorSpace(const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &tpetraMap)
Create a Thyra::VectorSpaceBase object given a Tpetra::Map.
Concrete Thyra::SpmdVectorBase using Tpetra::Vector.
RCP< TpetraVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraVector(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVector)
Nonmember constructor for TpetraVector.
Base class for all linear operators.
RCP< const TpetraVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > constTpetraVector(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVector)
Nonmember constructor for TpetraVector.
bool nonnull(const boost::shared_ptr< T > &p)
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
RCP< LinearOpBase< Scalar > > createLinearOp(const RCP< Tpetra::Operator< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraOperator, const RCP< const VectorSpaceBase< Scalar > > rangeSpace=Teuchos::null, const RCP< const VectorSpaceBase< Scalar > > domainSpace=Teuchos::null)
#define TEUCHOS_ASSERT(assertion_test)
Concrete Thyra::LinearOpBase subclass for Tpetra::Operator.