46 #ifndef XPETRA_MAPEXTRACTOR_HPP_
47 #define XPETRA_MAPEXTRACTOR_HPP_
54 #include <Teuchos_Describable.hpp>
69 #ifndef DOXYGEN_SHOULD_SKIP_THIS
71 template<
class S,
class LO,
class GO,
class N>
class BlockedMultiVector;
74 template <
class Scalar,
86 #undef XPETRA_MAPEXTRACTOR_SHORT
129 map_ = Teuchos::null;
135 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
137 "ExtractVector: map_->getMap(" << block <<
",false) is null");
142 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
144 "ExtractVector: map_->getMap(" << block <<
",false) is null");
154 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
156 "ExtractVector: map_->getMap(" << block <<
",false) is null");
160 if(bThyraMode ==
false)
return vv;
162 "MapExtractor::ExtractVector: ExtractVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
163 vv->replaceMap(
getMap(block,
true));
167 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
169 "ExtractVector: map_->getmap(" << block <<
",false) is null");
173 if(bThyraMode ==
false)
return vv;
175 "MapExtractor::ExtractVector: ExtractVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
176 vv->replaceMap(
getMap(block,
true));
180 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
182 "ExtractVector: map_->getmap(" << block <<
",false) is null");
184 if(bfull.is_null() ==
true) {
194 rcpNonConstFull->replaceMap(
map_->getImporter(block)->getSourceMap());
197 "MapExtractor::ExtractVector: ExtractVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
198 if(bThyraMode ==
true)
199 vv->replaceMap(
getMap(block,
true));
200 rcpNonConstFull->replaceMap(oldThyMapFull);
206 "ExtractVector: Number of blocks in map extractor is " <<
map_->getNumMaps() <<
" but should be " << bfull->getBlockedMap()->getNumMaps() <<
" (number of blocks in BlockedMultiVector)");
207 return bfull->getMultiVector(block,bThyraMode);
211 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
213 "ExtractVector: map_->getmap(" << block <<
",false) is null");
215 if(bfull.is_null() ==
true) {
224 full->replaceMap(
map_->getImporter(block)->getSourceMap());
227 "MapExtractor::ExtractVector: ExtractVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
228 if(bThyraMode ==
true)
229 vv->replaceMap(
getMap(block,
true));
230 full->replaceMap(oldThyMapFull);
236 "ExtractVector: Number of blocks in map extractor is " <<
map_->getNumMaps() <<
" but should be " << bfull->getBlockedMap()->getNumMaps() <<
" (number of blocks in BlockedMultiVector)");
237 return bfull->getMultiVector(block,bThyraMode);
241 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
243 "ExtractVector: map_->getmap(" << block <<
",false) is null");
245 "ExtractVector: Number of blocks in map extractor is " <<
map_->getNumMaps() <<
" but should be " << full->getBlockedMap()->getNumMaps() <<
" (number of blocks in BlockedMultiVector)");
250 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
252 "ExtractVector: map_->getmap(" << block <<
",false) is null");
254 "ExtractVector: Number of blocks in map extractor is " <<
map_->getNumMaps() <<
" but should be " << full->getBlockedMap()->getNumMaps() <<
" (number of blocks in BlockedMultiVector)");
263 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
265 "ExtractVector: map_->getmap(" << block <<
",false) is null");
267 "MapExtractor::InsertVector: InsertVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
283 "MapExtractor::InsertVector: InsertVector in Thyra-style mode: Xpetra GIDs of partial vector are not identical to target Map of Importer. This should not be.");
288 rcpNonConstPartial->replaceMap(
getMap(block,
false));
296 rcpNonConstPartial->replaceMap(oldThyMapPartial);
303 XPETRA_TEST_FOR_EXCEPTION(block >=
map_->getNumMaps(), std::out_of_range,
"ExtractVector: Error, block = " << block <<
" is too big. The MapExtractor only contains " <<
map_->getNumMaps() <<
" partial blocks.");
305 "ExtractVector: map_->getmap(" << block <<
",false) is null");
307 "MapExtractor::InsertVector: InsertVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
323 "MapExtractor::InsertVector: InsertVector in Thyra-style mode: Xpetra GIDs of partial vector are not identical to target Map of Importer. This should not be.");
328 rcpNonConstPartial->replaceMap(
getMap(block,
false));
336 rcpNonConstPartial->replaceMap(oldThyMapPartial);
351 "InsertVector: map_->getmap(" << block <<
",false) is null");
352 full->setMultiVector(block, partial, bThyraMode);
361 "InsertVector: map_->getmap(" << block <<
",false) is null");
362 bfull->setMultiVector(block, partial, bThyraMode);
367 "InsertVector: map_->getmap(" << block <<
",false) is null");
368 full->setMultiVector(block, partial, bThyraMode);
372 "InsertVector: map_->getmap(" << block <<
",false) is null");
373 full->setMultiVector(block, partial, bThyraMode);
380 "MapExtractor::getVector: getVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
386 "MapExtractor::getVector: getVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
405 return map_->getMap(i,bThyraMode);
419 return map_->getMapIndexForGID(gid);
429 #define XPETRA_MAPEXTRACTOR_SHORT
virtual void doExport(const DistObject< Packet, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)=0
Export data into this object using an Export object ("forward mode").
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Exception throws to report errors in the internal logical of the program.
virtual void replaceMap(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)=0
virtual void doImport(const DistObject< Packet, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)=0
Import data into this object using an Import object ("forward mode").
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
The Map describing the parallel distribution of this object.
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
#define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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.