Peano 4
Loading...
Searching...
No Matches
ParticleSet.cpph
Go to the documentation of this file.
4
5
6template <typename T>
8
9template <typename T>
10tarch::logging::Log toolbox::particles::ParticleSet<T>::_log("toolbox::particles::ParticleSet");
11
12template <typename T>
14
15template <typename T>
17
18template <typename T>
20
21template <typename T>
23
24template <typename T>
26
27template <typename T>
29
30template <typename T>
32
33template <typename T>
35
36template <typename T>
38
39template <typename T>
41
42template <typename T>
44
45template <typename T>
47
48template <typename T>
50
51template <typename T>
53
54template <typename T>
56
57
58
59#if PeanoDebug >= 1
60template <typename T>
62 _debugX = data;
63}
64
65
66template <typename T>
68 _debugH = data;
69}
70
71
72template <typename T>
74 return _debugX;
75}
76
77
78template <typename T>
80 return _debugH;
81}
82#endif
83
84
85template <typename T>
87 _numberOfLifts = 0;
88 _numberOfDrops = 0;
89 _numberOfLiftsIntoSieveSet = 0;
90 _numberOfDropsFromSieveSet = 0;
91 _numberOfReassignments = 0;
92}
93
94
95template <typename T>
97 _numberOfRemainingLocalParticles = 0;
98 _numberOfExpiredHaloParticles = 0;
99 _numberOfParticlesThatHaveLeftTheirDomain = 0;
100
101 _numberOfDroppedIncomingVirtualParticles = 0;
102 _numberOfRedundantlySharedLocalParticles = 0;
103 _numberOfReplacedVirtualParticlesAlongBoundary = 0;
104 _numberOfReplacedVirtualParticlesAlongBoundary = 0;
105
106 _numberOfAddedLocalParticlesAlongBoundary = 0;
107 _numberOfAddedVirtualParticlesAlongBoundary = 0;
108}
109
110
111template <typename T>
113 std::ostringstream msg;
114 msg << "#remaining=" << _numberOfRemainingLocalParticles
115 << ", #expired halo=" << _numberOfExpiredHaloParticles
116 << ", #left=" << _numberOfParticlesThatHaveLeftTheirDomain
117 << ", #dropped virtual copy from neighbour=" << _numberOfDroppedIncomingVirtualParticles
118 << ", #redundantly owned=" << _numberOfRedundantlySharedLocalParticles
119 << ", #replaced virtual=" << _numberOfReplacedVirtualParticlesAlongBoundary
120 << ", #added local (inflying)=" << _numberOfAddedLocalParticlesAlongBoundary
121 << ", #added virtual=" << _numberOfAddedVirtualParticlesAlongBoundary
122 << " (subdomain-local state updates due to UpdateParallelState (3x) vs boundary merges prior to each mesh sweep (5x))";
123 return msg.str();
124}
125
126
127template <typename T>
129 #if Parallel
130 const int localNumberOfRemainingLocalParticles = _numberOfRemainingLocalParticles;
131 const int localNumberOfExpiredHaloParticles = _numberOfExpiredHaloParticles;
132 const int localNumberOfParticlesThatHaveLeftTheirDomain = _numberOfParticlesThatHaveLeftTheirDomain;
133
135 .reduce(&localNumberOfRemainingLocalParticles, &_numberOfRemainingLocalParticles, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
137 });
139 .reduce(&localNumberOfExpiredHaloParticles, &_numberOfExpiredHaloParticles, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
141 });
143 .reduce(&localNumberOfParticlesThatHaveLeftTheirDomain, &_numberOfParticlesThatHaveLeftTheirDomain, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
145 });
146
147 const int localNumberOfDroppedIncomingVirtualParticles = _numberOfDroppedIncomingVirtualParticles;
148 const int localNumberOfRedundantlySharedLocalParticles = _numberOfRedundantlySharedLocalParticles;
149 const int localNumberOfReplacedVirtualParticlesAlongBoundary = _numberOfReplacedVirtualParticlesAlongBoundary;
150 const int localNumberOfAddedLocalParticlesAlongBoundary = _numberOfAddedLocalParticlesAlongBoundary;
151 const int localNumberOfAddedVirtualParticlesAlongBoundary = _numberOfAddedVirtualParticlesAlongBoundary;
152
154 .reduce(&localNumberOfDroppedIncomingVirtualParticles, &_numberOfDroppedIncomingVirtualParticles, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
156 });
158 .reduce(&localNumberOfRedundantlySharedLocalParticles, &_numberOfRedundantlySharedLocalParticles, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
160 });
162 .reduce(&localNumberOfReplacedVirtualParticlesAlongBoundary, &_numberOfReplacedVirtualParticlesAlongBoundary, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
164 });
166 .reduce(&localNumberOfAddedLocalParticlesAlongBoundary, &_numberOfAddedLocalParticlesAlongBoundary, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
168 });
170 .reduce(&localNumberOfAddedVirtualParticlesAlongBoundary, &_numberOfAddedVirtualParticlesAlongBoundary, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
172 });
173 #endif
174}
175
176
177template <typename T>
179 std::ostringstream msg;
180 msg << "sort statistics"
181 << ": #lifts=" << _numberOfLifts
182 << ", #drops=" << _numberOfDrops
183 << ", #lifts-into-sieve-set=" << _numberOfLiftsIntoSieveSet
184 << ", #drops-from-sieve-set=" << _numberOfDropsFromSieveSet
185 << ", #drops-into-horizontal-tree-decomposition=" << _numberOfDropsIntoHorizontalTreeDecomposition
186 << ", #reassignments=" << _numberOfReassignments;
187 return msg.str();
188}
189
190template <typename T>
192#if Parallel
193 int localNumberOfLifts = _numberOfLifts;
194 int localNumberOfDrops = _numberOfDrops;
195 int localNumberOfLiftsIntoSieveSet = _numberOfLiftsIntoSieveSet;
196 int localNumberOfDropsFromSieveSet = _numberOfDropsFromSieveSet;
197 int localNumberOfDropsIntoHorizontalTreeDecomposition =_numberOfDropsIntoHorizontalTreeDecomposition;
198 int localNumberOfReassignments = _numberOfReassignments;
199
200 tarch::mpi::Rank::getInstance().reduce(&localNumberOfLifts, &_numberOfLifts, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
202 });
203 tarch::mpi::Rank::getInstance().reduce(&localNumberOfDrops, &_numberOfDrops, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
205 });
207 .reduce(&localNumberOfLiftsIntoSieveSet, &_numberOfLiftsIntoSieveSet, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
209 });
211 .reduce(&localNumberOfDropsFromSieveSet, &_numberOfDropsFromSieveSet, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
213 });
215 .reduce(&localNumberOfDropsIntoHorizontalTreeDecomposition, &_numberOfDropsIntoHorizontalTreeDecomposition, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
217 });
219 .reduce(&localNumberOfReassignments, &_numberOfReassignments, 1, MPI_INT, MPI_SUM, tarch::mpi::Rank::getGlobalMasterRank(), [&]() -> void {
221 });
222 #endif
223}
224
225
226template <typename T>
228 int numberOfLiftsInThisTree,
229 int numberOfDropsInThisTree,
230 int numberOfReassignmentsInThisTree,
231 int numberOfLiftsIntoSieveSetInThisTree,
232 int numberOfDropsFromSieveSetInThisTree,
233 int numberOfDropsIntoHorizontalTreeDecomposition
234) {
235 tarch::multicore::Lock lock(_statisticsSemaphore);
236 _numberOfLifts += numberOfLiftsInThisTree;
237 _numberOfDrops += numberOfDropsInThisTree;
238 _numberOfReassignments += numberOfReassignmentsInThisTree;
239 _numberOfLiftsIntoSieveSet += numberOfLiftsIntoSieveSetInThisTree;
240 _numberOfDropsFromSieveSet += numberOfDropsFromSieveSetInThisTree;
241 _numberOfDropsIntoHorizontalTreeDecomposition += numberOfDropsIntoHorizontalTreeDecomposition;
242}
243
244
245template <typename T>
247 int numberOfRemainingLocalParticles,
248 int numberOfExpiredHaloParticles,
249 int numberOfParticlesThatHaveLeftTheirDomain
250) {
251 tarch::multicore::Lock lock(_statisticsSemaphore);
252 _numberOfRemainingLocalParticles += numberOfRemainingLocalParticles;
253 _numberOfExpiredHaloParticles += numberOfExpiredHaloParticles;
254 _numberOfParticlesThatHaveLeftTheirDomain += numberOfParticlesThatHaveLeftTheirDomain;
255}
256
257
258template <typename T>
260 return _numberOfDropsIntoHorizontalTreeDecomposition;
261}
262
263
264template <typename T>
266 return _numberOfLifts
267 + _numberOfDrops
268 +_numberOfReassignments
269 + _numberOfLiftsIntoSieveSet
270 + _numberOfDropsFromSieveSet
271 + _numberOfDropsIntoHorizontalTreeDecomposition > 0;
272}
273
274
275#ifdef Parallel
276template <typename T>
278 T::initDatatype();
279}
280
281
282template <typename T>
284 T::shutdownDatatype();
285}
286#endif
287
288
289template <typename T>
291 _sieveParticles.exchangeSieveListsGlobally();
292}
293
294
295template <typename T>
298 bool removeReturnedParticlesFromSet,
299 bool onlyReturnParticlesThatWillBeLocal
300) {
301 return _sieveParticles.getParticlesToBeSievedIntoVertex(marker, removeReturnedParticlesFromSet, onlyReturnParticlesThatWillBeLocal);
302}
303
304
305template <typename T>
307 return _sieveParticles.hasParticlesToBeSievedIntoVertices();
308}
309
310
311template <typename T>
313 return _sieveParticles.getNumberOfParticlesThatHaveBeSievedIntoVertices();
314}
315
316
317template <typename T>
318std::string toolbox::particles::ParticleSet<T>::toString(bool addBrackets) const {
319 std::ostringstream msg;
320 if (addBrackets)
321 msg << "(";
322
323 msg
324 << "#lifts=" << _numberOfLifts << ", #drops=" << _numberOfDrops << ", #assignments=" << _numberOfReassignments << ", #lifts-into-sieve-set=" << _numberOfLiftsIntoSieveSet
325 << ", #drops-from-sieve-set=" << _numberOfDropsFromSieveSet << ", #remaining-particles=" << _numberOfRemainingLocalParticles;
326
327#if PeanoDebug >= 1
328 msg << ",x=" << _debugX << ",h=" << _debugH;
329#endif
330
331 if (addBrackets)
332 msg << ")";
333 return msg.str();
334}
335
336
337template <typename T>
339 return _numberOfRemainingLocalParticles;
340}
Log Device.
Definition Log.h:516
static int getGlobalMasterRank()
Get the global master.
Definition Rank.cpp:414
void reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, std::function< void()> waitor=[]() -> void {})
Definition Rank.cpp:313
static Rank & getInstance()
This operation returns the singleton instance.
Definition Rank.cpp:538
Create a lock around a boolean semaphore region.
Definition Lock.h:19
virtual void receiveDanglingMessages() override
Answer to MPI Messages.
static ServiceRepository & getInstance()
Abstract base class for all flavours of particle sets.
Definition ParticleSet.h:52
static void reduceParticleStateStatistics()
Reduces and prints the global statistics.
static int getNumberOfDropsIntoHorizontalTreeDecomposition()
Return number of drops into cuts recorded.
static ParticleList getParticlesToBeSievedIntoVertex(const peano4::datamanagement::VertexMarker &marker, bool removeReturnedParticlesFromSet, bool onlyReturnParticlesThatWillBeLocal)
Make routine from SieveParticles public.
static std::string printParticleStateStatistics()
static bool hasParticlesToBeSievedIntoVertices()
Make routine from SieveParticles public.
static void clearParticleStateStatistics()
Clear stats.
static tarch::logging::Log _log
std::string toString(bool addBrackets=true) const
static bool registeredAnyResorting()
Returns true if there have been any lifts, drops, reassignments, ...
static void updateLiftDropStatistics(int numberOfLiftsInThisTree, int numberOfDropsInThisTree, int numberOfReassignmentsInThisTree, int numberOfLiftsIntoSieveSetInThisTree, int numberOfDropsFromSieveSetInThisTree, int numberOfDropsIntoHorizontalTreeDecomposition)
static int getNumberOfRemainingLocalParticles()
Return global sum of the particles that did remain within their partition at a time.
static int getNumberOfParticlesThatHaveBeSievedIntoVertices()
Return total number of particles to be sieved.
static void finishedTraversal()
Invoke exchangeSieveListsGlobally().
static void updateNumberOfLocalAndExpiredParticles(int numberOfRemainingLocalParticles, int numberOfExpiredHaloParticles, int numberOfParticlesThatHaveLeftTheirDomain)
static void clearReassignmentStatistics()
Clear stats of all counters that have to do with resorting.
static std::string printReassignmentStatistics()
Utility class for all flavours of particle sets.
Vertex marker to provide information about selected vertex.
Simple vector class.
Definition Vector.h:134