ParticleStorage.h 81.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//======================================================================================================================
//
//  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/>.
//
16
//! \file
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! \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
      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 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;
Sebastian Eibl's avatar
Sebastian Eibl committed
84
85
86
87
      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;
88
      using oldTorque_type = walberla::mesa_pd::Vec3;
89
      using radiusAtTemperature_type = walberla::real_t;
90
      using currentBlock_type = blockforest::BlockID;
91
92
93
94
95
96
97
98
      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;
99
100
101
102
      using hydrodynamicForce_type = walberla::mesa_pd::Vec3;
      using hydrodynamicTorque_type = walberla::mesa_pd::Vec3;
      using oldHydrodynamicForce_type = walberla::mesa_pd::Vec3;
      using oldHydrodynamicTorque_type = walberla::mesa_pd::Vec3;
103
104
105
106
107
108
109
      using virtualMass_type = walberla::real_t;
      using invMassIncludingVirtual_type = walberla::real_t;
      using oldLinearAcceleration_type = walberla::mesa_pd::Vec3;
      using invInertiaBF_type = walberla::mesa_pd::Mat3;
      using virtualInertiaBF_type = walberla::mesa_pd::Mat3;
      using invInertiaBFIncludingVirtual_type = walberla::mesa_pd::Mat3;
      using oldAngularAcceleration_type = walberla::mesa_pd::Vec3;
110
111
      using clusterID_type = int64_t;
      using segmentID_type = int64_t;
112
113
114
      using neighborState_type = std::unordered_set<walberla::mpi::MPIRank>;

      
Sebastian Eibl's avatar
Sebastian Eibl committed
115
      uid_type const & getUid() const {return storage_.getUid(i_);}
116
      uid_type& getUidRef() {return storage_.getUidRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
117
      void setUid(uid_type const & v) { storage_.setUid(i_, v);}
118
      
Sebastian Eibl's avatar
Sebastian Eibl committed
119
      position_type const & getPosition() const {return storage_.getPosition(i_);}
120
      position_type& getPositionRef() {return storage_.getPositionRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
121
      void setPosition(position_type const & v) { storage_.setPosition(i_, v);}
122
      
Sebastian Eibl's avatar
Sebastian Eibl committed
123
      interactionRadius_type const & getInteractionRadius() const {return storage_.getInteractionRadius(i_);}
124
      interactionRadius_type& getInteractionRadiusRef() {return storage_.getInteractionRadiusRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
125
      void setInteractionRadius(interactionRadius_type const & v) { storage_.setInteractionRadius(i_, v);}
126
      
Sebastian Eibl's avatar
Sebastian Eibl committed
127
      flags_type const & getFlags() const {return storage_.getFlags(i_);}
128
      flags_type& getFlagsRef() {return storage_.getFlagsRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
129
      void setFlags(flags_type const & v) { storage_.setFlags(i_, v);}
130
      
Sebastian Eibl's avatar
Sebastian Eibl committed
131
      owner_type const & getOwner() const {return storage_.getOwner(i_);}
132
      owner_type& getOwnerRef() {return storage_.getOwnerRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
133
      void setOwner(owner_type const & v) { storage_.setOwner(i_, v);}
134
      
Sebastian Eibl's avatar
Sebastian Eibl committed
135
      ghostOwners_type const & getGhostOwners() const {return storage_.getGhostOwners(i_);}
136
      ghostOwners_type& getGhostOwnersRef() {return storage_.getGhostOwnersRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
137
      void setGhostOwners(ghostOwners_type const & v) { storage_.setGhostOwners(i_, v);}
138
      
Sebastian Eibl's avatar
Sebastian Eibl committed
139
      linearVelocity_type const & getLinearVelocity() const {return storage_.getLinearVelocity(i_);}
140
      linearVelocity_type& getLinearVelocityRef() {return storage_.getLinearVelocityRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
141
      void setLinearVelocity(linearVelocity_type const & v) { storage_.setLinearVelocity(i_, v);}
142
      
Sebastian Eibl's avatar
Sebastian Eibl committed
143
      invMass_type const & getInvMass() const {return storage_.getInvMass(i_);}
144
      invMass_type& getInvMassRef() {return storage_.getInvMassRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
145
      void setInvMass(invMass_type const & v) { storage_.setInvMass(i_, v);}
146
      
Sebastian Eibl's avatar
Sebastian Eibl committed
147
      force_type const & getForce() const {return storage_.getForce(i_);}
148
      force_type& getForceRef() {return storage_.getForceRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
149
      void setForce(force_type const & v) { storage_.setForce(i_, v);}
150
      
Sebastian Eibl's avatar
Sebastian Eibl committed
151
      oldForce_type const & getOldForce() const {return storage_.getOldForce(i_);}
152
      oldForce_type& getOldForceRef() {return storage_.getOldForceRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
153
      void setOldForce(oldForce_type const & v) { storage_.setOldForce(i_, v);}
154
      
Sebastian Eibl's avatar
Sebastian Eibl committed
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
      shapeID_type const & getShapeID() const {return storage_.getShapeID(i_);}
      shapeID_type& getShapeIDRef() {return storage_.getShapeIDRef(i_);}
      void setShapeID(shapeID_type const & v) { storage_.setShapeID(i_, v);}
      
      rotation_type const & getRotation() const {return storage_.getRotation(i_);}
      rotation_type& getRotationRef() {return storage_.getRotationRef(i_);}
      void setRotation(rotation_type const & v) { storage_.setRotation(i_, v);}
      
      angularVelocity_type const & getAngularVelocity() const {return storage_.getAngularVelocity(i_);}
      angularVelocity_type& getAngularVelocityRef() {return storage_.getAngularVelocityRef(i_);}
      void setAngularVelocity(angularVelocity_type const & v) { storage_.setAngularVelocity(i_, v);}
      
      torque_type const & getTorque() const {return storage_.getTorque(i_);}
      torque_type& getTorqueRef() {return storage_.getTorqueRef(i_);}
      void setTorque(torque_type const & v) { storage_.setTorque(i_, v);}
      
Sebastian Eibl's avatar
Sebastian Eibl committed
171
      oldTorque_type const & getOldTorque() const {return storage_.getOldTorque(i_);}
172
      oldTorque_type& getOldTorqueRef() {return storage_.getOldTorqueRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
173
      void setOldTorque(oldTorque_type const & v) { storage_.setOldTorque(i_, v);}
174
      
175
176
177
      radiusAtTemperature_type const & getRadiusAtTemperature() const {return storage_.getRadiusAtTemperature(i_);}
      radiusAtTemperature_type& getRadiusAtTemperatureRef() {return storage_.getRadiusAtTemperatureRef(i_);}
      void setRadiusAtTemperature(radiusAtTemperature_type const & v) { storage_.setRadiusAtTemperature(i_, v);}
178
      
Sebastian Eibl's avatar
Sebastian Eibl committed
179
180
181
182
183
      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_);}
184
      type_type& getTypeRef() {return storage_.getTypeRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
185
      void setType(type_type const & v) { storage_.setType(i_, v);}
186
      
Sebastian Eibl's avatar
Sebastian Eibl committed
187
      nextParticle_type const & getNextParticle() const {return storage_.getNextParticle(i_);}
188
      nextParticle_type& getNextParticleRef() {return storage_.getNextParticleRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
189
      void setNextParticle(nextParticle_type const & v) { storage_.setNextParticle(i_, v);}
190
      
Sebastian Eibl's avatar
Sebastian Eibl committed
191
      oldContactHistory_type const & getOldContactHistory() const {return storage_.getOldContactHistory(i_);}
192
      oldContactHistory_type& getOldContactHistoryRef() {return storage_.getOldContactHistoryRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
193
      void setOldContactHistory(oldContactHistory_type const & v) { storage_.setOldContactHistory(i_, v);}
194
      
Sebastian Eibl's avatar
Sebastian Eibl committed
195
      newContactHistory_type const & getNewContactHistory() const {return storage_.getNewContactHistory(i_);}
196
      newContactHistory_type& getNewContactHistoryRef() {return storage_.getNewContactHistoryRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
197
      void setNewContactHistory(newContactHistory_type const & v) { storage_.setNewContactHistory(i_, v);}
198
      
Sebastian Eibl's avatar
Sebastian Eibl committed
199
      temperature_type const & getTemperature() const {return storage_.getTemperature(i_);}
200
      temperature_type& getTemperatureRef() {return storage_.getTemperatureRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
201
      void setTemperature(temperature_type const & v) { storage_.setTemperature(i_, v);}
202
      
Sebastian Eibl's avatar
Sebastian Eibl committed
203
      heatFlux_type const & getHeatFlux() const {return storage_.getHeatFlux(i_);}
204
      heatFlux_type& getHeatFluxRef() {return storage_.getHeatFluxRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
205
      void setHeatFlux(heatFlux_type const & v) { storage_.setHeatFlux(i_, v);}
206
      
Sebastian Eibl's avatar
Sebastian Eibl committed
207
      dv_type const & getDv() const {return storage_.getDv(i_);}
208
      dv_type& getDvRef() {return storage_.getDvRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
209
      void setDv(dv_type const & v) { storage_.setDv(i_, v);}
210
      
Sebastian Eibl's avatar
Sebastian Eibl committed
211
      dw_type const & getDw() const {return storage_.getDw(i_);}
212
      dw_type& getDwRef() {return storage_.getDwRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
213
      void setDw(dw_type const & v) { storage_.setDw(i_, v);}
214
      
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
      hydrodynamicForce_type const & getHydrodynamicForce() const {return storage_.getHydrodynamicForce(i_);}
      hydrodynamicForce_type& getHydrodynamicForceRef() {return storage_.getHydrodynamicForceRef(i_);}
      void setHydrodynamicForce(hydrodynamicForce_type const & v) { storage_.setHydrodynamicForce(i_, v);}
      
      hydrodynamicTorque_type const & getHydrodynamicTorque() const {return storage_.getHydrodynamicTorque(i_);}
      hydrodynamicTorque_type& getHydrodynamicTorqueRef() {return storage_.getHydrodynamicTorqueRef(i_);}
      void setHydrodynamicTorque(hydrodynamicTorque_type const & v) { storage_.setHydrodynamicTorque(i_, v);}
      
      oldHydrodynamicForce_type const & getOldHydrodynamicForce() const {return storage_.getOldHydrodynamicForce(i_);}
      oldHydrodynamicForce_type& getOldHydrodynamicForceRef() {return storage_.getOldHydrodynamicForceRef(i_);}
      void setOldHydrodynamicForce(oldHydrodynamicForce_type const & v) { storage_.setOldHydrodynamicForce(i_, v);}
      
      oldHydrodynamicTorque_type const & getOldHydrodynamicTorque() const {return storage_.getOldHydrodynamicTorque(i_);}
      oldHydrodynamicTorque_type& getOldHydrodynamicTorqueRef() {return storage_.getOldHydrodynamicTorqueRef(i_);}
      void setOldHydrodynamicTorque(oldHydrodynamicTorque_type const & v) { storage_.setOldHydrodynamicTorque(i_, v);}
      
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
258
      virtualMass_type const & getVirtualMass() const {return storage_.getVirtualMass(i_);}
      virtualMass_type& getVirtualMassRef() {return storage_.getVirtualMassRef(i_);}
      void setVirtualMass(virtualMass_type const & v) { storage_.setVirtualMass(i_, v);}
      
      invMassIncludingVirtual_type const & getInvMassIncludingVirtual() const {return storage_.getInvMassIncludingVirtual(i_);}
      invMassIncludingVirtual_type& getInvMassIncludingVirtualRef() {return storage_.getInvMassIncludingVirtualRef(i_);}
      void setInvMassIncludingVirtual(invMassIncludingVirtual_type const & v) { storage_.setInvMassIncludingVirtual(i_, v);}
      
      oldLinearAcceleration_type const & getOldLinearAcceleration() const {return storage_.getOldLinearAcceleration(i_);}
      oldLinearAcceleration_type& getOldLinearAccelerationRef() {return storage_.getOldLinearAccelerationRef(i_);}
      void setOldLinearAcceleration(oldLinearAcceleration_type const & v) { storage_.setOldLinearAcceleration(i_, v);}
      
      invInertiaBF_type const & getInvInertiaBF() const {return storage_.getInvInertiaBF(i_);}
      invInertiaBF_type& getInvInertiaBFRef() {return storage_.getInvInertiaBFRef(i_);}
      void setInvInertiaBF(invInertiaBF_type const & v) { storage_.setInvInertiaBF(i_, v);}
      
      virtualInertiaBF_type const & getVirtualInertiaBF() const {return storage_.getVirtualInertiaBF(i_);}
      virtualInertiaBF_type& getVirtualInertiaBFRef() {return storage_.getVirtualInertiaBFRef(i_);}
      void setVirtualInertiaBF(virtualInertiaBF_type const & v) { storage_.setVirtualInertiaBF(i_, v);}
      
      invInertiaBFIncludingVirtual_type const & getInvInertiaBFIncludingVirtual() const {return storage_.getInvInertiaBFIncludingVirtual(i_);}
      invInertiaBFIncludingVirtual_type& getInvInertiaBFIncludingVirtualRef() {return storage_.getInvInertiaBFIncludingVirtualRef(i_);}
      void setInvInertiaBFIncludingVirtual(invInertiaBFIncludingVirtual_type const & v) { storage_.setInvInertiaBFIncludingVirtual(i_, v);}
      
      oldAngularAcceleration_type const & getOldAngularAcceleration() const {return storage_.getOldAngularAcceleration(i_);}
      oldAngularAcceleration_type& getOldAngularAccelerationRef() {return storage_.getOldAngularAccelerationRef(i_);}
      void setOldAngularAcceleration(oldAngularAcceleration_type const & v) { storage_.setOldAngularAcceleration(i_, v);}
      
259
260
261
262
263
264
265
266
      clusterID_type const & getClusterID() const {return storage_.getClusterID(i_);}
      clusterID_type& getClusterIDRef() {return storage_.getClusterIDRef(i_);}
      void setClusterID(clusterID_type const & v) { storage_.setClusterID(i_, v);}
      
      segmentID_type const & getSegmentID() const {return storage_.getSegmentID(i_);}
      segmentID_type& getSegmentIDRef() {return storage_.getSegmentIDRef(i_);}
      void setSegmentID(segmentID_type const & v) { storage_.setSegmentID(i_, v);}
      
Sebastian Eibl's avatar
Sebastian Eibl committed
267
      neighborState_type const & getNeighborState() const {return storage_.getNeighborState(i_);}
268
      neighborState_type& getNeighborStateRef() {return storage_.getNeighborStateRef(i_);}
Sebastian Eibl's avatar
Sebastian Eibl committed
269
      void setNeighborState(neighborState_type const & v) { storage_.setNeighborState(i_, v);}
Sebastian Eibl's avatar
Sebastian Eibl committed
270
      
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327

      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()); }
328
   Particle operator[](const size_t n) { return *iterator(this, n); }
329
330

   
331
332
333
334
335
336
337
338
339
340
   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 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;
Sebastian Eibl's avatar
Sebastian Eibl committed
341
342
343
344
   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;
345
   using oldTorque_type = walberla::mesa_pd::Vec3;
346
   using radiusAtTemperature_type = walberla::real_t;
347
   using currentBlock_type = blockforest::BlockID;
348
349
350
351
352
353
354
355
   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;
356
357
358
359
   using hydrodynamicForce_type = walberla::mesa_pd::Vec3;
   using hydrodynamicTorque_type = walberla::mesa_pd::Vec3;
   using oldHydrodynamicForce_type = walberla::mesa_pd::Vec3;
   using oldHydrodynamicTorque_type = walberla::mesa_pd::Vec3;
360
361
362
363
364
365
366
   using virtualMass_type = walberla::real_t;
   using invMassIncludingVirtual_type = walberla::real_t;
   using oldLinearAcceleration_type = walberla::mesa_pd::Vec3;
   using invInertiaBF_type = walberla::mesa_pd::Mat3;
   using virtualInertiaBF_type = walberla::mesa_pd::Mat3;
   using invInertiaBFIncludingVirtual_type = walberla::mesa_pd::Mat3;
   using oldAngularAcceleration_type = walberla::mesa_pd::Vec3;
367
368
   using clusterID_type = int64_t;
   using segmentID_type = int64_t;
369
370
371
   using neighborState_type = std::unordered_set<walberla::mpi::MPIRank>;

   
Sebastian Eibl's avatar
Sebastian Eibl committed
372
   uid_type const & getUid(const size_t idx) const {return uid_[idx];}
373
   uid_type& getUidRef(const size_t idx) {return uid_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
374
   void setUid(const size_t idx, uid_type const & v) { uid_[idx] = v; }
375
   
Sebastian Eibl's avatar
Sebastian Eibl committed
376
   position_type const & getPosition(const size_t idx) const {return position_[idx];}
377
   position_type& getPositionRef(const size_t idx) {return position_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
378
   void setPosition(const size_t idx, position_type const & v) { position_[idx] = v; }
379
   
Sebastian Eibl's avatar
Sebastian Eibl committed
380
   interactionRadius_type const & getInteractionRadius(const size_t idx) const {return interactionRadius_[idx];}
381
   interactionRadius_type& getInteractionRadiusRef(const size_t idx) {return interactionRadius_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
382
   void setInteractionRadius(const size_t idx, interactionRadius_type const & v) { interactionRadius_[idx] = v; }
383
   
Sebastian Eibl's avatar
Sebastian Eibl committed
384
   flags_type const & getFlags(const size_t idx) const {return flags_[idx];}
385
   flags_type& getFlagsRef(const size_t idx) {return flags_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
386
   void setFlags(const size_t idx, flags_type const & v) { flags_[idx] = v; }
387
   
Sebastian Eibl's avatar
Sebastian Eibl committed
388
   owner_type const & getOwner(const size_t idx) const {return owner_[idx];}
389
   owner_type& getOwnerRef(const size_t idx) {return owner_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
390
   void setOwner(const size_t idx, owner_type const & v) { owner_[idx] = v; }
391
   
Sebastian Eibl's avatar
Sebastian Eibl committed
392
   ghostOwners_type const & getGhostOwners(const size_t idx) const {return ghostOwners_[idx];}
393
   ghostOwners_type& getGhostOwnersRef(const size_t idx) {return ghostOwners_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
394
   void setGhostOwners(const size_t idx, ghostOwners_type const & v) { ghostOwners_[idx] = v; }
395
   
Sebastian Eibl's avatar
Sebastian Eibl committed
396
   linearVelocity_type const & getLinearVelocity(const size_t idx) const {return linearVelocity_[idx];}
397
   linearVelocity_type& getLinearVelocityRef(const size_t idx) {return linearVelocity_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
398
   void setLinearVelocity(const size_t idx, linearVelocity_type const & v) { linearVelocity_[idx] = v; }
399
   
Sebastian Eibl's avatar
Sebastian Eibl committed
400
   invMass_type const & getInvMass(const size_t idx) const {return invMass_[idx];}
401
   invMass_type& getInvMassRef(const size_t idx) {return invMass_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
402
   void setInvMass(const size_t idx, invMass_type const & v) { invMass_[idx] = v; }
403
   
Sebastian Eibl's avatar
Sebastian Eibl committed
404
   force_type const & getForce(const size_t idx) const {return force_[idx];}
405
   force_type& getForceRef(const size_t idx) {return force_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
406
   void setForce(const size_t idx, force_type const & v) { force_[idx] = v; }
407
   
Sebastian Eibl's avatar
Sebastian Eibl committed
408
   oldForce_type const & getOldForce(const size_t idx) const {return oldForce_[idx];}
409
   oldForce_type& getOldForceRef(const size_t idx) {return oldForce_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
410
   void setOldForce(const size_t idx, oldForce_type const & v) { oldForce_[idx] = v; }
411
   
Sebastian Eibl's avatar
Sebastian Eibl committed
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
   shapeID_type const & getShapeID(const size_t idx) const {return shapeID_[idx];}
   shapeID_type& getShapeIDRef(const size_t idx) {return shapeID_[idx];}
   void setShapeID(const size_t idx, shapeID_type const & v) { shapeID_[idx] = v; }
   
   rotation_type const & getRotation(const size_t idx) const {return rotation_[idx];}
   rotation_type& getRotationRef(const size_t idx) {return rotation_[idx];}
   void setRotation(const size_t idx, rotation_type const & v) { rotation_[idx] = v; }
   
   angularVelocity_type const & getAngularVelocity(const size_t idx) const {return angularVelocity_[idx];}
   angularVelocity_type& getAngularVelocityRef(const size_t idx) {return angularVelocity_[idx];}
   void setAngularVelocity(const size_t idx, angularVelocity_type const & v) { angularVelocity_[idx] = v; }
   
   torque_type const & getTorque(const size_t idx) const {return torque_[idx];}
   torque_type& getTorqueRef(const size_t idx) {return torque_[idx];}
   void setTorque(const size_t idx, torque_type const & v) { torque_[idx] = v; }
   
Sebastian Eibl's avatar
Sebastian Eibl committed
428
   oldTorque_type const & getOldTorque(const size_t idx) const {return oldTorque_[idx];}
429
   oldTorque_type& getOldTorqueRef(const size_t idx) {return oldTorque_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
430
431
   void setOldTorque(const size_t idx, oldTorque_type const & v) { oldTorque_[idx] = v; }
   
432
433
434
   radiusAtTemperature_type const & getRadiusAtTemperature(const size_t idx) const {return radiusAtTemperature_[idx];}
   radiusAtTemperature_type& getRadiusAtTemperatureRef(const size_t idx) {return radiusAtTemperature_[idx];}
   void setRadiusAtTemperature(const size_t idx, radiusAtTemperature_type const & v) { radiusAtTemperature_[idx] = v; }
435
   
Sebastian Eibl's avatar
Sebastian Eibl committed
436
437
438
   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; }
439
   
Sebastian Eibl's avatar
Sebastian Eibl committed
440
   type_type const & getType(const size_t idx) const {return type_[idx];}
441
   type_type& getTypeRef(const size_t idx) {return type_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
442
   void setType(const size_t idx, type_type const & v) { type_[idx] = v; }
443
   
Sebastian Eibl's avatar
Sebastian Eibl committed
444
   nextParticle_type const & getNextParticle(const size_t idx) const {return nextParticle_[idx];}
445
   nextParticle_type& getNextParticleRef(const size_t idx) {return nextParticle_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
446
   void setNextParticle(const size_t idx, nextParticle_type const & v) { nextParticle_[idx] = v; }
447
   
Sebastian Eibl's avatar
Sebastian Eibl committed
448
   oldContactHistory_type const & getOldContactHistory(const size_t idx) const {return oldContactHistory_[idx];}
449
   oldContactHistory_type& getOldContactHistoryRef(const size_t idx) {return oldContactHistory_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
450
   void setOldContactHistory(const size_t idx, oldContactHistory_type const & v) { oldContactHistory_[idx] = v; }
451
   
Sebastian Eibl's avatar
Sebastian Eibl committed
452
   newContactHistory_type const & getNewContactHistory(const size_t idx) const {return newContactHistory_[idx];}
453
   newContactHistory_type& getNewContactHistoryRef(const size_t idx) {return newContactHistory_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
454
   void setNewContactHistory(const size_t idx, newContactHistory_type const & v) { newContactHistory_[idx] = v; }
455
   
Sebastian Eibl's avatar
Sebastian Eibl committed
456
   temperature_type const & getTemperature(const size_t idx) const {return temperature_[idx];}
457
   temperature_type& getTemperatureRef(const size_t idx) {return temperature_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
458
   void setTemperature(const size_t idx, temperature_type const & v) { temperature_[idx] = v; }
459
   
Sebastian Eibl's avatar
Sebastian Eibl committed
460
   heatFlux_type const & getHeatFlux(const size_t idx) const {return heatFlux_[idx];}
461
   heatFlux_type& getHeatFluxRef(const size_t idx) {return heatFlux_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
462
   void setHeatFlux(const size_t idx, heatFlux_type const & v) { heatFlux_[idx] = v; }
463
   
Sebastian Eibl's avatar
Sebastian Eibl committed
464
   dv_type const & getDv(const size_t idx) const {return dv_[idx];}
465
   dv_type& getDvRef(const size_t idx) {return dv_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
466
   void setDv(const size_t idx, dv_type const & v) { dv_[idx] = v; }
467
   
Sebastian Eibl's avatar
Sebastian Eibl committed
468
   dw_type const & getDw(const size_t idx) const {return dw_[idx];}
469
   dw_type& getDwRef(const size_t idx) {return dw_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
470
   void setDw(const size_t idx, dw_type const & v) { dw_[idx] = v; }
471
   
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
   hydrodynamicForce_type const & getHydrodynamicForce(const size_t idx) const {return hydrodynamicForce_[idx];}
   hydrodynamicForce_type& getHydrodynamicForceRef(const size_t idx) {return hydrodynamicForce_[idx];}
   void setHydrodynamicForce(const size_t idx, hydrodynamicForce_type const & v) { hydrodynamicForce_[idx] = v; }
   
   hydrodynamicTorque_type const & getHydrodynamicTorque(const size_t idx) const {return hydrodynamicTorque_[idx];}
   hydrodynamicTorque_type& getHydrodynamicTorqueRef(const size_t idx) {return hydrodynamicTorque_[idx];}
   void setHydrodynamicTorque(const size_t idx, hydrodynamicTorque_type const & v) { hydrodynamicTorque_[idx] = v; }
   
   oldHydrodynamicForce_type const & getOldHydrodynamicForce(const size_t idx) const {return oldHydrodynamicForce_[idx];}
   oldHydrodynamicForce_type& getOldHydrodynamicForceRef(const size_t idx) {return oldHydrodynamicForce_[idx];}
   void setOldHydrodynamicForce(const size_t idx, oldHydrodynamicForce_type const & v) { oldHydrodynamicForce_[idx] = v; }
   
   oldHydrodynamicTorque_type const & getOldHydrodynamicTorque(const size_t idx) const {return oldHydrodynamicTorque_[idx];}
   oldHydrodynamicTorque_type& getOldHydrodynamicTorqueRef(const size_t idx) {return oldHydrodynamicTorque_[idx];}
   void setOldHydrodynamicTorque(const size_t idx, oldHydrodynamicTorque_type const & v) { oldHydrodynamicTorque_[idx] = v; }
   
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
   virtualMass_type const & getVirtualMass(const size_t idx) const {return virtualMass_[idx];}
   virtualMass_type& getVirtualMassRef(const size_t idx) {return virtualMass_[idx];}
   void setVirtualMass(const size_t idx, virtualMass_type const & v) { virtualMass_[idx] = v; }
   
   invMassIncludingVirtual_type const & getInvMassIncludingVirtual(const size_t idx) const {return invMassIncludingVirtual_[idx];}
   invMassIncludingVirtual_type& getInvMassIncludingVirtualRef(const size_t idx) {return invMassIncludingVirtual_[idx];}
   void setInvMassIncludingVirtual(const size_t idx, invMassIncludingVirtual_type const & v) { invMassIncludingVirtual_[idx] = v; }
   
   oldLinearAcceleration_type const & getOldLinearAcceleration(const size_t idx) const {return oldLinearAcceleration_[idx];}
   oldLinearAcceleration_type& getOldLinearAccelerationRef(const size_t idx) {return oldLinearAcceleration_[idx];}
   void setOldLinearAcceleration(const size_t idx, oldLinearAcceleration_type const & v) { oldLinearAcceleration_[idx] = v; }
   
   invInertiaBF_type const & getInvInertiaBF(const size_t idx) const {return invInertiaBF_[idx];}
   invInertiaBF_type& getInvInertiaBFRef(const size_t idx) {return invInertiaBF_[idx];}
   void setInvInertiaBF(const size_t idx, invInertiaBF_type const & v) { invInertiaBF_[idx] = v; }
   
   virtualInertiaBF_type const & getVirtualInertiaBF(const size_t idx) const {return virtualInertiaBF_[idx];}
   virtualInertiaBF_type& getVirtualInertiaBFRef(const size_t idx) {return virtualInertiaBF_[idx];}
   void setVirtualInertiaBF(const size_t idx, virtualInertiaBF_type const & v) { virtualInertiaBF_[idx] = v; }
   
   invInertiaBFIncludingVirtual_type const & getInvInertiaBFIncludingVirtual(const size_t idx) const {return invInertiaBFIncludingVirtual_[idx];}
   invInertiaBFIncludingVirtual_type& getInvInertiaBFIncludingVirtualRef(const size_t idx) {return invInertiaBFIncludingVirtual_[idx];}
   void setInvInertiaBFIncludingVirtual(const size_t idx, invInertiaBFIncludingVirtual_type const & v) { invInertiaBFIncludingVirtual_[idx] = v; }
   
   oldAngularAcceleration_type const & getOldAngularAcceleration(const size_t idx) const {return oldAngularAcceleration_[idx];}
   oldAngularAcceleration_type& getOldAngularAccelerationRef(const size_t idx) {return oldAngularAcceleration_[idx];}
   void setOldAngularAcceleration(const size_t idx, oldAngularAcceleration_type const & v) { oldAngularAcceleration_[idx] = v; }
   
516
517
518
519
520
521
522
523
   clusterID_type const & getClusterID(const size_t idx) const {return clusterID_[idx];}
   clusterID_type& getClusterIDRef(const size_t idx) {return clusterID_[idx];}
   void setClusterID(const size_t idx, clusterID_type const & v) { clusterID_[idx] = v; }
   
   segmentID_type const & getSegmentID(const size_t idx) const {return segmentID_[idx];}
   segmentID_type& getSegmentIDRef(const size_t idx) {return segmentID_[idx];}
   void setSegmentID(const size_t idx, segmentID_type const & v) { segmentID_[idx] = v; }
   
Sebastian Eibl's avatar
Sebastian Eibl committed
524
   neighborState_type const & getNeighborState(const size_t idx) const {return neighborState_[idx];}
525
   neighborState_type& getNeighborStateRef(const size_t idx) {return neighborState_[idx];}
Sebastian Eibl's avatar
Sebastian Eibl committed
526
   void setNeighborState(const size_t idx, neighborState_type const & v) { neighborState_[idx] = v; }
Sebastian Eibl's avatar
Sebastian Eibl committed
527
   
528
529
530
531
532
533
534
535
536
537

   /**
    * @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
    */
538
   inline iterator create(const uid_type& uid);
539
540
541
542
   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
543
   inline iterator find(const uid_type& uid);
544
545
546
   inline void reserve(const size_t size);
   inline void clear();
   inline size_t size() const;
547
548
   template <class Compare>
   void sort(Compare comp);
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618

   /**
    * 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:
619
620
621
622
623
624
625
626
627
628
   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<linearVelocity_type> linearVelocity_ {};
   std::vector<invMass_type> invMass_ {};
   std::vector<force_type> force_ {};
   std::vector<oldForce_type> oldForce_ {};
Sebastian Eibl's avatar
Sebastian Eibl committed
629
630
631
632
   std::vector<shapeID_type> shapeID_ {};
   std::vector<rotation_type> rotation_ {};
   std::vector<angularVelocity_type> angularVelocity_ {};
   std::vector<torque_type> torque_ {};
633
   std::vector<oldTorque_type> oldTorque_ {};
634
   std::vector<radiusAtTemperature_type> radiusAtTemperature_ {};
Sebastian Eibl's avatar
Sebastian Eibl committed
635
   std::vector<currentBlock_type> currentBlock_ {};
636
637
638
639
640
641
642
643
   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_ {};
644
645
646
647
   std::vector<hydrodynamicForce_type> hydrodynamicForce_ {};
   std::vector<hydrodynamicTorque_type> hydrodynamicTorque_ {};
   std::vector<oldHydrodynamicForce_type> oldHydrodynamicForce_ {};
   std::vector<oldHydrodynamicTorque_type> oldHydrodynamicTorque_ {};
648
649
650
651
652
653
654
   std::vector<virtualMass_type> virtualMass_ {};
   std::vector<invMassIncludingVirtual_type> invMassIncludingVirtual_ {};
   std::vector<oldLinearAcceleration_type> oldLinearAcceleration_ {};
   std::vector<invInertiaBF_type> invInertiaBF_ {};
   std::vector<virtualInertiaBF_type> virtualInertiaBF_ {};
   std::vector<invInertiaBFIncludingVirtual_type> invInertiaBFIncludingVirtual_ {};
   std::vector<oldAngularAcceleration_type> oldAngularAcceleration_ {};
655
656
   std::vector<clusterID_type> clusterID_ {};
   std::vector<segmentID_type> segmentID_ {};
657
658
659
   std::vector<neighborState_type> neighborState_ {};
   std::unordered_map<uid_type, size_t> uidToIdx_;
   static_assert(std::is_same<uid_type, id_t>::value,
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
                 "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();
   getLinearVelocityRef() = rhs.getLinearVelocity();
   getInvMassRef() = rhs.getInvMass();
   getForceRef() = rhs.getForce();
   getOldForceRef() = rhs.getOldForce();
Sebastian Eibl's avatar
Sebastian Eibl committed
677
678
679
680
   getShapeIDRef() = rhs.getShapeID();
   getRotationRef() = rhs.getRotation();
   getAngularVelocityRef() = rhs.getAngularVelocity();
   getTorqueRef() = rhs.getTorque();
681
   getOldTorqueRef() = rhs.getOldTorque();
682
   getRadiusAtTemperatureRef() = rhs.getRadiusAtTemperature();
Sebastian Eibl's avatar
Sebastian Eibl committed
683
   getCurrentBlockRef() = rhs.getCurrentBlock();
684
685
686
687
688
689
   getTypeRef() = rhs.getType();
   getNextParticleRef() = rhs.getNextParticle();
   getOldContactHistoryRef() = rhs.getOldContactHistory();
   getNewContactHistoryRef() = rhs.getNewContactHistory();
   getTemperatureRef() = rhs.getTemperature();
   getHeatFluxRef() = rhs.getHeatFlux();
690
691
   getDvRef() = rhs.getDv();
   getDwRef() = rhs.getDw();
692
693
694
695
   getHydrodynamicForceRef() = rhs.getHydrodynamicForce();
   getHydrodynamicTorqueRef() = rhs.getHydrodynamicTorque();
   getOldHydrodynamicForceRef() = rhs.getOldHydrodynamicForce();
   getOldHydrodynamicTorqueRef() = rhs.getOldHydrodynamicTorque();
696
697
698
699
700
701
702
   getVirtualMassRef() = rhs.getVirtualMass();
   getInvMassIncludingVirtualRef() = rhs.getInvMassIncludingVirtual();
   getOldLinearAccelerationRef() = rhs.getOldLinearAcceleration();
   getInvInertiaBFRef() = rhs.getInvInertiaBF();
   getVirtualInertiaBFRef() = rhs.getVirtualInertiaBF();
   getInvInertiaBFIncludingVirtualRef() = rhs.getInvInertiaBFIncludingVirtual();
   getOldAngularAccelerationRef() = rhs.getOldAngularAcceleration();
703
704
   getClusterIDRef() = rhs.getClusterID();
   getSegmentIDRef() = rhs.getSegmentID();
Sebastian Eibl's avatar
Sebastian Eibl committed
705
   getNeighborStateRef() = rhs.getNeighborState();
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
   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());
   getLinearVelocityRef() = std::move(rhs.getLinearVelocityRef());
   getInvMassRef() = std::move(rhs.getInvMassRef());
   getForceRef() = std::move(rhs.getForceRef());
   getOldForceRef() = std::move(rhs.getOldForceRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
722
723
724
725
   getShapeIDRef() = std::move(rhs.getShapeIDRef());
   getRotationRef() = std::move(rhs.getRotationRef());
   getAngularVelocityRef() = std::move(rhs.getAngularVelocityRef());
   getTorqueRef() = std::move(rhs.getTorqueRef());
726
   getOldTorqueRef() = std::move(rhs.getOldTorqueRef());
727
   getRadiusAtTemperatureRef() = std::move(rhs.getRadiusAtTemperatureRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
728
   getCurrentBlockRef() = std::move(rhs.getCurrentBlockRef());
729
730
731
732
733
734
   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());
735
736
   getDvRef() = std::move(rhs.getDvRef());
   getDwRef() = std::move(rhs.getDwRef());
737
738
739
740
   getHydrodynamicForceRef() = std::move(rhs.getHydrodynamicForceRef());
   getHydrodynamicTorqueRef() = std::move(rhs.getHydrodynamicTorqueRef());
   getOldHydrodynamicForceRef() = std::move(rhs.getOldHydrodynamicForceRef());
   getOldHydrodynamicTorqueRef() = std::move(rhs.getOldHydrodynamicTorqueRef());
741
742
743
744
745
746
747
   getVirtualMassRef() = std::move(rhs.getVirtualMassRef());
   getInvMassIncludingVirtualRef() = std::move(rhs.getInvMassIncludingVirtualRef());
   getOldLinearAccelerationRef() = std::move(rhs.getOldLinearAccelerationRef());
   getInvInertiaBFRef() = std::move(rhs.getInvInertiaBFRef());
   getVirtualInertiaBFRef() = std::move(rhs.getVirtualInertiaBFRef());
   getInvInertiaBFIncludingVirtualRef() = std::move(rhs.getInvInertiaBFIncludingVirtualRef());
   getOldAngularAccelerationRef() = std::move(rhs.getOldAngularAccelerationRef());
748
749
   getClusterIDRef() = std::move(rhs.getClusterIDRef());
   getSegmentIDRef() = std::move(rhs.getSegmentIDRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
750
   getNeighborStateRef() = std::move(rhs.getNeighborStateRef());
751
752
753
   return *this;
}

754
755
756
757
758
759
760
761
762
763
764
765
766
767
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.getLinearVelocityRef(), rhs.getLinearVelocityRef());
   std::swap(lhs.getInvMassRef(), rhs.getInvMassRef());
   std::swap(lhs.getForceRef(), rhs.getForceRef());
   std::swap(lhs.getOldForceRef(), rhs.getOldForceRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
768
769
770
771
   std::swap(lhs.getShapeIDRef(), rhs.getShapeIDRef());
   std::swap(lhs.getRotationRef(), rhs.getRotationRef());
   std::swap(lhs.getAngularVelocityRef(), rhs.getAngularVelocityRef());
   std::swap(lhs.getTorqueRef(), rhs.getTorqueRef());
772
   std::swap(lhs.getOldTorqueRef(), rhs.getOldTorqueRef());
773
   std::swap(lhs.getRadiusAtTemperatureRef(), rhs.getRadiusAtTemperatureRef());
Sebastian Eibl's avatar
Sebastian Eibl committed
774
   std::swap(lhs.getCurrentBlockRef(), rhs.getCurrentBlockRef());
775
776
777
778
779
780
   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
781
782
   std::swap(lhs.getDvRef(), rhs.getDvRef());
   std::swap(lhs.getDwRef(), rhs.getDwRef());
783
784
785
786
   std::swap(lhs.getHydrodynamicForceRef(), rhs.getHydrodynamicForceRef());
   std::swap(lhs.getHydrodynamicTorqueRef(), rhs.getHydrodynamicTorqueRef());
   std::swap(lhs.getOldHydrodynamicForceRef(), rhs.getOldHydrodynamicForceRef());
   std::swap(lhs.getOldHydrodynamicTorqueRef(), rhs.getOldHydrodynamicTorqueRef());
787
788
789
790
791
792
793
   std::swap(lhs.getVirtualMassRef(), rhs.getVirtualMassRef());
   std::swap(lhs.getInvMassIncludingVirtualRef(), rhs.getInvMassIncludingVirtualRef());
   std::swap(lhs.getOldLinearAccelerationRef(), rhs.getOldLinearAccelerationRef());
   std::swap(lhs.getInvInertiaBFRef(), rhs.getInvInertiaBFRef());
   std::swap(lhs.getVirtualInertiaBFRef(), rhs.getVirtualInertiaBFRef());
   std::swap(lhs.getInvInertiaBFIncludingVirtualRef(), rhs.getInvInertiaBFIncludingVirtualRef());
   std::swap(lhs.getOldAngularAccelerationRef(), rhs.getOldAngularAccelerationRef());
794
795
   std::swap(lhs.getClusterIDRef(), rhs.getClusterIDRef());
   std::swap(lhs.getSegmentIDRef(), rhs.getSegmentIDRef());
796
   std::swap(lhs.getNeighborStateRef(), rhs.getNeighborStateRef());
797
798
}

799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
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" <<
         "linearVelocity      : " << p.getLinearVelocity() << "\n" <<
         "invMass             : " << p.getInvMass() << "\n" <<
         "force               : " << p.getForce() << "\n" <<
         "oldForce            : " << p.getOldForce() << "\n" <<
Sebastian Eibl's avatar
Sebastian Eibl committed
814
815
816
817
         "shapeID             : " << p.getShapeID() << "\n" <<
         "rotation            : " << p.getRotation() << "\n" <<
         "angularVelocity     : " << p.getAngularVelocity() << "\n" <<
         "torque              : " << p.getTorque() << "\n" <<
818
         "oldTorque           : " << p.getOldTorque() << "\n" <<
819
         "radiusAtTemperature : " << p.getRadiusAtTemperature() << "\n" <<
Sebastian Eibl's avatar
Sebastian Eibl committed
820
         "currentBlock        : " << p.getCurrentBlock() << "\n" <<
821
822
823
824
825
826
         "type                : " << p.getType() << "\n" <<
         "nextParticle        : " << p.getNextParticle() << "\n" <<
         "oldContactHistory   : " << p.getOldContactHistory() << "\n" <<
         "newContactHistory   : " << p.getNewContactHistory() << "\n" <<
         "temperature         : " << p.getTemperature() << "\n" <<
         "heatFlux            : " << p.getHeatFlux() << "\n" <<
827
828
         "dv                  : " << p.getDv() << "\n" <<
         "dw                  : " << p.getDw() << "\n" <<
829
830
831
832
         "hydrodynamicForce   : " << p.getHydrodynamicForce() << "\n" <<
         "hydrodynamicTorque  : " << p.getHydrodynamicTorque() << "\n" <<
         "oldHydrodynamicForce: " << p.getOldHydrodynamicForce() << "\n" <<
         "oldHydrodynamicTorque: " << p.getOldHydrodynamicTorque() << "\n" <<
833
834
835
836
837
838
839
         "virtualMass         : " << p.getVirtualMass() << "\n" <<
         "invMassIncludingVirtual: " << p.getInvMassIncludingVirtual() << "\n" <<
         "oldLinearAcceleration: " << p.getOldLinearAcceleration() << "\n" <<
         "invInertiaBF        : " << p.getInvInertiaBF() << "\n" <<
         "virtualInertiaBF    : " << p.getVirtualInertiaBF() << "\n" <<
         "invInertiaBFIncludingVirtual: " << p.getInvInertiaBFIncludingVirtual() << "\n" <<
         "oldAngularAcceleration: " << p.getOldAngularAcceleration() << "\n" <<
840
841
         "clusterID           : " << p.getClusterID() << "\n" <<
         "segmentID           : " << p.getSegmentID() << "\n" <<
Sebastian Eibl's avatar
Sebastian Eibl committed
842
         "neighborState       : " << p.getNeighborState() << "\n" <<
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
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
         "================================" << 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();
   linearVelocity_.emplace_back(real_t(0));
   invMass_.emplace_back(real_t(1));
   force_.emplace_back(real_t(0));
   oldForce_.emplace_back(real_t(0));
Sebastian Eibl's avatar
Sebastian Eibl committed
930
931
932
933
   shapeID_.emplace_back();
   rotation_.emplace_back();
   angularVelocity_.emplace_back(real_t(0));
   torque_.emplace_back(real_t(0));
934
   oldTorque_.emplace_back(real_t(0));
935
   radiusAtTemperature_.emplace_back(real_t(0));
936
   currentBlock_.emplace_back();
937
938
939
940
941
942
   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));
943
944
   dv_.emplace_back(real_t(0));
   dw_.emplace_back(real_t(0));
945
946
947
948
   hydrodynamicForce_.emplace_back(real_t(0));
   hydrodynamicTorque_.emplace_back(real_t(0));
   oldHydrodynamicForce_.emplace_back(real_t(0));
   oldHydrodynamicTorque_.emplace_back(real_t(0));
949
950
951
952
953
954
955
   virtualMass_.emplace_back(real_t(0));
   invMassIncludingVirtual_.emplace_back(real_t(0));
   oldLinearAcceleration_.emplace_back(real_t(0));
   invInertiaBF_.emplace_back(real_t(0));
   virtualInertiaBF_.emplace_back(real_t(0));
   invInertiaBFIncludingVirtual_.emplace_back(real_t(0));
   oldAngularAcceleration_.emplace_back(real_t(0));
956
957
   clusterID_.emplace_back(-1);
   segmentID_.emplace_back(-1);
Sebastian Eibl's avatar
Sebastian Eibl committed
958
   neighborState_.emplace_back();
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
   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();
   linearVelocity_.pop_back();
   invMass_.pop_back();
   force_.pop_back();
   oldForce_.pop_back();
Sebastian Eibl's avatar
Sebastian Eibl committed
1001
1002
1003
1004
   shapeID_.pop_back();
   rotation_.pop_back();
   angularVelocity_.pop_back();
   torque_.pop_back();
1005
   oldTorque_.pop_back();
1006
   radiusAtTemperature_.pop_back();
Sebastian Eibl's avatar
Sebastian Eibl committed
1007
   currentBlock_.pop_back();
1008
1009
1010
1011
1012
1013
   type_.pop_back();
   nextParticle_.pop_back();
   oldContactHistory_.pop_back();
   newContactHistory_.pop_back();
   temperature_.pop_back();
   heatFlux_.pop_back();
1014
1015
   dv_.pop_back();
   dw_.pop_back();
1016
1017
1018
1019
   hydrodynamicForce_.pop_back();
   hydrodynamicTorque_.pop_back();
   oldHydrodynamicForce_.pop_back();
   oldHydrodynamicTorque_.pop_back();
1020
1021
1022
1023
1024
1025
1026
   virtualMass_.pop_back();
   invMassIncludingVirtual_.pop_back();
   oldLinearAcceleration_.pop_back();
   invInertiaBF_.pop_back();
   virtualInertiaBF_.pop_back();
   invInertiaBFIncludingVirtual_.pop_back();
   oldAngularAcceleration_.pop_back();
1027
1028
   clusterID_.pop_back();
   segmentID_.pop_back();
Sebastian Eibl's avatar
Sebastian Eibl committed
1029
   neighborState_.pop_back();
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
   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();
1043
   WALBERLA_ASSERT_EQUAL(getUid(it->second), uid, "Lookup via uidToIdx map is not up to date!!!");
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
   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);
   linearVelocity_.reserve(size);
   invMass_.reserve(size);
   force_.reserve(size);
   oldForce_.reserve(size);
Sebastian Eibl's avatar
Sebastian Eibl committed
1059
1060
1061
1062
   shapeID_.reserve(size);
   rotation_.reserve(size);
   angularVelocity_.reserve(size);
   torque_.reserve(size);
1063
   oldTorque_.reserve(size);
1064
   radiusAtTemperature_.reserve(size);
Sebastian Eibl's avatar
Sebastian Eibl committed
1065
   currentBlock_.reserve(size);
1066
1067
1068
1069
1070
1071
   type_.reserve(size);
   nextParticle_.reserve(size);
   oldContactHistory_.reserve(size);
   newContactHistory_.reserve(size);
   temperature_.reserve(size);
   heatFlux_.reserve(size);
1072
1073
   dv_.reserve(size);
   dw_.reserve(size);
1074
1075
1076
1077
   hydrodynamicForce_.reserve(size);
   hydrodynamicTorque_.reserve(size);
   oldHydrodynamicForce_.reserve(size);
   oldHydrodynamicTorque_.reserve(size);
1078
1079
1080
1081
1082
1083
1084
   virtualMass_.reserve(size);
   invMassIncludingVirtual_.reserve(size);
   oldLinearAcceleration_.reserve(size);
   invInertiaBF_.reserve(size);
   virtualInertiaBF_.reserve(size);
   invInertiaBFIncludingVirtual_.reserve(size);
   oldAngularAcceleration_.reserve(size);
1085
1086
   clusterID_.reserve(size);
   segmentID_.reserve(size);
Sebastian Eibl's avatar
Sebastian Eibl committed
1087
   neighborState_.reserve(size);
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
}

inline void ParticleStorage::clear()
{
   uid_.clear();
   position_.clear();
   interactionRadius_.clear();
   flags_.clear();
   owner_.clear();
   ghostOwners_.clear();
   linearVelocity_.clear();
   invMass_.clear();
   force_.clear();
   oldForce_.clear();
Sebastian Eibl's avatar
Sebastian Eibl committed
1102
1103
1104
1105
   shapeID_.clear();
   rotation_.clear();
   angularVelocity_.clear();
   torque_.clear();
1106
   oldTorque_.clear();
1107
   radiusAtTemperature_.clear();
Sebastian Eibl's avatar
Sebastian Eibl committed
1108
   currentBlock_.clear();
1109
1110
1111
1112
1113
1114
   type_.clear();
   nextParticle_.clear();
   oldContactHistory_.clear();
   newContactHistory_.clear();
   temperature_.clear();
   heatFlux_.clear();
1115
1116
   dv_.clear();
   dw_.clear();
1117
1118
1119
1120
   hydrodynamicForce_.clear();
   hydrodynamicTorque_.clear();
   oldHydrodynamicForce_.clear();
   oldHydrodynamicTorque_.clear();
1121
1122
1123
1124
1125
1126
1127
   virtualMass_.clear();
   invMassIncludingVirtual_.clear();
   oldLinearAcceleration_.clear();
   invInertiaBF_.clear();
   virtualInertiaBF_.clear();
   invInertiaBFIncludingVirtual_.clear();
   oldAngularAcceleration_.clear();
1128
1129
   clusterID_.clear();
   segmentID_.clear();
Sebastian Eibl's avatar
Sebastian Eibl committed
1130
   neighborState_.clear();
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
   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(), linearVelocity.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), invMass.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), force.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldForce.size() );
Sebastian Eibl's avatar
Sebastian Eibl committed
1146
1147
1148
1149
   //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() );
1150
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldTorque.size() );
1151
   //WALBERLA_ASSERT_EQUAL( uid_.size(), radiusAtTemperature.size() );
Sebastian Eibl's avatar
Sebastian Eibl committed
1152
   //WALBERLA_ASSERT_EQUAL( uid_.size(), currentBlock.size() );
1153
1154
1155
1156
1157
1158
   //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() );
1159
1160
   //WALBERLA_ASSERT_EQUAL( uid_.size(), dv.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), dw.size() );
1161
1162
1163
1164
   //WALBERLA_ASSERT_EQUAL( uid_.size(), hydrodynamicForce.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), hydrodynamicTorque.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldHydrodynamicForce.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldHydrodynamicTorque.size() );
1165
1166
1167
1168
1169
1170
1171
   //WALBERLA_ASSERT_EQUAL( uid_.size(), virtualMass.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), invMassIncludingVirtual.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldLinearAcceleration.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), invInertiaBF.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), virtualInertiaBF.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), invInertiaBFIncludingVirtual.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), oldAngularAcceleration.size() );
1172
1173
   //WALBERLA_ASSERT_EQUAL( uid_.size(), clusterID.size() );
   //WALBERLA_ASSERT_EQUAL( uid_.size(), segmentID.size() );
Sebastian Eibl's avatar
Sebastian Eibl committed
1174
   //WALBERLA_ASSERT_EQUAL( uid_.size(), neighborState.size() );
1175
1176
   return uid_.size();
}
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214