All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Xpetra_MapExtractor.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_MAPEXTRACTOR_HPP_
47 #define XPETRA_MAPEXTRACTOR_HPP_
48 
49 #include <map>
50 
51 #include <iostream>
52 
53 #include <Teuchos_RCP.hpp>
54 #include <Teuchos_Describable.hpp>
55 #include <Xpetra_Import.hpp>
56 #include <Xpetra_Map.hpp>
57 
58 #include <Xpetra_Import.hpp>
59 #include <Xpetra_ImportFactory.hpp>
60 #include <Xpetra_MapFactory.hpp>
61 #include <Xpetra_MapUtils.hpp>
62 #include <Xpetra_MultiVector.hpp>
64 #include <Xpetra_Vector.hpp>
65 #include <Xpetra_VectorFactory.hpp>
66 
67 namespace Xpetra {
68 
69 #ifndef DOXYGEN_SHOULD_SKIP_THIS
70  // forward declaration of BlockedMultiVector, needed to prevent circular inclusions
71  template<class S, class LO, class GO, class N> class BlockedMultiVector;
72 #endif
73 
74  template <class Scalar,
75  class LocalOrdinal,
76  class GlobalOrdinal,
77  class Node>
79  public:
80  typedef Scalar scalar_type;
81  typedef LocalOrdinal local_ordinal_type;
82  typedef GlobalOrdinal global_ordinal_type;
83  typedef Node node_type;
84 
85  private:
86 #undef XPETRA_MAPEXTRACTOR_SHORT
87 #include "Xpetra_UseShortNames.hpp"
88 
89  public:
90 
103  MapExtractor(const RCP<const Map>& fullmap, const std::vector<RCP<const Map> >& maps, bool bThyraMode = false) {
104  map_ = Teuchos::rcp(new BlockedMap(fullmap, maps, bThyraMode));
105  }
106 
108  MapExtractor(const std::vector<RCP<const Map> >& maps, const std::vector<RCP<const Map> >& thyramaps) {
109  map_ = Teuchos::rcp(new BlockedMap(maps, thyramaps));
110  }
111 
120  map_(map) { }
121 
123  MapExtractor(const MapExtractor& input) {
124  map_ = Teuchos::rcp(new BlockedMap(*(input.getBlockedMap())));
125  }
126 
128  virtual ~MapExtractor() {
129  map_ = Teuchos::null;
130  }
131 
134  void ExtractVector(const Vector& full, size_t block, Vector& partial) const {
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");
138 
139  partial.doImport(full, *(map_->getImporter(block)), Xpetra::INSERT);
140  }
141  void ExtractVector(const MultiVector& full, size_t block, MultiVector& partial) const {
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");
145 
146  partial.doImport(full, *(map_->getImporter(block)), Xpetra::INSERT);
147  }
148  void ExtractVector(RCP<const Vector>& full, size_t block, RCP< Vector>& partial) const { ExtractVector(*full, block, *partial); }
149  void ExtractVector(RCP< Vector>& full, size_t block, RCP< Vector>& partial) const { ExtractVector(*full, block, *partial); }
150  void ExtractVector(RCP<const MultiVector>& full, size_t block, RCP<MultiVector>& partial) const { ExtractVector(*full, block, *partial); }
151  void ExtractVector(RCP< MultiVector>& full, size_t block, RCP<MultiVector>& partial) const { ExtractVector(*full, block, *partial); }
152 
153  RCP< Vector> ExtractVector(RCP<const Vector>& full, size_t block, bool bThyraMode = false) const {
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");
157  // first extract partial vector from full vector (using xpetra style GIDs)
158  const RCP<Vector> vv = VectorFactory::Build(getMap(block,false), false);
159  ExtractVector(*full, block, *vv);
160  if(bThyraMode == false) return vv;
161  TEUCHOS_TEST_FOR_EXCEPTION(map_->getThyraMode() == false && bThyraMode == true, Xpetra::Exceptions::RuntimeError,
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)); // switch to Thyra-style map
164  return vv;
165  }
166  RCP< Vector> ExtractVector(RCP< Vector>& full, size_t block, bool bThyraMode = false) const {
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");
170  // first extract partial vector from full vector (using xpetra style GIDs)
171  const RCP<Vector> vv = VectorFactory::Build(getMap(block,false), false);
172  ExtractVector(*full, block, *vv);
173  if(bThyraMode == false) return vv;
174  TEUCHOS_TEST_FOR_EXCEPTION(map_->getThyraMode() == false && bThyraMode == true, Xpetra::Exceptions::RuntimeError,
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)); // switch to Thyra-style map
177  return vv;
178  }
179  RCP<MultiVector> ExtractVector(RCP<const MultiVector>& full, size_t block, bool bThyraMode = false) const {
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");
183  RCP<const BlockedMultiVector> bfull = Teuchos::rcp_dynamic_cast<const BlockedMultiVector>(full);
184  if(bfull.is_null() == true) {
185  // standard case: full is not of type BlockedMultiVector
186  // first extract partial vector from full vector (using xpetra style GIDs)
187  const RCP<MultiVector> vv = MultiVectorFactory::Build(getMap(block,false), full->getNumVectors(), false);
188  //if(bThyraMode == false) {
189  // ExtractVector(*full, block, *vv);
190  // return vv;
191  //} else {
192  RCP<const Map> oldThyMapFull = full->getMap(); // temporarely store map of full
193  RCP<MultiVector> rcpNonConstFull = Teuchos::rcp_const_cast<MultiVector>(full);
194  rcpNonConstFull->replaceMap(map_->getImporter(block)->getSourceMap());
195  ExtractVector(*rcpNonConstFull, block, *vv);
196  TEUCHOS_TEST_FOR_EXCEPTION(map_->getThyraMode() == false && bThyraMode == true, Xpetra::Exceptions::RuntimeError,
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)); // switch to Thyra-style map
200  rcpNonConstFull->replaceMap(oldThyMapFull);
201  return vv;
202  //}
203  } else {
204  // special case: full is of type BlockedMultiVector
205  XPETRA_TEST_FOR_EXCEPTION(map_->getNumMaps() != bfull->getBlockedMap()->getNumMaps(), Xpetra::Exceptions::RuntimeError,
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);
208  }
209  }
210  RCP<MultiVector> ExtractVector(RCP< MultiVector>& full, size_t block, bool bThyraMode = false) const {
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");
214  RCP<BlockedMultiVector> bfull = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(full);
215  if(bfull.is_null() == true) {
216  // standard case: full is not of type BlockedMultiVector
217  // first extract partial vector from full vector (using xpetra style GIDs)
218  const RCP<MultiVector> vv = MultiVectorFactory::Build(getMap(block,false), full->getNumVectors(), false);
219  //if(bThyraMode == false) {
220  // ExtractVector(*full, block, *vv);
221  // return vv;
222  //} else {
223  RCP<const Map> oldThyMapFull = full->getMap(); // temporarely store map of full
224  full->replaceMap(map_->getImporter(block)->getSourceMap());
225  ExtractVector(*full, block, *vv);
226  TEUCHOS_TEST_FOR_EXCEPTION(map_->getThyraMode() == false && bThyraMode == true, Xpetra::Exceptions::RuntimeError,
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)); // switch to Thyra-style map
230  full->replaceMap(oldThyMapFull);
231  return vv;
232  //}
233  } else {
234  // special case: full is of type BlockedMultiVector
235  XPETRA_TEST_FOR_EXCEPTION(map_->getNumMaps() != bfull->getBlockedMap()->getNumMaps(), Xpetra::Exceptions::RuntimeError,
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);
238  }
239  }
240  RCP<MultiVector> ExtractVector(RCP<const BlockedMultiVector>& full, size_t block, bool bThyraMode = false) const {
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");
244  XPETRA_TEST_FOR_EXCEPTION(map_->getNumMaps() != full->getBlockedMap()->getNumMaps(), Xpetra::Exceptions::RuntimeError,
245  "ExtractVector: Number of blocks in map extractor is " << map_->getNumMaps() << " but should be " << full->getBlockedMap()->getNumMaps() << " (number of blocks in BlockedMultiVector)");
246  Teuchos::RCP<MultiVector> vv = full->getMultiVector(block,bThyraMode);
247  return vv;
248  }
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");
253  XPETRA_TEST_FOR_EXCEPTION(map_->getNumMaps() != full->getBlockedMap()->getNumMaps(), Xpetra::Exceptions::RuntimeError,
254  "ExtractVector: Number of blocks in map extractor is " << map_->getNumMaps() << " but should be " << full->getBlockedMap()->getNumMaps() << " (number of blocks in BlockedMultiVector)");
255  Teuchos::RCP<MultiVector> vv = full->getMultiVector(block,bThyraMode);
256  return vv;
257  }
259 
262  void InsertVector(const Vector& partial, size_t block, Vector& full, bool bThyraMode = false) const {
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");
266  XPETRA_TEST_FOR_EXCEPTION(map_->getThyraMode() == false && bThyraMode == true, Xpetra::Exceptions::RuntimeError,
267  "MapExtractor::InsertVector: InsertVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
268  if(bThyraMode) {
269  // NOTE: the importer objects in the BlockedMap are always using Xpetra GIDs (or Thyra style Xpetra GIDs)
270  // The source map corresponds to the full map (in Xpetra GIDs) starting with GIDs from zero. The GIDs are consecutive in Thyra mode
271  // The target map is the partial map (in the corresponding Xpetra GIDs)
272 
273  // TODO can we skip the Export call in special cases (i.e. Src = Target map, same length, etc...)
274 
275  // store original GIDs (could be Thyra GIDs)
276  RCP<const MultiVector> rcpPartial = Teuchos::rcpFromRef(partial);
277  RCP<MultiVector> rcpNonConstPartial = Teuchos::rcp_const_cast<MultiVector>(rcpPartial);
278  RCP<const Map> oldThyMapPartial = rcpNonConstPartial->getMap(); // temporarely store map of partial
279  RCP<const Map> oldThyMapFull = full.getMap(); // temporarely store map of full
280 
281  // check whether getMap(block,false) is identical to target map of importer
282  XPETRA_TEST_FOR_EXCEPTION(map_->getMap(block,false)->isSameAs(*(map_->getImporter(block)->getTargetMap()))==false, Xpetra::Exceptions::RuntimeError,
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.");
284 
285  //XPETRA_TEST_FOR_EXCEPTION(full.getMap()->isSameAs(*(map_->getImporter(block)->getSourceMap()))==false, Xpetra::Exceptions::RuntimeError,
286  // "MapExtractor::InsertVector: InsertVector in Thyra-style mode: Xpetra GIDs of full vector are not identical to source Map of Importer. This should not be.");
287 
288  rcpNonConstPartial->replaceMap(getMap(block,false)); // temporarely switch to xpetra-style map
289  full.replaceMap(map_->getImporter(block)->getSourceMap()); // temporarely switch to Xpetra GIDs
290 
291  // do the Export
292  full.doExport(*rcpNonConstPartial, *(map_->getImporter(block)), Xpetra::INSERT);
293 
294  // switch back to original maps
295  full.replaceMap(oldThyMapFull); // reset original map (Thyra GIDs)
296  rcpNonConstPartial->replaceMap(oldThyMapPartial); // change map back to original map
297  } else {
298  // Xpetra style numbering
299  full.doExport(partial, *(map_->getImporter(block)), Xpetra::INSERT);
300  }
301  }
302  void InsertVector(const MultiVector& partial, size_t block, MultiVector& full, bool bThyraMode = false) const {
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");
306  XPETRA_TEST_FOR_EXCEPTION(map_->getThyraMode() == false && bThyraMode == true, Xpetra::Exceptions::RuntimeError,
307  "MapExtractor::InsertVector: InsertVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
308  if(bThyraMode) {
309  // NOTE: the importer objects in the BlockedMap are always using Xpetra GIDs (or Thyra style Xpetra GIDs)
310  // The source map corresponds to the full map (in Xpetra GIDs) starting with GIDs from zero. The GIDs are consecutive in Thyra mode
311  // The target map is the partial map (in the corresponding Xpetra GIDs)
312 
313  // TODO can we skip the Export call in special cases (i.e. Src = Target map, same length, etc...)
314 
315  // store original GIDs (could be Thyra GIDs)
316  RCP<const MultiVector> rcpPartial = Teuchos::rcpFromRef(partial);
317  RCP<MultiVector> rcpNonConstPartial = Teuchos::rcp_const_cast<MultiVector>(rcpPartial);
318  RCP<const Map> oldThyMapPartial = rcpNonConstPartial->getMap(); // temporarely store map of partial
319  RCP<const Map> oldThyMapFull = full.getMap(); // temporarely store map of full
320 
321  // check whether getMap(block,false) is identical to target map of importer
322  XPETRA_TEST_FOR_EXCEPTION(map_->getMap(block,false)->isSameAs(*(map_->getImporter(block)->getTargetMap()))==false, Xpetra::Exceptions::RuntimeError,
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.");
324 
325  //XPETRA_TEST_FOR_EXCEPTION(full.getMap()->isSameAs(*(map_->getImporter(block)->getSourceMap()))==false, Xpetra::Exceptions::RuntimeError,
326  // "MapExtractor::InsertVector: InsertVector in Thyra-style mode: Xpetra GIDs of full vector are not identical to source Map of Importer. This should not be.");
327 
328  rcpNonConstPartial->replaceMap(getMap(block,false)); // temporarely switch to xpetra-style map
329  full.replaceMap(map_->getImporter(block)->getSourceMap()); // temporarely switch to Xpetra GIDs
330 
331  // do the Export
332  full.doExport(*rcpNonConstPartial, *(map_->getImporter(block)), Xpetra::INSERT);
333 
334  // switch back to original maps
335  full.replaceMap(oldThyMapFull); // reset original map (Thyra GIDs)
336  rcpNonConstPartial->replaceMap(oldThyMapPartial); // change map back to original map
337  } else {
338  // Xpetra style numbering
339  full.doExport(partial, *(map_->getImporter(block)), Xpetra::INSERT);
340  }
341  }
342 
343  void InsertVector(RCP<const Vector> partial, size_t block, RCP< Vector> full, bool bThyraMode = false) const { InsertVector(*partial, block, *full, bThyraMode); }
344  void InsertVector(RCP< Vector> partial, size_t block, RCP< Vector> full, bool bThyraMode = false) const { InsertVector(*partial, block, *full, bThyraMode); }
345  void InsertVector(RCP<const MultiVector> partial, size_t block, RCP<MultiVector> full, bool bThyraMode = false) const {
346  RCP<BlockedMultiVector> bfull = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(full);
347  if(bfull.is_null() == true)
348  InsertVector(*partial, block, *full, bThyraMode);
349  else {
351  "InsertVector: map_->getmap(" << block << ",false) is null");
352  full->setMultiVector(block, partial, bThyraMode);
353  }
354  }
355  void InsertVector(RCP< MultiVector> partial, size_t block, RCP<MultiVector> full, bool bThyraMode = false) const {
356  RCP<BlockedMultiVector> bfull = Teuchos::rcp_dynamic_cast<BlockedMultiVector>(full);
357  if(bfull.is_null() == true)
358  InsertVector(*partial, block, *full, bThyraMode);
359  else {
361  "InsertVector: map_->getmap(" << block << ",false) is null");
362  bfull->setMultiVector(block, partial, bThyraMode);
363  }
364  }
365  void InsertVector(RCP<const MultiVector> partial, size_t block, RCP<Xpetra::BlockedMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > full, bool bThyraMode = false) const {
367  "InsertVector: map_->getmap(" << block << ",false) is null");
368  full->setMultiVector(block, partial, bThyraMode);
369  }
370  void InsertVector(RCP< MultiVector> partial, size_t block, RCP<Xpetra::BlockedMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > full, bool bThyraMode = false) const {
372  "InsertVector: map_->getmap(" << block << ",false) is null");
373  full->setMultiVector(block, partial, bThyraMode);
374  }
375 
377 
378  RCP< Vector> getVector(size_t i, bool bThyraMode = false, bool bZero = true) const {
379  XPETRA_TEST_FOR_EXCEPTION(map_->getThyraMode() == false && bThyraMode == true, Xpetra::Exceptions::RuntimeError,
380  "MapExtractor::getVector: getVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
381  // TODO check whether this can return a blocked multivector
382  return VectorFactory::Build(getMap(i, bThyraMode), bZero);
383  }
384  RCP<MultiVector> getVector(size_t i, size_t numvec, bool bThyraMode = false, bool bZero = true) const {
385  XPETRA_TEST_FOR_EXCEPTION(map_->getThyraMode() == false && bThyraMode == true, Xpetra::Exceptions::RuntimeError,
386  "MapExtractor::getVector: getVector in Thyra-style numbering only possible if MapExtractor has been created using Thyra-style numbered submaps.");
387  // TODO check whether this can return a blocked multivector
388  return MultiVectorFactory::Build(getMap(i, bThyraMode), numvec, bZero);
389  }
390 
392  bool getThyraMode() const { return map_->getThyraMode(); }
393 
396 
398  size_t NumMaps() const { return map_->getNumMaps(); }
399 
404  const RCP<const Map> getMap(size_t i, bool bThyraMode = false) const {
405  return map_->getMap(i,bThyraMode);
406  }
407 
409  const RCP<const Map> getMap() const { return map_; }
410 
412  const RCP<const BlockedMap> getBlockedMap() const { return map_; }
413 
415  const RCP<const Map> getFullMap() const { return map_->getFullMap(); }
416 
418  size_t getMapIndexForGID(GlobalOrdinal gid) const {
419  return map_->getMapIndexForGID(gid);
420  }
421 
423 
424  private:
426  };
427 }
428 
429 #define XPETRA_MAPEXTRACTOR_SHORT
430 #endif /* XPETRA_MAPEXTRACTOR_HPP_ */
GlobalOrdinal global_ordinal_type
void ExtractVector(RCP< const Vector > &full, size_t block, RCP< Vector > &partial) const
RCP< Vector > ExtractVector(RCP< const Vector > &full, size_t block, bool bThyraMode=false) const
size_t getMapIndexForGID(GlobalOrdinal gid) const
returns map index in map extractor which contains GID
MapExtractor(const MapExtractor &input)
copy constructor
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 (&quot;forward mode&quot;).
void ExtractVector(const MultiVector &full, size_t block, MultiVector &partial) const
void ExtractVector(RCP< const MultiVector > &full, size_t block, RCP< MultiVector > &partial) const
void InsertVector(const MultiVector &partial, size_t block, MultiVector &full, bool bThyraMode=false) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const RCP< const Map > getFullMap() const
the full map
void InsertVector(RCP< const MultiVector > partial, size_t block, RCP< MultiVector > full, bool bThyraMode=false) const
void InsertVector(RCP< const Vector > partial, size_t block, RCP< Vector > full, bool bThyraMode=false) const
Exception throws to report errors in the internal logical of the program.
void InsertVector(RCP< MultiVector > partial, size_t block, RCP< MultiVector > full, bool bThyraMode=false) const
virtual void replaceMap(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)=0
virtual ~MapExtractor()
Destructor.
void InsertVector(RCP< const MultiVector > partial, size_t block, RCP< Xpetra::BlockedMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > full, bool bThyraMode=false) const
bool getThyraMode() const
returns true, if sub maps are stored in Thyra-style numbering
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 (&quot;forward mode&quot;).
RCP< MultiVector > getVector(size_t i, size_t numvec, bool bThyraMode=false, bool bZero=true) const
void InsertVector(RCP< MultiVector > partial, size_t block, RCP< Xpetra::BlockedMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > full, bool bThyraMode=false) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const RCP< const BlockedMap > getBlockedMap() const
get the underlying BlockedMap object (as BlockedMap)
RCP< MultiVector > ExtractVector(RCP< MultiVector > &full, size_t block, bool bThyraMode=false) const
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
The Map describing the parallel distribution of this object.
void InsertVector(const Vector &partial, size_t block, Vector &full, bool bThyraMode=false) const
Teuchos::RCP< const BlockedMap > map_
blocked map containing the sub block maps (either thyra or xpetra mode)
MapExtractor(const RCP< const Map > &fullmap, const std::vector< RCP< const Map > > &maps, bool bThyraMode=false)
RCP< MultiVector > ExtractVector(RCP< const MultiVector > &full, size_t block, bool bThyraMode=false) const
RCP< MultiVector > ExtractVector(RCP< Xpetra::BlockedMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &full, size_t block, bool bThyraMode=false) const
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
Constructor specifying the number of non-zeros for all rows.
const RCP< const Map > getMap(size_t i, bool bThyraMode=false) const
void ExtractVector(const Vector &full, size_t block, Vector &partial) const
void InsertVector(RCP< Vector > partial, size_t block, RCP< Vector > full, bool bThyraMode=false) const
#define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
const RCP< const Map > getMap() const
get the underlying BlockedMap object (as Map)
RCP< Vector > getVector(size_t i, bool bThyraMode=false, bool bZero=true) const
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.
void ExtractVector(RCP< MultiVector > &full, size_t block, RCP< MultiVector > &partial) const
MapExtractor(const std::vector< RCP< const Map > > &maps, const std::vector< RCP< const Map > > &thyramaps)
Expert constructor for Thyra maps.
MapExtractor(const Teuchos::RCP< const BlockedMap > &map)
RCP< Vector > ExtractVector(RCP< Vector > &full, size_t block, bool bThyraMode=false) const
size_t NumMaps() const
number of partial maps
void ExtractVector(RCP< Vector > &full, size_t block, RCP< Vector > &partial) const
RCP< MultiVector > ExtractVector(RCP< const BlockedMultiVector > &full, size_t block, bool bThyraMode=false) const
bool is_null() const