10 #ifndef HAVE_XPETRA_THYRAUTILS_DEF_HPP
11 #define HAVE_XPETRA_THYRAUTILS_DEF_HPP
13 #ifdef HAVE_XPETRA_THYRA
15 #include "Xpetra_BlockedCrsMatrix.hpp"
21 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
22 Teuchos::RCP<Xpetra::StridedMap<LocalOrdinal, GlobalOrdinal, Node>>
24 toXpetra(
const Teuchos::RCP<
const Thyra::VectorSpaceBase<Scalar>>& vectorSpace,
const Teuchos::RCP<
const Teuchos::Comm<int>>& comm, std::vector<size_t>& stridingInfo, LocalOrdinal stridedBlockId, GlobalOrdinal offset) {
25 Teuchos::RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>> map =
toXpetra(vectorSpace, comm);
27 if (stridedBlockId == -1) {
28 TEUCHOS_TEST_FOR_EXCEPT(map->getLocalNumElements() % stridingInfo.size() != 0);
30 TEUCHOS_TEST_FOR_EXCEPT(map->getLocalNumElements() % stridingInfo[stridedBlockId] != 0);
37 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
38 Teuchos::RCP<Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>
40 toXpetra(
const Teuchos::RCP<
const Thyra::VectorSpaceBase<Scalar>>& vectorSpace,
const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
43 using Teuchos::rcp_dynamic_cast;
44 using ThyVecSpaceBase = Thyra::VectorSpaceBase<Scalar>;
45 using ThyProdVecSpaceBase = Thyra::ProductVectorSpaceBase<Scalar>;
46 using ThyUtils = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
48 RCP<Map> resultMap = Teuchos::null;
49 RCP<const ThyProdVecSpaceBase> prodVectorSpace = rcp_dynamic_cast<
const ThyProdVecSpaceBase>(vectorSpace);
50 if (prodVectorSpace != Teuchos::null) {
53 TEUCHOS_TEST_FOR_EXCEPTION(prodVectorSpace->numBlocks() == 0, std::logic_error,
"Found a product vector space with zero blocks.");
54 std::vector<RCP<const Map>> mapsThyra(prodVectorSpace->numBlocks(), Teuchos::null);
55 std::vector<RCP<const Map>> mapsXpetra(prodVectorSpace->numBlocks(), Teuchos::null);
56 for (
int b = 0; b < prodVectorSpace->numBlocks(); ++b) {
57 RCP<const ThyVecSpaceBase> bv = prodVectorSpace->getBlock(b);
64 std::vector<GlobalOrdinal> gidOffsets(prodVectorSpace->numBlocks(), 0);
65 for (
int i = 1; i < prodVectorSpace->numBlocks(); ++i) {
66 gidOffsets[i] = mapsThyra[i - 1]->getMaxAllGlobalIndex() + gidOffsets[i - 1] + 1;
69 for (
int b = 0; b < prodVectorSpace->numBlocks(); ++b) {
70 RCP<const ThyVecSpaceBase> bv = prodVectorSpace->getBlock(b);
77 #ifdef HAVE_XPETRA_TPETRA
80 Teuchos::RCP<const Thyra::TpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpetra_vsc = Teuchos::rcp_dynamic_cast<
const Thyra::TpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(vectorSpace);
81 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::is_null(tpetra_vsc) ==
true,
Xpetra::Exceptions::RuntimeError,
"toXpetra failed to convert provided vector space to Thyra::TpetraVectorSpace. This is the general implementation for Tpetra only.");
83 typedef Tpetra::Map<LocalOrdinal, GlobalOrdinal, Node> TpMap;
84 typedef Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> TpVector;
85 typedef Thyra::TpetraOperatorVectorExtraction<Scalar, LocalOrdinal, GlobalOrdinal, Node> TOE;
86 typedef Thyra::VectorBase<Scalar> ThyVecBase;
87 RCP<ThyVecBase> rgVec = Thyra::createMember<Scalar>(vectorSpace, std::string(
"label"));
88 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(rgVec));
89 RCP<const TpVector> rgTpetraVec = TOE::getTpetraVector(rgVec);
90 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(rgTpetraVec));
91 RCP<const TpMap> rgTpetraMap = rgTpetraVec->getMap();
92 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(rgTpetraMap));
95 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Cannot transform Thyra::VectorSpace to Xpetra::Map. This is the general implementation for Tpetra only, but Tpetra is disabled.");
98 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(resultMap));
102 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 Teuchos::RCP<const Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
105 toXpetra(Teuchos::RCP<
const Thyra::MultiVectorBase<Scalar>> v,
const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
108 using Teuchos::rcp_dynamic_cast;
110 using ThyMultVecBase = Thyra::MultiVectorBase<Scalar>;
111 using ThyProdMultVecBase = Thyra::ProductMultiVectorBase<Scalar>;
112 using ThyUtils = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
115 RCP<MultiVector> xpMultVec = Teuchos::null;
118 Teuchos::RCP<const ThyProdMultVecBase> thyProdVec = rcp_dynamic_cast<
const ThyProdMultVecBase>(v);
119 if (thyProdVec != Teuchos::null) {
123 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(Teuchos::rcp_dynamic_cast<BlockedMap>(fullMap)));
128 RCP<BlockedMultiVector> xpBlockedMultVec = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(xpMultVec,
true);
131 for (
int b = 0; b < thyProdVec->productSpace()->numBlocks(); ++b) {
132 RCP<const ThyMultVecBase> thyBlockMV = thyProdVec->getMultiVectorBlock(b);
135 xpBlockedMultVec->setMultiVector(b, xpBlockMV,
true );
139 #ifdef HAVE_XPETRA_TPETRA
140 typedef Thyra::TpetraOperatorVectorExtraction<Scalar, LocalOrdinal, GlobalOrdinal, Node> ConverterT;
141 typedef Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> TpMultVec;
143 typedef Thyra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> ThyTpMultVec;
144 typedef Thyra::SpmdMultiVectorBase<Scalar> ThySpmdMultVecBase;
146 RCP<const ThySpmdMultVecBase> thyraSpmdMultiVector = rcp_dynamic_cast<
const ThySpmdMultVecBase>(v);
147 RCP<const ThyTpMultVec> thyraTpetraMultiVector = rcp_dynamic_cast<
const ThyTpMultVec>(thyraSpmdMultiVector);
148 TEUCHOS_TEST_FOR_EXCEPTION(thyraTpetraMultiVector == Teuchos::null,
Xpetra::Exceptions::RuntimeError,
"toXpetra failed to convert provided multi vector to Thyra::TpetraMultiVector. This is the general implementation for Tpetra only.");
149 const RCP<const TpMultVec> tpMultVec = ConverterT::getConstTpetraMultiVector(v);
150 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(tpMultVec));
151 RCP<TpMultVec> tpNonConstMultVec = Teuchos::rcp_const_cast<TpMultVec>(tpMultVec);
152 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(tpNonConstMultVec));
153 xpMultVec = rcp(
new XpTpMultVec(tpNonConstMultVec));
155 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Cannot transform Thyra::MultiVector to Xpetra::MultiVector. This is the general implementation for Tpetra only, but Teptra is disabled.");
158 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(xpMultVec));
162 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
163 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
165 toXpetra(Teuchos::RCP<Thyra::MultiVectorBase<Scalar>> v,
const Teuchos::RCP<
const Teuchos::Comm<int>>& comm) {
166 Teuchos::RCP<const Thyra::MultiVectorBase<Scalar>> cv =
167 Teuchos::rcp_const_cast<
const Thyra::MultiVectorBase<Scalar>>(v);
168 Teuchos::RCP<const Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> r =
173 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
174 bool Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
175 isTpetra(
const Teuchos::RCP<
const Thyra::LinearOpBase<Scalar>>& op) {
176 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(op));
179 bool bIsTpetra =
false;
180 #ifdef HAVE_XPETRA_TPETRA
181 Teuchos::RCP<const Thyra::TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpetra_op = Teuchos::rcp_dynamic_cast<
const Thyra::TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(op);
182 bIsTpetra = Teuchos::is_null(tpetra_op) ?
false :
true;
186 #ifdef HAVE_XPETRA_EPETRA
187 Teuchos::rcp_dynamic_cast<const Thyra::EpetraLinearOp>(op) == Teuchos::null &&
189 Teuchos::rcp_dynamic_cast<
const Thyra::DefaultBlockedLinearOp<Scalar>>(op) == Teuchos::null) {
191 typedef Thyra::TpetraLinearOp<Scalar, LocalOrdinal, GlobalOrdinal, Node> TpetraLinearOp_t;
192 if (Teuchos::rcp_dynamic_cast<const TpetraLinearOp_t>(op) == Teuchos::null) {
193 std::cout <<
"ATTENTION: The dynamic cast to the TpetraLinearOp failed even though it should be a TpetraLinearOp." << std::endl;
194 std::cout <<
" If you are using Panzer or Stratimikos you might check that the template parameters are " << std::endl;
195 std::cout <<
" properly set!" << std::endl;
196 std::cout << Teuchos::rcp_dynamic_cast<const TpetraLinearOp_t>(op,
true) << std::endl;
205 if(bIsTpetra ==
false) {
206 Teuchos::RCP<const Thyra::BlockedLinearOpBase<Scalar> > ThyBlockedOp =
207 Teuchos::rcp_dynamic_cast<
const Thyra::BlockedLinearOpBase<Scalar> >(op);
208 if(ThyBlockedOp != Teuchos::null) {
209 TEUCHOS_TEST_FOR_EXCEPT(ThyBlockedOp->blockExists(0,0)==
false);
210 Teuchos::RCP<const Thyra::LinearOpBase<Scalar> > b00 =
211 ThyBlockedOp->getBlock(0,0);
212 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(b00));
213 bIsTpetra = isTpetra(b00);
221 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
222 bool Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
223 isEpetra(
const Teuchos::RCP<
const Thyra::LinearOpBase<Scalar>>& op) {
227 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
228 bool Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
229 isBlockedOperator(
const Teuchos::RCP<
const Thyra::LinearOpBase<Scalar>>& op) {
231 Teuchos::RCP<const Thyra::BlockedLinearOpBase<Scalar>> ThyBlockedOp =
232 Teuchos::rcp_dynamic_cast<
const Thyra::BlockedLinearOpBase<Scalar>>(op);
233 if (ThyBlockedOp != Teuchos::null) {
239 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
240 Teuchos::RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
242 toXpetra(
const Teuchos::RCP<
const Thyra::LinearOpBase<Scalar>>& op) {
243 #ifdef HAVE_XPETRA_TPETRA
245 typedef Thyra::TpetraOperatorVectorExtraction<Scalar, LocalOrdinal, GlobalOrdinal, Node> TOE;
246 Teuchos::RCP<const Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> TpetraOp = TOE::getConstTpetraOperator(op);
249 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(TpetraOp));
250 Teuchos::RCP<const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> TpetraRowMat = Teuchos::rcp_dynamic_cast<
const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(TpetraOp,
true);
251 Teuchos::RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> TpetraCrsMat = Teuchos::rcp_dynamic_cast<
const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(TpetraRowMat,
true);
252 Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> TpetraNcnstCrsMat = Teuchos::rcp_const_cast<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(TpetraCrsMat);
253 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(TpetraNcnstCrsMat));
255 Teuchos::RCP<Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xTpetraCrsMat =
257 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(xTpetraCrsMat));
259 Teuchos::RCP<Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpCrsMat =
261 Teuchos::RCP<Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpCrsWrap =
263 Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpMat =
269 #ifdef HAVE_XPETRA_EPETRA
274 return Teuchos::null;
277 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
278 Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
280 toXpetra(
const Teuchos::RCP<Thyra::LinearOpBase<Scalar>>& op) {
283 using Teuchos::rcp_const_cast;
284 using Teuchos::rcp_dynamic_cast;
286 #ifdef HAVE_XPETRA_TPETRA
288 typedef Thyra::TpetraOperatorVectorExtraction<Scalar, LocalOrdinal, GlobalOrdinal, Node> TOE;
289 typedef Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node> TpetraOperator_t;
290 RCP<const TpetraOperator_t> TpetraOp = TOE::getConstTpetraOperator(op);
291 TEUCHOS_TEST_FOR_EXCEPT(is_null(TpetraOp));
292 RCP<const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> TpetraRowMat =
293 rcp_dynamic_cast<
const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(TpetraOp,
true);
294 RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> TpetraCrsMat =
295 rcp_dynamic_cast<
const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(TpetraRowMat,
true);
297 RCP<Xpetra::TpetraCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xTpetraCrsMat =
299 rcp_const_cast<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(TpetraCrsMat)));
300 TEUCHOS_TEST_FOR_EXCEPT(is_null(xTpetraCrsMat));
301 RCP<Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpCrsMat =
303 RCP<Xpetra::CrsMatrixWrap<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpCrsWrap =
305 RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpMat =
311 #ifdef HAVE_XPETRA_EPETRA
316 return Teuchos::null;
319 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
320 Teuchos::RCP<const Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
321 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
322 toXpetraOperator(
const Teuchos::RCP<
const Thyra::LinearOpBase<Scalar>>& op) {
323 #ifdef HAVE_XPETRA_TPETRA
325 typedef Thyra::TpetraOperatorVectorExtraction<Scalar, LocalOrdinal, GlobalOrdinal, Node> TOE;
326 Teuchos::RCP<const Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> TpetraOp = TOE::getConstTpetraOperator(op);
328 auto nonConstTpetraOp = Teuchos::rcp_const_cast<Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(TpetraOp);
330 Teuchos::RCP<Xpetra::TpetraOperator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xTpetraOp =
332 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(xTpetraOp));
334 Teuchos::RCP<Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpOp =
340 #ifdef HAVE_XPETRA_EPETRA
345 return Teuchos::null;
348 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
349 Teuchos::RCP<Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
350 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
351 toXpetraOperator(
const Teuchos::RCP<Thyra::LinearOpBase<Scalar>>& op) {
352 #ifdef HAVE_XPETRA_TPETRA
354 typedef Thyra::TpetraOperatorVectorExtraction<Scalar, LocalOrdinal, GlobalOrdinal, Node> TOE;
355 Teuchos::RCP<Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> TpetraOp = TOE::getTpetraOperator(op);
357 Teuchos::RCP<Xpetra::TpetraOperator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xTpetraOp =
359 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(xTpetraOp));
361 Teuchos::RCP<Xpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpOp =
367 #ifdef HAVE_XPETRA_EPETRA
372 return Teuchos::null;
375 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
376 Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
378 toXpetra(
const Teuchos::RCP<Thyra::DiagonalLinearOpBase<Scalar>>& op) {
379 using Teuchos::rcp_const_cast;
380 using Teuchos::rcp_dynamic_cast;
382 RCP<const Thyra::VectorBase<Scalar>> diag = op->getDiag();
384 RCP<const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpDiag;
385 #ifdef HAVE_XPETRA_TPETRA
386 using thyTpV = Thyra::TpetraVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
387 using tV = Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
388 if (!rcp_dynamic_cast<const thyTpV>(diag).is_null()) {
389 RCP<const tV> tDiag = Thyra::TpetraOperatorVectorExtraction<Scalar, LocalOrdinal, GlobalOrdinal, Node>::getConstTpetraVector(diag);
390 if (!tDiag.is_null())
394 TEUCHOS_ASSERT(!xpDiag.is_null());
399 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
400 Teuchos::RCP<const Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
402 toXpetra(
const Teuchos::RCP<
const Thyra::DiagonalLinearOpBase<Scalar>>& op) {
403 return toXpetra(Teuchos::rcp_const_cast<Thyra::DiagonalLinearOpBase<Scalar>>(op));
406 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
407 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar>>
408 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
410 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar>> thyraMap = Teuchos::null;
413 RCP<const BlockedMap> bmap = Teuchos::rcp_dynamic_cast<
const BlockedMap>(map);
414 if (bmap.is_null() ==
false) {
415 Teuchos::Array<Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar>>> vecSpaces(bmap->getNumMaps());
416 for (
size_t i = 0; i < bmap->getNumMaps(); i++) {
418 Teuchos::RCP<const Thyra::VectorSpaceBase<Scalar>> vs =
419 Xpetra::ThyraUtils<Scalar, LO, GO, Node>::toThyra(bmap->getMap(i,
true));
423 thyraMap = Thyra::productVectorSpace<Scalar>(vecSpaces());
428 #ifdef HAVE_XPETRA_TPETRA
431 if (tpetraMap == Teuchos::null)
432 throw Exceptions::BadCast(
"Xpetra::ThyraUtils::toThyra: Cast from Xpetra::Map to Xpetra::TpetraMap failed");
433 RCP<Thyra::TpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>> thyraTpetraMap = Thyra::tpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(tpetraMap->getTpetra_Map());
434 thyraMap = thyraTpetraMap;
438 #ifdef HAVE_XPETRA_EPETRA
447 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
448 Teuchos::RCP<const Thyra::MultiVectorBase<Scalar>>
449 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
452 #ifdef HAVE_XPETRA_TPETRA
454 auto thyTpMap = Thyra::tpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Teuchos::rcp_dynamic_cast<
const TpetraMap>(vec->getMap())->getTpetra_Map());
455 RCP<Tpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpMV = Teuchos::rcp_dynamic_cast<
const TpetraMultiVector>(vec)->getTpetra_MultiVector();
456 auto thyDomMap = Thyra::tpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Tpetra::createLocalMapWithNode<LocalOrdinal, GlobalOrdinal, Node>(vec->getNumVectors(), vec->getMap()->getComm()));
457 auto thyMV = rcp(
new Thyra::TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>());
458 thyMV->initialize(thyTpMap, thyDomMap, tpMV);
463 #ifdef HAVE_XPETRA_EPETRA
472 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
473 Teuchos::RCP<const Thyra::VectorBase<Scalar>>
474 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
477 #ifdef HAVE_XPETRA_TPETRA
479 auto thyTpMap = Thyra::tpetraVectorSpace<Scalar, LocalOrdinal, GlobalOrdinal, Node>(Teuchos::rcp_dynamic_cast<
const TpetraMap>(vec->getMap())->getTpetra_Map());
480 RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpVec = Teuchos::rcp_dynamic_cast<
const TpetraVector>(vec)->getTpetra_Vector();
481 auto thyVec = rcp(
new Thyra::TpetraVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>());
482 thyVec->initialize(thyTpMap, tpVec);
487 #ifdef HAVE_XPETRA_EPETRA
496 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
497 void Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
501 using Teuchos::rcp_dynamic_cast;
502 typedef Thyra::VectorSpaceBase<Scalar> ThyVecSpaceBase;
503 typedef Thyra::SpmdVectorSpaceBase<Scalar> ThySpmdVecSpaceBase;
504 typedef Thyra::MultiVectorBase<Scalar> ThyMultVecBase;
507 typedef Thyra::ProductMultiVectorBase<Scalar> ThyProdMultVecBase;
510 RCP<ThyProdMultVecBase> prodTarget = rcp_dynamic_cast<ThyProdMultVecBase>(target);
511 if (prodTarget != Teuchos::null) {
512 RCP<const BlockedMultiVector> bSourceVec = rcp_dynamic_cast<
const BlockedMultiVector>(source);
513 if (bSourceVec.is_null() ==
true) {
517 TEUCHOS_TEST_FOR_EXCEPTION(mapExtractor == Teuchos::null, std::logic_error,
"Found a Thyra product vector, but user did not provide an Xpetra::MapExtractor.");
518 TEUCHOS_TEST_FOR_EXCEPTION(prodTarget->productSpace()->numBlocks() != as<int>(mapExtractor->NumMaps()), std::logic_error,
"Inconsistent numbers of sub maps in Thyra::ProductVectorSpace and Xpetra::MapExtractor.");
520 for (
int bbb = 0; bbb < prodTarget->productSpace()->numBlocks(); ++bbb) {
522 RCP<MultiVector> xpSubBlock = mapExtractor->ExtractVector(source, bbb,
false);
525 Teuchos::RCP<ThyMultVecBase> thySubBlock = prodTarget->getNonconstMultiVectorBlock(bbb);
526 RCP<const ThyVecSpaceBase> vs = thySubBlock->range();
527 RCP<const ThySpmdVecSpaceBase> mpi_vs = rcp_dynamic_cast<
const ThySpmdVecSpaceBase>(vs);
528 const LocalOrdinal localOffset = (mpi_vs != Teuchos::null ? mpi_vs->localOffset() : 0);
529 const LocalOrdinal localSubDim = (mpi_vs != Teuchos::null ? mpi_vs->localSubDim() : vs->dim());
530 RCP<Thyra::DetachedMultiVectorView<Scalar>> thyData =
531 Teuchos::rcp(
new Thyra::DetachedMultiVectorView<Scalar>(*thySubBlock, Teuchos::Range1D(localOffset, localOffset + localSubDim - 1)));
534 for (
size_t j = 0; j < xpSubBlock->getNumVectors(); ++j) {
535 Teuchos::ArrayRCP<const Scalar> xpData = xpSubBlock->getData(j);
538 for (LocalOrdinal i = 0; i < localSubDim; ++i) {
539 (*thyData)(i, j) = xpData[i];
546 TEUCHOS_TEST_FOR_EXCEPTION(prodTarget->productSpace()->numBlocks() != as<int>(bSourceVec->getBlockedMap()->getNumMaps()), std::logic_error,
"Inconsistent numbers of sub maps in Thyra::ProductVectorSpace and Xpetra::BlockedMultiVector.");
548 for (
int bbb = 0; bbb < prodTarget->productSpace()->numBlocks(); ++bbb) {
550 RCP<MultiVector> xpSubBlock = bSourceVec->getMultiVector(bbb,
true);
552 Teuchos::RCP<const ThyMultVecBase> thyXpSubBlock = toThyraMultiVector(xpSubBlock);
555 Teuchos::RCP<ThyMultVecBase> thySubBlock = prodTarget->getNonconstMultiVectorBlock(bbb);
556 Thyra::assign(thySubBlock.ptr(), *thyXpSubBlock);
564 RCP<const ThySpmdVecSpaceBase> mpi_vs = rcp_dynamic_cast<
const ThySpmdVecSpaceBase>(target->range());
565 TEUCHOS_TEST_FOR_EXCEPTION(mpi_vs == Teuchos::null, std::logic_error,
"Failed to cast Thyra::VectorSpaceBase to Thyra::SpmdVectorSpaceBase.");
566 const LocalOrdinal localOffset = (mpi_vs != Teuchos::null ? mpi_vs->localOffset() : 0);
567 const LocalOrdinal localSubDim = (mpi_vs != Teuchos::null ? mpi_vs->localSubDim() : target->range()->dim());
568 RCP<Thyra::DetachedMultiVectorView<Scalar>> thyData =
569 Teuchos::rcp(
new Thyra::DetachedMultiVectorView<Scalar>(*target, Teuchos::Range1D(localOffset, localOffset + localSubDim - 1)));
572 for (
size_t j = 0; j < source->getNumVectors(); ++j) {
573 Teuchos::ArrayRCP<const Scalar> xpData = source->getData(j);
575 for (LocalOrdinal i = 0; i < localSubDim; ++i) {
576 (*thyData)(i, j) = xpData[i];
582 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
583 Teuchos::RCP<const Thyra::LinearOpBase<Scalar>>
584 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
587 Teuchos::RCP<const Thyra::LinearOpBase<Scalar>> thyraOp = Teuchos::null;
591 #ifdef HAVE_XPETRA_TPETRA
593 if (tpetraMat != Teuchos::null) {
596 Teuchos::RCP<const Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpCrsMat = xTpCrsMat->
getTpetra_CrsMatrix();
597 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(tpCrsMat));
599 Teuchos::RCP<const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpRowMat = Teuchos::rcp_dynamic_cast<
const Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(tpCrsMat,
true);
600 Teuchos::RCP<const Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpOperator = Teuchos::rcp_dynamic_cast<
const Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(tpRowMat,
true);
602 thyraOp = Thyra::createConstLinearOp(tpOperator);
603 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(thyraOp));
605 #ifdef HAVE_XPETRA_EPETRA
606 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Xpetra::Exceptions::RuntimeError,
"Cast to Tpetra::CrsMatrix failed. Assume matrix should be Epetra then. Epetra needs SC=double, LO=int, and GO=int or GO=long long");
608 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Xpetra::Exceptions::RuntimeError,
"Cast to Tpetra::CrsMatrix failed. Assume matrix should be Epetra then. No Epetra available");
614 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
618 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
619 Teuchos::RCP<Thyra::LinearOpBase<Scalar>>
620 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
623 Teuchos::RCP<Thyra::LinearOpBase<Scalar>> thyraOp = Teuchos::null;
627 #ifdef HAVE_XPETRA_TPETRA
629 if (tpetraMat != Teuchos::null) {
633 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(tpCrsMat));
635 Teuchos::RCP<Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpRowMat = Teuchos::rcp_dynamic_cast<Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(tpCrsMat,
true);
636 Teuchos::RCP<Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>> tpOperator = Teuchos::rcp_dynamic_cast<Tpetra::Operator<Scalar, LocalOrdinal, GlobalOrdinal, Node>>(tpRowMat,
true);
638 thyraOp = Thyra::createLinearOp(tpOperator);
639 TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(thyraOp));
642 #ifdef HAVE_XPETRA_EPETRA
643 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Xpetra::Exceptions::RuntimeError,
"Cast to TpetraCrsMatrix failed. Assuming matrix supposed to be Epetra. Epetra needs SC=double, LO=int, and GO=int or GO=long long");
645 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Xpetra::Exceptions::RuntimeError,
"Cast to TpetraCrsMatrix failed. Guess, matrix should be Epetra then, but no Epetra available.");
651 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
655 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
656 Teuchos::RCP<Thyra::LinearOpBase<Scalar>>
657 Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
659 int nRows = mat->Rows();
660 int nCols = mat->Cols();
662 Teuchos::RCP<Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> Ablock = mat->getInnermostCrsMatrix();
664 TEUCHOS_TEST_FOR_EXCEPT(Ablock_wrap.is_null() ==
true);
666 #ifdef HAVE_XPETRA_TPETRA
668 if (tpetraMat != Teuchos::null) {
670 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<Scalar>> blockMat =
671 Thyra::defaultBlockedLinearOp<Scalar>();
673 blockMat->beginBlockFill(nRows, nCols);
675 for (
int r = 0; r < nRows; ++r) {
676 for (
int c = 0; c < nCols; ++c) {
677 Teuchos::RCP<Matrix> xpmat = mat->getMatrix(r, c);
679 if (xpmat == Teuchos::null)
continue;
681 Teuchos::RCP<Thyra::LinearOpBase<Scalar>> thBlock = Teuchos::null;
684 Teuchos::RCP<Xpetra::BlockedCrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>> xpblock =
686 if (xpblock != Teuchos::null) {
687 if (xpblock->Rows() == 1 && xpblock->Cols() == 1) {
689 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpblock->getCrsMatrix());
690 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
691 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
694 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpblock);
698 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpmat);
699 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
700 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
703 blockMat->setBlock(r, c, thBlock);
707 blockMat->endBlockFill();
712 #ifdef HAVE_XPETRA_EPETRA
713 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Xpetra::Exceptions::RuntimeError,
"Cast to TpetraCrsMatrix failed. Assuming matrix supposed to be Epetra. Epetra needs SC=double, LO=int, and GO=int or GO=long long");
715 TEUCHOS_TEST_FOR_EXCEPTION(
true,
Xpetra::Exceptions::RuntimeError,
"Cast to TpetraCrsMatrix failed. Guess, matrix should be Epetra then, but no Epetra available.");
717 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
719 #endif // endif HAVE_XPETRA_TPETRA
723 #if defined(HAVE_XPETRA_EPETRA) && !defined(HAVE_XPETRA_TPETRA)
725 TEUCHOS_UNREACHABLE_RETURN(Teuchos::null);
726 #endif // endif HAVE_XPETRA_EPETRA
729 #ifdef HAVE_XPETRA_EPETRA
731 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
734 Teuchos::RCP<Thyra::LinearOpBase<double>>
736 int nRows = mat->Rows();
737 int nCols = mat->Cols();
739 Teuchos::RCP<Xpetra::Matrix<double, int, int, EpetraNode>> Ablock = mat->getInnermostCrsMatrix();
741 TEUCHOS_TEST_FOR_EXCEPT(Ablock_wrap.is_null() ==
true);
743 bool bTpetra =
false;
744 bool bEpetra =
false;
745 #ifdef HAVE_XPETRA_TPETRA
747 #if ((defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_INT) && defined(HAVE_TPETRA_INST_DOUBLE)) || \
748 (!defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_INT) && defined(HAVE_TPETRA_INST_DOUBLE)))
750 if (tpetraMat != Teuchos::null) bTpetra =
true;
756 #ifdef HAVE_XPETRA_EPETRA
758 if (epetraMat != Teuchos::null) bEpetra =
true;
761 TEUCHOS_TEST_FOR_EXCEPT(bTpetra == bEpetra);
764 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<Scalar>> blockMat =
765 Thyra::defaultBlockedLinearOp<Scalar>();
767 blockMat->beginBlockFill(nRows, nCols);
769 for (
int r = 0; r < nRows; ++r) {
770 for (
int c = 0; c < nCols; ++c) {
771 Teuchos::RCP<Matrix> xpmat = mat->getMatrix(r, c);
773 if (xpmat == Teuchos::null)
continue;
775 Teuchos::RCP<Thyra::LinearOpBase<Scalar>> thBlock = Teuchos::null;
778 Teuchos::RCP<BlockedCrsMatrix> xpblock = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(xpmat);
779 if (xpblock != Teuchos::null) {
780 if (xpblock->Rows() == 1 && xpblock->Cols() == 1) {
782 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpblock->getCrsMatrix());
783 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
784 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
787 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpblock);
791 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpmat);
792 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
793 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
796 blockMat->setBlock(r, c, thBlock);
800 blockMat->endBlockFill();
804 #endif // #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
806 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
809 Teuchos::RCP<Thyra::LinearOpBase<double>>
811 int nRows = mat->Rows();
812 int nCols = mat->Cols();
814 Teuchos::RCP<Xpetra::Matrix<double, int, long long, EpetraNode>> Ablock = mat->getInnermostCrsMatrix();
816 TEUCHOS_TEST_FOR_EXCEPT(Ablock_wrap.is_null() ==
true);
818 bool bTpetra =
false;
819 bool bEpetra =
false;
820 #ifdef HAVE_XPETRA_TPETRA
822 #if ((defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_OPENMP) && defined(HAVE_TPETRA_INST_INT_LONG_LONG) && defined(HAVE_TPETRA_INST_DOUBLE)) || \
823 (!defined(EPETRA_HAVE_OMP) && defined(HAVE_TPETRA_INST_SERIAL) && defined(HAVE_TPETRA_INST_INT_LONG_LONG) && defined(HAVE_TPETRA_INST_DOUBLE)))
825 if (tpetraMat != Teuchos::null) bTpetra =
true;
831 #ifdef HAVE_XPETRA_EPETRA
833 if (epetraMat != Teuchos::null) bEpetra =
true;
836 TEUCHOS_TEST_FOR_EXCEPT(bTpetra == bEpetra);
839 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<Scalar>> blockMat =
840 Thyra::defaultBlockedLinearOp<Scalar>();
842 blockMat->beginBlockFill(nRows, nCols);
844 for (
int r = 0; r < nRows; ++r) {
845 for (
int c = 0; c < nCols; ++c) {
846 Teuchos::RCP<Matrix> xpmat = mat->getMatrix(r, c);
848 if (xpmat == Teuchos::null)
continue;
850 Teuchos::RCP<Thyra::LinearOpBase<Scalar>> thBlock = Teuchos::null;
853 Teuchos::RCP<BlockedCrsMatrix> xpblock = Teuchos::rcp_dynamic_cast<BlockedCrsMatrix>(xpmat);
854 if (xpblock != Teuchos::null) {
855 if (xpblock->Rows() == 1 && xpblock->Cols() == 1) {
857 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpblock->getCrsMatrix());
858 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
859 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
862 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpblock);
866 Teuchos::RCP<CrsMatrixWrap> xpwrap = Teuchos::rcp_dynamic_cast<CrsMatrixWrap>(xpmat);
867 TEUCHOS_TEST_FOR_EXCEPT(xpwrap.is_null() ==
true);
868 thBlock = Xpetra::ThyraUtils<Scalar, LocalOrdinal, GlobalOrdinal, Node>::toThyra(xpwrap->getCrsMatrix());
871 blockMat->setBlock(r, c, thBlock);
875 blockMat->endBlockFill();
879 #endif // #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
static Teuchos::RCP< MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Build(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &map, size_t NumVectors, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
Exception throws to report errors in the internal logical of the program.
static Teuchos::RCP< Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > transformThyra2XpetraGIDs(const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &input, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlInput, const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > &nonOvlReferenceInput)
replace set of global ids by new global ids
static RCP< Matrix > Build(const RCP< const Map > &rowMap)
RCP< const Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_CrsMatrix() const
Get the underlying Tpetra matrix.
RCP< Tpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_CrsMatrixNonConst() const
Get the underlying Tpetra matrix.
Concrete implementation of Xpetra::Matrix.
static RCP< Xpetra::StridedMap< LocalOrdinal, GlobalOrdinal, Node > > Build(UnderlyingLib lib, global_size_t numGlobalElements, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int >> &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, LocalGlobal lg=Xpetra::GloballyDistributed)
Map constructor with Xpetra-defined contiguous uniform distribution.
Xpetra-specific matrix class.
const RCP< Map< LocalOrdinal, GlobalOrdinal, Node > > toXpetraNonConst(const RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)