00001 // @HEADER 00002 // 00003 // *********************************************************************** 00004 // 00005 // Xpetra: A linear algebra interface package 00006 // Copyright 2012 Sandia Corporation 00007 // 00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00009 // the U.S. Government retains certain rights in this software. 00010 // 00011 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are 00013 // met: 00014 // 00015 // 1. Redistributions of source code must retain the above copyright 00016 // notice, this list of conditions and the following disclaimer. 00017 // 00018 // 2. Redistributions in binary form must reproduce the above copyright 00019 // notice, this list of conditions and the following disclaimer in the 00020 // documentation and/or other materials provided with the distribution. 00021 // 00022 // 3. Neither the name of the Corporation nor the names of the 00023 // contributors may be used to endorse or promote products derived from 00024 // this software without specific prior written permission. 00025 // 00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00037 // 00038 // Questions? Contact 00039 // Jeremie Gaidamour (jngaida@sandia.gov) 00040 // Jonathan Hu (jhu@sandia.gov) 00041 // Ray Tuminaro (rstumin@sandia.gov) 00042 // 00043 // *********************************************************************** 00044 // 00045 // @HEADER 00046 #ifndef XPETRA_EPETRABLOCKMAP_HPP 00047 #define XPETRA_EPETRABLOCKMAP_HPP 00048 00049 #include "Xpetra_ConfigDefs.hpp" 00050 00051 #ifndef HAVE_XPETRA_EPETRA 00052 #error This file should be included only if HAVE_XPETRA_EPETRA is defined. 00053 #endif 00054 00055 #include "Xpetra_Map.hpp" 00056 #include "Xpetra_BlockMap.hpp" 00057 00058 #include "Epetra_BlockMap.h" 00059 #include "Xpetra_EpetraUtils.hpp" 00060 #include "Xpetra_EpetraExceptions.hpp" 00061 00062 namespace Xpetra { 00063 00070 class EpetraBlockMap : public Xpetra::BlockMap<int,int> { 00071 00072 typedef int LocalOrdinal; 00073 typedef int GlobalOrdinal; 00074 typedef Kokkos::DefaultNode::DefaultNodeType Node; 00075 00076 public: 00077 00079 00080 00083 EpetraBlockMap(global_size_t numGlobalBlocks, 00084 int blockSize, 00085 int indexBase, 00086 const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 00087 const Teuchos::RCP<Kokkos::DefaultNode::DefaultNodeType> &node = Kokkos::DefaultNode::getDefaultNode()) : map_(rcp(new Epetra_BlockMap(numGlobalBlocks, blockSize, indexBase, *Teuchos2Epetra_Comm(comm)))) { } 00088 00089 //TODO 00090 //CATCH_EPETRA_EXCEPTION_AND_THROW_INVALID_ARG((map_ = (rcp(new Epetra_Map(numGlobalElements, indexBase, *Teuchos2Epetra_Comm(comm)))));); 00091 00094 EpetraBlockMap(global_size_t numGlobalBlocks, 00095 size_t numLocalBlocks, 00096 int blockSize, 00097 int indexBase, 00098 const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 00099 const Teuchos::RCP<Kokkos::DefaultNode::DefaultNodeType> &node = Kokkos::DefaultNode::getDefaultNode()) : map_(rcp(new Epetra_BlockMap(numGlobalBlocks, numLocalBlocks, blockSize, indexBase, *Teuchos2Epetra_Comm(comm)))) { } 00100 00103 // EpetraBlockMap(global_size_t numGlobalBlocks, 00104 // const Teuchos::ArrayView<const int>& myGlobalBlockIDs, 00105 // const Teuchos::ArrayView<const int>& myFirstGlobalPointInBlocks, 00106 // const Teuchos::ArrayView<const int>& myBlockSizes, 00107 // int indexBase, 00108 // const Teuchos::RCP<const Teuchos::Comm<int> > &comm, 00109 // const Teuchos::RCP<Kokkos::DefaultNode::DefaultNodeType> &node = Kokkos::DefaultNode::getDefaultNode()) { 00110 // 00111 // map_ = rcp(new Epetra_BlockMap(numGlobalBlocks, myGlobalBlockIDs, myFirstGlobalPointInBlocks, myBlockSizes, indexBase, *Teuchos2Epetra_Comm(comm))); 00112 // } 00113 00120 // EpetraBlockMap(const Teuchos::RCP<const Map<int,int> >& pointMap, 00121 // const Teuchos::ArrayView<const int>& myGlobalBlockIDs, 00122 // const Teuchos::ArrayView<const int>& myBlockSizes, 00123 // const Teuchos::RCP<Kokkos::DefaultNode::DefaultNodeType> &node = Kokkos::DefaultNode::getDefaultNode()) { 00124 // 00125 // map_ = rcp(new Epetra_BlockMap(pointMap, myGlobalBlockIDs, myBlockSizes)); 00126 // } 00127 00128 EpetraBlockMap(const Teuchos::RCP<const Epetra_BlockMap > &map) : map_(map) { } 00129 00131 virtual ~EpetraBlockMap(){ } 00132 00134 00136 00137 #ifdef XPETRA_NOT_IMPLEMENTED 00138 const Teuchos::RCP<const Map<int,int> >& getPointMap() const { return map_->getPointMap(); } 00139 #endif 00140 00141 global_size_t getGlobalNumBlocks() const { return map_->NumGlobalElements(); } 00142 00144 size_t getNodeNumBlocks() const { return map_->NumMyElements(); } 00145 00146 //TODO Teuchos::ArrayView<const int> getNodeBlockIDs() const { return map_->getNodeBlockIDs(); } 00147 00148 bool isBlockSizeConstant() const { return map_->ConstantElementSize(); } 00149 00151 //TODO Teuchos::ArrayRCP<const int> getNodeFirstPointInBlocks() const { return map_->FirstPointInElementList(); } 00152 00153 #ifdef XPETRA_NOT_IMPLEMENTED_FOR_EPETRA 00154 00155 00158 Teuchos::ArrayRCP<const int> getNodeFirstPointInBlocks_Device() const { return map_->getNodeFirstPointInBlocks_Device(); } 00159 #endif 00160 00162 00164 int getGlobalBlockID(int localBlockID) const { return map_->GID(localBlockID); } 00165 00167 00169 int getLocalBlockID(int globalBlockID) const { return map_->LID(globalBlockID); } 00170 00172 00175 int getLocalBlockSize(int localBlockID) const { return map_->ElementSize(localBlockID); } 00176 00178 00181 int getFirstLocalPointInLocalBlock(int localBlockID) const { return map_->FirstPointInElement(localBlockID); } 00182 00183 #ifdef XPETRA_NOT_IMPLEMENTED_FOR_EPETRA 00184 00185 00188 int getFirstGlobalPointInLocalBlock(int localBlockID) const { return; } 00189 #endif 00190 00192 00193 RCP< const Epetra_BlockMap > getEpetra_BlockMap() const { return map_; } 00194 00195 private: 00196 const RCP< const Epetra_BlockMap > map_; 00197 00198 00199 };//class EpetraBlockMap 00200 00201 // //----------------------------------------------------------------- 00202 // template<class int,class int,class Node> 00203 // Teuchos::RCP<const Xpetra::Map<int,int> > 00204 // convertEpetraBlockMapToEpetraPointMap(const Teuchos::RCP<const Xpetra::EpetraBlockMap<int,int> >& blockMap) { 00205 // return rcp(new EpetraMap(convertEpetraBlockMapToEpetraPointMap(blockMap.getEpetra_BlockMap()))); 00206 // } 00207 00208 }//namespace Xpetra 00209 00210 #endif
1.7.6.1