mantaflow  0.10
A framework for fluid simulation
particle.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * MantaFlow fluid solver framework
5  * Copyright 2011 Tobias Pfaff, Nils Thuerey
6  *
7  * This program is free software, distributed under the terms of the
8  * GNU General Public License (GPL)
9  * http://www.gnu.org/licenses
10  *
11  * Base class for particle systems
12  *
13  ******************************************************************************/
14 
15 #ifndef _PARTICLE_H
16 #define _PARTICLE_H
17 
18 #include <vector>
19 #include "grid.h"
20 #include "vectorbase.h"
21 #include "integrator.h"
22 #include "randomstream.h"
23 namespace Manta {
24 
25 // fwd decl
26 template<class T> class Grid;
27 class ParticleDataBase;
28 template<class T> class ParticleDataImpl;
29 
32 PYTHON class ParticleBase : public PbClass {
33 public:
34  enum SystemType { BASE=0, PARTICLE, VORTEX, FILAMENT, FLIP, TURBULENCE, INDEX };
35 
36  enum ParticleStatus {
37  PNONE = 0,
38  PNEW = (1<<1), // particles newly created in this step
39  PDELETE = (1<<10), // mark as deleted, will be deleted in next compress() step
40  PINVALID = (1<<30), // unused
41  };
42 
43  PYTHON() ParticleBase(FluidSolver* parent);
44  virtual ~ParticleBase();
45 
47  virtual void cloneParticleData(ParticleBase* nm);
48 
49  virtual SystemType getType() const { return BASE; }
50  virtual std::string infoString() const;
51  virtual ParticleBase* clone() { assertMsg( false , "Dont use, override..."); return NULL; }
52 
54  virtual IndexInt getSizeSlow() const { assertMsg( false , "Dont use, override..."); return 0; }
55 
57  inline void addBuffered(const Vec3& pos);
58 
60 
62  PYTHON() PbClass* create(PbType type, PbTypeVec T=PbTypeVec(), const std::string& name = "");
64  void registerPdata(ParticleDataBase* pdata);
65  void registerPdataReal(ParticleDataImpl<Real>* pdata);
66  void registerPdataVec3(ParticleDataImpl<Vec3>* pdata);
67  void registerPdataInt (ParticleDataImpl<int >* pdata);
69  void deregister(ParticleDataBase* pdata);
71  void addAllPdata();
72  // note - deletion of pdata is handled in compress function
73 
75  IndexInt getNumPdata() const { return mPartData.size(); }
77  ParticleDataBase* getPdata(int i) { return mPartData[i]; }
78 
79 protected:
81  std::vector<Vec3> mNewBuffer;
82 
85 
87  std::vector<ParticleDataBase*> mPartData;
89  std::vector< ParticleDataImpl<Real> *> mPdataReal;
90  std::vector< ParticleDataImpl<Vec3> *> mPdataVec3;
91  std::vector< ParticleDataImpl<int> *> mPdataInt;
93  bool mFreePdata;
94 };
95 
96 
98 
99 PYTHON template<class S> class ParticleSystem : public ParticleBase {
101 public:
102  PYTHON() ParticleSystem(FluidSolver* parent) : ParticleBase(parent), mDeletes(0), mDeleteChunk(0) {}
103  virtual ~ParticleSystem() {};
104 
105  virtual SystemType getType() const { return S::getType(); };
106 
108  inline S& operator[](IndexInt idx) { DEBUG_ONLY(checkPartIndex(idx)); return mData[idx]; }
109  inline const S& operator[](IndexInt idx) const { DEBUG_ONLY(checkPartIndex(idx)); return mData[idx]; }
112  inline IndexInt size() const { return mData.size(); }
114  virtual IndexInt getSizeSlow() const { return size(); }
116  PYTHON() int pySize() const { return (int)mData.size(); }
117 
119  inline int getStatus(IndexInt idx) const { DEBUG_ONLY(checkPartIndex(idx)); return mData[idx].flag; }
120  inline bool isActive(IndexInt idx) const { DEBUG_ONLY(checkPartIndex(idx)); return (mData[idx].flag & PDELETE) == 0; }
121 
123  PYTHON() void setPos(const IndexInt idx, const Vec3& pos) { DEBUG_ONLY(checkPartIndex(idx)); mData[idx].pos = pos; }
124  PYTHON() Vec3 getPos(IndexInt idx) const { DEBUG_ONLY(checkPartIndex(idx)); return mData[idx].pos; }
126  PYTHON() void getPosPdata(ParticleDataImpl<Vec3>& target) const;
127  PYTHON() void setPosPdata(const ParticleDataImpl<Vec3>& source);
129  void transformPositions( Vec3i dimOld, Vec3i dimNew );
130 
132  void doCompress() { if ( mDeletes > mDeleteChunk) compress(); }
134  void insertBufferedParticles();
136  void resizeAll(IndexInt newsize);
137 
139  inline void kill(IndexInt idx);
140  IndexInt add(const S& data);
142  PYTHON() void clear();
143 
145  PYTHON() void advectInGrid( const FlagGrid& flags, const MACGrid& vel, const int integrationMode,
146  const bool deleteInObstacle=true, const bool stopInObstacle=true,
147  const ParticleDataImpl<int> *ptype=NULL, const int exclude=0);
148 
150  PYTHON() void projectOutside(Grid<Vec3>& gradient);
151  PYTHON() void projectOutOfBnd(const FlagGrid &flags, const Real bnd, const std::string& plane="xXyYzZ", const ParticleDataImpl<int> *ptype=NULL, const int exclude=0);
152 
153  virtual ParticleBase* clone();
154  virtual std::string infoString() const;
155 
157  inline void checkPartIndex(IndexInt idx) const;
158 
159 protected:
161  IndexInt mDeletes, mDeleteChunk;
163  std::vector<S> mData;
164 
166  virtual void compress();
167 };
168 
169 //******************************************************************************
170 
176 public:
177  BasicParticleData() : pos(0.), flag(0) {}
178  BasicParticleData(const Vec3& p) : pos(p), flag(0) {}
179  static ParticleBase::SystemType getType() { return ParticleBase::PARTICLE; }
180 
183  int flag;
184 };
185 
187 PYTHON class BasicParticleSystem : public ParticleSystem<BasicParticleData> {
188 public:
189  PYTHON() BasicParticleSystem(FluidSolver* parent);
190 
192  PYTHON() void save(const std::string name) const;
193  PYTHON() void load(const std::string name);
194 
196  void writeParticlesText(const std::string name) const;
198  void writeParticlesRawPositionsGz(const std::string name) const;
199  void writeParticlesRawVelocityGz(const std::string name) const;
200 
202  PYTHON() void readParticles(BasicParticleSystem* from);
203 
205  PYTHON() void addParticle(Vec3 pos) { add(BasicParticleData(pos)); }
206 
208  std::vector<BasicParticleData>& getData() { return mData; }
209 
210  PYTHON() void printParts(IndexInt start=-1, IndexInt stop=-1, bool printIndex=false);
211 };
212 
213 
214 //******************************************************************************
215 
217 // used for grid based neighborhood searches on generic particle systems (stores
218 // only active particles, and reduces copied data)
219 // note - pos & flag are disabled here, do not use!
221 public:
222  ParticleIndexData() : sourceIndex(0) {}
223  static ParticleBase::SystemType getType() { return ParticleBase::INDEX; }
224 
225  IndexInt sourceIndex; // index of this particle in the original particle system
228  static Vec3 pos; // do not use...
229  static int flag; // not needed usally
230  //Vec3 pos; // enable for debugging
231 };
232 
234 PYTHON class ParticleIndexSystem : public ParticleSystem<ParticleIndexData> {
235 public:
237 
239  void resize(IndexInt size) { mData.resize(size); }
240 };
241 
242 
243 
244 //******************************************************************************
245 
248 PYTHON template<class DATA, class CON> class ConnectedParticleSystem : public ParticleSystem<DATA> {
249 public:
250  PYTHON() ConnectedParticleSystem(FluidSolver* parent) : ParticleSystem<DATA>(parent) {}
251 
253  inline bool isSegActive(int i) { return (mSegments[i].flag & ParticleBase::PDELETE) == 0; }
254  inline int segSize() const { return mSegments.size(); }
255  inline CON& seg(int i) { return mSegments[i]; }
256  inline const CON& seg(int i) const { return mSegments[i]; }
257 
258  virtual ParticleBase* clone();
259 
260 protected:
261  std::vector<CON> mSegments;
262  virtual void compress();
263 };
264 
265 //******************************************************************************
266 
269 PYTHON class ParticleDataBase : public PbClass {
270 public:
271  PYTHON() ParticleDataBase(FluidSolver* parent);
272  virtual ~ParticleDataBase();
273 
275  enum PdataType { TypeNone = 0, TypeReal = 1, TypeInt = 2, TypeVec3 = 4 };
276 
278  virtual IndexInt getSizeSlow() const { assertMsg( false , "Dont use, override..."); return 0; }
279  virtual void addEntry() { assertMsg( false , "Dont use, override..."); return; }
280  virtual ParticleDataBase* clone() { assertMsg( false , "Dont use, override..."); return NULL; }
281  virtual PdataType getType() const { assertMsg( false , "Dont use, override..."); return TypeNone; }
282  virtual void resize(IndexInt size) { assertMsg( false , "Dont use, override..."); return; }
283  virtual void copyValueSlow(IndexInt from, IndexInt to) { assertMsg( false , "Dont use, override..."); return; }
284 
286  void setParticleSys(ParticleBase* set) { mpParticleSys = set; }
287 
289  inline void checkPartIndex(IndexInt idx) const;
290 
291 protected:
292  ParticleBase* mpParticleSys;
293 };
294 
295 
298 PYTHON template<class T> class ParticleDataImpl : public ParticleDataBase {
299 public:
300  PYTHON() ParticleDataImpl(FluidSolver* parent);
302  virtual ~ParticleDataImpl();
303 
305  inline T& get(IndexInt idx) { DEBUG_ONLY(checkPartIndex(idx)); return mData[idx]; }
306  inline const T& get(IndexInt idx) const { DEBUG_ONLY(checkPartIndex(idx)); return mData[idx]; }
307  inline T& operator[](IndexInt idx) { DEBUG_ONLY(checkPartIndex(idx)); return mData[idx]; }
308  inline const T& operator[](IndexInt idx) const { DEBUG_ONLY(checkPartIndex(idx)); return mData[idx]; }
309 
311  PYTHON() void clear();
312 
314  PYTHON() void setSource(Grid<T>* grid, bool isMAC=false );
315 
317  virtual IndexInt getSizeSlow() const;
318  virtual void addEntry();
319  virtual ParticleDataBase* clone();
320  virtual PdataType getType() const;
321  virtual void resize(IndexInt s);
322  virtual void copyValueSlow(IndexInt from, IndexInt to);
323 
324  IndexInt size() const { return mData.size(); }
325 
327  inline void copyValue(IndexInt from, IndexInt to) { get(to) = get(from); }
328  void initNewValue(IndexInt idx, Vec3 pos);
329 
331  PYTHON() void setConst(T s);
332  PYTHON() void setConstRange(T s, const int begin, const int end);
333  PYTHON() ParticleDataImpl<T>& copyFrom(const ParticleDataImpl<T>& a);
334  PYTHON() void add(const ParticleDataImpl<T>& a);
335  PYTHON() void sub(const ParticleDataImpl<T>& a);
336  PYTHON() void addConst(T s);
337  PYTHON() void addScaled(const ParticleDataImpl<T>& a, const T& factor);
338  PYTHON() void mult( const ParticleDataImpl<T>& a);
339  PYTHON() void multConst(T s);
340  PYTHON() void safeDiv(const ParticleDataImpl<T>& a);
341  PYTHON() void clamp(Real min, Real max);
342  PYTHON() void clampMin(Real vmin);
343  PYTHON() void clampMax(Real vmax);
344 
345  PYTHON() Real getMaxAbs();
346  PYTHON() Real getMax();
347  PYTHON() Real getMin();
348 
349  PYTHON() T sum(const ParticleDataImpl<int> *t=NULL, const int itype=0) const;
350  PYTHON() Real sumSquare() const;
351  PYTHON() Real sumMagnitude() const;
352 
354  PYTHON() void setConstIntFlag(T s, const ParticleDataImpl<int>& t, const int flag);
355 
356  PYTHON() void printPdata(IndexInt start=-1, IndexInt stop=-1, bool printIndex=false);
357 
359  PYTHON() void save(const std::string name);
360  PYTHON() void load(const std::string name);
361 protected:
363  std::vector<T> mData;
364 
366  Grid<T>* mpGridSource;
368  bool mGridSourceMAC;
369 };
370 
371 
372 
373 
374 
375 
376 //******************************************************************************
377 // Implementation
378 //******************************************************************************
379 
380 const int DELETE_PART = 20; // chunk size for compression
381 
382 void ParticleBase::addBuffered(const Vec3& pos) {
383  mNewBuffer.push_back(pos);
384 }
385 
386 template<class S>
388  mDeleteChunk = mDeletes = 0;
389  this->resizeAll(0); // instead of mData.clear
390 }
391 
392 template<class S>
393 IndexInt ParticleSystem<S>::add(const S& data) {
394  mData.push_back(data);
395  mDeleteChunk = mData.size() / DELETE_PART;
396  this->addAllPdata();
397  return mData.size()-1;
398 }
399 
400 template<class S>
401 inline void ParticleSystem<S>::kill(IndexInt idx) {
402  assertMsg(idx>=0 && idx<size(), "Index out of bounds");
403  mData[idx].flag |= PDELETE;
404  if ( (++mDeletes > mDeleteChunk) && (mAllowCompress) ) compress();
405 }
406 
407 template<class S>
409  for(IndexInt i=0; i<(IndexInt)this->size(); ++i) {
410  target[i] = this->getPos(i);
411  }
412 }
413 template<class S>
415  for(IndexInt i=0; i<(IndexInt)this->size(); ++i) {
416  this->setPos(i, source[i]);
417  }
418 }
419 
420 template<class S>
422 {
423  Vec3 factor = calcGridSizeFactor( dimNew, dimOld );
424  for(IndexInt i=0; i<(IndexInt)this->size(); ++i) {
425  this->setPos(i, this->getPos(i) * factor );
426  }
427 }
428 
429 // check for deletion/invalid position, otherwise return velocity
431 template<class S> std::vector<Vec3> GridAdvectKernel (std::vector<S>& p, const MACGrid& vel, const FlagGrid& flags, Real dt, bool deleteInObstacle, bool stopInObstacle , const ParticleDataImpl<int> *ptype, const int exclude) {}
432 ;
433 
434 // final check after advection to make sure particles haven't escaped
435 // (similar to particle advection kernel)
437 void KnDeleteInObstacle(std::vector<S>& p, const FlagGrid& flags) {}
438 
439 
440 // try to get closer to actual obstacle boundary
441 static inline Vec3 bisectBacktracePos(const FlagGrid& flags, const Vec3& oldp, const Vec3& newp)
442 {
443  Real s = 0.;
444  for(int i=1; i<5; ++i) {
445  Real ds = 1./(Real)(1<<i);
446  if (!flags.isObstacle( oldp*(1.-(s+ds)) + newp*(s+ds) )) {
447  s += ds;
448  }
449  }
450  return( oldp*(1.-(s)) + newp*(s) );
451 }
452 
453 // at least make sure all particles are inside domain
455 void KnClampPositions(std::vector<S>& p, const FlagGrid& flags, ParticleDataImpl<Vec3> *posOld = NULL, bool stopInObstacle=true, const ParticleDataImpl<int> *ptype=NULL, const int exclude=0) {}
456 
457 
458 // advection plugin
459 template<class S>
460 void ParticleSystem<S>::advectInGrid(const FlagGrid& flags, const MACGrid& vel, const int integrationMode,
461  const bool deleteInObstacle, const bool stopInObstacle,
462  const ParticleDataImpl<int> *ptype, const int exclude) {
463  // position clamp requires old positions, backup
464  ParticleDataImpl<Vec3> *posOld = NULL;
465  if(!deleteInObstacle) {
466  posOld = new ParticleDataImpl<Vec3>(this->getParent());
467  posOld->resize(mData.size());
468  for(IndexInt i=0; i<(IndexInt)mData.size();++i) (*posOld)[i] = mData[i].pos;
469  }
470 
471  // update positions
472  GridAdvectKernel<S> kernel(mData, vel, flags, getParent()->getDt(), deleteInObstacle, stopInObstacle, ptype, exclude );
473  integratePointSet(kernel, integrationMode);
474 
475  if(!deleteInObstacle) {
476  KnClampPositions<S> (mData, flags, posOld , stopInObstacle, ptype, exclude );
477  delete posOld;
478  } else {
479  KnDeleteInObstacle<S> (mData, flags);
480  }
481 }
482 
484 void KnProjectParticles(ParticleSystem<S>& part, Grid<Vec3>& gradient) {}
485 
486 
487 template<class S>
489  KnProjectParticles<S>(*this, gradient);
490 }
491 
493 void KnProjectOutOfBnd(ParticleSystem<S> &part, const FlagGrid &flags, const Real bnd, const bool *axis, const ParticleDataImpl<int> *ptype, const int exclude) {}
494 
495 
496 template<class S>
497 void ParticleSystem<S>::projectOutOfBnd(const FlagGrid &flags, const Real bnd, const std::string& plane, const ParticleDataImpl<int> *ptype, const int exclude) {
498  bool axis[6] = { false };
499  for(std::string::const_iterator it=plane.begin(); it!=plane.end(); ++it) {
500  if(*it=='x') axis[0] = true;
501  if(*it=='X') axis[1] = true;
502  if(*it=='y') axis[2] = true;
503  if(*it=='Y') axis[3] = true;
504  if(*it=='z') axis[4] = true;
505  if(*it=='Z') axis[5] = true;
506  }
507  KnProjectOutOfBnd<S>(*this, flags, bnd, axis, ptype, exclude);
508 }
509 
510 template<class S>
511 void ParticleSystem<S>::resizeAll(IndexInt size) {
512  // resize all buffers to target size in 1 go
513  mData.resize(size);
514  for(IndexInt i=0; i<(IndexInt)mPartData.size(); ++i)
515  mPartData[i]->resize(size);
516 }
517 
518 template<class S>
520  IndexInt nextRead = mData.size();
521  for (IndexInt i=0; i<(IndexInt)mData.size(); i++) {
522  while ((mData[i].flag & PDELETE) != 0) {
523  nextRead--;
524  mData[i] = mData[nextRead];
525  // ugly, but prevent virtual function calls here:
526  for(IndexInt pd=0; pd<(IndexInt)mPdataReal.size(); ++pd) mPdataReal[pd]->copyValue(nextRead, i);
527  for(IndexInt pd=0; pd<(IndexInt)mPdataVec3.size(); ++pd) mPdataVec3[pd]->copyValue(nextRead, i);
528  for(IndexInt pd=0; pd<(IndexInt)mPdataInt .size(); ++pd) mPdataInt [pd]->copyValue(nextRead, i);
529  mData[nextRead].flag = PINVALID;
530  }
531  }
532  if(nextRead<(IndexInt)mData.size()) debMsg("Deleted "<<((IndexInt)mData.size() - nextRead)<<" particles", 1); // debug info
533 
534  resizeAll(nextRead);
535  mDeletes = 0;
536  mDeleteChunk = mData.size() / DELETE_PART;
537 }
538 
540 template<class S>
542  if(mNewBuffer.size()==0) return;
543  IndexInt newCnt = mData.size();
544  resizeAll(newCnt + mNewBuffer.size());
545 
546  // clear new flag everywhere
547  for(IndexInt i=0; i<(IndexInt)mData.size(); ++i) mData[i].flag &= ~PNEW;
548 
549  for(IndexInt i=0; i<(IndexInt)mNewBuffer.size(); ++i) {
550  // note, other fields are not initialized here...
551  mData[newCnt].pos = mNewBuffer[i];
552  mData[newCnt].flag = PNEW;
553  // now init pdata fields from associated grids...
554  for(IndexInt pd=0; pd<(IndexInt)mPdataReal.size(); ++pd)
555  mPdataReal[pd]->initNewValue(newCnt, mNewBuffer[i] );
556  for(IndexInt pd=0; pd<(IndexInt)mPdataVec3.size(); ++pd)
557  mPdataVec3[pd]->initNewValue(newCnt, mNewBuffer[i] );
558  for(IndexInt pd=0; pd<(IndexInt)mPdataInt.size(); ++pd)
559  mPdataInt[pd]->initNewValue(newCnt, mNewBuffer[i] );
560  newCnt++;
561  }
562  if(mNewBuffer.size()>0) debMsg("Added & initialized "<<(IndexInt)mNewBuffer.size()<<" particles", 2); // debug info
563  mNewBuffer.clear();
564 }
565 
566 
567 template<class DATA, class CON>
569  const IndexInt sz = ParticleSystem<DATA>::size();
570  IndexInt *renumber_back = new IndexInt[sz];
571  IndexInt *renumber = new IndexInt[sz];
572  for (IndexInt i=0; i<sz; i++)
573  renumber[i] = renumber_back[i] = -1;
574 
575  // reorder elements
576  std::vector<DATA>& data = ParticleSystem<DATA>::mData;
577  IndexInt nextRead = sz;
578  for (IndexInt i=0; i<nextRead; i++) {
579  if ((data[i].flag & ParticleBase::PDELETE) != 0) {
580  nextRead--;
581  data[i] = data[nextRead];
582  data[nextRead].flag = 0;
583  renumber_back[i] = nextRead;
584  } else
585  renumber_back[i] = i;
586  }
587 
588  // acceleration structure
589  for (IndexInt i=0; i<nextRead; i++)
590  renumber[renumber_back[i]] = i;
591 
592  // rename indices in filaments
593  for (IndexInt i=0; i<(IndexInt)mSegments.size(); i++)
594  mSegments[i].renumber(renumber);
595 
596  ParticleSystem<DATA>::mData.resize(nextRead);
599 
600  delete[] renumber;
601  delete[] renumber_back;
602 }
603 
604 template<class S>
606  ParticleSystem<S>* nm = new ParticleSystem<S>(getParent());
607  if(this->mAllowCompress) compress();
608 
609  nm->mData = mData;
610  nm->setName(getName());
611  this->cloneParticleData(nm);
612  return nm;
613 }
614 
615 template<class DATA,class CON>
618  if(this->mAllowCompress) compress();
619 
620  nm->mData = this->mData;
621  nm->mSegments = mSegments;
622  nm->setName(this->getName());
623  this->cloneParticleData(nm);
624  return nm;
625 }
626 
627 template<class S>
628 std::string ParticleSystem<S>::infoString() const {
629  std::stringstream s;
630  s << "ParticleSys '" << getName() << "'\n-> ";
631  if(this->getNumPdata()>0) s<< "pdata: "<< this->getNumPdata();
632  s << "parts: " << size();
633  //for(IndexInt i=0; i<(IndexInt)mPartData.size(); ++i) { sstr << i<<":" << mPartData[i]->size() <<" "; }
634  return s.str();
635 }
636 
637 template<class S>
638 inline void ParticleSystem<S>::checkPartIndex(IndexInt idx) const {
639  IndexInt mySize = this->size();
640  if (idx<0 || idx > mySize ) {
641  errMsg( "ParticleBase " << " size " << mySize << " : index " << idx << " out of bound " );
642  }
643 }
644 
645 inline void ParticleDataBase::checkPartIndex(IndexInt idx) const {
646  IndexInt mySize = this->getSizeSlow();
647  if (idx<0 || idx > mySize ) {
648  errMsg( "ParticleData " << " size " << mySize << " : index " << idx << " out of bound " );
649  }
650  if ( mpParticleSys && mpParticleSys->getSizeSlow()!=mySize ) {
651  errMsg( "ParticleData " << " size " << mySize << " does not match parent! (" << mpParticleSys->getSizeSlow() << ") " );
652  }
653 }
654 
655 // set contents to zero, as for a grid
656 template<class T>
658  for(IndexInt i=0; i<(IndexInt)mData.size(); ++i) mData[i] = 0.;
659 }
660 
662 int countParticles(const ParticleDataImpl<int> &t, const int flag);
663 
664 } // namespace
665 
666 #endif
667 
668 
669 
Definition: particle.h:175
Definition: commonkernels.h:22
ParticleDataBase * getPdata(int i)
access one of the fields
Definition: particle.h:77
Definition: grid.h:267
void kill(IndexInt idx)
adding and deleting
Definition: particle.h:401
PYTHON() void addParticle(Vec3 pos)
add particles in python
Definition: particle.h:205
Definition: particle.h:269
bool mFreePdata
indicate that pdata of this particle system is copied, and needs to be freed
Definition: particle.h:93
S & operator[](IndexInt idx)
accessors
Definition: particle.h:108
virtual void compress()
reduce storage , called by doCompress
Definition: particle.h:519
Definition: grid.h:229
std::vector< ParticleDataImpl< Real > * > mPdataReal
lists of different types, for fast operations w/o virtual function calls (all calls necessary per par...
Definition: particle.h:89
STL namespace.
PYTHON() int pySize() const
note , special call for python, note - doesnt support more than 2b parts!
Definition: particle.h:116
Vec3 pos
data (note, this size is currently hard coded for uni i/o)
Definition: particle.h:182
Definition: particle.h:234
virtual void cloneParticleData(ParticleBase *nm)
copy all the particle data thats registered with the other particle system to this one ...
Definition: particle.cpp:49
Basic inlined vector class.
Definition: vectorbase.h:71
IndexInt size() const
Definition: particle.h:112
IndexInt mDeletes
deletion count , and interval for re-compressing
Definition: particle.h:161
virtual void compress()
reduce storage , called by doCompress
Definition: particle.h:568
void insertBufferedParticles()
insert buffered positions as new particles, update additional particle data
Definition: particle.h:541
bool isObstacle(IndexInt idx) const
check for different flag types
Definition: grid.h:291
void transformPositions(Vec3i dimOld, Vec3i dimNew)
transform coordinate system from one grid size to another (usually upon load)
Definition: particle.h:421
int getStatus(IndexInt idx) const
query status
Definition: particle.h:119
void deregister(ParticleDataBase *pdata)
remove a particle data entry
Definition: particle.cpp:58
Main class for particle systems.
Definition: particle.h:100
Index into other particle system.
Definition: particle.h:220
void doCompress()
explicitly trigger compression from outside
Definition: particle.h:132
void addAllPdata()
add one zero entry to all data fields
Definition: particle.cpp:124
void checkPartIndex(IndexInt idx) const
debugging
Definition: particle.h:645
IndexInt getNumPdata() const
how many are there?
Definition: particle.h:75
static Vec3 pos
Definition: particle.h:228
Definition: particle.h:32
void setParticleSys(ParticleBase *set)
set base pointer
Definition: particle.h:286
std::vector< ParticleDataBase * > mPartData
store particle data , each pointer has its own storage vector of a certain type (int, real, vec3)
Definition: particle.h:87
Vec3 calcGridSizeFactor(Vec3i s1, Vec3i s2)
helper to compute grid conversion factor between local coordinates of two grids
Definition: grid.h:349
void checkPartIndex(IndexInt idx) const
debugging
Definition: particle.h:638
bool mAllowCompress
allow automatic compression / resize? disallowed for, eg, flip particle systems
Definition: particle.h:84
std::vector< BasicParticleData > & getData()
dangerous, get low level access - avoid usage, only used in vortex filament advection for now ...
Definition: particle.h:208
void resize(IndexInt size)
we only need a resize function...
Definition: particle.h:239
void integratePointSet(VelKernel &k, int mode)
Integrate a particle set with a given velocity kernel.
Definition: integrator.h:28
int countParticles(const ParticleDataImpl< int > &t, const int flag)
count by type flag
virtual IndexInt getSizeSlow() const
slow virtual function to query size, do not use in kernels! use size() instead
Definition: particle.h:54
Definition: particle.h:248
void resizeAll(IndexInt newsize)
resize data vector, and all pdata fields
Definition: particle.h:511
virtual IndexInt getSizeSlow() const
interface functions, using assert instead of pure virtual for python compatibility ...
Definition: particle.h:278
virtual IndexInt getSizeSlow() const
slow virtual function of base class, also returns size
Definition: particle.h:114
std::vector< S > mData
the particle data
Definition: particle.h:163
bool isSegActive(int i)
accessors
Definition: particle.h:253
void copyValue(IndexInt from, IndexInt to)
fast inlined functions for per particle operations
Definition: particle.h:327
std::vector< Vec3 > mNewBuffer
new particle candidates
Definition: particle.h:81
void addBuffered(const Vec3 &pos)
add a position as potential candidate for new particle (todo, make usable from parallel threads) ...
Definition: particle.h:382
void registerPdata(ParticleDataBase *pdata)
add a particle data field, set its parent particle-system pointer
Definition: particle.cpp:100
Definition: particle.h:187
Definition: fluidsolver.h:28
PdataType
data type IDs, in line with those for grids
Definition: particle.h:275