46 #ifndef XPETRA_REORDEREDBLOCKEDMULTIVECTOR_HPP
47 #define XPETRA_REORDEREDBLOCKEDMULTIVECTOR_HPP
57 #include "Xpetra_BlockedMap.hpp"
58 #include "Xpetra_BlockedMultiVector.hpp"
69 template <
class Scalar,
82 #undef XPETRA_REORDEREDBLOCKEDMULTIVECTOR_SHORT
99 (Teuchos::RCP<const BlockedMap>& rangeMap,
100 Teuchos::RCP<const Xpetra::BlockReorderManager> brm,
111 brm_ = Teuchos::null;
118 Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
mergeSubBlockMaps(Teuchos::RCP<const Xpetra::BlockReorderManager> brm) {
119 RCP<const BlockedMap> bmap =
fullVec_->getBlockedMap();
122 size_t numBlocks = brm->GetNumBlocks();
124 Teuchos::RCP<const Map> map = Teuchos::null;
131 map = bmap->getMap(Teuchos::as<size_t>(leaf->GetIndex()),
false);
134 std::vector<Teuchos::RCP<const Map> > subMaps (numBlocks, Teuchos::null);
136 for(
size_t i = 0; i < numBlocks; i++) {
137 Teuchos::RCP<const Xpetra::BlockReorderManager> blkMgr = brm->GetBlock(Teuchos::as<int>(i));
139 TEUCHOS_ASSERT(subMaps[i].is_null()==
false);
144 TEUCHOS_ASSERT(map.is_null()==
false);
153 std::string
description()
const {
return "ReorderedBlockedMultiVector"; }
156 void describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const {
157 TEUCHOS_ASSERT(
brm_ != Teuchos::null);
165 Teuchos::RCP<const Xpetra::BlockReorderManager >
brm_;
166 Teuchos::RCP<const Xpetra::BlockedMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
fullVec_;
171 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
176 RCP<const Xpetra::BlockedMap<LocalOrdinal,GlobalOrdinal,Node> > bmap = bvec->getBlockedMap();
179 size_t numBlocks = brm->GetNumBlocks();
181 Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node>> map = Teuchos::null;
187 map = bmap->getMap(Teuchos::as<size_t>(leaf->GetIndex()), bThyraMode);
190 std::vector<Teuchos::RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > > subMaps (numBlocks, Teuchos::null);
192 for(
size_t i = 0; i < numBlocks; i++) {
193 Teuchos::RCP<const Xpetra::BlockReorderManager> blkMgr = brm->GetBlock(Teuchos::as<int>(i));
195 TEUCHOS_ASSERT(subMaps[i].is_null()==
false);
212 TEUCHOS_ASSERT(map.is_null()==
false);
216 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
227 size_t rowSz = rowMgr->GetNumBlocks();
229 Teuchos::RCP<BlockedMultiVector> rbvec = Teuchos::null;
234 Teuchos::RCP<const Xpetra::BlockReorderLeaf> rowleaf = Teuchos::rcp_dynamic_cast<
const Xpetra::BlockReorderLeaf>(rowMgr);
237 Teuchos::RCP<MultiVector> vec = bvec->getMultiVector(rowleaf->GetIndex(),
false);
239 TEUCHOS_ASSERT(vec != Teuchos::null);
242 Teuchos::RCP<BlockedMultiVector> subBVec = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(vec);
243 if(subBVec == Teuchos::null) {
257 RCP<const BlockedMap> fullBlockedMap = bvec->getBlockedMap();
258 Teuchos::RCP<const Map> submap = fullBlockedMap->getMap(rowleaf->GetIndex(),
false);
259 std::vector<Teuchos::RCP<const Map> > rowSubMaps (1, submap);
260 Teuchos::RCP<const BlockedMap> bbmap = Teuchos::rcp(
new BlockedMap(submap, rowSubMaps,
false));
262 rbvec = Teuchos::rcp(
new ReorderedBlockedMultiVector(bbmap, rowMgr, bvec));
263 rbvec->setMultiVector(0,Teuchos::rcp_const_cast<MultiVector>(vec),
false);
268 TEUCHOS_ASSERT(rbvec != Teuchos::null);
273 Teuchos::RCP<const BlockedMap> rgBlockedMap = Teuchos::null;
274 std::vector<Teuchos::RCP<const Map> > rowSubMaps (rowSz, Teuchos::null);
275 for(
size_t i = 0; i < rowSz; i++) {
276 Teuchos::RCP<const Xpetra::BlockReorderManager> rowSubMgr = rowMgr->GetBlock(Teuchos::as<int>(i));
278 TEUCHOS_ASSERT(rowSubMaps[i].is_null()==
false);
281 rgBlockedMap = Teuchos::rcp(
new BlockedMap(rgMergedSubMaps, rowSubMaps,
false));
282 rbvec = Teuchos::rcp(
new ReorderedBlockedMultiVector(rgBlockedMap, rowMgr,bvec));
284 for(
size_t i = 0; i < rowSz; i++) {
285 Teuchos::RCP<const Xpetra::BlockReorderManager> rowSubMgr = rowMgr->GetBlock(Teuchos::as<int>(i));
286 Teuchos::RCP<const MultiVector> subvec =
mergeSubBlocks(rowSubMgr, bvec);
287 rbvec->setMultiVector(i,Teuchos::rcp_const_cast<MultiVector>(subvec),
false);
294 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
302 TEUCHOS_ASSERT(bvec->getBlockedMap()->getThyraMode() ==
true);
305 size_t rowSz = rowMgr->GetNumBlocks();
307 Teuchos::RCP<BlockedMultiVector> rbvec = Teuchos::null;
311 Teuchos::RCP<const Xpetra::BlockReorderLeaf> rowleaf = Teuchos::rcp_dynamic_cast<
const Xpetra::BlockReorderLeaf>(rowMgr);
314 Teuchos::RCP<MultiVector> vec = bvec->getMultiVector(rowleaf->GetIndex(),
true);
316 TEUCHOS_ASSERT(vec.is_null() ==
false);
319 Teuchos::RCP<BlockedMultiVector> bbvec = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(vec);
320 if(bbvec == Teuchos::null) {
323 RCP<const BlockedMap> fullBlockedRangeMap = bvec->getBlockedMap();
325 Teuchos::RCP<const Map> xpsubmap = fullBlockedRangeMap->getMap(rowleaf->GetIndex(),
false);
326 Teuchos::RCP<const Map> thysubmap = fullBlockedRangeMap->getMap(rowleaf->GetIndex(),
true);
327 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (1, xpsubmap);
328 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (1, thysubmap);
330 Teuchos::RCP<const BlockedMap> rgBlockedMap = Teuchos::rcp(
new BlockedMap(rowXpSubMaps, rowTySubMaps));
334 rbvec = Teuchos::rcp(
new ReorderedBlockedMultiVector(rgBlockedMap, rowMgr, bvec));
335 rbvec->setMultiVector(0,vec,
true);
338 rbvec = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(vec);
344 std::vector<Teuchos::RCP<const Map> > rowXpSubMaps (rowSz, Teuchos::null);
345 std::vector<Teuchos::RCP<const Map> > rowTySubMaps (rowSz, Teuchos::null);
346 for(
size_t i = 0; i < rowSz; i++) {
347 Teuchos::RCP<const Xpetra::BlockReorderManager> rowSubMgr = rowMgr->GetBlock(Teuchos::as<int>(i));
351 TEUCHOS_ASSERT(rowXpSubMaps[i].is_null()==
false);
352 TEUCHOS_ASSERT(rowTySubMaps[i].is_null()==
false);
355 Teuchos::RCP<const BlockedMap> rgBlockedMap = Teuchos::rcp(
new BlockedMap(rowXpSubMaps, rowTySubMaps));
357 rbvec = Teuchos::rcp(
new ReorderedBlockedMultiVector(rgBlockedMap, rowMgr,bvec));
359 for(
size_t i = 0; i < rowSz; i++) {
360 Teuchos::RCP<const Xpetra::BlockReorderManager> rowSubMgr = rowMgr->GetBlock(Teuchos::as<int>(i));
362 rbvec->setMultiVector(i,Teuchos::rcp_const_cast<MultiVector>(subvec),
true);
369 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
372 Teuchos::RCP<const Xpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > rbvec = Teuchos::null;
373 if(bvec->getBlockedMap()->getThyraMode() ==
false) {
378 TEUCHOS_ASSERT(rbvec.is_null() ==
false);
382 template<
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
387 Teuchos::RCP<const MultiVector> rbvec = Teuchos::null;
388 if(bvec->getBlockedMap()->getThyraMode() ==
false) {
389 rbvec =
mergeSubBlocks(brm,Teuchos::rcp_const_cast<const BlockedMultiVector>(bvec));
393 TEUCHOS_ASSERT(rbvec.is_null() ==
false);
394 return Teuchos::rcp_const_cast<MultiVector>(rbvec);
400 #define XPETRA_REORDEREDBLOCKEDMULTIVECTOR_SHORT
virtual ~ReorderedBlockedMultiVector()
Destructor.
Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlockMaps(Teuchos::RCP< const Xpetra::BlockReorderManager > brm, Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bmat, bool bThyraMode)
Xpetra utility class for common map-related routines.
static Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > concatenateMaps(const std::vector< Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > > &subMaps)
Helper function to concatenate several maps.
Teuchos::RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlocksThyra(Teuchos::RCP< const Xpetra::BlockReorderManager > rowMgr, Teuchos::RCP< const Xpetra::BlockReorderManager > colMgr, Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bmat)
Teuchos::RCP< const Xpetra::BlockedMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > fullVec_
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Teuchos::RCP< const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlocks(Teuchos::RCP< const Xpetra::BlockReorderManager > rowMgr, Teuchos::RCP< const Xpetra::BlockReorderManager > colMgr, Teuchos::RCP< const Xpetra::BlockedCrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bmat)
Teuchos::RCP< const Xpetra::Map< LocalOrdinal, GlobalOrdinal, Node > > mergeSubBlockMaps(Teuchos::RCP< const Xpetra::BlockReorderManager > brm)
ReorderedBlockedMultiVector(Teuchos::RCP< const BlockedMap > &rangeMap, Teuchos::RCP< const Xpetra::BlockReorderManager > brm, Teuchos::RCP< const Xpetra::BlockedMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bvec)
Constructor.
GlobalOrdinal global_ordinal_type
LocalOrdinal local_ordinal_type
Teuchos::RCP< const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > buildReorderedBlockedMultiVector(Teuchos::RCP< const Xpetra::BlockReorderManager > brm, Teuchos::RCP< const Xpetra::BlockedMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > bvec)
std::string description() const
Return a simple one-line description of this object.
Teuchos::RCP< const Xpetra::BlockReorderManager > brm_