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> class BlockedMultiVector;
71 
72  // forward declaration of BlockedMap, needed because some functions take them as parameters
73  // (This should go away when BlockedMap is converted to ETI)
74  template<class LO, class GO, class N> class BlockedMap;
75 #endif
76 
77 
78 
79  template <class Scalar,
80  class LocalOrdinal,
81  class GlobalOrdinal,
82  class Node>
83  class MapExtractor : public Teuchos::Describable
84  {
85 
86  public:
87  typedef Scalar scalar_type;
88  typedef LocalOrdinal local_ordinal_type;
89  typedef GlobalOrdinal global_ordinal_type;
90  typedef Node node_type;
91 
92  private:
93 #undef XPETRA_MAPEXTRACTOR_SHORT
94 #include "Xpetra_UseShortNames.hpp"
95 
96  public:
97 
110  MapExtractor(const RCP<const Map>& fullmap, const std::vector<RCP<const Map> >& maps, bool bThyraMode = false);
111 
112 
114  MapExtractor(const std::vector<RCP<const Map> >& maps, const std::vector<RCP<const Map> >& thyramaps);
115 
116 
123  MapExtractor(const Teuchos::RCP< const Xpetra::BlockedMap<LocalOrdinal,GlobalOrdinal,Node> > &map);
124 
125 
127  MapExtractor(const MapExtractor& input);
128 
129 
131  virtual ~MapExtractor();
132 
133 
136  void ExtractVector(const Vector& full, size_t block, Vector& partial) const;
137  void ExtractVector(const MultiVector& full, size_t block, MultiVector& partial) const;
138  void ExtractVector(RCP<const Vector>& full, size_t block, RCP< Vector>& partial) const;
139  void ExtractVector(RCP< Vector>& full, size_t block, RCP< Vector>& partial) const;
140  void ExtractVector(RCP<const MultiVector>& full, size_t block, RCP<MultiVector>& partial) const;
141  void ExtractVector(RCP< MultiVector>& full, size_t block, RCP<MultiVector>& partial) const;
142 
143  RCP< Vector> ExtractVector(RCP<const Vector>& full, size_t block, bool bThyraMode = false) const;
144  RCP< Vector> ExtractVector(RCP< Vector>& full, size_t block, bool bThyraMode = false) const;
145  RCP<MultiVector> ExtractVector(RCP<const MultiVector>& full, size_t block, bool bThyraMode = false) const;
146  RCP<MultiVector> ExtractVector(RCP< MultiVector>& full, size_t block, bool bThyraMode = false) const;
147 
148  RCP<MultiVector> ExtractVector(RCP<const Xpetra::BlockedMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& full, size_t block, bool bThyraMode = false) const;
149  RCP<MultiVector> ExtractVector(RCP< Xpetra::BlockedMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> >& full, size_t block, bool bThyraMode = false) const;
150 
152 
155  void InsertVector(const Vector& partial, size_t block, Vector& full, bool bThyraMode = false) const;
156  void InsertVector(const MultiVector& partial, size_t block, MultiVector& full, bool bThyraMode = false) const;
157  void InsertVector(RCP<const Vector> partial, size_t block, RCP< Vector> full, bool bThyraMode = false) const;
158  void InsertVector(RCP< Vector> partial, size_t block, RCP< Vector> full, bool bThyraMode = false) const;
159  void InsertVector(RCP<const MultiVector> partial, size_t block, RCP<MultiVector> full, bool bThyraMode = false) const;
160  void InsertVector(RCP< MultiVector> partial, size_t block, RCP<MultiVector> full, bool bThyraMode = false) const;
161  void InsertVector(RCP<const MultiVector> partial, size_t block, RCP<Xpetra::BlockedMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > full, bool bThyraMode = false) const;
162  void InsertVector(RCP< MultiVector> partial, size_t block, RCP<Xpetra::BlockedMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > full, bool bThyraMode = false) const;
163 
165 
166  RCP< Vector> getVector(size_t i, bool bThyraMode = false, bool bZero= true) const;
167  RCP<MultiVector> getVector(size_t i, size_t numvec, bool bThyraMode = false, bool bZero = true) const;
168 
170  bool getThyraMode() const;
171 
174 
176  size_t NumMaps() const;
177 
182  const RCP<const Map> getMap(size_t i, bool bThyraMode = false) const;
183 
185  const RCP<const Map> getMap() const;
186 
188  const RCP<const Xpetra::BlockedMap<LocalOrdinal,GlobalOrdinal,Node>> getBlockedMap() const;
189 
191  const RCP<const Map> getFullMap() const;
192 
194  size_t getMapIndexForGID(GlobalOrdinal gid) const;
195 
197 
198  private:
199  Teuchos::RCP<const Xpetra::BlockedMap<LocalOrdinal,GlobalOrdinal,Node>> map_;
200  };
201 
202 
203 } // namespace xpetra
204 
205 #define XPETRA_MAPEXTRACTOR_SHORT
206 #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.
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
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)
MapExtractor(const RCP< const Map > &fullmap, const std::vector< RCP< const Map > > &maps, bool bThyraMode=false)
void ExtractVector(const Vector &full, size_t block, Vector &partial) const
size_t NumMaps() const
number of partial maps
Teuchos::RCP< const Xpetra::BlockedMap< LocalOrdinal, GlobalOrdinal, Node > > map_
blocked map containing the sub block maps (either thyra or xpetra mode)