All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Xpetra_EpetraBlockMap.hpp
Go to the documentation of this file.
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 //                    Jonathan Hu       (jhu@sandia.gov)
00040 //                    Andrey Prokopenko (aprokop@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 public:
00072   typedef int LocalOrdinal;
00073   typedef int GlobalOrdinal;
00074   typedef BlockMap<int, int>::node_type Node;
00075 
00077 
00078 
00081   EpetraBlockMap(global_size_t numGlobalBlocks,
00082                  int blockSize,
00083                  int indexBase,
00084                  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
00085                  const Teuchos::RCP<Node>& node = KokkosClassic::Details::getNode<Node> ()) :
00086     map_ (rcp (new Epetra_BlockMap (numGlobalBlocks, blockSize, indexBase,
00087                                     *Teuchos2Epetra_Comm (comm))))
00088   {}
00089 
00090   //TODO
00091   //CATCH_EPETRA_EXCEPTION_AND_THROW_INVALID_ARG((map_ = (rcp(new Epetra_Map(numGlobalElements, indexBase, *Teuchos2Epetra_Comm(comm))))););
00092 
00095   EpetraBlockMap(global_size_t numGlobalBlocks,
00096                  size_t numLocalBlocks,
00097                  int blockSize,
00098                  int indexBase,
00099                  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
00100                  const Teuchos::RCP<Node>& node = KokkosClassic::Details::getNode<Node> ()) :
00101     map_ (rcp (new Epetra_BlockMap (numGlobalBlocks, numLocalBlocks, blockSize,
00102                                     indexBase, *Teuchos2Epetra_Comm(comm))))
00103   {}
00104 
00107  // EpetraBlockMap(global_size_t numGlobalBlocks,
00108 //                  const Teuchos::ArrayView<const int>& myGlobalBlockIDs,
00109 //                  const Teuchos::ArrayView<const int>& myFirstGlobalPointInBlocks,
00110 //                  const Teuchos::ArrayView<const int>& myBlockSizes,
00111 //                  int indexBase,
00112 //                  const Teuchos::RCP<const Teuchos::Comm<int> > &comm,
00113 //                  const Teuchos::RCP<Node> &node = KokkosClassic::Details::getNode<Node> ()) {
00114 //
00115 //     map_ = rcp(new Epetra_BlockMap(numGlobalBlocks, myGlobalBlockIDs, myFirstGlobalPointInBlocks, myBlockSizes, indexBase, *Teuchos2Epetra_Comm(comm)));
00116 //   }
00117 
00124 //   EpetraBlockMap(const Teuchos::RCP<const Map<int,int> >& pointMap,
00125 //                  const Teuchos::ArrayView<const int>& myGlobalBlockIDs,
00126 //                  const Teuchos::ArrayView<const int>& myBlockSizes,
00127 //                  const Teuchos::RCP<Node>& node = KokkosClassic::Details::getNode<Node> ()) {
00128 //
00129 //     map_ = rcp(new Epetra_BlockMap(pointMap, myGlobalBlockIDs, myBlockSizes));
00130 //   }
00131 
00132   EpetraBlockMap(const Teuchos::RCP<const Epetra_BlockMap > &map) : map_(map) {  }
00133 
00135   virtual ~EpetraBlockMap(){  }
00136 
00138 
00140 
00141 #ifdef XPETRA_NOT_IMPLEMENTED
00142   const Teuchos::RCP<const Map<int,int> >& getPointMap() const {  return map_->getPointMap(); }
00143 #endif
00144 
00145   global_size_t getGlobalNumBlocks() const {  return map_->NumGlobalElements(); }
00146 
00148   size_t getNodeNumBlocks() const {  return map_->NumMyElements(); }
00149 
00150   //TODO Teuchos::ArrayView<const int> getNodeBlockIDs() const {  return map_->getNodeBlockIDs(); }
00151 
00152   bool isBlockSizeConstant() const {  return map_->ConstantElementSize(); }
00153 
00155   //TODO Teuchos::ArrayRCP<const int> getNodeFirstPointInBlocks() const {  return map_->FirstPointInElementList(); }
00156 
00157 #ifdef XPETRA_NOT_IMPLEMENTED_FOR_EPETRA
00158 
00159 
00162   Teuchos::ArrayRCP<const int> getNodeFirstPointInBlocks_Device() const {  return map_->getNodeFirstPointInBlocks_Device(); }
00163 #endif
00164 
00166 
00168   int getGlobalBlockID(int localBlockID) const {  return map_->GID(localBlockID); }
00169 
00171 
00173   int getLocalBlockID(int globalBlockID) const {  return map_->LID(globalBlockID); }
00174 
00176 
00179   int getLocalBlockSize(int localBlockID) const {  return map_->ElementSize(localBlockID); }
00180 
00182 
00185   int getFirstLocalPointInLocalBlock(int localBlockID) const {  return map_->FirstPointInElement(localBlockID); }
00186 
00187 #ifdef XPETRA_NOT_IMPLEMENTED_FOR_EPETRA
00188 
00189 
00192   int getFirstGlobalPointInLocalBlock(int localBlockID) const {  return; }
00193 #endif
00194 
00196 
00197   RCP< const Epetra_BlockMap > getEpetra_BlockMap() const {  return map_; }
00198 
00199 private:
00200   const RCP< const Epetra_BlockMap > map_;
00201 
00202 
00203 };//class EpetraBlockMap
00204 
00205 // //-----------------------------------------------------------------
00206 // template<class int,class int,class Node>
00207 // Teuchos::RCP<const Xpetra::Map<int,int> >
00208 // convertEpetraBlockMapToEpetraPointMap(const Teuchos::RCP<const Xpetra::EpetraBlockMap<int,int> >& blockMap) {
00209 //   return rcp(new EpetraMap(convertEpetraBlockMapToEpetraPointMap(blockMap.getEpetra_BlockMap())));
00210 // }
00211 
00212 }//namespace Xpetra
00213 
00214 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines