51 #ifdef HAVE_XPETRA_EPETRA 59 #define sumAll(rcpComm, in, out) \ 60 Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_SUM, in, Teuchos::outArg(out)); 61 #define minAll(rcpComm, in, out) \ 62 Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_MIN, in, Teuchos::outArg(out)); 63 #define maxAll(rcpComm, in, out) \ 64 Teuchos::reduceAll(*rcpComm, Teuchos::REDUCE_MAX, in, Teuchos::outArg(out)); 72 :
EpetraMap(numGlobalElements, indexBase, comm, lg, node),
StridedMap<int, int>(numGlobalElements, indexBase, stridingInfo, comm, stridedBlockId, offset)
75 global_size_t numGlobalNodes = Teuchos::OrdinalTraits<global_size_t>::invalid();
76 if(numGlobalElements != Teuchos::OrdinalTraits<global_size_t>::invalid())
80 RCP<Epetra_Map> nodeMap = Teuchos::null;
84 int nStridedOffset = 0;
86 if(stridedBlockId > -1) {
88 for(
int j=0; j<stridedBlockId; j++) {
89 nStridedOffset += stridingInfo[j];
91 nDofsPerNode = stridingInfo[stridedBlockId];
93 numGlobalElements = nodeMap->NumGlobalElements()*nDofsPerNode;
95 std::vector<int> dofgids;
96 for(
int i = 0; i<nodeMap->NumMyElements(); i++) {
97 int gid = nodeMap->GID(i);
98 for(
int dof = 0; dof < nDofsPerNode; ++dof) {
105 if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
111 TEUCHOS_TEST_FOR_EXCEPTION(
map_->NumMyPoints() % nDofsPerNode != 0,
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
112 if(stridedBlockId == -1) {
113 TEUCHOS_TEST_FOR_EXCEPTION(
getNodeNumElements() != Teuchos::as<size_t>(nodeMap->NumMyElements()*nDofsPerNode),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
114 TEUCHOS_TEST_FOR_EXCEPTION(
getGlobalNumElements() != Teuchos::as<size_t>(nodeMap->NumGlobalElements()*nDofsPerNode),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
116 TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() < Teuchos::as<size_t>(stridedBlockId),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: stridedBlockId > stridingInfo.size()");
117 int nDofsInStridedBlock = stridingInfo[stridedBlockId];
118 TEUCHOS_TEST_FOR_EXCEPTION(
getNodeNumElements() != Teuchos::as<size_t>(nodeMap->NumMyElements()*nDofsInStridedBlock),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
119 TEUCHOS_TEST_FOR_EXCEPTION(
getGlobalNumElements() != Teuchos::as<size_t>(nodeMap->NumGlobalElements()*nDofsInStridedBlock),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
126 std::vector<size_t>& stridingInfo,
const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
LocalOrdinal stridedBlockId,
GlobalOrdinal offset,
const Teuchos::RCP<Node> &node)
127 :
EpetraMap(numGlobalElements, numLocalElements, indexBase, comm, node),
StridedMap<int, int>(numGlobalElements, numLocalElements, indexBase, stridingInfo, comm, stridedBlockId, offset)
131 global_size_t numGlobalNodes = Teuchos::OrdinalTraits<global_size_t>::invalid();
132 if(numGlobalElements != Teuchos::OrdinalTraits<global_size_t>::invalid())
138 size_t numLocalNodes = numLocalElements / blockSize;
141 RCP<Epetra_Map> nodeMap = Teuchos::null;
145 int nStridedOffset = 0;
147 if(stridedBlockId > -1) {
149 for(
int j=0; j<stridedBlockId; j++) {
150 nStridedOffset += stridingInfo[j];
152 nDofsPerNode = stridingInfo[stridedBlockId];
154 numGlobalElements = nodeMap->NumGlobalElements()*nDofsPerNode;
156 std::vector<int> dofgids;
157 for(
int i = 0; i<nodeMap->NumMyElements(); i++) {
158 int gid = nodeMap->GID(i);
159 for(
int dof = 0; dof < nDofsPerNode; ++dof) {
166 if (numGlobalElements == Teuchos::OrdinalTraits<global_size_t>::invalid()) {
172 TEUCHOS_TEST_FOR_EXCEPTION(
map_->NumMyPoints() % nDofsPerNode != 0,
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
173 if(stridedBlockId == -1) {
174 TEUCHOS_TEST_FOR_EXCEPTION(
getNodeNumElements() != Teuchos::as<size_t>(nodeMap->NumMyElements()*nDofsPerNode),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
175 TEUCHOS_TEST_FOR_EXCEPTION(
getGlobalNumElements() != Teuchos::as<size_t>(nodeMap->NumGlobalElements()*nDofsPerNode),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
177 TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() < Teuchos::as<size_t>(stridedBlockId),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: stridedBlockId > stridingInfo.size()");
178 int nDofsInStridedBlock = stridingInfo[stridedBlockId];
179 TEUCHOS_TEST_FOR_EXCEPTION(
getNodeNumElements() != Teuchos::as<size_t>(nodeMap->NumMyElements()*nDofsInStridedBlock),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
180 TEUCHOS_TEST_FOR_EXCEPTION(
getGlobalNumElements() != Teuchos::as<size_t>(nodeMap->NumGlobalElements()*nDofsInStridedBlock),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
188 std::vector<size_t>& stridingInfo,
const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
LocalOrdinal stridedBlockId,
const Teuchos::RCP<Node> &node)
189 :
EpetraMap(numGlobalElements, elementList, indexBase, comm, node),
Xpetra::
StridedMap<int,int>(numGlobalElements, elementList, indexBase, stridingInfo, comm, stridedBlockId)
192 if(stridedBlockId != -1) {
193 TEUCHOS_TEST_FOR_EXCEPTION(stridingInfo.size() < Teuchos::as<size_t>(stridedBlockId),
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: stridedBlockId > stridingInfo.size()");
194 nDofsPerNode = Teuchos::as<int>(stridingInfo[stridedBlockId]);
196 TEUCHOS_TEST_FOR_EXCEPTION(
map_->NumMyPoints() % nDofsPerNode != 0,
Exceptions::RuntimeError,
"StridedEpetraMap::StridedEpetraMap: wrong distribution of dofs among processors.");
207 std::ostringstream oss;
224 using Teuchos::VERB_DEFAULT;
225 using Teuchos::VERB_NONE;
226 using Teuchos::VERB_LOW;
227 using Teuchos::VERB_MEDIUM;
228 using Teuchos::VERB_HIGH;
229 using Teuchos::VERB_EXTREME;
233 int myImageID = comm_->getRank();
234 int numImages = comm_->getSize();
236 Teuchos::EVerbosityLevel vl = verbLevel;
237 if (vl == VERB_DEFAULT) vl = VERB_LOW;
243 width = std::max<size_t>(width,12) + 2;
245 Teuchos::OSTab tab(out);
247 if (vl == VERB_NONE) {
250 else if (vl == VERB_LOW) {
254 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
255 if (myImageID == imageCtr) {
256 if (myImageID == 0) {
264 if (vl == VERB_HIGH || vl == VERB_EXTREME) {
265 out <<
"Number of Local Elements = " << nME << endl
270 if (vl == VERB_EXTREME) {
271 out << std::setw(width) <<
"Node ID" 272 << std::setw(width) <<
"Local Index" 273 << std::setw(width) <<
"Global Index" 275 for (
size_t i=0; i < nME; i++) {
276 out << std::setw(width) << myImageID
277 << std::setw(width) << i
278 << std::setw(width) << myEntries[i]
std::string description() const
Return a simple one-line description of this object.
bool isContiguous() const
True if this Map is distributed contiguously, else false.
#define IF_EPETRA_EXCEPTION_THEN_THROW_GLOBAL_INVALID_ARG(sourceCode)
GlobalOrdinal getMaxAllGlobalIndex() const
The maximum global index over all processes in the communicator.
Exception throws to report errors in the internal logical of the program.
Teuchos::ArrayView< const GlobalOrdinal > getNodeElementList() const
Return a view of the global indices owned by this node.
RCP< const Epetra_BlockMap > map_
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, int > > &graph)
size_t getNodeNumElements() const
Returns the number of elements belonging to the calling node.
size_t getNodeNumElements() const
The number of elements belonging to the calling node.
GlobalOrdinal getMinGlobalIndex() const
The minimum global index owned by the calling process.
global_size_t getGlobalNumElements() const
Returns the number of elements in this Map.
std::string description() const
Return a simple one-line description of this object.
size_t getFixedBlockSize() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to a FancyOStream object.
int offset_
offset for gids in map (default = 0)
size_t global_size_t
Global size_t object.
const Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Get this Map's Comm object.
bool isDistributed() const
Whether this Map is globally distributed or locally replicated.
global_size_t getGlobalNumElements() const
The number of elements in this Map.
StridedEpetraMap(global_size_t numGlobalElements, GlobalOrdinal indexBase, std::vector< size_t > &stridingInfo, const Teuchos::RCP< const Teuchos::Comm< int > > &comm, LocalOrdinal stridedBlockId=-1, GlobalOrdinal offset=0, LocalGlobal lg=GloballyDistributed, const Teuchos::RCP< Node > &node=Kokkos::DefaultNode::getDefaultNode())
Map constructor with Tpetra-defined contiguous uniform distribution. The elements are distributed amo...
GlobalOrdinal getMaxGlobalIndex() const
The maximum global index owned by the calling process.
GlobalOrdinal getMinAllGlobalIndex() const
The minimum global index over all processes in the communicator.
GlobalOrdinal getIndexBase() const
The index base for this Map.
Class that stores a strided map.