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"
75typedef typename Tpetra::Map<>::local_ordinal_type TpetraLOType;
76typedef typename Tpetra::Map<>::global_ordinal_type TpetraGOType;
77typedef typename Tpetra::Map<>::node_type TpetraNodeType;
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 >(),
192 Teuchos::ArrayView< const int >(),
193 const Layout layout = DEFAULT_ORDER);
221 Teuchos::ParameterList &
plist);
236 Teuchos::ParameterList &
plist);
269 const Teuchos::ArrayView< padding_type > &
padding =
270 Teuchos::ArrayView< padding_type >(),
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;
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 >
740 Teuchos::RCP< const Epetra_Map >
753 Teuchos::RCP< const Epetra_Map >
773 Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
791 Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
806 Teuchos::Array< dim_type >
813 Teuchos::Array< dim_type >
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;
1020 mutable Teuchos::Array< Teuchos::RCP< const Epetra_Map > >
_epetraAxisMaps;
1037Teuchos::RCP< const Teuchos::Comm< int > >
1040 return _mdComm->getTeuchosComm();
1045Teuchos::RCP< const MDComm >
1056 return _mdComm->onSubcommunicator();
1064 return _mdComm->numDims();
1069Teuchos::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);
1117Teuchos::Array< dim_type >
1137Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
1145 for (
int axis = 0; axis <
num_dims; ++axis)
1148 Teuchos::Array< LocalOrdinal > index(
num_dims);
1155 for (
int axis = 0; axis <
num_dims; ++axis)
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(),
1233template<
class LocalOrdinal,
1234 class GlobalOrdinal,
1236Teuchos::RCP< const Tpetra::Map< LocalOrdinal, GlobalOrdinal, Node > >
1238getTpetraAxisMap(
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(),
A Slice defines a subset of a container.
Memory-safe templated multi-dimensional array class.
Definition Domi_MDArray.hpp:287
const Teuchos::Array< T > & array() const
Return the underlying Teuchos::Array
Definition Domi_MDArray.hpp:1055
iterator end()
Return the ending iterator.
Definition Domi_MDArray.hpp:1082
iterator begin()
Return the beginning iterator.
Definition Domi_MDArray.hpp:1073
Iterator class suitable for multi-dimensional arrays.
Definition Domi_MDIterator.hpp:102
Multi-dimensional map.
Definition Domi_MDMap.hpp:146
bool isReplicatedBoundary(int axis) const
Return whether the given axis supports a replicated boundary.
dim_type getGlobalDim(int axis, bool withBndryPad=false) const
Get the global dimension along the specified axis.
dim_type getLocalDim(int axis, bool withPad=false) const
Get the local dimension along the specified axis.
MDMap(const Teuchos::RCP< const MDComm > mdComm, Teuchos::ParameterList &plist)
Constructor with MDComm and ParameterList.
int getUpperPadSize(int axis) const
Get the size of the upper padding along the given axis.
size_type getLocalID(const Teuchos::ArrayView< dim_type > &localIndex) const
Convert a local index to a local ID.
MDMap(const MDMap &parent, int axis, const Slice &slice, int bndryPad=0)
Parent/single slice sub-map constructor.
int numDims() const
Get the number of dimensions.
Definition Domi_MDMap.hpp:1062
int getLowerBndryPad(int axis) const
Get the size of the lower boundary padding along the given axis.
Teuchos::RCP< const MDComm > getMDComm() const
Access the underlying MDComm object.
Definition Domi_MDMap.hpp:1046
int getCommPadSize(int axis) const
Get the communication padding size along the given axis.
MDMap(const Teuchos::RCP< const MDComm > mdComm, const Teuchos::ArrayView< Slice > &myGlobalBounds, const Teuchos::ArrayView< padding_type > &padding=Teuchos::ArrayView< padding_type >(), const Teuchos::ArrayView< const int > &replicatedBoundary=Teuchos::ArrayView< const int >(), const Layout layout=DEFAULT_ORDER)
Constructor with global bounds for this processor.
Slice getLocalInteriorBounds(int axis) const
Get the local interior loop bounds along the specified axis.
Teuchos::ArrayView< Teuchos::RCP< const Domi::MDMap > > getAxisMaps() const
Return an array of axis maps.
int getUpperBndryPad(int axis) const
Get the size of the upper boundary padding along the given axis.
MDMap & operator=(const MDMap &source)
Assignment operator.
bool isContiguous() const
True if there are no stride gaps on any processor.
size_type getGlobalID(const Teuchos::ArrayView< dim_type > &globalIndex) const
convert a global index to a global ID
Teuchos::Array< dim_type > getGlobalIndex(size_type globalID) const
Convert a global ID to a global index.
bool isSameAs(const MDMap &mdMap, const int verbose=0) const
True if two MDMaps are "identical".
MDMap(const Teuchos::RCP< const Teuchos::Comm< int > > teuchosComm, Teuchos::ParameterList &plist)
Constructor with Teuchos::Comm and ParameterList.
Teuchos::RCP< const Domi::MDMap > getAxisMap(int axis) const
Return an axis map for the given axis.
int getBndryPadSize(int axis) const
Get the boundary padding size along the given axis.
Teuchos::Array< int > getCommDims() const
Get the communicator sizes along each axis.
Definition Domi_MDMap.hpp:1070
MDMap(const MDMap &parent, const Teuchos::ArrayView< Slice > &slices, const Teuchos::ArrayView< int > &bndryPad=Teuchos::ArrayView< int >())
Parent/array of slices sub-map constructor.
Teuchos::Array< int > getBndryPadSizes() const
Get the boundary padding sizes along each axis.
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.
Teuchos::Array< dim_type > getLocalDims() const
Get an array of the local dimensions, including padding.
Slice getGlobalRankBounds(int axis, bool withBndryPad=false) const
Get the global loop bounds along the specified axis.
Teuchos::Array< dim_type > getLocalIndex(size_type localID) const
Convert a local ID to a local index.
int getLowerNeighbor(int axis) const
Get the rank of the lower neighbor.
Definition Domi_MDMap.hpp:1102
bool isCompatible(const MDMap &mdMap) const
True if two MDMaps are "compatible".
MDMap(const MDMap &parent, int axis, dim_type index)
Parent/single global ordinal sub-map constructor.
bool isPeriodic(int axis) const
Return the periodic flag for the given axis.
Definition Domi_MDMap.hpp:1086
Teuchos::RCP< const Teuchos::Comm< int > > getTeuchosComm() const
Get the Teuchos communicator.
Definition Domi_MDMap.hpp:1038
Teuchos::ArrayView< const Slice > getLocalBounds() const
Get the local loop bounds along every axis.
int getCommIndex(int axis) const
Get the axis rank of this processor.
Definition Domi_MDMap.hpp:1094
size_type getLocalID(size_type globalID) const
Convert a global ID to a local ID.
int getUpperNeighbor(int axis) const
Get the rank of the upper neighbor.
Definition Domi_MDMap.hpp:1110
Slice getGlobalBounds(int axis, bool withBndryPad=false) const
Get the bounds of the global problem.
Layout getLayout() const
Get the storage order.
MDMap(Teuchos::ParameterList &plist)
Constructor with ParameterList.
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.
size_type getGlobalID(size_type localID) const
Convert a local ID to a global ID.
bool onSubcommunicator() const
Query whether this processor is on the sub-communicator.
Definition Domi_MDMap.hpp:1054
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
Teuchos::Array< dim_type > getGlobalDims() const
Get an array of the the global dimensions, including boundary padding.
Definition Domi_MDMap.hpp:1119
int getLowerPadSize(int axis) const
Get the size of the lower padding along the given axis.
MDMap(const MDMap &source)
Copy constructor.
Slice getLocalBounds(int axis, bool withPad=false) const
Get the local loop bounds along the specified axis.
A Slice contains a start, stop, and step index, describing a subset of an ordered container.
Definition Domi_Slice.hpp:138
const dim_type start() const
Start index.
Definition Domi_Slice.hpp:431