All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Xpetra_EpetraMap.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 //                    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_EPETRAMAP_HPP
00047 #define XPETRA_EPETRAMAP_HPP
00048 
00049 /* this file is automatically generated - do not edit (see script/epetra.py) */
00050 
00051 #include "Xpetra_EpetraConfigDefs.hpp"
00052 
00053 #include "Xpetra_Map.hpp"
00054 
00055 #include <Epetra_Map.h>
00056 #include <Epetra_BlockMap.h>
00057 
00058 #include "Xpetra_Utils.hpp"
00059 #include "Xpetra_EpetraUtils.hpp"
00060 
00061 #include "Xpetra_ConfigDefs.hpp"
00062 
00063 namespace Xpetra {
00064 
00065   // TODO: move that elsewhere
00066   const Epetra_Map & toEpetra(const Map<int,int> &);
00067   const Epetra_Map & toEpetra(const RCP< const Map<int, int> > &);
00068   //const RCP< const Map<int, int> > toXpetra(const RCP< const Epetra_Map > &);
00069   const RCP< const Map<int, int> > toXpetra(const Epetra_BlockMap &);
00070   //
00071 
00072   class EpetraMap
00073     : public virtual Map<int, int>
00074   {
00075 
00076     typedef int LocalOrdinal;
00077     typedef int GlobalOrdinal;
00078     typedef Kokkos::DefaultNode::DefaultNodeType Node;
00079 
00080   public:
00081 
00083 
00084 
00086     EpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode());
00087 
00089     EpetraMap(global_size_t numGlobalElements, size_t numLocalElements, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode());
00090 
00092     EpetraMap(global_size_t numGlobalElements, const Teuchos::ArrayView< const GlobalOrdinal > &elementList, GlobalOrdinal indexBase, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode());
00093 
00095 
00097 
00098 
00100     global_size_t getGlobalNumElements() const { XPETRA_MONITOR("EpetraMap::getGlobalNumElements"); return map_->NumGlobalElements(); }
00101 
00103     size_t getNodeNumElements() const { XPETRA_MONITOR("EpetraMap::getNodeNumElements"); return map_->NumMyElements(); }
00104 
00106     GlobalOrdinal getIndexBase() const { XPETRA_MONITOR("EpetraMap::getIndexBase"); return map_->IndexBase(); }
00107 
00109     LocalOrdinal getMinLocalIndex() const { XPETRA_MONITOR("EpetraMap::getMinLocalIndex"); return map_->MinLID(); }
00110 
00112     LocalOrdinal getMaxLocalIndex() const { XPETRA_MONITOR("EpetraMap::getMaxLocalIndex"); return map_->MaxLID(); }
00113 
00115     GlobalOrdinal getMinGlobalIndex() const { XPETRA_MONITOR("EpetraMap::getMinGlobalIndex"); return map_->MinMyGID(); }
00116 
00118     GlobalOrdinal getMaxGlobalIndex() const { XPETRA_MONITOR("EpetraMap::getMaxGlobalIndex"); return map_->MaxMyGID(); }
00119 
00121     GlobalOrdinal getMinAllGlobalIndex() const { XPETRA_MONITOR("EpetraMap::getMinAllGlobalIndex"); return map_->MinAllGID(); }
00122 
00124     GlobalOrdinal getMaxAllGlobalIndex() const { XPETRA_MONITOR("EpetraMap::getMaxAllGlobalIndex"); return map_->MaxAllGID(); }
00125 
00127     LocalOrdinal getLocalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMap::getLocalElement"); return map_->LID(globalIndex); }
00128 
00130     LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList, const Teuchos::ArrayView< LocalOrdinal > &LIDList) const;
00131 
00133     LookupStatus getRemoteIndexList(const Teuchos::ArrayView< const GlobalOrdinal > &GIDList, const Teuchos::ArrayView< int > &nodeIDList) const;
00134 
00136     Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const;
00137 
00139 
00141 
00142 
00144     bool isNodeLocalElement(LocalOrdinal localIndex) const { XPETRA_MONITOR("EpetraMap::isNodeLocalElement"); return map_->MyLID(localIndex); }
00145 
00147     bool isNodeGlobalElement(GlobalOrdinal globalIndex) const { XPETRA_MONITOR("EpetraMap::isNodeGlobalElement"); return map_->MyGID(globalIndex); }
00148 
00150     bool isContiguous() const { XPETRA_MONITOR("EpetraMap::isContiguous"); return map_->LinearMap(); }
00151 
00153     bool isDistributed() const { XPETRA_MONITOR("EpetraMap::isDistributed"); return map_->DistributedGlobal(); }
00154 
00156     bool isCompatible(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMap::isCompatible"); return map_->PointSameAs(toEpetra(map)); }
00157 
00159     bool isSameAs(const Map< LocalOrdinal, GlobalOrdinal, Node > &map) const { XPETRA_MONITOR("EpetraMap::isSameAs"); return map_->SameAs(toEpetra(map)); }
00160 
00162 
00164 
00165 
00167     const Teuchos::RCP< const Teuchos::Comm< int > >  getComm() const { XPETRA_MONITOR("EpetraMap::getComm"); return toXpetra(map_->Comm()); }
00168 
00170     const Teuchos::RCP< Node >  getNode() const;
00171 
00173 
00175 
00176 
00178     std::string description() const;
00179 
00181     void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00182 
00184 
00186     GlobalOrdinal getGlobalElement(LocalOrdinal localIndex) const {
00187       XPETRA_MONITOR("EpetraMap::getGlobalElement");
00188 
00189       GlobalOrdinal gid = map_->GID(localIndex);
00190       if (gid == map_->IndexBase()-1) return (-1);
00191       else                            return (gid);
00192      }
00193 
00195 
00196 
00198     virtual ~EpetraMap() { } // virtual because EpetraMap used as a base class of EpetraStridedMap
00199     
00201     EpetraMap(const Teuchos::RCP<const Epetra_BlockMap> &map) 
00202       : map_(map) { }
00203 
00205     UnderlyingLib lib() const { return Xpetra::UseEpetra; }
00206 
00208     //const RCP< const Epetra_Map > & getEpetra_Map() const { return map_; }
00209     const Epetra_BlockMap& getEpetra_BlockMap() const { return *map_; }
00210     const Epetra_Map& getEpetra_Map() const { return (Epetra_Map &)*map_; } // Ugly, but the same is done in Epetra_CrsMatrix.h to get the map.
00211 
00213    
00214   protected:
00215 
00216     RCP<const Epetra_BlockMap> map_;
00217     //const RCP< const Epetra_BlockMap > map_;
00218     //const RCP< const Epetra::Map< LocalOrdinal, GlobalOrdinal, Node > > map_;
00219 
00220   }; // EpetraMap class
00221 
00222 } // Xpetra namespace
00223 
00224 #endif // XPETRA_EPETRAMAP_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines