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 // ***********************************************************************
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_DECL_HPP_
47 #define XPETRA_MAPEXTRACTOR_DECL_HPP_
48 
49 #include <map>
50 
51 #include <iostream>
52 
53 #include <Teuchos_RCP.hpp>
54 #include <Teuchos_Describable.hpp>
55 
56 #include <Xpetra_Import.hpp>
57 #include <Xpetra_ImportFactory.hpp>
58 #include <Xpetra_Map_decl.hpp>
60 #include <Xpetra_MapUtils.hpp>
62 #include <Xpetra_Vector.hpp>
65 
66 namespace Xpetra {
67 
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69 // forward declaration of BlockedMultiVector, needed to prevent circular inclusions
70 template <class S, class LO, class GO, class N>
71 class BlockedMultiVector;
72 
73 // forward declaration of BlockedMap, needed because some functions take them as parameters
74 // (This should go away when BlockedMap is converted to ETI)
75 template <class LO, class GO, class N>
76 class BlockedMap;
77 #endif
78 
79 template <class Scalar,
80  class LocalOrdinal,
81  class GlobalOrdinal,
82  class Node>
83 class MapExtractor : public Teuchos::Describable {
84  public:
85  typedef Scalar scalar_type;
86  typedef LocalOrdinal local_ordinal_type;
87  typedef GlobalOrdinal global_ordinal_type;
88  typedef Node node_type;
89 
90  private:
91 #undef XPETRA_MAPEXTRACTOR_SHORT
92 #include "Xpetra_UseShortNames.hpp"
93 
94  public:
107  MapExtractor(const RCP<const Map>& fullmap, const std::vector<RCP<const Map>>& maps, bool bThyraMode = false);
108 
110  MapExtractor(const std::vector<RCP<const Map>>& maps, const std::vector<RCP<const Map>>& thyramaps);
111 
118  MapExtractor(const Teuchos::RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>>& blockedMap);
119 
121  MapExtractor(const MapExtractor& input);
122 
124  virtual ~MapExtractor();
125 
128  void ExtractVector(const Vector& full, size_t block, Vector& partial) const;
129  void ExtractVector(const MultiVector& full, size_t block, MultiVector& partial) const;
130  void ExtractVector(RCP<const Vector>& full, size_t block, RCP<Vector>& partial) const;
131  void ExtractVector(RCP<Vector>& full, size_t block, RCP<Vector>& partial) const;
132  void ExtractVector(RCP<const MultiVector>& full, size_t block, RCP<MultiVector>& partial) const;
133  void ExtractVector(RCP<MultiVector>& full, size_t block, RCP<MultiVector>& partial) const;
134 
135  RCP<Vector> ExtractVector(RCP<const Vector>& full, size_t block, bool bThyraMode = false) const;
136  RCP<Vector> ExtractVector(RCP<Vector>& full, size_t block, bool bThyraMode = false) const;
137  RCP<MultiVector> ExtractVector(RCP<const MultiVector>& full, size_t block, bool bThyraMode = false) const;
138  RCP<MultiVector> ExtractVector(RCP<MultiVector>& full, size_t block, bool bThyraMode = false) const;
139 
140  RCP<MultiVector> ExtractVector(RCP<const Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& full, size_t block, bool bThyraMode = false) const;
141  RCP<MultiVector> ExtractVector(RCP<Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& full, size_t block, bool bThyraMode = false) const;
142 
144 
147  void InsertVector(const Vector& partial, size_t block, Vector& full, bool bThyraMode = false) const;
148  void InsertVector(const MultiVector& partial, size_t block, MultiVector& full, bool bThyraMode = false) const;
149  void InsertVector(RCP<const Vector> partial, size_t block, RCP<Vector> full, bool bThyraMode = false) const;
150  void InsertVector(RCP<Vector> partial, size_t block, RCP<Vector> full, bool bThyraMode = false) const;
151  void InsertVector(RCP<const MultiVector> partial, size_t block, RCP<MultiVector> full, bool bThyraMode = false) const;
152  void InsertVector(RCP<MultiVector> partial, size_t block, RCP<MultiVector> full, bool bThyraMode = false) const;
153  void InsertVector(RCP<const MultiVector> partial, size_t block, RCP<Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> full, bool bThyraMode = false) const;
154  void InsertVector(RCP<MultiVector> partial, size_t block, RCP<Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> full, bool bThyraMode = false) const;
155 
157 
158  RCP<Vector> getVector(size_t i, bool bThyraMode = false, bool bZero = true) const;
159  RCP<MultiVector> getVector(size_t i, size_t numvec, bool bThyraMode = false, bool bZero = true) const;
160 
162  bool getThyraMode() const;
163 
166 
168  size_t NumMaps() const;
169 
174  const RCP<const Map> getMap(size_t i, bool bThyraMode = false) const;
175 
177  const RCP<const Map> getMap() const;
178 
180  const RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> getBlockedMap() const;
181 
183  const RCP<const Map> getFullMap() const;
184 
186  size_t getMapIndexForGID(GlobalOrdinal gid) const;
187 
189 
190  private:
192  Teuchos::RCP<const Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node>> map_;
193 };
194 
195 } // namespace Xpetra
196 
197 #define XPETRA_MAPEXTRACTOR_SHORT
198 #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