Peano
Loading...
Searching...
No Matches
GridVertex.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include <string>
6
7#ifdef Parallel
8#include <functional>
9#include <mpi.h>
10#endif
11
15#include "tarch/la/Vector.h"
16#include "tarch/mpi/Rank.h"
18
19namespace peano4 {
20 namespace grid {
21 struct GridVertex;
22 } // namespace grid
23} // namespace peano4
24
26public:
27 enum class State : int {
28 HangingVertex = 0,
29 New = 1,
30 Unrefined = 2,
31 Refined = 3,
33 Refining = 5,
35 Erasing = 7,
36 Delete = 8
37 };
38
41 State __state,
43 tarch::la::Vector<TwoPowerD, int> __backupOfAdjacentRanks,
44 bool __hasBeenAntecessorOfRefinedVertexInPreviousTreeSweep,
45 bool __isAntecessorOfRefinedVertexInCurrentTreeSweep,
46 bool __hasBeenParentOfSubtreeVertexInPreviousTreeSweep,
47 bool __isParentOfSubtreeVertexInCurrentTreeSweep,
48 int __numberOfAdjacentRefinedLocalCells,
50 int __level
51 );
52
54 void setState(State value);
57 int getAdjacentRanks(int index) const;
58 void setAdjacentRanks(int index, int value);
61 int getBackupOfAdjacentRanks(int index) const;
62 void setBackupOfAdjacentRanks(int index, int value);
73#if PeanoDebug > 0
76 double getX(int index) const;
77 void setX(int index, double value);
78#endif
79 int getLevel() const;
80 void setLevel(int value);
81 GridVertex(const GridVertex& copy);
82 GridVertex& operator=(const GridVertex& other);
83
84#ifdef Parallel
90 [[clang::map_mpi_datatype]]
91 static MPI_Datatype getForkDatatype();
92
93 [[clang::map_mpi_datatype]]
94 static MPI_Datatype getJoinDatatype();
95
96 [[clang::map_mpi_datatype]]
97 static MPI_Datatype getBoundaryExchangeDatatype();
98
99 [[clang::map_mpi_datatype]]
100 static MPI_Datatype getMultiscaleDataExchangeDatatype();
101
102 [[clang::map_mpi_datatype]]
103 static MPI_Datatype getGlobalCommunciationDatatype();
104
105 [[clang::map_mpi_datatype]]
106 static void freeForkDatatype();
107
108 [[clang::map_mpi_datatype]]
109 static void freeJoinDatatype();
110
111 [[clang::map_mpi_datatype]]
112 static void freeBoundaryExchangeDatatype();
113
114 [[clang::map_mpi_datatype]]
116
117 [[clang::map_mpi_datatype]]
119
124 int
125 getSenderRank() const;
126
131 static void initDatatype();
132
136 static void shutdownDatatype();
137
146 static void send(const peano4::grid::GridVertex& buffer, int destination, int tag, MPI_Comm communicator);
147 static void receive(peano4::grid::GridVertex& buffer, int source, int tag, MPI_Comm communicator);
148
155 static void send(
156 const peano4::grid::GridVertex& buffer,
157 int destination,
158 int tag,
159 std::function<void()> startCommunicationFunctor,
160 std::function<void()> waitFunctor,
161 MPI_Comm communicator
162 );
163 static void receive(
165 int source,
166 int tag,
167 std::function<void()> startCommunicationFunctor,
168 std::function<void()> waitFunctor,
169 MPI_Comm communicator
170 );
171#endif
172
174
177
178#ifdef Parallel
179 static void sendAndPollDanglingMessages(
180 const peano4::grid::GridVertex& message,
181 int destination,
182 int tag,
183 MPI_Comm communicator = tarch::mpi::Rank::getInstance().getCommunicator()
184 );
187 int source,
188 int tag,
189 MPI_Comm communicator = tarch::mpi::Rank::getInstance().getCommunicator()
190 );
191#endif
192
193 std::string toString() const;
194
195private:
196 [[clang::pack]] State _state;
197#if defined(__PACKED_ATTRIBUTES_LANGUAGE_EXTENSION__)
198 [[clang::pack_range(-1, std::numeric_limits<int>::max())]] int _adjacentRanks[TwoPowerD];
199#endif
200#if !defined(__PACKED_ATTRIBUTES_LANGUAGE_EXTENSION__)
202#endif
208 [[clang::pack_range(0, TwoPowerD)]] int _numberOfAdjacentRefinedLocalCells;
209#if PeanoDebug > 0
210#if defined(__PACKED_ATTRIBUTES_LANGUAGE_EXTENSION__)
211 [[clang::truncate_mantissa(48)]] double _x[Dimensions];
212#endif
213#if !defined(__PACKED_ATTRIBUTES_LANGUAGE_EXTENSION__)
215#endif
216#endif
217
219
220#ifdef Parallel
221private:
223
224#if !defined(__MPI_ATTRIBUTES_LANGUAGE_EXTENSION__)
231 static MPI_Datatype Datatype;
232#endif
233#endif
234};
#define TwoPowerD
Definition Globals.h:19
state setX(0.0)
static Rank & getInstance()
This operation returns the singleton instance.
Definition Rank.cpp:539
bool getIsParentOfSubtreeVertexInCurrentTreeSweep() const
tarch::la::Vector< TwoPowerD, int > getAdjacentRanks() const
static MPI_Datatype getJoinDatatype()
tarch::la::Vector< TwoPowerD, int > _backupOfAdjacentRanks
Definition GridVertex.h:203
int getNumberOfAdjacentRefinedLocalCells() const
static MPI_Datatype Datatype
Whenever we use LLVM's MPI extension (DaStGe), we rely on lazy initialisation of the datatype.
Definition GridVertex.h:231
static void freeMultiscaleDataExchangeDatatype()
static void freeBoundaryExchangeDatatype()
void setBackupOfAdjacentRanks(const tarch::la::Vector< TwoPowerD, int > &value)
void setIsAntecessorOfRefinedVertexInCurrentTreeSweep(bool value)
static MPI_Datatype getForkDatatype()
Hands out MPI datatype if we work without the LLVM MPI extension.
static MPI_Datatype getBoundaryExchangeDatatype()
bool _hasBeenParentOfSubtreeVertexInPreviousTreeSweep
Definition GridVertex.h:206
bool getHasBeenAntecessorOfRefinedVertexInPreviousTreeSweep() const
static void freeJoinDatatype()
static void freeForkDatatype()
static MPI_Datatype getMultiscaleDataExchangeDatatype()
GridVertex(ObjectConstruction)
Definition GridVertex.h:175
static MPI_Datatype getGlobalCommunciationDatatype()
tarch::la::Vector< TwoPowerD, int > getBackupOfAdjacentRanks() const
static void receiveAndPollDanglingMessages(peano4::grid::GridVertex &message, int source, int tag, MPI_Comm communicator=tarch::mpi::Rank::getInstance().getCommunicator())
static void shutdownDatatype()
Free the underlying MPI datatype.
void setLevel(int value)
static void receive(peano4::grid::GridVertex &buffer, int source, int tag, MPI_Comm communicator)
static void sendAndPollDanglingMessages(const peano4::grid::GridVertex &message, int destination, int tag, MPI_Comm communicator=tarch::mpi::Rank::getInstance().getCommunicator())
bool _isParentOfSubtreeVertexInCurrentTreeSweep
Definition GridVertex.h:207
bool _hasBeenAntecessorOfRefinedVertexInPreviousTreeSweep
Definition GridVertex.h:204
bool _isAntecessorOfRefinedVertexInCurrentTreeSweep
Definition GridVertex.h:205
void setNumberOfAdjacentRefinedLocalCells(int value)
void setIsParentOfSubtreeVertexInCurrentTreeSweep(bool value)
std::string toString() const
tarch::la::Vector< TwoPowerD, int > _adjacentRanks
Definition GridVertex.h:201
static void send(const peano4::grid::GridVertex &buffer, int destination, int tag, MPI_Comm communicator)
In DaStGen (the first version), I had a non-static version of the send as well as the receive.
bool getIsAntecessorOfRefinedVertexInCurrentTreeSweep() const
void setHasBeenParentOfSubtreeVertexInPreviousTreeSweep(bool value)
GridVertex & operator=(const GridVertex &other)
void setHasBeenAntecessorOfRefinedVertexInPreviousTreeSweep(bool value)
void setState(State value)
void setAdjacentRanks(const tarch::la::Vector< TwoPowerD, int > &value)
bool getHasBeenParentOfSubtreeVertexInPreviousTreeSweep() const
peano4::grid::GridVertex::State getState() const
static void freeGlobalCommunciationDatatype()
static void initDatatype()
Wrapper around getDatatype() to trigger lazy evaluation if we use the lazy initialisation.
Simple vector class.
Definition Vector.h:134