Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_MapExtractor_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef XPETRA_MAPEXTRACTOR_DECL_HPP_
11 #define XPETRA_MAPEXTRACTOR_DECL_HPP_
12 
13 #include <map>
14 
15 #include <iostream>
16 
17 #include <Teuchos_RCP.hpp>
18 #include <Teuchos_Describable.hpp>
19 
20 #include <Xpetra_Import.hpp>
21 #include <Xpetra_ImportFactory.hpp>
22 #include <Xpetra_Map_decl.hpp>
24 #include <Xpetra_MapUtils.hpp>
26 #include <Xpetra_Vector.hpp>
29 
30 namespace Xpetra {
31 
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 // forward declaration of BlockedMultiVector, needed to prevent circular inclusions
34 template <class S, class LO, class GO, class N>
35 class BlockedMultiVector;
36 
37 // forward declaration of BlockedMap, needed because some functions take them as parameters
38 // (This should go away when BlockedMap is converted to ETI)
39 template <class LO, class GO, class N>
40 class BlockedMap;
41 #endif
42 
43 template <class Scalar,
44  class LocalOrdinal,
45  class GlobalOrdinal,
46  class Node>
47 class MapExtractor : public Teuchos::Describable {
48  public:
49  typedef Scalar scalar_type;
50  typedef LocalOrdinal local_ordinal_type;
51  typedef GlobalOrdinal global_ordinal_type;
52  typedef Node node_type;
53 
54  private:
55 #undef XPETRA_MAPEXTRACTOR_SHORT
56 #include "Xpetra_UseShortNames.hpp"
57 
58  public:
71  MapExtractor(const RCP<const Map>& fullmap, const std::vector<RCP<const Map>>& maps, bool bThyraMode = false);
72 
74  MapExtractor(const std::vector<RCP<const Map>>& maps, const std::vector<RCP<const Map>>& thyramaps);
75 
82  MapExtractor(const Teuchos::RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>& blockedMap);
83 
85  MapExtractor(const MapExtractor& input);
86 
88  virtual ~MapExtractor();
89 
92  void ExtractVector(const Vector& full, size_t block, Vector& partial) const;
93  void ExtractVector(const MultiVector& full, size_t block, MultiVector& partial) const;
94  void ExtractVector(RCP<const Vector>& full, size_t block, RCP<Vector>& partial) const;
95  void ExtractVector(RCP<Vector>& full, size_t block, RCP<Vector>& partial) const;
96  void ExtractVector(RCP<const MultiVector>& full, size_t block, RCP<MultiVector>& partial) const;
97  void ExtractVector(RCP<MultiVector>& full, size_t block, RCP<MultiVector>& partial) const;
98 
99  RCP<Vector> ExtractVector(RCP<const Vector>& full, size_t block, bool bThyraMode = false) const;
100  RCP<Vector> ExtractVector(RCP<Vector>& full, size_t block, bool bThyraMode = false) const;
101  RCP<MultiVector> ExtractVector(RCP<const MultiVector>& full, size_t block, bool bThyraMode = false) const;
102  RCP<MultiVector> ExtractVector(RCP<MultiVector>& full, size_t block, bool bThyraMode = false) const;
103 
104  RCP<MultiVector> ExtractVector(RCP<const Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& full, size_t block, bool bThyraMode = false) const;
105  RCP<MultiVector> ExtractVector(RCP<Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& full, size_t block, bool bThyraMode = false) const;
106 
108 
111  void InsertVector(const Vector& partial, size_t block, Vector& full, bool bThyraMode = false) const;
112  void InsertVector(const MultiVector& partial, size_t block, MultiVector& full, bool bThyraMode = false) const;
113  void InsertVector(RCP<const Vector> partial, size_t block, RCP<Vector> full, bool bThyraMode = false) const;
114  void InsertVector(RCP<Vector> partial, size_t block, RCP<Vector> full, bool bThyraMode = false) const;
115  void InsertVector(RCP<const MultiVector> partial, size_t block, RCP<MultiVector> full, bool bThyraMode = false) const;
116  void InsertVector(RCP<MultiVector> partial, size_t block, RCP<MultiVector> full, bool bThyraMode = false) const;
117  void InsertVector(RCP<const MultiVector> partial, size_t block, RCP<Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> full, bool bThyraMode = false) const;
118  void InsertVector(RCP<MultiVector> partial, size_t block, RCP<Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> full, bool bThyraMode = false) const;
119 
121 
122  RCP<Vector> getVector(size_t i, bool bThyraMode = false, bool bZero = true) const;
123  RCP<MultiVector> getVector(size_t i, size_t numvec, bool bThyraMode = false, bool bZero = true) const;
124 
126  bool getThyraMode() const;
127 
130 
132  size_t NumMaps() const;
133 
138  const RCP<const Map> getMap(size_t i, bool bThyraMode = false) const;
139 
141  const RCP<const Map> getMap() const;
142 
144  const RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> getBlockedMap() const;
145 
147  const RCP<const Map> getFullMap() const;
148 
150  size_t getMapIndexForGID(GlobalOrdinal gid) const;
151 
153 
154  private:
156  Teuchos::RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> map_;
157 };
158 
159 } // namespace Xpetra
160 
161 #define XPETRA_MAPEXTRACTOR_SHORT
162 #endif /* XPETRA_MAPEXTRACTOR_HPP_ */
size_t getMapIndexForGID(GlobalOrdinal gid) const
returns map index in map extractor which contains GID
const RCP< const Map > getFullMap() const
the full map
const RCP< const Xpetra::BlockedMap< LocalOrdinal, GlobalOrdinal, Node > > getBlockedMap() const
get the underlying BlockedMap object (as BlockedMap)
virtual ~MapExtractor()
Destructor.
MapExtractor(const RCP< const Map > &fullmap, const std::vector< RCP< const Map >> &maps, bool bThyraMode=false)
bool getThyraMode() const
returns true, if sub maps are stored in Thyra-style numbering
RCP< Vector > getVector(size_t i, bool bThyraMode=false, bool bZero=true) const
Teuchos::RCP< const Xpetra::BlockedMap< LocalOrdinal, GlobalOrdinal, Node > > map_
blocked map containing the sub block maps (either thyra or xpetra mode)
void InsertVector(const Vector &partial, size_t block, Vector &full, bool bThyraMode=false) const
const RCP< const Map > getMap() const
get the underlying BlockedMap object (as Map)
void ExtractVector(const Vector &full, size_t block, Vector &partial) const
size_t NumMaps() const
number of partial maps