Xpetra_EpetraBlockMap.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 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_EPETRABLOCKMAP_HPP
47 #define XPETRA_EPETRABLOCKMAP_HPP
48 
49 #include "Xpetra_ConfigDefs.hpp"
50 
51 #ifndef HAVE_XPETRA_EPETRA
52 #error This file should be included only if HAVE_XPETRA_EPETRA is defined.
53 #endif
54 
55 #include "Xpetra_Map.hpp"
56 #include "Xpetra_BlockMap.hpp"
57 
58 #include "Epetra_BlockMap.h"
59 #include "Xpetra_EpetraUtils.hpp"
61 
62 namespace Xpetra {
63 
70 class EpetraBlockMap : public Xpetra::BlockMap<int,int> {
71 
72  typedef int LocalOrdinal;
73  typedef int GlobalOrdinal;
75 
76  public:
77 
79 
80 
83  EpetraBlockMap(global_size_t numGlobalBlocks,
84  int blockSize,
85  int indexBase,
86  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
87  const Teuchos::RCP<Kokkos::DefaultNode::DefaultNodeType> &node = Kokkos::DefaultNode::getDefaultNode()) : map_(rcp(new Epetra_BlockMap(numGlobalBlocks, blockSize, indexBase, *Teuchos2Epetra_Comm(comm)))) { }
88 
89  //TODO
90  //CATCH_EPETRA_EXCEPTION_AND_THROW_INVALID_ARG((map_ = (rcp(new Epetra_Map(numGlobalElements, indexBase, *Teuchos2Epetra_Comm(comm))))););
91 
94  EpetraBlockMap(global_size_t numGlobalBlocks,
95  size_t numLocalBlocks,
96  int blockSize,
97  int indexBase,
98  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
99  const Teuchos::RCP<Kokkos::DefaultNode::DefaultNodeType> &node = Kokkos::DefaultNode::getDefaultNode()) : map_(rcp(new Epetra_BlockMap(numGlobalBlocks, numLocalBlocks, blockSize, indexBase, *Teuchos2Epetra_Comm(comm)))) { }
100 
103  // EpetraBlockMap(global_size_t numGlobalBlocks,
104 // const Teuchos::ArrayView<const int>& myGlobalBlockIDs,
105 // const Teuchos::ArrayView<const int>& myFirstGlobalPointInBlocks,
106 // const Teuchos::ArrayView<const int>& myBlockSizes,
107 // int indexBase,
108 // const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
109 // const Teuchos::RCP<Kokkos::DefaultNode::DefaultNodeType> &node = Kokkos::DefaultNode::getDefaultNode()) {
110 //
111 // map_ = rcp(new Epetra_BlockMap(numGlobalBlocks, myGlobalBlockIDs, myFirstGlobalPointInBlocks, myBlockSizes, indexBase, *Teuchos2Epetra_Comm(comm)));
112 // }
113 
120 // EpetraBlockMap(const Teuchos::RCP<const Map<int,int> >& pointMap,
121 // const Teuchos::ArrayView<const int>& myGlobalBlockIDs,
122 // const Teuchos::ArrayView<const int>& myBlockSizes,
123 // const Teuchos::RCP<Kokkos::DefaultNode::DefaultNodeType> &node = Kokkos::DefaultNode::getDefaultNode()) {
124 //
125 // map_ = rcp(new Epetra_BlockMap(pointMap, myGlobalBlockIDs, myBlockSizes));
126 // }
127 
128  EpetraBlockMap(const Teuchos::RCP<const Epetra_BlockMap > &map) : map_(map) { }
129 
131  virtual ~EpetraBlockMap(){ }
132 
134 
136 
137 #ifdef XPETRA_NOT_IMPLEMENTED
138  const Teuchos::RCP<const Map<int,int> >& getPointMap() const { return map_->getPointMap(); }
139 #endif
140 
141  global_size_t getGlobalNumBlocks() const { return map_->NumGlobalElements(); }
142 
144  size_t getNodeNumBlocks() const { return map_->NumMyElements(); }
145 
146  //TODO Teuchos::ArrayView<const int> getNodeBlockIDs() const { return map_->getNodeBlockIDs(); }
147 
148  bool isBlockSizeConstant() const { return map_->ConstantElementSize(); }
149 
151  //TODO Teuchos::ArrayRCP<const int> getNodeFirstPointInBlocks() const { return map_->FirstPointInElementList(); }
152 
153 #ifdef XPETRA_NOT_IMPLEMENTED_FOR_EPETRA
154 
158  Teuchos::ArrayRCP<const int> getNodeFirstPointInBlocks_Device() const { return map_->getNodeFirstPointInBlocks_Device(); }
159 #endif
160 
162 
164  int getGlobalBlockID(int localBlockID) const { return map_->GID(localBlockID); }
165 
167 
169  int getLocalBlockID(int globalBlockID) const { return map_->LID(globalBlockID); }
170 
172 
175  int getLocalBlockSize(int localBlockID) const { return map_->ElementSize(localBlockID); }
176 
178 
181  int getFirstLocalPointInLocalBlock(int localBlockID) const { return map_->FirstPointInElement(localBlockID); }
182 
183 #ifdef XPETRA_NOT_IMPLEMENTED_FOR_EPETRA
184 
188  int getFirstGlobalPointInLocalBlock(int localBlockID) const { return; }
189 #endif
190 
192 
193  RCP< const Epetra_BlockMap > getEpetra_BlockMap() const { return map_; }
194 
195 private:
196  const RCP< const Epetra_BlockMap > map_;
197 
198 
199 };//class EpetraBlockMap
200 
201 // //-----------------------------------------------------------------
202 // template<class int,class int,class Node>
203 // Teuchos::RCP<const Xpetra::Map<int,int> >
204 // convertEpetraBlockMapToEpetraPointMap(const Teuchos::RCP<const Xpetra::EpetraBlockMap<int,int> >& blockMap) {
205 // return rcp(new EpetraMap(convertEpetraBlockMapToEpetraPointMap(blockMap.getEpetra_BlockMap())));
206 // }
207 
208 }//namespace Xpetra
209 
210 #endif
Kokkos::DefaultNode::DefaultNodeType Node
int getFirstLocalPointInLocalBlock(int localBlockID) const
Return the first local point-index corresponding to localBlockID.
Xpetra namespace
static Teuchos::RCP< DefaultNodeType > getDefaultNode()
RCP< const Epetra_BlockMap > getEpetra_BlockMap() const
global_size_t getGlobalNumBlocks() const
virtual ~EpetraBlockMap()
EpetraBlockMap destructor.
Block-entry counterpart to Xpetra::Map.
int getLocalBlockID(int globalBlockID) const
Return the localBlockID corresponding to the given globalBlockID.
const RCP< const Epetra_BlockMap > map_
EpetraBlockMap(const Teuchos::RCP< const Epetra_BlockMap > &map)
EpetraBlockMap constructor specifying numGlobalBlocks and lists of local blocks first-global-point-in...
size_t global_size_t
Global size_t object.
size_t getNodeNumBlocks() const
Return number of blocks on the local processor.
EpetraBlockMap(global_size_t numGlobalBlocks, int blockSize, int indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Kokkos::DefaultNode::DefaultNodeType > &node=Kokkos::DefaultNode::getDefaultNode())
EpetraBlockMap constructor specifying numGlobalBlocks and constant blockSize.
EpetraBlockMap(global_size_t numGlobalBlocks, size_t numLocalBlocks, int blockSize, int indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Kokkos::DefaultNode::DefaultNodeType > &node=Kokkos::DefaultNode::getDefaultNode())
EpetraBlockMap constructor specifying num global and local blocks, and constant blockSize.
Block-entry counterpart to Xpetra::Map.
int getGlobalBlockID(int localBlockID) const
Return ArrayRCP of first-local-point in local blocks.
int getLocalBlockSize(int localBlockID) const
Return the block-size for localBlockID.