ParticleStorage.h 57.3 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//======================================================================================================================
//
//  This file is part of waLBerla. waLBerla is free software: you can
//  redistribute it and/or modify it under the terms of the GNU General Public
//  License as published by the Free Software Foundation, either version 3 of
//  the License, or (at your option) any later version.
//
//  waLBerla is distributed in the hope that it will be useful, but WITHOUT
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
//  for more details.
//
//  You should have received a copy of the GNU General Public License along
//  with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file ParticleStorage.h
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================

//======================================================================================================================
//
//  THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================

#pragma once

#include <atomic>
#include <limits>
#include <map>
#include <type_traits>
#include <unordered_map>
Sebastian Eibl's avatar
Sebastian Eibl committed
34
#include <unordered_set>
35
36
37
38
39
40
#include <vector>

#include <mesa_pd/data/ContactHistory.h>
#include <mesa_pd/data/DataTypes.h>
#include <mesa_pd/data/IAccessor.h>
#include <mesa_pd/data/Flags.h>
Sebastian Eibl's avatar
Sebastian Eibl committed
41
#include <blockforest/BlockForest.h>
42
43
44
45
46
#include <mesa_pd/data/STLOverloads.h>

#include <core/Abort.h>
#include <core/debug/Debug.h>
#include <core/math/AABB.h>
Sebastian Eibl's avatar
Sebastian Eibl committed
47
#include <core/mpi/MPIWrapper.h>
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <core/OpenMP.h>
#include <core/STLIO.h>
#include <core/UniqueID.h>

namespace walberla {
namespace mesa_pd {
namespace data {

class ParticleStorage;

class ParticleStorage
{
public:
   class Particle
   {
   public:
      constexpr Particle(ParticleStorage& storage, const size_t i) : storage_(storage), i_(i) {}
      constexpr Particle(const Particle&)  = default;
      constexpr Particle(Particle&&)  = default;

      Particle& operator=(const Particle& rhs);
      Particle& operator=(Particle&& rhs);

      Particle* operator->(){return this;}

      
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
      using uid_type = walberla::id_t;
      using position_type = walberla::mesa_pd::Vec3;
      using interactionRadius_type = walberla::real_t;
      using flags_type = walberla::mesa_pd::data::particle_flags::FlagT;
      using owner_type = int;
      using ghostOwners_type = std::unordered_set<walberla::mpi::MPIRank>;
      using shapeID_type = size_t;
      using rotation_type = walberla::mesa_pd::Rot3;
      using angularVelocity_type = walberla::mesa_pd::Vec3;
      using torque_type = walberla::mesa_pd::Vec3;
      using linearVelocity_type = walberla::mesa_pd::Vec3;
      using invMass_type = walberla::real_t;
      using force_type = walberla::mesa_pd::Vec3;
      using oldForce_type = walberla::mesa_pd::Vec3;
      using oldTorque_type = walberla::mesa_pd::Vec3;
Sebastian Eibl's avatar
Sebastian Eibl committed
89
      using currentBlock_type = blockforest::Block*;
90
91
92
93
94
95
96
97
98
99
100
      using type_type = uint_t;
      using nextParticle_type = int;
      using oldContactHistory_type = std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>;
      using newContactHistory_type = std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>;
      using temperature_type = walberla::real_t;
      using heatFlux_type = walberla::real_t;
      using dv_type = walberla::mesa_pd::Vec3;
      using dw_type = walberla::mesa_pd::Vec3;
      using neighborState_type = std::unordered_set<walberla::mpi::MPIRank>;

      
Sebastian Eibl's avatar
Sebastian Eibl committed
101
      uid_type const & getUid() const {return storage_.getUid(i_);}
102
      uid_type& getUidRef() {return storage_.getUidRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
103
      void setUid(uid_type const & v) { storage_.setUid(i_, v);}
104
      
Sebastian Eibl's avatar
Sebastian Eibl committed
105
      position_type const & getPosition() const {return storage_.getPosition(i_);}
106
      position_type& getPositionRef() {return storage_.getPositionRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
107
      void setPosition(position_type const & v) { storage_.setPosition(i_, v);}
108
      
Sebastian Eibl's avatar
Sebastian Eibl committed
109
      interactionRadius_type const & getInteractionRadius() const {return storage_.getInteractionRadius(i_);}
110
      interactionRadius_type& getInteractionRadiusRef() {return storage_.getInteractionRadiusRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
111
      void setInteractionRadius(interactionRadius_type const & v) { storage_.setInteractionRadius(i_, v);}
112
      
Sebastian Eibl's avatar
Sebastian Eibl committed
113
      flags_type const & getFlags() const {return storage_.getFlags(i_);}
114
      flags_type& getFlagsRef() {return storage_.getFlagsRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
115
      void setFlags(flags_type const & v) { storage_.setFlags(i_, v);}
116
      
Sebastian Eibl's avatar
Sebastian Eibl committed
117
      owner_type const & getOwner() const {return storage_.getOwner(i_);}
118
      owner_type& getOwnerRef() {return storage_.getOwnerRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
119
      void setOwner(owner_type const & v) { storage_.setOwner(i_, v);}
120
      
Sebastian Eibl's avatar
Sebastian Eibl committed
121
      ghostOwners_type const & getGhostOwners() const {return storage_.getGhostOwners(i_);}
122
      ghostOwners_type& getGhostOwnersRef() {return storage_.getGhostOwnersRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
123
      void setGhostOwners(ghostOwners_type const & v) { storage_.setGhostOwners(i_, v);}
124
      
Sebastian Eibl's avatar
Sebastian Eibl committed
125
      shapeID_type const & getShapeID() const {return storage_.getShapeID(i_);}
126
      shapeID_type& getShapeIDRef() {return storage_.getShapeIDRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
127
      void setShapeID(shapeID_type const & v) { storage_.setShapeID(i_, v);}
128
      
Sebastian Eibl's avatar
Sebastian Eibl committed
129
      rotation_type const & getRotation() const {return storage_.getRotation(i_);}
130
      rotation_type& getRotationRef() {return storage_.getRotationRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
131
      void setRotation(rotation_type const & v) { storage_.setRotation(i_, v);}
132
      
Sebastian Eibl's avatar
Sebastian Eibl committed
133
      angularVelocity_type const & getAngularVelocity() const {return storage_.getAngularVelocity(i_);}
134
      angularVelocity_type& getAngularVelocityRef() {return storage_.getAngularVelocityRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
135
      void setAngularVelocity(angularVelocity_type const & v) { storage_.setAngularVelocity(i_, v);}
136
      
Sebastian Eibl's avatar
Sebastian Eibl committed
137
      torque_type const & getTorque() const {return storage_.getTorque(i_);}
138
      torque_type& getTorqueRef() {return storage_.getTorqueRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
139
      void setTorque(torque_type const & v) { storage_.setTorque(i_, v);}
140
      
Sebastian Eibl's avatar
Sebastian Eibl committed
141
      linearVelocity_type const & getLinearVelocity() const {return storage_.getLinearVelocity(i_);}
142
      linearVelocity_type& getLinearVelocityRef() {return storage_.getLinearVelocityRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
143
      void setLinearVelocity(linearVelocity_type const & v) { storage_.setLinearVelocity(i_, v);}
144
      
Sebastian Eibl's avatar
Sebastian Eibl committed
145
      invMass_type const & getInvMass() const {return storage_.getInvMass(i_);}
146
      invMass_type& getInvMassRef() {return storage_.getInvMassRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
147
      void setInvMass(invMass_type const & v) { storage_.setInvMass(i_, v);}
148
      
Sebastian Eibl's avatar
Sebastian Eibl committed
149
      force_type const & getForce() const {return storage_.getForce(i_);}
150
      force_type& getForceRef() {return storage_.getForceRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
151
      void setForce(force_type const & v) { storage_.setForce(i_, v);}
152
      
Sebastian Eibl's avatar
Sebastian Eibl committed
153
      oldForce_type const & getOldForce() const {return storage_.getOldForce(i_);}
154
      oldForce_type& getOldForceRef() {return storage_.getOldForceRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
155
      void setOldForce(oldForce_type const & v) { storage_.setOldForce(i_, v);}
156
      
Sebastian Eibl's avatar
Sebastian Eibl committed
157
      oldTorque_type const & getOldTorque() const {return storage_.getOldTorque(i_);}
158
      oldTorque_type& getOldTorqueRef() {return storage_.getOldTorqueRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
159
      void setOldTorque(oldTorque_type const & v) { storage_.setOldTorque(i_, v);}
160
      
Sebastian Eibl's avatar
Sebastian Eibl committed
161
162
163
164
165
      currentBlock_type const & getCurrentBlock() const {return storage_.getCurrentBlock(i_);}
      currentBlock_type& getCurrentBlockRef() {return storage_.getCurrentBlockRef(i_);}
      void setCurrentBlock(currentBlock_type const & v) { storage_.setCurrentBlock(i_, v);}
      
      type_type const & getType() const {return storage_.getType(i_);}
166
      type_type& getTypeRef() {return storage_.getTypeRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
167
      void setType(type_type const & v) { storage_.setType(i_, v);}
168
      
Sebastian Eibl's avatar
Sebastian Eibl committed
169
      nextParticle_type const & getNextParticle() const {return storage_.getNextParticle(i_);}
170
      nextParticle_type& getNextParticleRef() {return storage_.getNextParticleRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
171
      void setNextParticle(nextParticle_type const & v) { storage_.setNextParticle(i_, v);}
172
      
Sebastian Eibl's avatar
Sebastian Eibl committed
173
      oldContactHistory_type const & getOldContactHistory() const {return storage_.getOldContactHistory(i_);}
174
      oldContactHistory_type& getOldContactHistoryRef() {return storage_.getOldContactHistoryRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
175
      void setOldContactHistory(oldContactHistory_type const & v) { storage_.setOldContactHistory(i_, v);}
176
      
Sebastian Eibl's avatar
Sebastian Eibl committed
177
      newContactHistory_type const & getNewContactHistory() const {return storage_.getNewContactHistory(i_);}
178
      newContactHistory_type& getNewContactHistoryRef() {return storage_.getNewContactHistoryRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
179
      void setNewContactHistory(newContactHistory_type const & v) { storage_.setNewContactHistory(i_, v);}
180
      
Sebastian Eibl's avatar
Sebastian Eibl committed
181
      temperature_type const & getTemperature() const {return storage_.getTemperature(i_);}
182
      temperature_type& getTemperatureRef() {return storage_.getTemperatureRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
183
      void setTemperature(temperature_type const & v) { storage_.setTemperature(i_, v);}
184
      
Sebastian Eibl's avatar
Sebastian Eibl committed
185
      heatFlux_type const & getHeatFlux() const {return storage_.getHeatFlux(i_);}
186
      heatFlux_type& getHeatFluxRef() {return storage_.getHeatFluxRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
187
      void setHeatFlux(heatFlux_type const & v) { storage_.setHeatFlux(i_, v);}
188
      
Sebastian Eibl's avatar
Sebastian Eibl committed
189
      dv_type const & getDv() const {return storage_.getDv(i_);}
190
      dv_type& getDvRef() {return storage_.getDvRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
191
      void setDv(dv_type const & v) { storage_.setDv(i_, v);}
192
      
Sebastian Eibl's avatar
Sebastian Eibl committed
193
      dw_type const & getDw() const {return storage_.getDw(i_);}
194
      dw_type& getDwRef() {return storage_.getDwRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
195
      void setDw(dw_type const & v) { storage_.setDw(i_, v);}
196
      
Sebastian Eibl's avatar
Sebastian Eibl committed
197
      neighborState_type const & getNeighborState() const {return storage_.getNeighborState(i_);}
198
      neighborState_type& getNeighborStateRef() {return storage_.getNeighborStateRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
199
      void setNeighborState(neighborState_type const & v) { storage_.setNeighborState(i_, v);}
Sebastian Eibl's avatar
Sebastian Eibl committed
200
      
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

      size_t getIdx() const {return i_;}
   public:
      ParticleStorage& storage_;
      const size_t i_;
   };

   class iterator
   {
   public:
      using iterator_category = std::random_access_iterator_tag;
      using value_type        = Particle;
      using pointer           = Particle*;
      using reference         = Particle&;
      using difference_type   = std::ptrdiff_t;

      explicit iterator(ParticleStorage* storage, const size_t i) : storage_(storage), i_(i) {}
      iterator(const iterator& it)         = default;
      iterator(iterator&& it)              = default;
      iterator& operator=(const iterator&) = default;
      iterator& operator=(iterator&&)      = default;


      Particle operator*() const {return Particle{*storage_, i_};}
      Particle operator->() const {return Particle{*storage_, i_};}
      iterator& operator++(){ ++i_; return *this; }
      iterator operator++(int){ iterator tmp(*this); ++(*this); return tmp; }
      iterator& operator--(){ --i_; return *this; }
      iterator operator--(int){ iterator tmp(*this); --(*this); return tmp; }

      iterator& operator+=(const size_t n){ i_+=n; return *this; }
      iterator& operator-=(const size_t n){ i_-=n; return *this; }

      friend iterator operator+(const iterator& it, const size_t n);
      friend iterator operator+(const size_t n, const iterator& it);
      friend iterator operator-(const iterator& it, const size_t n);
      friend difference_type operator-(const iterator& lhs, const iterator& rhs);

      friend bool operator==(const iterator& lhs, const iterator& rhs);
      friend bool operator!=(const iterator& lhs, const iterator& rhs);
      friend bool operator<(const iterator& lhs, const iterator& rhs);
      friend bool operator>(const iterator& lhs, const iterator& rhs);
      friend bool operator<=(const iterator& lhs, const iterator& rhs);
      friend bool operator>=(const iterator& lhs, const iterator& rhs);

      friend void swap(iterator& lhs, iterator& rhs);

      size_t getIdx() const {return i_;}
   private:
      ParticleStorage* storage_;
      size_t i_;
   };

   explicit ParticleStorage(const size_t size);

   iterator begin() { return iterator(this, 0); }
   iterator end()   { return iterator(this, size()); }
258
   Particle operator[](const size_t n) { return *iterator(this, n); }
259
260

   
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
   using uid_type = walberla::id_t;
   using position_type = walberla::mesa_pd::Vec3;
   using interactionRadius_type = walberla::real_t;
   using flags_type = walberla::mesa_pd::data::particle_flags::FlagT;
   using owner_type = int;
   using ghostOwners_type = std::unordered_set<walberla::mpi::MPIRank>;
   using shapeID_type = size_t;
   using rotation_type = walberla::mesa_pd::Rot3;
   using angularVelocity_type = walberla::mesa_pd::Vec3;
   using torque_type = walberla::mesa_pd::Vec3;
   using linearVelocity_type = walberla::mesa_pd::Vec3;
   using invMass_type = walberla::real_t;
   using force_type = walberla::mesa_pd::Vec3;
   using oldForce_type = walberla::mesa_pd::Vec3;
   using oldTorque_type = walberla::mesa_pd::Vec3;
Sebastian Eibl's avatar
Sebastian Eibl committed
276
   using currentBlock_type = blockforest::Block*;
277
278
279
280
281
282
283
284
285
286
287
   using type_type = uint_t;
   using nextParticle_type = int;
   using oldContactHistory_type = std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>;
   using newContactHistory_type = std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>;
   using temperature_type = walberla::real_t;
   using heatFlux_type = walberla::real_t;
   using dv_type = walberla::mesa_pd::Vec3;
   using dw_type = walberla::mesa_pd::Vec3;
   using neighborState_type = std::unordered_set<walberla::mpi::MPIRank>;

   
Sebastian Eibl's avatar
Sebastian Eibl committed
288
   uid_type const & getUid(const size_t idx) const {return uid_[idx];}
289
   uid_type& getUidRef(const size_t idx) {return uid_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
290
   void setUid(const size_t idx, uid_type const & v) { uid_[idx] = v; }
291
   
Sebastian Eibl's avatar
Sebastian Eibl committed
292
   position_type const & getPosition(const size_t idx) const {return position_[idx];}
293
   position_type& getPositionRef(const size_t idx) {return position_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
294
   void setPosition(const size_t idx, position_type const & v) { position_[idx] = v; }
295
   
Sebastian Eibl's avatar
Sebastian Eibl committed
296
   interactionRadius_type const & getInteractionRadius(const size_t idx) const {return interactionRadius_[idx];}
297
   interactionRadius_type& getInteractionRadiusRef(const size_t idx) {return interactionRadius_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
298
   void setInteractionRadius(const size_t idx, interactionRadius_type const & v) { interactionRadius_[idx] = v; }
299
   
Sebastian Eibl's avatar
Sebastian Eibl committed
300
   flags_type const & getFlags(const size_t idx) const {return flags_[idx];}
301
   flags_type& getFlagsRef(const size_t idx) {return flags_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
302
   void setFlags(const size_t idx, flags_type const & v) { flags_[idx] = v; }
303
   
Sebastian Eibl's avatar
Sebastian Eibl committed
304
   owner_type const & getOwner(const size_t idx) const {return owner_[idx];}
305
   owner_type& getOwnerRef(const size_t idx) {return owner_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
306
   void setOwner(const size_t idx, owner_type const & v) { owner_[idx] = v; }
307
   
Sebastian Eibl's avatar
Sebastian Eibl committed
308
   ghostOwners_type const & getGhostOwners(const size_t idx) const {return ghostOwners_[idx];}
309
   ghostOwners_type& getGhostOwnersRef(const size_t idx) {return ghostOwners_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
310
   void setGhostOwners(const size_t idx, ghostOwners_type const & v) { ghostOwners_[idx] = v; }
311
   
Sebastian Eibl's avatar
Sebastian Eibl committed
312
   shapeID_type const & getShapeID(const size_t idx) const {return shapeID_[idx];}
313
   shapeID_type& getShapeIDRef(const size_t idx) {return shapeID_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
314
   void setShapeID(const size_t idx, shapeID_type const & v) { shapeID_[idx] = v; }
315
   
Sebastian Eibl's avatar
Sebastian Eibl committed
316
   rotation_type const & getRotation(const size_t idx) const {return rotation_[idx];}
317
   rotation_type& getRotationRef(const size_t idx) {return rotation_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
318
   void setRotation(const size_t idx, rotation_type const & v) { rotation_[idx] = v; }
319
   
Sebastian Eibl's avatar
Sebastian Eibl committed
320
   angularVelocity_type const & getAngularVelocity(const size_t idx) const {return angularVelocity_[idx];}
321
   angularVelocity_type& getAngularVelocityRef(const size_t idx) {return angularVelocity_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
322
   void setAngularVelocity(const size_t idx, angularVelocity_type const & v) { angularVelocity_[idx] = v; }
323
   
Sebastian Eibl's avatar
Sebastian Eibl committed
324
   torque_type const & getTorque(const size_t idx) const {return torque_[idx];}
325
   torque_type& getTorqueRef(const size_t idx) {return torque_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
326
   void setTorque(const size_t idx, torque_type const & v) { torque_[idx] = v; }
327
   
Sebastian Eibl's avatar
Sebastian Eibl committed
328
   linearVelocity_type const & getLinearVelocity(const size_t idx) const {return linearVelocity_[idx];}
329
   linearVelocity_type& getLinearVelocityRef(const size_t idx) {return linearVelocity_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
330
   void setLinearVelocity(const size_t idx, linearVelocity_type const & v) { linearVelocity_[idx] = v; }
331
   
Sebastian Eibl's avatar
Sebastian Eibl committed
332
   invMass_type const & getInvMass(const size_t idx) const {return invMass_[idx];}
333
   invMass_type& getInvMassRef(const size_t idx) {return invMass_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
334
   void setInvMass(const size_t idx, invMass_type const & v) { invMass_[idx] = v; }
335
   
Sebastian Eibl's avatar
Sebastian Eibl committed
336
   force_type const & getForce(const size_t idx) const {return force_[idx];}
337
   force_type& getForceRef(const size_t idx) {return force_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
338
   void setForce(const size_t idx, force_type const & v) { force_[idx] = v; }
339
   
Sebastian Eibl's avatar
Sebastian Eibl committed
340
   oldForce_type const & getOldForce(const size_t idx) const {return oldForce_[idx];}
341
   oldForce_type& getOldForceRef(const size_t idx) {return oldForce_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
342
   void setOldForce(const size_t idx, oldForce_type const & v) { oldForce_[idx] = v; }
343
   
Sebastian Eibl's avatar
Sebastian Eibl committed
344
   oldTorque_type const & getOldTorque(const size_t idx) const {return oldTorque_[idx];}
345
   oldTorque_type& getOldTorqueRef(const size_t idx) {return oldTorque_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
346
347
348
349
350
   void setOldTorque(const size_t idx, oldTorque_type const & v) { oldTorque_[idx] = v; }
   
   currentBlock_type const & getCurrentBlock(const size_t idx) const {return currentBlock_[idx];}
   currentBlock_type& getCurrentBlockRef(const size_t idx) {return currentBlock_[idx];}
   void setCurrentBlock(const size_t idx, currentBlock_type const & v) { currentBlock_[idx] = v; }
351
   
Sebastian Eibl's avatar
Sebastian Eibl committed
352
   type_type const & getType(const size_t idx) const {return type_[idx];}
353
   type_type& getTypeRef(const size_t idx) {return type_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
354
   void setType(const size_t idx, type_type const & v) { type_[idx] = v; }
355
   
Sebastian Eibl's avatar
Sebastian Eibl committed
356
   nextParticle_type const & getNextParticle(const size_t idx) const {return nextParticle_[idx];}
357
   nextParticle_type& getNextParticleRef(const size_t idx) {return nextParticle_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
358
   void setNextParticle(const size_t idx, nextParticle_type const & v) { nextParticle_[idx] = v; }
359
   
Sebastian Eibl's avatar
Sebastian Eibl committed
360
   oldContactHistory_type const & getOldContactHistory(const size_t idx) const {return oldContactHistory_[idx];}
361
   oldContactHistory_type& getOldContactHistoryRef(const size_t idx) {return oldContactHistory_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
362
   void setOldContactHistory(const size_t idx, oldContactHistory_type const & v) { oldContactHistory_[idx] = v; }
363
   
Sebastian Eibl's avatar
Sebastian Eibl committed
364
   newContactHistory_type const & getNewContactHistory(const size_t idx) const {return newContactHistory_[idx];}
365
   newContactHistory_type& getNewContactHistoryRef(const size_t idx) {return newContactHistory_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
366
   void setNewContactHistory(const size_t idx, newContactHistory_type const & v) { newContactHistory_[idx] = v; }
367
   
Sebastian Eibl's avatar
Sebastian Eibl committed
368
   temperature_type const & getTemperature(const size_t idx) const {return temperature_[idx];}
369
   temperature_type& getTemperatureRef(const size_t idx) {return temperature_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
370
   void setTemperature(const size_t idx, temperature_type const & v) { temperature_[idx] = v; }
371
   
Sebastian Eibl's avatar
Sebastian Eibl committed
372
   heatFlux_type const & getHeatFlux(const size_t idx) const {return heatFlux_[idx];}
373
   heatFlux_type& getHeatFluxRef(const size_t idx) {return heatFlux_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
374
   void setHeatFlux(const size_t idx, heatFlux_type const & v) { heatFlux_[idx] = v; }
375
   
Sebastian Eibl's avatar
Sebastian Eibl committed
376
   dv_type const & getDv(const size_t idx) const {return dv_[idx];}
377
   dv_type& getDvRef(const size_t idx) {return dv_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
378
   void setDv(const size_t idx, dv_type const & v) { dv_[idx] = v; }
379
   
Sebastian Eibl's avatar
Sebastian Eibl committed
380
   dw_type const & getDw(const size_t idx) const {return dw_[idx];}
381
   dw_type& getDwRef(const size_t idx) {return dw_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
382
   void setDw(const size_t idx, dw_type const & v) { dw_[idx] = v; }
383
   
Sebastian Eibl's avatar
Sebastian Eibl committed
384
   neighborState_type const & getNeighborState(const size_t idx) const {return neighborState_[idx];}
385
   neighborState_type& getNeighborStateRef(const size_t idx) {return neighborState_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
386
   void setNeighborState(const size_t idx, neighborState_type const & v) { neighborState_[idx] = v; }
Sebastian Eibl's avatar
Sebastian Eibl committed
387
   
388
389
390
391
392
393
394
395
396
397

   /**
    * @brief creates a new particle and returns an iterator pointing to it
    *
    * \attention Use this function only if you know what you are doing!
    * Messing with the uid might break the simulation!
    * If you are unsure use create(bool) instead.
    * @param uid unique id of the particle to be created
    * @return iterator to the newly created particle
    */
398
   inline iterator create(const uid_type& uid);
399
400
401
402
   inline iterator create(const bool global = false);
   inline iterator erase(iterator& it);
   /// Finds the entry corresponding to \p uid.
   /// \return iterator to the object or end iterator
403
   inline iterator find(const uid_type& uid);
404
405
406
   inline void reserve(const size_t size);
   inline void clear();
   inline size_t size() const;
407
408
   template <class Compare>
   void sort(Compare comp);
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478

   /**
    * Calls the provided functor \p func for all Particles.
    *
    * Additional arguments can be provided.
    * Call syntax for the provided functor
    * \code
    * func( *this, i, std::forward<Args>(args)... );
    * \endcode
    * \param openmp enables/disables OpenMP parallelization of the kernel call
    */
   template <typename Selector, typename Accessor, typename Func, typename... Args>
   inline void forEachParticle(const bool openmp,
                               const Selector& selector,
                               Accessor& acForPS,
                               Func&& func,
                               Args&&... args);
   template <typename Selector, typename Accessor, typename Func, typename... Args>
   inline void forEachParticle(const bool openmp,
                               const Selector& selector,
                               Accessor& acForPS,
                               Func&& func,
                               Args&&... args) const;
   /**
    * Calls the provided functor \p func for all Particle pairs.
    *
    * Additional arguments can be provided. No pairs with twice the same Particle.
    * Call syntax for the provided functor
    * \code
    * func( *this, i, j, std::forward<Args>(args)... );
    * \endcode
    * \param openmp enables/disables OpenMP parallelization of the kernel call
    */
   template <typename Selector, typename Accessor, typename Func, typename... Args>
   inline void forEachParticlePair(const bool openmp,
                                   const Selector& selector,
                                   Accessor& acForPS,
                                   Func&& func,
                                   Args&&... args);
   template <typename Selector, typename Accessor, typename Func, typename... Args>
   inline void forEachParticlePair(const bool openmp,
                                   const Selector& selector,
                                   Accessor& acForPS,
                                   Func&& func,
                                   Args&&... args) const;
   /**
    * Calls the provided functor \p func for all Particle pairs.
    *
    * Additional arguments can be provided. No pairs with twice the same Particle.
    * Index of the first particle i will be always smaller than j! No pair is called twice!
    * Call syntax for the provided functor
    * \code
    * func( *this, i, j, std::forward<Args>(args)... );
    * \endcode
    * \param openmp enables/disables OpenMP parallelization of the kernel call
    */
   template <typename Selector, typename Accessor, typename Func, typename... Args>
   inline void forEachParticlePairHalf(const bool openmp,
                                       const Selector& selector,
                                       Accessor& acForPS,
                                       Func&& func,
                                       Args&&... args);
   template <typename Selector, typename Accessor, typename Func, typename... Args>
   inline void forEachParticlePairHalf(const bool openmp,
                                       const Selector& selector,
                                       Accessor& acForPS,
                                       Func&& func,
                                       Args&&... args) const;

   private:
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
   std::vector<uid_type> uid_ {};
   std::vector<position_type> position_ {};
   std::vector<interactionRadius_type> interactionRadius_ {};
   std::vector<flags_type> flags_ {};
   std::vector<owner_type> owner_ {};
   std::vector<ghostOwners_type> ghostOwners_ {};
   std::vector<shapeID_type> shapeID_ {};
   std::vector<rotation_type> rotation_ {};
   std::vector<angularVelocity_type> angularVelocity_ {};
   std::vector<torque_type> torque_ {};
   std::vector<linearVelocity_type> linearVelocity_ {};
   std::vector<invMass_type> invMass_ {};
   std::vector<force_type> force_ {};
   std::vector<oldForce_type> oldForce_ {};
   std::vector<oldTorque_type> oldTorque_ {};
Sebastian Eibl's avatar
Sebastian Eibl committed
494
   std::vector<currentBlock_type> currentBlock_ {};
495
496
497
498
499
500
501
502
503
504
505
   std::vector<type_type> type_ {};
   std::vector<nextParticle_type> nextParticle_ {};
   std::vector<oldContactHistory_type> oldContactHistory_ {};
   std::vector<newContactHistory_type> newContactHistory_ {};
   std::vector<temperature_type> temperature_ {};
   std::vector<heatFlux_type> heatFlux_ {};
   std::vector<dv_type> dv_ {};
   std::vector<dw_type> dw_ {};
   std::vector<neighborState_type> neighborState_ {};
   std::unordered_map<uid_type, size_t> uidToIdx_;
   static_assert(std::is_same<uid_type, id_t>::value,
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
                 "Property uid of type id_t is missing. This property is required!");
};
using Particle = ParticleStorage::Particle;

inline
ParticleStorage::Particle& ParticleStorage::Particle::operator=(const ParticleStorage::Particle& rhs)
{
   getUidRef() = rhs.getUid();
   getPositionRef() = rhs.getPosition();
   getInteractionRadiusRef() = rhs.getInteractionRadius();
   getFlagsRef() = rhs.getFlags();
   getOwnerRef() = rhs.getOwner();
   getGhostOwnersRef() = rhs.getGhostOwners();
   getShapeIDRef() = rhs.getShapeID();
   getRotationRef() = rhs.getRotation();
   getAngularVelocityRef() = rhs.getAngularVelocity();
   getTorqueRef() = rhs.getTorque();
   getLinearVelocityRef() = rhs.getLinearVelocity();
   getInvMassRef() = rhs.getInvMass();
   getForceRef() = rhs.getForce();
   getOldForceRef() = rhs.getOldForce();
   getOldTorqueRef() = rhs.getOldTorque();
Sebastian Eibl's avatar
Sebastian Eibl committed
528
   getCurrentBlockRef() = rhs.getCurrentBlock();
529
530
531
532
533
534
   getTypeRef() = rhs.getType();
   getNextParticleRef() = rhs.getNextParticle();
   getOldContactHistoryRef() = rhs.getOldContactHistory();
   getNewContactHistoryRef() = rhs.getNewContactHistory();
   getTemperatureRef() = rhs.getTemperature();
   getHeatFluxRef() = rhs.getHeatFlux();
535
536
   getDvRef() = rhs.getDv();
   getDwRef() = rhs.getDw();
Sebastian Eibl's avatar
Sebastian Eibl committed
537
   getNeighborStateRef() = rhs.getNeighborState();
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
   return *this;
}

inline
ParticleStorage::Particle& ParticleStorage::Particle::operator=(ParticleStorage::Particle&& rhs)
{
   getUidRef() = std::move(rhs.getUidRef());
   getPositionRef() = std::move(rhs.getPositionRef());
   getInteractionRadiusRef() = std::move(rhs.getInteractionRadiusRef());
   getFlagsRef() = std::move(rhs.getFlagsRef());
   getOwnerRef() = std::move(rhs.getOwnerRef());
   getGhostOwnersRef() = std::move(rhs.getGhostOwnersRef());
   getShapeIDRef() = std::move(rhs.getShapeIDRef());
   getRotationRef() = std::move(rhs.getRotationRef());
   getAngularVelocityRef() = std::move(rhs.getAngularVelocityRef());
   getTorqueRef() = std::move(rhs.getTorqueRef());
   getLinearVelocityRef() = std::move(rhs.getLinearVelocityRef());
   getInvMassRef() = std::move(rhs.getInvMassRef());
   getForceRef() = std::move(rhs.getForceRef());
   getOldForceRef() = std::move(rhs.getOldForceRef());
   getOldTorqueRef() = std::move(rhs.getOldTorqueRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
559
   getCurrentBlockRef() = std::move(rhs.getCurrentBlockRef());
560
561
562
563
564
565
   getTypeRef() = std::move(rhs.getTypeRef());
   getNextParticleRef() = std::move(rhs.getNextParticleRef());
   getOldContactHistoryRef() = std::move(rhs.getOldContactHistoryRef());
   getNewContactHistoryRef() = std::move(rhs.getNewContactHistoryRef());
   getTemperatureRef() = std::move(rhs.getTemperatureRef());
   getHeatFluxRef() = std::move(rhs.getHeatFluxRef());
566
567
   getDvRef() = std::move(rhs.getDvRef());
   getDwRef() = std::move(rhs.getDwRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
568
   getNeighborStateRef() = std::move(rhs.getNeighborStateRef());
569
570
571
   return *this;
}

572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
inline
void swap(ParticleStorage::Particle lhs, ParticleStorage::Particle rhs)
{
   if (lhs.i_ == rhs.i_) return;
   std::swap(lhs.getUidRef(), rhs.getUidRef());
   std::swap(lhs.getPositionRef(), rhs.getPositionRef());
   std::swap(lhs.getInteractionRadiusRef(), rhs.getInteractionRadiusRef());
   std::swap(lhs.getFlagsRef(), rhs.getFlagsRef());
   std::swap(lhs.getOwnerRef(), rhs.getOwnerRef());
   std::swap(lhs.getGhostOwnersRef(), rhs.getGhostOwnersRef());
   std::swap(lhs.getShapeIDRef(), rhs.getShapeIDRef());
   std::swap(lhs.getRotationRef(), rhs.getRotationRef());
   std::swap(lhs.getAngularVelocityRef(), rhs.getAngularVelocityRef());
   std::swap(lhs.getTorqueRef(), rhs.getTorqueRef());
   std::swap(lhs.getLinearVelocityRef(), rhs.getLinearVelocityRef());
   std::swap(lhs.getInvMassRef(), rhs.getInvMassRef());
   std::swap(lhs.getForceRef(), rhs.getForceRef());
   std::swap(lhs.getOldForceRef(), rhs.getOldForceRef());
   std::swap(lhs.getOldTorqueRef(), rhs.getOldTorqueRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
591
   std::swap(lhs.getCurrentBlockRef(), rhs.getCurrentBlockRef());
592
593
594
595
596
597
   std::swap(lhs.getTypeRef(), rhs.getTypeRef());
   std::swap(lhs.getNextParticleRef(), rhs.getNextParticleRef());
   std::swap(lhs.getOldContactHistoryRef(), rhs.getOldContactHistoryRef());
   std::swap(lhs.getNewContactHistoryRef(), rhs.getNewContactHistoryRef());
   std::swap(lhs.getTemperatureRef(), rhs.getTemperatureRef());
   std::swap(lhs.getHeatFluxRef(), rhs.getHeatFluxRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
598
599
   std::swap(lhs.getDvRef(), rhs.getDvRef());
   std::swap(lhs.getDwRef(), rhs.getDwRef());
600
   std::swap(lhs.getNeighborStateRef(), rhs.getNeighborStateRef());
601
602
}

603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
inline
std::ostream& operator<<( std::ostream& os, const ParticleStorage::Particle& p )
{
   os << "==========    ==========" << "\n" <<
         "idx                 : " << p.getIdx() << "\n" <<
         "uid                 : " << p.getUid() << "\n" <<
         "position            : " << p.getPosition() << "\n" <<
         "interactionRadius   : " << p.getInteractionRadius() << "\n" <<
         "flags               : " << p.getFlags() << "\n" <<
         "owner               : " << p.getOwner() << "\n" <<
         "ghostOwners         : " << p.getGhostOwners() << "\n" <<
         "shapeID             : " << p.getShapeID() << "\n" <<
         "rotation            : " << p.getRotation() << "\n" <<
         "angularVelocity     : " << p.getAngularVelocity() << "\n" <<
         "torque              : " << p.getTorque() << "\n" <<
         "linearVelocity      : " << p.getLinearVelocity() << "\n" <<
         "invMass             : " << p.getInvMass() << "\n" <<
         "force               : " << p.getForce() << "\n" <<
         "oldForce            : " << p.getOldForce() << "\n" <<
         "oldTorque           : " << p.getOldTorque() << "\n" <<
Sebastian Eibl's avatar
Sebastian Eibl committed
623
         "currentBlock        : " << p.getCurrentBlock() << "\n" <<
624
625
626
627
628
629
         "type                : " << p.getType() << "\n" <<
         "nextParticle        : " << p.getNextParticle() << "\n" <<
         "oldContactHistory   : " << p.getOldContactHistory() << "\n" <<
         "newContactHistory   : " << p.getNewContactHistory() << "\n" <<
         "temperature         : " << p.getTemperature() << "\n" <<
         "heatFlux            : " << p.getHeatFlux() << "\n" <<
630
631
         "dv                  : " << p.getDv() << "\n" <<
         "dw                  : " << p.getDw() << "\n" <<
Sebastian Eibl's avatar
Sebastian Eibl committed
632
         "neighborState       : " << p.getNeighborState() << "\n" <<
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
         "================================" << std::endl;
   return os;
}

inline
ParticleStorage::iterator operator+(const ParticleStorage::iterator& it, const size_t n)
{
   return ParticleStorage::iterator(it.storage_, it.i_+n);
}

inline
ParticleStorage::iterator operator+(const size_t n, const ParticleStorage::iterator& it)
{
   return it + n;
}

inline
ParticleStorage::iterator operator-(const ParticleStorage::iterator& it, const size_t n)
{
   return ParticleStorage::iterator(it.storage_, it.i_-n);
}

inline
ParticleStorage::iterator::difference_type operator-(const ParticleStorage::iterator& lhs, const ParticleStorage::iterator& rhs)
{
   return int64_c(lhs.i_) - int64_c(rhs.i_);
}

inline bool operator==(const ParticleStorage::iterator& lhs, const ParticleStorage::iterator& rhs)
{
   WALBERLA_ASSERT_EQUAL(lhs.storage_, rhs.storage_);
   return (lhs.i_ == rhs.i_);
}
inline bool operator!=(const ParticleStorage::iterator& lhs, const ParticleStorage::iterator& rhs)
{
   WALBERLA_ASSERT_EQUAL(lhs.storage_, rhs.storage_);
   return (lhs.i_ != rhs.i_);
}
inline bool operator<(const ParticleStorage::iterator& lhs, const ParticleStorage::iterator& rhs)
{
   WALBERLA_ASSERT_EQUAL(lhs.storage_, rhs.storage_);
   return (lhs.i_ < rhs.i_);
}
inline bool operator>(const ParticleStorage::iterator& lhs, const ParticleStorage::iterator& rhs)
{
   WALBERLA_ASSERT_EQUAL(lhs.storage_, rhs.storage_);
   return (lhs.i_ > rhs.i_);
}
inline bool operator<=(const ParticleStorage::iterator& lhs, const ParticleStorage::iterator& rhs)
{
   WALBERLA_ASSERT_EQUAL(lhs.storage_, rhs.storage_);
   return (lhs.i_ <= rhs.i_);
}
inline bool operator>=(const ParticleStorage::iterator& lhs, const ParticleStorage::iterator& rhs)
{
   WALBERLA_ASSERT_EQUAL(lhs.storage_, rhs.storage_);
   return (lhs.i_ >= rhs.i_);
}

inline void swap(ParticleStorage::iterator& lhs, ParticleStorage::iterator& rhs)
{
   WALBERLA_ASSERT_EQUAL(lhs.storage_, rhs.storage_);
   std::swap(lhs.i_, rhs.i_);
}

inline
ParticleStorage::ParticleStorage(const size_t size)
{
   reserve(size);
}


inline ParticleStorage::iterator ParticleStorage::create(const id_t& uid)
{
   WALBERLA_ASSERT_EQUAL(uidToIdx_.find(uid),
                         uidToIdx_.end(),
                         "particle with the same uid(" << uid <<") already existing at index(" << uidToIdx_.find(uid)->second << ")");
   uid_.emplace_back(UniqueID<data::Particle>::invalidID());
   position_.emplace_back(real_t(0));
   interactionRadius_.emplace_back(real_t(0));
   flags_.emplace_back();
   owner_.emplace_back(-1);
   ghostOwners_.emplace_back();
   shapeID_.emplace_back();
   rotation_.emplace_back();
   angularVelocity_.emplace_back(real_t(0));
   torque_.emplace_back(real_t(0));
   linearVelocity_.emplace_back(real_t(0));
   invMass_.emplace_back(real_t(1));
   force_.emplace_back(real_t(0));
   oldForce_.emplace_back(real_t(0));
   oldTorque_.emplace_back(real_t(0));
Sebastian Eibl's avatar
Sebastian Eibl committed
725
   currentBlock_.emplace_back(nullptr);
726
727
728
729
730
731
   type_.emplace_back(0);
   nextParticle_.emplace_back(-1);
   oldContactHistory_.emplace_back();
   newContactHistory_.emplace_back();
   temperature_.emplace_back(real_t(0));
   heatFlux_.emplace_back(real_t(0));
732
733
   dv_.emplace_back(real_t(0));
   dw_.emplace_back(real_t(0));
Sebastian Eibl's avatar
Sebastian Eibl committed
734
   neighborState_.emplace_back();
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
   uid_.back() = uid;
   uidToIdx_[uid] = uid_.size() - 1;
   return iterator(this, size() - 1);
}

inline ParticleStorage::iterator ParticleStorage::create(const bool global)
{
   if (global)
   {
      auto it = create(UniqueID<Particle>::createGlobal());
      data::particle_flags::set(flags_.back(), data::particle_flags::GLOBAL);
      data::particle_flags::set(flags_.back(), data::particle_flags::NON_COMMUNICATING);
      return it;
   } else
   {
      return create(UniqueID<Particle>::create());
   }
}

inline ParticleStorage::iterator ParticleStorage::erase(iterator& it)
{
   //swap with last element and pop
   auto last = --end();
   auto numElementsRemoved = uidToIdx_.erase(it->getUid());
   WALBERLA_CHECK_EQUAL(numElementsRemoved,
                        1,
                        "Particle with uid " << it->getUid() << " cannot be removed (not existing).");
   if (it != last) //skip swap if last element is removed
   {
      *it = *last;
      uidToIdx_[it->getUid()] = it.getIdx();
   }
   uid_.pop_back();
   position_.pop_back();
   interactionRadius_.pop_back();
   flags_.pop_back();
   owner_.pop_back();
   ghostOwners_.pop_back();
   shapeID_.pop_back();
   rotation_.pop_back();
   angularVelocity_.pop_back();
   torque_.pop_back();
   linearVelocity_.pop_back();
   invMass_.pop_back();
   force_.pop_back();
   oldForce_.pop_back();
   oldTorque_.pop_back();
Sebastian Eibl's avatar
Sebastian Eibl committed
782
   currentBlock_.pop_back();
783
784
785
786
787
788
   type_.pop_back();
   nextParticle_.pop_back();
   oldContactHistory_.pop_back();
   newContactHistory_.pop_back();
   temperature_.pop_back();
   heatFlux_.pop_back();
789
790
   dv_.pop_back();
   dw_.pop_back();
Sebastian Eibl's avatar
Sebastian Eibl committed
791
   neighborState_.pop_back();
792
793
794
795
796
797
798
799
800
801
802
803
804
   return it;
}

inline ParticleStorage::iterator ParticleStorage::find(const id_t& uid)
{
   //linear search through uid vector
   //auto it = std::find(uid_.begin(), uid_.end(), uid);
   //if (it == uid_.end()) return end();
   //return iterator(this, uint_c(std::distance(uid_.begin(), it)));

   //use unordered_map for faster lookup
   auto it = uidToIdx_.find(uid);
   if (it == uidToIdx_.end()) return end();
805
   WALBERLA_ASSERT_EQUAL(getUid(it->second), uid, "Lookup via uidToIdx map is not up to date!!!");
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
   return iterator(this, it->second);
}

inline void ParticleStorage::reserve(const size_t size)
{
   uid_.reserve(size);
   position_.reserve(size);
   interactionRadius_.reserve(size);
   flags_.reserve(size);
   owner_.reserve(size);
   ghostOwners_.reserve(size);
   shapeID_.reserve(size);
   rotation_.reserve(size);
   angularVelocity_.reserve(size);
   torque_.reserve(size);
   linearVelocity_.reserve(size);
   invMass_.reserve(size);
   force_.reserve(size);
   oldForce_.reserve(size);
   oldTorque_.reserve(size);
Sebastian Eibl's avatar
Sebastian Eibl committed
826
   currentBlock_.reserve(size);
827
828
829
830
831
832
   type_.reserve(size);
   nextParticle_.reserve(size);
   oldContactHistory_.reserve(size);
   newContactHistory_.reserve(size);
   temperature_.reserve(size);
   heatFlux_.reserve(size);
833
834
   dv_.reserve(size);
   dw_.reserve(size);
Sebastian Eibl's avatar
Sebastian Eibl committed
835
   neighborState_.reserve(size);
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
}

inline void ParticleStorage::clear()
{
   uid_.clear();
   position_.clear();
   interactionRadius_.clear();
   flags_.clear();
   owner_.clear();
   ghostOwners_.clear();
   shapeID_.clear();
   rotation_.clear();
   angularVelocity_.clear();
   torque_.clear();
   linearVelocity_.clear();
   invMass_.clear();
   force_.clear();
   oldForce_.clear();
   oldTorque_.clear();
Sebastian Eibl's avatar
Sebastian Eibl committed
855
   currentBlock_.clear();
856
857
858
859
860
861
   type_.clear();
   nextParticle_.clear();
   oldContactHistory_.clear();
   newContactHistory_.clear();
   temperature_.clear();
   heatFlux_.clear();
862
863
   dv_.clear();
   dw_.clear();
Sebastian Eibl's avatar
Sebastian Eibl committed
864
   neighborState_.clear();
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
   uidToIdx_.clear();
}

inline size_t ParticleStorage::size() const
{
   //WALBERLA_ASSERT_EQUAL( uid_.size(), uid.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), position.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), interactionRadius.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), flags.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), owner.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), ghostOwners.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), shapeID.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), rotation.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), angularVelocity.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), torque.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), linearVelocity.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), invMass.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), force.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldForce.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldTorque.size() );
Sebastian Eibl's avatar
Sebastian Eibl committed
885
   //WALBERLA_ASSERT_EQUAL( uid_.size(), currentBlock.size() );
886
887
888
889
890
891
   //WALBERLA_ASSERT_EQUAL( uid_.size(), type.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), nextParticle.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldContactHistory.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), newContactHistory.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), temperature.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), heatFlux.size() );
892
893
   //WALBERLA_ASSERT_EQUAL( uid_.size(), dv.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), dw.size() );
Sebastian Eibl's avatar
Sebastian Eibl committed
894
   //WALBERLA_ASSERT_EQUAL( uid_.size(), neighborState.size() );
895
896
   return uid_.size();
}
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937

template <class Compare>
void ParticleStorage::sort(Compare comp)
{
   using WeightPair = std::pair<size_t, double>; //idx, weight

   const size_t length = size();
   std::vector<size_t>     newIdx(length); //where is old idx now?
   std::vector<size_t>     oldIdx(length); //what old idx is at that idx?
   std::vector<WeightPair> weight(length);

   for (size_t idx = 0; idx < length; ++idx)
   {
      newIdx[idx] = idx;
      oldIdx[idx] = idx;
      weight[idx] = std::make_pair(idx, comp.getWeight(operator[](idx)));
   }
   std::sort(weight.begin(), weight.end(), [](const WeightPair& lhs, const WeightPair& rhs){return lhs.second < rhs.second;});
   for (size_t idx = 0; idx < length; ++idx)
   {
      using std::swap;
      WALBERLA_ASSERT_IDENTICAL(weight[idx].second, comp.getWeight(operator[](newIdx[weight[idx].first])));

      WALBERLA_ASSERT_LESS_EQUAL(comp.getWeight(operator[](newIdx[weight[idx].first])), comp.getWeight(operator[](idx)));
      swap( operator[](idx), operator[](newIdx[weight[idx].first]) );
      const auto lhsIDX = idx;
      const auto rhsIDX = newIdx[weight[idx].first];

      newIdx[oldIdx[lhsIDX]] = rhsIDX;
      newIdx[oldIdx[rhsIDX]] = lhsIDX;

      swap(oldIdx[lhsIDX], oldIdx[rhsIDX]);
   }

   //rebuild lookup table
   uidToIdx_.clear();
   for (size_t idx = 0; idx < length; ++idx)
   {
      uidToIdx_[getUid(idx)] = idx;
   }
}
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
template <typename Selector, typename Accessor, typename Func, typename... Args>
inline void ParticleStorage::forEachParticle(const bool openmp,
                                             const Selector& selector,
                                             Accessor& acForPS,
                                             Func&& func, Args&&... args) 
{
   static_assert (std::is_base_of<data::IAccessor, Accessor>::value, "please provide a valid accessor" );

   WALBERLA_UNUSED(openmp);
   const uint64_t len = size();
   #ifdef _OPENMP
   #pragma omp parallel for schedule(static) if (openmp)
   #endif
   for (int64_t i = 0; i < int64_c(len); ++i)
   {
      if (selector(uint64_c(i), acForPS))
         func( uint64_c(i), std::forward<Args>(args)... );
   }
}
template <typename Selector, typename Accessor, typename Func, typename... Args>
inline void ParticleStorage::forEachParticle(const bool openmp,
                                             const Selector& selector,
                                             Accessor& acForPS,
                                             Func&& func, Args&&... args) const
{
   static_assert (std::is_base_of<data::IAccessor, Accessor>::value, "please provide a valid accessor" );

   WALBERLA_UNUSED(openmp);
   const uint64_t len = size();
   #ifdef _OPENMP
   #pragma omp parallel for schedule(static) if (openmp)
   #endif
   for (int64_t i = 0; i < int64_c(len); ++i)
   {
      if (selector(uint64_c(i), acForPS))
         func( uint64_c(i), std::forward<Args>(args)... );
   }
}
template <typename Selector, typename Accessor, typename Func, typename... Args>
inline void ParticleStorage::forEachParticlePair(const bool openmp,
                                                 const Selector& selector,
                                                 Accessor& acForPS,
                                                 Func&& func, Args&&... args) 
{
   static_assert (std::is_base_of<data::IAccessor, Accessor>::value, "please provide a valid accessor" );

   WALBERLA_UNUSED(openmp);
   const uint64_t len = size();
   #ifdef _OPENMP
   #pragma omp parallel for schedule(static) if (openmp)
   #endif
   for (int64_t i = 0; i < int64_c(len); ++i)
   {
      for (int64_t j = 0; j < int64_c(len); ++j)
      {
         if (i!=j)
         {
            if (selector(uint64_c(i), uint64_c(j), acForPS))
            {
               func( uint64_c(i), uint64_c(j), std::forward<Args>(args)... );
            }
         }
      }
   }
}
template <typename Selector, typename Accessor, typename Func, typename... Args>
inline void ParticleStorage::forEachParticlePair(const bool openmp,
                                                 const Selector& selector,
                                                 Accessor& acForPS,
                                                 Func&& func, Args&&... args) const
{
   static_assert (std::is_base_of<data::IAccessor, Accessor>::value, "please provide a valid accessor" );

   WALBERLA_UNUSED(openmp);
   const uint64_t len = size();
   #ifdef _OPENMP
   #pragma omp parallel for schedule(static) if (openmp)
   #endif
   for (int64_t i = 0; i < int64_c(len); ++i)
   {
      for (int64_t j = 0; j < int64_c(len); ++j)
      {
         if (i!=j)
         {
            if (selector(uint64_c(i), uint64_c(j), acForPS))
            {
               func( uint64_c(i), uint64_c(j), std::forward<Args>(args)... );
            }
         }
      }
   }
}
template <typename Selector, typename Accessor, typename Func, typename... Args>
inline void ParticleStorage::forEachParticlePairHalf(const bool openmp,
                                                     const Selector& selector,
                                                     Accessor& acForPS,
                                                     Func&& func, Args&&... args) 
{
   static_assert (std::is_base_of<data::IAccessor, Accessor>::value, "please provide a valid accessor" );

   WALBERLA_UNUSED(openmp);
   const uint64_t len = size();
   #ifdef _OPENMP
   #pragma omp parallel for schedule(static) if (openmp)
   #endif
   for (int64_t i = 0; i < int64_c(len); ++i)
   {
      for (int64_t j = i+1; j < int64_c(len); ++j)
      {
         if (selector(uint64_c(i), uint64_c(j), acForPS))
         {
            func( uint64_c(i), uint64_c(j), std::forward<Args>(args)... );
         }
      }
   }
}
template <typename Selector, typename Accessor, typename Func, typename... Args>
inline void ParticleStorage::forEachParticlePairHalf(const bool openmp,
                                                     const Selector& selector,
                                                     Accessor& acForPS,
                                                     Func&& func, Args&&... args) const
{
   static_assert (std::is_base_of<data::IAccessor, Accessor>::value, "please provide a valid accessor" );

   WALBERLA_UNUSED(openmp);
   const uint64_t len = size();
   #ifdef _OPENMP
   #pragma omp parallel for schedule(static) if (openmp)
   #endif
   for (int64_t i = 0; i < int64_c(len); ++i)
   {
      for (int64_t j = i+1; j < int64_c(len); ++j)
      {
         if (selector(uint64_c(i), uint64_c(j), acForPS))
         {
            func( uint64_c(i), uint64_c(j), std::forward<Args>(args)... );
         }
      }
   }
}
///Predicate that selects a certain property from a Particle
class SelectParticleUid
{
public:
   using return_type = walberla::id_t;
   walberla::id_t& operator()(data::Particle& p) const {return p.getUidRef();}
   walberla::id_t& operator()(data::Particle&& p) const {return p.getUidRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1085
   walberla::id_t const & operator()(const data::Particle& p) const {return p.getUid();}
1086
1087
1088
1089
1090
1091
1092
1093
};
///Predicate that selects a certain property from a Particle
class SelectParticlePosition
{
public:
   using return_type = walberla::mesa_pd::Vec3;
   walberla::mesa_pd::Vec3& operator()(data::Particle& p) const {return p.getPositionRef();}
   walberla::mesa_pd::Vec3& operator()(data::Particle&& p) const {return p.getPositionRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1094
   walberla::mesa_pd::Vec3 const & operator()(const data::Particle& p) const {return p.getPosition();}
1095
1096
1097
1098
1099
1100
1101
1102
};
///Predicate that selects a certain property from a Particle
class SelectParticleInteractionRadius
{
public:
   using return_type = walberla::real_t;
   walberla::real_t& operator()(data::Particle& p) const {return p.getInteractionRadiusRef();}
   walberla::real_t& operator()(data::Particle&& p) const {return p.getInteractionRadiusRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1103
   walberla::real_t const & operator()(const data::Particle& p) const {return p.getInteractionRadius();}
1104
1105
1106
1107
1108
1109
1110
1111
};
///Predicate that selects a certain property from a Particle
class SelectParticleFlags
{
public:
   using return_type = walberla::mesa_pd::data::particle_flags::FlagT;
   walberla::mesa_pd::data::particle_flags::FlagT& operator()(data::Particle& p) const {return p.getFlagsRef();}
   walberla::mesa_pd::data::particle_flags::FlagT& operator()(data::Particle&& p) const {return p.getFlagsRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1112
   walberla::mesa_pd::data::particle_flags::FlagT const & operator()(const data::Particle& p) const {return p.getFlags();}
1113
1114
1115
1116
1117
1118
1119
1120
};
///Predicate that selects a certain property from a Particle
class SelectParticleOwner
{
public:
   using return_type = int;
   int& operator()(data::Particle& p) const {return p.getOwnerRef();}
   int& operator()(data::Particle&& p) const {return p.getOwnerRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1121
   int const & operator()(const data::Particle& p) const {return p.getOwner();}
1122
1123
1124
1125
1126
};
///Predicate that selects a certain property from a Particle
class SelectParticleGhostOwners
{
public:
Sebastian Eibl's avatar
Sebastian Eibl committed
1127
1128
1129
   using return_type = std::unordered_set<walberla::mpi::MPIRank>;
   std::unordered_set<walberla::mpi::MPIRank>& operator()(data::Particle& p) const {return p.getGhostOwnersRef();}
   std::unordered_set<walberla::mpi::MPIRank>& operator()(data::Particle&& p) const {return p.getGhostOwnersRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1130
   std::unordered_set<walberla::mpi::MPIRank> const & operator()(const data::Particle& p) const {return p.getGhostOwners();}
1131
1132
1133
1134
1135
1136
1137
1138
};
///Predicate that selects a certain property from a Particle
class SelectParticleShapeID
{
public:
   using return_type = size_t;
   size_t& operator()(data::Particle& p) const {return p.getShapeIDRef();}
   size_t& operator()(data::Particle&& p) const {return p.getShapeIDRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1139
   size_t const & operator()(const data::Particle& p) const {return p.getShapeID();}
1140
1141
1142
1143
1144
1145
1146
1147
};
///Predicate that selects a certain property from a Particle
class SelectParticleRotation
{
public:
   using return_type = walberla::mesa_pd::Rot3;
   walberla::mesa_pd::Rot3& operator()(data::Particle& p) const {return p.getRotationRef();}
   walberla::mesa_pd::Rot3& operator()(data::Particle&& p) const {return p.getRotationRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1148
   walberla::mesa_pd::Rot3 const & operator()(const data::Particle& p) const {return p.getRotation();}
1149
1150
1151
1152
1153
1154
1155
1156
};
///Predicate that selects a certain property from a Particle
class SelectParticleAngularVelocity
{
public:
   using return_type = walberla::mesa_pd::Vec3;
   walberla::mesa_pd::Vec3& operator()(data::Particle& p) const {return p.getAngularVelocityRef();}
   walberla::mesa_pd::Vec3& operator()(data::Particle&& p) const {return p.getAngularVelocityRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1157
   walberla::mesa_pd::Vec3 const & operator()(const data::Particle& p) const {return p.getAngularVelocity();}
1158
1159
1160
1161
1162
1163
1164
1165
};
///Predicate that selects a certain property from a Particle
class SelectParticleTorque
{
public:
   using return_type = walberla::mesa_pd::Vec3;
   walberla::mesa_pd::Vec3& operator()(data::Particle& p) const {return p.getTorqueRef();}
   walberla::mesa_pd::Vec3& operator()(data::Particle&& p) const {return p.getTorqueRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1166
   walberla::mesa_pd::Vec3 const & operator()(const data::Particle& p) const {return p.getTorque();}
1167
1168
1169
1170
1171
1172
1173
1174
};
///Predicate that selects a certain property from a Particle
class SelectParticleLinearVelocity
{
public:
   using return_type = walberla::mesa_pd::Vec3;
   walberla::mesa_pd::Vec3& operator()(data::Particle& p) const {return p.getLinearVelocityRef();}
   walberla::mesa_pd::Vec3& operator()(data::Particle&& p) const {return p.getLinearVelocityRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1175
   walberla::mesa_pd::Vec3 const & operator()(const data::Particle& p) const {return p.getLinearVelocity();}
1176
1177
1178
1179
1180
1181
1182
1183
};
///Predicate that selects a certain property from a Particle
class SelectParticleInvMass
{
public:
   using return_type = walberla::real_t;
   walberla::real_t& operator()(data::Particle& p) const {return p.getInvMassRef();}
   walberla::real_t& operator()(data::Particle&& p) const {return p.getInvMassRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1184
   walberla::real_t const & operator()(const data::Particle& p) const {return p.getInvMass();}
1185
1186
1187
1188
1189
1190
1191
1192
};
///Predicate that selects a certain property from a Particle
class SelectParticleForce
{
public:
   using return_type = walberla::mesa_pd::Vec3;
   walberla::mesa_pd::Vec3& operator()(data::Particle& p) const {return p.getForceRef();}
   walberla::mesa_pd::Vec3& operator()(data::Particle&& p) const {return p.getForceRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1193
   walberla::mesa_pd::Vec3 const & operator()(const data::Particle& p) const {return p.getForce();}
1194
1195
1196
1197
1198
1199
1200
1201
};
///Predicate that selects a certain property from a Particle
class SelectParticleOldForce
{
public:
   using return_type = walberla::mesa_pd::Vec3;
   walberla::mesa_pd::Vec3& operator()(data::Particle& p) const {return p.getOldForceRef();}
   walberla::mesa_pd::Vec3& operator()(data::Particle&& p) const {return p.getOldForceRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1202
   walberla::mesa_pd::Vec3 const & operator()(const data::Particle& p) const {return p.getOldForce();}
1203
1204
1205
1206
1207
1208
1209
1210
};
///Predicate that selects a certain property from a Particle
class SelectParticleOldTorque
{
public:
   using return_type = walberla::mesa_pd::Vec3;
   walberla::mesa_pd::Vec3& operator()(data::Particle& p) const {return p.getOldTorqueRef();}
   walberla::mesa_pd::Vec3& operator()(data::Particle&& p) const {return p.getOldTorqueRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
   walberla::mesa_pd::Vec3 const & operator()(const data::Particle& p) const {return p.getOldTorque();}
};
///Predicate that selects a certain property from a Particle
class SelectParticleCurrentBlock
{
public:
   using return_type = blockforest::Block*;
   blockforest::Block*& operator()(data::Particle& p) const {return p.getCurrentBlockRef();}
   blockforest::Block*& operator()(data::Particle&& p) const {return p.getCurrentBlockRef();}
   blockforest::Block* const & operator()(const data::Particle& p) const {return p.getCurrentBlock();}
1221
1222
1223
1224
1225
1226
1227
1228
};
///Predicate that selects a certain property from a Particle
class SelectParticleType
{
public:
   using return_type = uint_t;
   uint_t& operator()(data::Particle& p) const {return p.getTypeRef();}
   uint_t& operator()(data::Particle&& p) const {return p.getTypeRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1229
   uint_t const & operator()(const data::Particle& p) const {return p.getType();}
1230
1231
1232
1233
1234
1235
1236
1237
};
///Predicate that selects a certain property from a Particle
class SelectParticleNextParticle
{
public:
   using return_type = int;
   int& operator()(data::Particle& p) const {return p.getNextParticleRef();}
   int& operator()(data::Particle&& p) const {return p.getNextParticleRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1238
   int const & operator()(const data::Particle& p) const {return p.getNextParticle();}
1239
1240
1241
1242
1243
1244
1245
1246
};
///Predicate that selects a certain property from a Particle
class SelectParticleOldContactHistory
{
public:
   using return_type = std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>;
   std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>& operator()(data::Particle& p) const {return p.getOldContactHistoryRef();}
   std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>& operator()(data::Particle&& p) const {return p.getOldContactHistoryRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1247
   std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory> const & operator()(const data::Particle& p) const {return p.getOldContactHistory();}
1248
1249
1250
1251
1252
1253
1254
1255
};
///Predicate that selects a certain property from a Particle
class SelectParticleNewContactHistory
{
public:
   using return_type = std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>;
   std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>& operator()(data::Particle& p) const {return p.getNewContactHistoryRef();}
   std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>& operator()(data::Particle&& p) const {return p.getNewContactHistoryRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1256
   std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory> const & operator()(const data::Particle& p) const {return p.getNewContactHistory();}
1257
1258
1259
1260
1261
1262
1263
1264
};
///Predicate that selects a certain property from a Particle
class SelectParticleTemperature
{
public:
   using return_type = walberla::real_t;
   walberla::real_t& operator()(data::Particle& p) const {return p.getTemperatureRef();}
   walberla::real_t& operator()(data::Particle&& p) const {return p.getTemperatureRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1265
   walberla::real_t const & operator()(const data::Particle& p) const {return p.getTemperature();}
1266
1267
1268
1269
1270
1271
1272
1273
};
///Predicate that selects a certain property from a Particle
class SelectParticleHeatFlux
{
public:
   using return_type = walberla::real_t;
   walberla::real_t& operator()(data::Particle& p) const {return p.getHeatFluxRef();}
   walberla::real_t& operator()(data::Particle&& p) const {return p.getHeatFluxRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1274
   walberla::real_t const & operator()(const data::Particle& p) const {return p.getHeatFlux();}
1275
};
1276
1277
1278
1279
1280
1281
1282
///Predicate that selects a certain property from a Particle
class SelectParticleDv
{
public:
   using return_type = walberla::mesa_pd::Vec3;
   walberla::mesa_pd::Vec3& operator()(data::Particle& p) const {return p.getDvRef();}
   walberla::mesa_pd::Vec3& operator()(data::Particle&& p) const {return p.getDvRef();}
Sebastian Eibl's avatar
Sebastian Eibl committed
1283
   walberla::mesa_pd::Vec3 const & operator()(const data::Particle& p) const {return p.getDv();}