43 #ifndef DOMI_MDMAP_HPP 
   44 #define DOMI_MDMAP_HPP 
   52 #include "Domi_ConfigDefs.hpp" 
   53 #include "Domi_Utils.hpp" 
   54 #include "Domi_getValidParameters.hpp" 
   56 #include "Domi_MDComm.hpp" 
   57 #include "Domi_MDArray.hpp" 
   60 #include "Teuchos_Comm.hpp" 
   61 #include "Teuchos_DefaultComm.hpp" 
   62 #include "Teuchos_CommHelpers.hpp" 
   63 #include "Teuchos_Tuple.hpp" 
   66 #include "Kokkos_Core.hpp" 
   69 #include "Epetra_Map.h" 
   73 #include "Tpetra_Map.hpp" 
   74 #include "Tpetra_Util.hpp" 
   75 typedef Tpetra::Details::DefaultTypes::local_ordinal_type  TpetraLOType;
 
   76 typedef Tpetra::Details::DefaultTypes::global_ordinal_type TpetraGOType;
 
   77 typedef Tpetra::Details::DefaultTypes::node_type           TpetraNodeType;
 
  185   MDMap(
const Teuchos::RCP< const MDComm > mdComm,
 
  186         const Teuchos::ArrayView< const dim_type > & dimensions,
 
  187         const Teuchos::ArrayView< const int > & commPad =
 
  188           Teuchos::ArrayView< const int >(),
 
  189         const Teuchos::ArrayView< const int > & bndryPad =
 
  190           Teuchos::ArrayView< const int >(),
 
  191         const Teuchos::ArrayView< const int > & replicatedBoundary =
 
  192           Teuchos::ArrayView< const int >(),
 
  193         const Layout layout = DEFAULT_ORDER);
 
  206   MDMap(Teuchos::ParameterList & plist);
 
  220   MDMap(
const Teuchos::RCP< 
const Teuchos::Comm< int > > teuchosComm,
 
  221         Teuchos::ParameterList & plist);
 
  235   MDMap(
const Teuchos::RCP< const MDComm > mdComm,
 
  236         Teuchos::ParameterList & plist);
 
  267   MDMap(
const Teuchos::RCP< const MDComm > mdComm,
 
  268         const Teuchos::ArrayView< Slice > & myGlobalBounds,
 
  269         const Teuchos::ArrayView< padding_type > & padding =
 
  270           Teuchos::ArrayView< padding_type >(),
 
  271         const Teuchos::ArrayView< const int > & replicatedBoundary =
 
  272           Teuchos::ArrayView< const int >(),
 
  273         const Layout layout = DEFAULT_ORDER);
 
  338         const Teuchos::ArrayView< Slice > & slices,
 
  339         const Teuchos::ArrayView< int > & bndryPad =
 
  340           Teuchos::ArrayView< int >());
 
  368   inline Teuchos::RCP< const Teuchos::Comm< int > > 
getTeuchosComm() 
const;
 
  375   inline Teuchos::RCP< const MDComm > 
getMDComm() 
const;
 
  490                         bool withBndryPad=
false) 
const;
 
  501                         bool withBndryPad=
false) 
const;
 
  517                             bool withBndryPad=
false) 
const;
 
  532                        bool withPad=
false) 
const;
 
  557                        bool withPad=
false) 
const;
 
  666   bool isPad(
const Teuchos::ArrayView< dim_type > & index) 
const;
 
  674   bool isCommPad(
const Teuchos::ArrayView< dim_type > & index) 
const;
 
  682   bool isBndryPad(
const Teuchos::ArrayView< dim_type > & index) 
const;
 
  701   Teuchos::ArrayView< Teuchos::RCP< const Domi::MDMap > >
 
  708   Teuchos::RCP< const Domi::MDMap > 
getAxisMap(
int axis) 
const;
 
  726   Teuchos::RCP< const MDMap >
 
  728                     const dim_type trailingDim=0) 
const;
 
  740   Teuchos::RCP< const Epetra_Map >
 
  741   getEpetraMap(
bool withCommPad=
true) 
const;
 
  753   Teuchos::RCP< const Epetra_Map >
 
  754   getEpetraAxisMap(
int axis,
 
  755                    bool withCommPad=
true) 
const;
 
  770   template< 
class LocalOrdinal  = TpetraLOType,
 
  771             class GlobalOrdinal = TpetraGOType,
 
  772             class Node          = TpetraNodeType>
 
  773   Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
 
  774   getTpetraMap(
bool withCommPad=
true) 
const;
 
  788   template< 
class LocalOrdinal  = TpetraLOType,
 
  789             class GlobalOrdinal = TpetraGOType,
 
  790             class Node          = TpetraNodeType >
 
  791   Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
 
  792   getTpetraAxisMap(
int axis,
 
  793                    bool withCommPad=
true) 
const;
 
  806   Teuchos::Array< dim_type >
 
  813   Teuchos::Array< dim_type >
 
  827   getGlobalID(
const Teuchos::ArrayView< dim_type > & globalIndex) 
const;
 
  836   size_type 
getLocalID(size_type globalID) 
const;
 
  843   getLocalID(
const Teuchos::ArrayView< dim_type > & localIndex) 
const;
 
  888                 const int verbose = 0) 
const;
 
  908   void computeBounds();
 
  911   Teuchos::RCP< const MDComm > _mdComm;
 
  915   Teuchos::Array< dim_type > _globalDims;
 
  919   Teuchos::Array< Slice > _globalBounds;
 
  928   Teuchos::Array< Teuchos::Array< Slice > > _globalRankBounds;
 
  933   Teuchos::Array< size_type > _globalStrides;
 
  937   size_type _globalMin;
 
  941   size_type _globalMax;
 
  945   Teuchos::Array< dim_type > _localDims;
 
  953   Teuchos::Array< Slice > _localBounds;
 
  956   Teuchos::Array< size_type > _localStrides;
 
  968   Teuchos::Array< int > _commPadSizes;
 
  973   Teuchos::Array< padding_type > _pad;
 
  976   Teuchos::Array< int > _bndryPadSizes;
 
  984   Teuchos::Array< padding_type > _bndryPad;
 
  991   Teuchos::Array< int > _replicatedBoundary;
 
 1000   mutable Teuchos::Array< Teuchos::RCP< const MDMap > > _axisMaps;
 
 1007   mutable Teuchos::RCP< const Epetra_Map > _epetraMap;
 
 1014   mutable Teuchos::RCP< const Epetra_Map > _epetraOwnMap;
 
 1020   mutable Teuchos::Array< Teuchos::RCP< const Epetra_Map > > _epetraAxisMaps;
 
 1026   mutable Teuchos::Array< Teuchos::RCP< const Epetra_Map > > _epetraAxisOwnMaps;
 
 1037 Teuchos::RCP< const Teuchos::Comm< int > >
 
 1040   return _mdComm->getTeuchosComm();
 
 1045 Teuchos::RCP< const MDComm >
 
 1056   return _mdComm->onSubcommunicator();
 
 1064   return _mdComm->numDims();
 
 1069 Teuchos::Array< int >
 
 1072   return _mdComm->getCommDims();
 
 1080   return _mdComm->getCommDim(axis);
 
 1088   return _mdComm->isPeriodic(axis);
 
 1096   return _mdComm->getCommIndex(axis);
 
 1104   return _mdComm->getLowerNeighbor(axis);
 
 1112   return _mdComm->getUpperNeighbor(axis);
 
 1117 Teuchos::Array< dim_type >
 
 1134 template< 
class LocalOrdinal,
 
 1135           class GlobalOrdinal,
 
 1137 Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
 
 1138 MDMap::getTpetraMap(
bool withCommPad)
 const 
 1144     Teuchos::Array<dim_type> localDims(num_dims);
 
 1145     for (
int axis = 0; axis < num_dims; ++axis)
 
 1146       localDims[axis] = _localDims[axis];
 
 1148     Teuchos::Array< LocalOrdinal > index(num_dims);
 
 1152          it != elementMDArray.end(); ++it)
 
 1154       GlobalOrdinal globalID = 0;
 
 1155       for (
int axis = 0; axis < num_dims; ++axis)
 
 1158         GlobalOrdinal start = _globalRankBounds[axis][axisRank].start() -
 
 1160         globalID += (start + it.index(axis)) * _globalStrides[axis];
 
 1166     const Teuchos::Array< GlobalOrdinal > & myElements =
 
 1167       elementMDArray.array();
 
 1168     Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm =
 
 1169       _mdComm->getTeuchosComm();
 
 1171       Teuchos::rcp(
new Tpetra::Map< LocalOrdinal,
 
 1173                                     Node >(Teuchos::OrdinalTraits< Tpetra::global_size_t >::invalid(),
 
 1182     Teuchos::Array< LocalOrdinal > index(num_dims);
 
 1183     Teuchos::Array< dim_type >     myDims(num_dims);
 
 1184     for (
int axis = 0; axis < num_dims; ++axis)
 
 1187         _localDims[axis] - _pad[axis][0] - _pad[axis][1];
 
 1190         myDims[axis] += _bndryPad[axis][0];
 
 1192         myDims[axis] += _bndryPad[axis][1];
 
 1194     MDArray< GlobalOrdinal > elementMDArray(myDims());
 
 1197     for (
typename MDArray< GlobalOrdinal >::iterator it = elementMDArray.begin();
 
 1198          it != elementMDArray.end(); ++it)
 
 1200       GlobalOrdinal globalID = 0;
 
 1201       for (
int axis = 0; axis < num_dims; ++axis)
 
 1204         GlobalOrdinal start = _globalRankBounds[axis][axisRank].start();
 
 1206           start -= _bndryPad[axis][0];
 
 1208           start += _bndryPad[axis][1];
 
 1209         globalID += (start + it.index(axis)) * _globalStrides[axis];
 
 1214     const Teuchos::Array< GlobalOrdinal> & myElements =
 
 1215       elementMDArray.array();
 
 1216     Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm =
 
 1217       _mdComm->getTeuchosComm();
 
 1219       Teuchos::rcp(
new Tpetra::Map< LocalOrdinal,
 
 1221                                     Node >(Teuchos::OrdinalTraits< Tpetra::global_size_t>::invalid(),
 
 1233 template< 
class LocalOrdinal,
 
 1234           class GlobalOrdinal,
 
 1236 Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
 
 1238 getTpetraAxisMap(
int axis,
 
 1239                  bool withCommPad)
 const 
 1241 #ifdef HAVE_DOMI_ARRAY_BOUNDSCHECK 
 1242   TEUCHOS_TEST_FOR_EXCEPTION(
 
 1243     ((axis < 0) || (axis >= 
numDims())),
 
 1245     "invalid axis index = " << axis << 
" (number of dimensions = " <<
 
 1248   Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm =
 
 1249     _mdComm->getTeuchosComm();
 
 1250   Teuchos::Array< GlobalOrdinal > elements(
getLocalDim(axis,withCommPad));
 
 1252   if (withCommPad && (
getCommIndex(axis) != 0)) start -= _pad[axis][0];
 
 1253   for (LocalOrdinal i = 0; i < elements.size(); ++i)
 
 1254     elements[i] = i + start;
 
 1255   return Teuchos::rcp(
new Tpetra::Map< LocalOrdinal,
 
 1257                                        Node >(Teuchos::OrdinalTraits< Tpetra::global_size_t>::invalid(),
 
size_type getGlobalID(size_type localID) const 
Convert a local ID to a global ID. 
 
Teuchos::Array< int > getCommDims() const 
Get the communicator sizes along each axis. 
Definition: Domi_MDMap.hpp:1070
 
Slice getGlobalBounds(int axis, bool withBndryPad=false) const 
Get the bounds of the global problem. 
 
Slice getLocalInteriorBounds(int axis) const 
Get the local interior loop bounds along the specified axis. 
 
Iterator class suitable for multi-dimensional arrays. 
Definition: Domi_MDIterator.hpp:100
 
int getCommPadSize(int axis) const 
Get the communication padding size along the given axis. 
 
Slice getGlobalRankBounds(int axis, bool withBndryPad=false) const 
Get the global loop bounds along the specified axis. 
 
bool isCompatible(const MDMap &mdMap) const 
True if two MDMaps are "compatible". 
 
int getBndryPadSize(int axis) const 
Get the boundary padding size along the given axis. 
 
int getUpperPadSize(int axis) const 
Get the size of the upper padding along the given axis. 
 
Teuchos::Array< dim_type > getLocalDims() const 
Get an array of the local dimensions, including padding. 
 
Teuchos::ArrayView< Teuchos::RCP< const Domi::MDMap > > getAxisMaps() const 
Return an array of axis maps. 
 
int getCommIndex(int axis) const 
Get the axis rank of this processor. 
Definition: Domi_MDMap.hpp:1094
 
int getLowerPadSize(int axis) const 
Get the size of the lower padding along the given axis. 
 
A Slice defines a subset of a container. 
 
int getUpperNeighbor(int axis) const 
Get the rank of the upper neighbor. 
Definition: Domi_MDMap.hpp:1110
 
size_type getLocalID(size_type globalID) const 
Convert a global ID to a local ID. 
 
A Slice contains a start, stop, and step index, describing a subset of an ordered container...
Definition: Domi_Slice.hpp:137
 
bool onSubcommunicator() const 
Query whether this processor is on the sub-communicator. 
Definition: Domi_MDMap.hpp:1054
 
int numDims() const 
Get the number of dimensions. 
Definition: Domi_MDMap.hpp:1062
 
int getLowerNeighbor(int axis) const 
Get the rank of the lower neighbor. 
Definition: Domi_MDMap.hpp:1102
 
Teuchos::Array< dim_type > getGlobalIndex(size_type globalID) const 
Convert a global ID to a global index. 
 
Teuchos::RCP< const Domi::MDMap > getAxisMap(int axis) const 
Return an axis map for the given axis. 
 
dim_type getGlobalDim(int axis, bool withBndryPad=false) const 
Get the global dimension along the specified axis. 
 
MDMap & operator=(const MDMap &source)
Assignment operator. 
 
bool isSameAs(const MDMap &mdMap, const int verbose=0) const 
True if two MDMaps are "identical". 
 
Teuchos::RCP< const MDComm > getMDComm() const 
Access the underlying MDComm object. 
Definition: Domi_MDMap.hpp:1046
 
Teuchos::RCP< const MDMap > getAugmentedMDMap(const dim_type leadingDim, const dim_type trailingDim=0) const 
Return an RCP to a new MDMap that is a simple augmentation of this MDMap. 
 
const dim_type start() const 
Start index. 
Definition: Domi_Slice.hpp:431
 
bool isReplicatedBoundary(int axis) const 
Return whether the given axis supports a replicated boundary. 
 
bool isContiguous() const 
True if there are no stride gaps on any processor. 
 
Teuchos::RCP< const Teuchos::Comm< int > > getTeuchosComm() const 
Get the Teuchos communicator. 
Definition: Domi_MDMap.hpp:1038
 
int getLowerBndryPad(int axis) const 
Get the size of the lower boundary padding along the given axis. 
 
Teuchos::Array< int > getBndryPadSizes() const 
Get the boundary padding sizes along each axis. 
 
Teuchos::Array< dim_type > getLocalIndex(size_type localID) const 
Convert a local ID to a local index. 
 
Teuchos::Array< dim_type > getGlobalDims() const 
Get an array of the the global dimensions, including boundary padding. 
Definition: Domi_MDMap.hpp:1119
 
bool hasPadding() const 
Return true if there is any padding stored locally. 
 
int getCommDim(int axis) const 
Get the communicator size along the given axis. 
Definition: Domi_MDMap.hpp:1078
 
Multi-dimensional map. 
Definition: Domi_MDMap.hpp:145
 
Memory-safe templated multi-dimensional array class. 
Definition: Domi_MDArray.hpp:65
 
dim_type getLocalDim(int axis, bool withPad=false) const 
Get the local dimension along the specified axis. 
 
int getUpperBndryPad(int axis) const 
Get the size of the upper boundary padding along the given axis. 
 
bool isPeriodic(int axis) const 
Return the periodic flag for the given axis. 
Definition: Domi_MDMap.hpp:1086
 
Layout getLayout() const 
Get the storage order. 
 
MDMap(const Teuchos::RCP< const MDComm > mdComm, const Teuchos::ArrayView< const dim_type > &dimensions, const Teuchos::ArrayView< const int > &commPad=Teuchos::ArrayView< const int >(), const Teuchos::ArrayView< const int > &bndryPad=Teuchos::ArrayView< const int >(), const Teuchos::ArrayView< const int > &replicatedBoundary=Teuchos::ArrayView< const int >(), const Layout layout=DEFAULT_ORDER)
Main constructor. 
 
Teuchos::ArrayView< const Slice > getLocalBounds() const 
Get the local loop bounds along every axis.