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>(
100 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
101 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
104 getOrCreateLocallyReplicatedTpetraVectorSpace(
105 const RCP<
const VectorSpaceBase<Scalar> > space,
111 return getOrCreateLocallyReplicatedTpetraVectorSpace
112 <Scalar, LocalOrdinal, GlobalOrdinal, Node>
113 (space, tpetraComm, numCols);
120 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
123 const RCP<
const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > &tpetraMap
126 return tpetraVectorSpace<Scalar>(tpetraMap);
130 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
133 const RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector_in,
134 const RCP<
const VectorSpaceBase<Scalar> > space_in
138 getOrCreateTpetraVectorSpace(space_in, tpetraVector_in->getMap()),
144 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
147 const RCP<
const Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector_in,
148 const RCP<
const VectorSpaceBase<Scalar> > space
152 getOrCreateTpetraVectorSpace(space, tpetraVector_in->getMap()),
158 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
161 const RCP<Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraMultiVector_in,
162 const RCP<
const VectorSpaceBase<Scalar> > rangeSpace,
163 const RCP<
const VectorSpaceBase<Scalar> > domainSpace
167 getOrCreateTpetraVectorSpace(rangeSpace, tpetraMultiVector_in->getMap()),
168 getOrCreateLocallyReplicatedTpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
169 domainSpace, tpetraMultiVector_in->getMap()->getComm(),
170 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
171 tpetraMultiVector_in->getMap()->getNode(),
172 #endif // TPETRA_ENABLE_DEPRECATED_CODE
173 tpetraMultiVector_in->getNumVectors()
180 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
183 const RCP<
const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraMultiVector_in,
184 const RCP<
const VectorSpaceBase<Scalar> > rangeSpace,
185 const RCP<
const VectorSpaceBase<Scalar> > domainSpace
189 getOrCreateTpetraVectorSpace(rangeSpace, tpetraMultiVector_in->getMap()),
190 getOrCreateLocallyReplicatedTpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(
191 domainSpace, tpetraMultiVector_in->getMap()->getComm(),
192 #ifdef TPETRA_ENABLE_DEPRECATED_CODE
193 tpetraMultiVector_in->getMap()->getNode(),
194 #endif // TPETRA_ENABLE_DEPRECATED_CODE
195 tpetraMultiVector_in->getNumVectors()
202 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
205 const RCP<Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator_in,
206 const RCP<
const VectorSpaceBase<Scalar> > rangeSpace,
207 const RCP<
const VectorSpaceBase<Scalar> > domainSpace
210 return tpetraLinearOp<Scalar,LocalOrdinal,GlobalOrdinal,Node>(
211 getOrCreateTpetraVectorSpace(rangeSpace, tpetraOperator_in->getRangeMap()),
212 getOrCreateTpetraVectorSpace(domainSpace, tpetraOperator_in->getDomainMap()),
218 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
221 const RCP<
const Tpetra::Operator<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraOperator_in,
222 const RCP<
const VectorSpaceBase<Scalar> > rangeSpace,
223 const RCP<
const VectorSpaceBase<Scalar> > domainSpace
226 return constTpetraLinearOp<Scalar,LocalOrdinal,GlobalOrdinal,Node>(
227 getOrCreateTpetraVectorSpace(rangeSpace, tpetraOperator_in->getRangeMap()),
228 getOrCreateTpetraVectorSpace(domainSpace, tpetraOperator_in->getDomainMap()),
236 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
237 RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
242 return Teuchos::rcp_dynamic_cast<
const TpetraVectorSpace_t>(vs,
true)->getTpetraMap();
246 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
252 return Teuchos::rcp_dynamic_cast<TpetraVector_t>(v,
true)->getTpetraVector();
256 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
262 return Teuchos::rcp_dynamic_cast<
const TpetraVector_t>(v,
true)->getConstTpetraVector();
266 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
276 using Teuchos::rcp_dynamic_cast;
279 ThyraTpetraMultiVector_t;
281 rcp_dynamic_cast<ThyraTpetraMultiVector_t>(mv);
283 return tmv->getTpetraMultiVector();
289 rcp_dynamic_cast<ThyraTpetraVector_t>(mv);
291 return tv->getTpetraVector();
295 "Error, the input mv = " << mv->description() <<
" does not support the"
296 " Thyra::TpetraMultiVector or the Thyra::TpetraVector interfaces!");
303 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
313 using Teuchos::rcp_dynamic_cast;
316 ThyraTpetraMultiVector_t;
318 rcp_dynamic_cast<
const ThyraTpetraMultiVector_t>(mv);
320 return tmv->getConstTpetraMultiVector();
326 rcp_dynamic_cast<
const ThyraTpetraVector_t>(mv);
328 return tv->getConstTpetraVector();
332 "Error, the input mv = " << mv->description() <<
" does not support the"
333 " Thyra::TpetraMultiVector or the Thyra::TpetraVector interfaces!");
340 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
346 return Teuchos::rcp_dynamic_cast<TpetraLinearOp_t>(op,
true)->getTpetraOperator();
350 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
356 return Teuchos::rcp_dynamic_cast<
const TpetraLinearOp_t>(op,
true)->getConstTpetraOperator();
363 #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.