Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef XPETRA_STRIDEDEPETRAMAP_HPP
00050 #define XPETRA_STRIDEDEPETRAMAP_HPP
00051
00052 #include "Xpetra_EpetraConfigDefs.hpp"
00053
00054 #include "Xpetra_StridedMap.hpp"
00055 #include "Xpetra_EpetraMap.hpp"
00056
00057
00058
00059 #include "Xpetra_EpetraUtils.hpp"
00060 #include "Xpetra_ConfigDefs.hpp"
00061
00062 namespace Xpetra {
00063
00064
00065 class StridedEpetraMap
00066 : public virtual EpetraMap, public virtual StridedMap<int, int>
00067 {
00068
00069 typedef int LocalOrdinal;
00070 typedef int GlobalOrdinal;
00071 typedef Kokkos::DefaultNode::DefaultNodeType Node;
00072
00073 public:
00074
00076
00077
00079 StridedEpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, std::vector<size_t>& stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset = 0, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode());
00080
00082 StridedEpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, std::vector<size_t>& stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset = 0, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode());
00083
00085 StridedEpetraMap(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, std::vector<size_t>& stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode());
00086
00088 ~StridedEpetraMap() { }
00089
00091
00093
00094
00096 global_size_t getGlobalNumElements() const { return EpetraMap::getGlobalNumElements(); }
00097
00099 size_t getNodeNumElements() const { return EpetraMap::getNodeNumElements(); }
00100
00102 GlobalOrdinal getIndexBase() const { return EpetraMap::getIndexBase(); }
00103
00105 LocalOrdinal getMinLocalIndex() const { return EpetraMap::getMinLocalIndex(); }
00106
00108 LocalOrdinal getMaxLocalIndex() const { return EpetraMap::getMaxLocalIndex(); }
00109
00111 GlobalOrdinal getMinGlobalIndex() const { return EpetraMap::getMinGlobalIndex(); }
00112
00114 GlobalOrdinal getMaxGlobalIndex() const { return EpetraMap::getMaxGlobalIndex(); }
00115
00117 GlobalOrdinal getMinAllGlobalIndex() const { return EpetraMap::getMinAllGlobalIndex(); }
00118
00120 GlobalOrdinal getMaxAllGlobalIndex() const { return EpetraMap::getMaxAllGlobalIndex(); }
00121
00123 LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { return EpetraMap::getLocalElement(globalIndex); }
00124
00126 LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const { return EpetraMap::getRemoteIndexList(GIDList, nodeIDList, LIDList); }
00127
00129 LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const { return EpetraMap::getRemoteIndexList(GIDList, nodeIDList); }
00130
00132 Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const { return EpetraMap::getNodeElementList(); }
00133
00135 bool isNodeLocalElement(LocalOrdinal localIndex) const { return EpetraMap::isNodeLocalElement(localIndex); }
00136
00138 bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { return EpetraMap::isNodeGlobalElement(globalIndex); }
00139
00141 bool isContiguous() const { return EpetraMap::isContiguous(); }
00142
00144 bool isDistributed() const { return EpetraMap::isDistributed(); }
00145
00147
00149
00150
00152 const Teuchos::RCP< const Teuchos::Comm< int > > getComm() const { return EpetraMap::getComm(); }
00153
00155 const Teuchos::RCP< Node > getNode() const { return EpetraMap::getNode(); }
00156
00158
00159
00161
00162
00164 bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { return EpetraMap::isCompatible(map); }
00165
00167 bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { return EpetraMap::isSameAs(map); }
00168
00170
00172
00173
00175 std::string description() const;
00176
00178 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00179
00181
00183 GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const { return EpetraMap::getGlobalElement(localIndex); }
00184
00186
00187
00189 StridedEpetraMap(const Teuchos::RCP<const Epetra_BlockMap> &map, std::vector<size_t>& stridingInfo, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset = 0)
00190 : EpetraMap(map), StridedMap<int, int>(stridingInfo, stridedBlockId, offset) {
00191 int nDofsPerNode = Teuchos::as<int>(getFixedBlockSize());
00192 TEUCHOS_TEST_FOR_EXCEPTION(map_->NumMyPoints() % nDofsPerNode != 0, Exceptions::RuntimeError, "StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
00193 TEUCHOS_TEST_FOR_EXCEPTION(CheckConsistency() == false, Exceptions::RuntimeError, "StridedEpetraMap::StridedEpetraMap: CheckConsistency() == false");
00194 }
00195
00197 UnderlyingLib lib() const { return Xpetra::UseEpetra; }
00198
00199
00200
00201
00202
00203
00205
00206 private:
00207
00208 bool CheckConsistency() {
00209 if(getStridedBlockId() == -1) {
00210
00211 if(getNodeNumElements() % getFixedBlockSize() != 0) return false;
00212 if(getGlobalNumElements() % getFixedBlockSize() != 0) return false;
00213 }
00214 else {
00215 Teuchos::ArrayView< const GlobalOrdinal > dofGids = getNodeElementList();
00216
00217
00218
00219 size_t nStridedOffset = 0;
00220 for(int j=0; j<stridedBlockId_; j++) {
00221 nStridedOffset += stridingInfo_[j];
00222 }
00223
00224
00225 const GlobalOrdinal goStridedOffset = Teuchos::as<GlobalOrdinal>(nStridedOffset);
00226 const GlobalOrdinal goZeroOffset = (dofGids[0] - nStridedOffset - offset_) / Teuchos::as<GlobalOrdinal>(getFixedBlockSize());
00227
00228
00229
00230
00231
00232
00233
00234 GlobalOrdinal cnt = 0;
00235 for(size_t i = 0; i<Teuchos::as<size_t>(dofGids.size())/stridingInfo_[stridedBlockId_]; i+=stridingInfo_[stridedBlockId_]) {
00236
00237 for(size_t j=0; j<stridingInfo_[stridedBlockId_]; j++) {
00238 const GlobalOrdinal gid = dofGids[i+j];
00239 if((gid - Teuchos::as<GlobalOrdinal>(j) - goStridedOffset - offset_) / Teuchos::as<GlobalOrdinal>(getFixedBlockSize()) - goZeroOffset - cnt != 0) {
00240
00241 return false;
00242 }
00243 }
00244 cnt++;
00245 }
00246
00247 }
00248
00249 return true;
00250 }
00251
00252
00253 };
00254
00255 }
00256
00257 #endif // XPETRA_STRIDEDEPETRAMAP_HPP