Lagrangian Particle Code for The Simulation of 2D/3D Fluid Dynamics
 All Classes Files Functions Variables Typedefs Friends Pages
initializer.h
Go to the documentation of this file.
1 
23 #ifndef __INITIALIZER_H__
24 #define __INITIALIZER_H__
25 
26 #include <cstddef>
27 #include <fstream>
28 #include <vector>
29 
30 class EOS;
31 class Geometry;
32 class State;
33 
34 
51 class BoundingBox {
52 public:
66  BoundingBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax):
67  m_fXmin(xmin), m_fXmax(xmax), m_fYmin(ymin), m_fYmax(ymax), m_fZmin(zmin), m_fZmax(zmax),
68  m_iStartIndex(0), m_iNumber(0) {}
69 
75  double getXmin() {return m_fXmin;}
76 
82  double getXmax() {return m_fXmax;}
83 
89  double getYmin() {return m_fYmin;}
90 
96  double getYmax() {return m_fYmax;}
97 
103  double getZmin() {return m_fZmin;}
104 
110  double getZmax() {return m_fZmax;}
111 
120  size_t getStartIndex() {return m_iStartIndex;}
121 
128  size_t getNumber() {return m_iNumber;}
129 
130 
136  void setXmin(double xmin) {m_fXmin=xmin;}
137 
143  void setXmax(double xmax) {m_fXmax=xmax;}
144 
150  void setYmin(double ymin) {m_fYmin=ymin;}
151 
157  void setYmax(double ymax) {m_fYmax=ymax;}
158 
164  void setZmin(double zmin) {m_fZmin=zmin;}
165 
171  void setZmax(double zmax) {m_fZmax=zmax;}
172 
181  void setStartIndex(size_t index) {m_iStartIndex=index;}
182 
189  void setNumber(size_t num) {m_iNumber=num;}
190 private:
191  double m_fXmin, m_fXmax, m_fYmin, m_fYmax, m_fZmin, m_fZmax;
192  size_t m_iStartIndex;
193  size_t m_iNumber;
194 };
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
227 class Initializer {
228 public:
237  Initializer(const std::string& inputfileName, const std::string& debugfileName="debug", bool ifDebug=false);
242  ~Initializer();
243 
249  bool getIfDebug() const {return m_iIfDebug;}
250 
256  std::string getDebugfileName() const {return m_sDebugfileName;}
257 
263  int getNumThreads() const {return m_iNumThreads;}
264 
270  double getStartTime() const {return m_fStartTime;}
271 
277  double getEndTime() const {return m_fEndTime;}
278 
284  double getWriteTimeInterval() const {return m_fWriteTimeInterval;}
285 
291  double getCFLCoeff() const {return m_fCFLCoeff;}
292 
298  int getDimension() const {return m_iDimension;}
299 
305  bool getRandomDirSplitOrder() const {return m_iRandomDirSplitOrder;}
306 
312  int getLPFOrder() const {return m_iLPFOrder;}
313 
319  int getEOSChoice() const {return m_iEOSChoice;} //TODO
320 
326  double getInitParticleSpacing() const {return m_fInitParticleSpacing;}
327 
333  double getGravity() const {return m_fGravity;}
334 
340  bool getMovingBoxForGhostParticle() const {return m_iMovingBoxForGhostParticle;}
341 
348  bool getUseLimiter() const {return m_iUseLimiter;}
349 
356  double getThresholdP() const {return m_fThresholdP;}
357 
358 
364  std::size_t getMaxNeighbourNum() const {return m_iMaxNeighbourNum;}
365 
373  std::size_t getMaxNeighbourNumInOneDir() const {return m_iMaxNeighbourNumInOneDir;}
374 
382  std::size_t getNumRow2ndOrder() const {return m_iNumRow2ndOrder;}
383 
391  std::size_t getNumRow1stOrder() const {return m_iNumRow1stOrder;}
392 
402  std::size_t getNumCol2ndOrder() const {return m_iNumCol2ndOrder;}
403 
413  std::size_t getNumCol1stOrder() const {return m_iNumCol1stOrder;}
414 
420  double getNeiSearchRadius() const {return m_fNeiSearchRadius;}
421 
430  double getInvalidPressure() const {return m_fInvalidPressure;}
431 
439  double getInvalidVolume() const {return m_fInvalidVolume;}
440 
446  int getTreeDepth() const {return m_iTreeDepth;}
447 
462  double getContactLength() const {return m_fContactLength;}
463 
472  std::size_t getCapacity() const {return m_iCapacity;}
473 
479  std::size_t getFluidNum() const {return m_iFluidNum;}
480 
486  std::size_t getBoundaryNum() const {return m_iBoundaryNum;}
487 
493  std::size_t getFluidStartIndex() const {return m_iFluidStartIndex;}
494 
500  std::size_t getBoundaryStartIndex() const {return m_iBoundaryStartIndex;}
501 
507  std::size_t getGhostStartIndex() const {return m_iGhostStartIndex;}
508 
517  std::size_t getNumParticleWithinSearchRadius() const {return m_iNumParticleWithinSearchRadius;}
518 
519 
530  double* getPositionX() const {return m_vPositionX;}
531 
542  double* getPositionY() const {return m_vPositionY;}
543 
554  double* getPositionZ() const {return m_vPositionZ;}
555 
566  double* getVelocityU() const {return m_vVelocityU;}
567 
578  double* getVelocityV() const {return m_vVelocityV;}
579 
590  double* getVelocityW() const {return m_vVelocityW;}
591 
602  double* getVolume() const {return m_vVolume;}
603 
614  double* getPressure() const {return m_vPressure;}
615 
626  double* getSoundSpeed() const {return m_vSoundSpeed;}
627 
636  int* getObjectTag() const {return m_vObjectTag;}
637 
648  EOS* getEOS() const {return m_pEOS;}
649 
655  const std::vector<BoundingBox*>& getFluidBoundingBox() const {return m_vFluidBoundingBox;}
656 
662  const std::vector<std::string>& getBoundaryObjTypes() const {return m_vBoundaryObjTypes;}
663 private:
664 
665  //--------------------------Data from arg list--------------------------------
666  const std::string m_sDebugfileName;
667  bool m_iIfDebug;
668 
669  //----------------------------------------------------------------------------
670 
671  //--------------------------Data from the inputfile---------------------------
672 
673  int m_iNumThreads;
674  double m_fStartTime;
675  double m_fEndTime;
676  double m_fWriteTimeInterval;
677  double m_fCFLCoeff;
678  int m_iDimension;
679  int m_iFluidObjNum;
680  int m_iBoundaryObjNum;
681  bool m_iRandomDirSplitOrder;
682  int m_iLPFOrder;
683  int m_iEOSChoice;
684  double m_fGamma;
685  double m_fPinf;
686  double m_fEinf;
687  double m_fInitParticleSpacing;
688  double m_fGravity;
689  bool m_iMovingBoxForGhostParticle;
690  bool m_iUseLimiter;
691  double m_fThresholdP;
692  //-----------------------------------------------------------------------------
693 
694 
695  //-------------Predetermined parameters specified in this class----------------
696 
697  std::size_t m_iMaxNeighbourNum;
698  std::size_t m_iMaxNeighbourNumInOneDir;
699  std::size_t m_iNumRow2ndOrder;
700  std::size_t m_iNumRow1stOrder;
701  std::size_t m_iNumCol2ndOrder;//TODO///< the number of columns of A when solving 2nd order LPF
702  std::size_t m_iNumCol1stOrder;//TODO///< the number of columns of A when solving 1st order LPF
703  double m_fNeiSearchRadius;
704  double m_fInvalidPressure;
705  double m_fInvalidVolume;
706  int m_iTreeDepth;
707  double m_fContactLength;
708 
709  // ----------------------------------------------------------------------------
710 
711 
712  //------Parameters computed by the input parameters after initialization-------
713 
714  std::size_t m_iCapacity;
715  std::size_t m_iFluidNum;
716  std::size_t m_iBoundaryNum;
717  //std::size_t m_iGhostNum; ///< NUmber of ghost particles
718  //std::size_t m_iTotalNum;///< Number of all particles
719  std::size_t m_iFluidStartIndex;
720  std::size_t m_iBoundaryStartIndex;
721  std::size_t m_iGhostStartIndex;
722  std::vector<BoundingBox*> m_vFluidBoundingBox;
723  std::vector<Geometry*> m_vFluidObj;
724  std::vector<BoundingBox*> m_vBoundaryBoundingBox;
725  std::vector<Geometry*> m_vBoundaryObj;
726  std::vector<State*> m_vFluidObjState;
727  std::vector<std::string> m_vFluidObjNames;
728  std::vector<std::string> m_vFluidObjStateNames;
729  std::vector<std::string> m_vBoundaryObjNames;
730  std::vector<std::string> m_vBoundaryObjTypes;
731 
732  size_t m_iNumParticleWithinSearchRadius;
733 
734  //----------------------------------------------------------------------------
735 
736  //----------------------------Array data--------------------------------------
737 
738  double* m_vPositionX;
739  double* m_vPositionY;
740  double* m_vPositionZ;
741  double* m_vVelocityU;
742  double* m_vVelocityV;
743  double* m_vVelocityW;
744  double* m_vVolume;
745  double* m_vPressure;
746  double* m_vSoundSpeed;
747  //double* m_vEnergy;///< energy
748  int* m_vObjectTag;
749 
750  //-----------------------------------------------------------------------------
751 
752  EOS* m_pEOS;
753  std::ofstream debug;
754 
755 private:
756  //--------------------------------Methods--------------------------------------
757 
759  void initParticleDataMemory();
760 
762  void setParams();
763 
765  void computeInitBoundingBox();
766 
768  void initGeometryAndState();
769 
771  size_t initGeometryAndState1D(bool saveData);
772 
774  size_t initGeometryAndStateOnHexPacking(bool saveData, const std::string& kind);
775 
777  void computeNumParticleWithinSearchRadius();
778 
780  void setBoundingBoxStartIndex();
781 
783  void setObjectTag();
784 };
785 
786 
787 
788 
789 
790 
791 #endif // __INITIALIZER_H__
This class is keeps the information of the boundaries of a fluid/boundary object. ...
Definition: initializer.h:51
void setYmin(double ymin)
Setter function of the minimum value in y-coordinate of the bounding box.
Definition: initializer.h:150
void setXmin(double xmin)
Setter function of the minimum value in x-coordinate of the bounding box.
Definition: initializer.h:136
bool getIfDebug() const
Getter function of the boolean value on whether to print debug information.
Definition: initializer.h:249
double getContactLength() const
Getter function of the specified length such that if the distance between two particles coming from d...
Definition: initializer.h:462
double * getSoundSpeed() const
Getter function of the array of sound speed of the initialized particles.
Definition: initializer.h:626
EOS * getEOS() const
Getter function of the pointer to an object in the EOS family.
Definition: initializer.h:648
double getWriteTimeInterval() const
Getter function of the specified physical time interval between writes.
Definition: initializer.h:284
void setNumber(size_t num)
Setter function of the number of particles of the fluid/boundary object inside this bounding box...
Definition: initializer.h:189
double * getVolume() const
Getter function of the array of volume of the initialized particles.
Definition: initializer.h:602
size_t getNumber()
Getter function of the number of particles of the fluid/boundary object inside this bounding box...
Definition: initializer.h:128
double getStartTime() const
Getter function of the specified simulation physical start time.
Definition: initializer.h:270
std::size_t getNumCol2ndOrder() const
Getter function of the theoretical minimum number of neighbours required in one direction of a partic...
Definition: initializer.h:402
~Initializer()
Destructor.
Definition: initializer.cpp:195
const std::vector< std::string > & getBoundaryObjTypes() const
Getter function of the types of the initialized boundary objects.
Definition: initializer.h:662
Initializer(const std::string &inputfileName, const std::string &debugfileName="debug", bool ifDebug=false)
Constructor.
Definition: initializer.cpp:21
int getTreeDepth() const
Getter function of the specified tree depth for the octree neighbour search algorithm.
Definition: initializer.h:446
double getThresholdP() const
Getter function of the specified threshold value on pressure if limiter is used.
Definition: initializer.h:356
std::size_t getNumRow1stOrder() const
Getter function of the specified minimum number of neighbours in one direction of a particle for usin...
Definition: initializer.h:391
double getZmin()
Getter function of the minimum value in z-coordinate of the bounding box.
Definition: initializer.h:103
int getEOSChoice() const
Getter function of the specified choice of equation of state (eos)
Definition: initializer.h:319
bool getRandomDirSplitOrder() const
Getter function of the specified boolean value on whether to use random order of Strang splitting or ...
Definition: initializer.h:305
double * getPositionY() const
Getter function of the array of y-coordinates of the initialized particles.
Definition: initializer.h:542
double getYmax()
Getter function of the maximum value in y-coordinate of the bounding box.
Definition: initializer.h:96
int getNumThreads() const
Getter function of the specified number of threads.
Definition: initializer.h:263
An abstract class for the initialization of the geometry of fluid objects.
Definition: geometry.h:38
std::size_t getGhostStartIndex() const
Getter function of the start index of ghost particles in the particle arrays of the ParticleData clas...
Definition: initializer.h:507
void setYmax(double ymax)
Setter function of the maximum value in y-coordinate of the bounding box.
Definition: initializer.h:157
double getZmax()
Getter function of the maximum value in z-coordinate of the bounding box.
Definition: initializer.h:110
double getYmin()
Getter function of the minimum value in y-coordinate of the bounding box.
Definition: initializer.h:89
double * getPositionX() const
Getter function of the array of x-coordinates of the initialized particles.
Definition: initializer.h:530
int getLPFOrder() const
Getter function of the specified order of Local Polynomial Fitting.
Definition: initializer.h:312
double getInvalidPressure() const
Getter function of the specified maximum/minimum pressure value a particle can possibly attain...
Definition: initializer.h:430
double getCFLCoeff() const
Getter function of the specified CFL coefficient.
Definition: initializer.h:291
std::size_t getNumRow2ndOrder() const
Getter function of the specified minimum number of neighbours in one direction of a particle for usin...
Definition: initializer.h:382
void setXmax(double xmax)
Setter function of the maximum value in x-coordinate of the bounding box.
Definition: initializer.h:143
An abstract class for the initialization of the state of fluid objects.
Definition: state.h:41
double getNeiSearchRadius() const
Getter function of the specified radius for neighbour search.
Definition: initializer.h:420
This class initializes the simulation.
Definition: initializer.h:227
bool getUseLimiter() const
Getter function of the specified boolean value on whether to use limiter or not.
Definition: initializer.h:348
An abstract class for the calculation of energy and sound speed based on different EOS models...
Definition: eos.h:42
void setStartIndex(size_t index)
Setter function of the start index in the particle arrays of the fluid/boundary object inside this bo...
Definition: initializer.h:181
bool getMovingBoxForGhostParticle() const
Getter function of the specified boolean value on whether to update the bounding box of fluid objects...
Definition: initializer.h:340
int * getObjectTag() const
Getter function of the array of "object tags" of the initialized particles.
Definition: initializer.h:636
double getEndTime() const
Getter function of the specified simulation physical end time.
Definition: initializer.h:277
std::size_t getMaxNeighbourNum() const
Getter function of the specified maximum number of neighbours of a particle.
Definition: initializer.h:364
void setZmax(double zmax)
Setter function of the maximum value in z-coordinate of the bounding box.
Definition: initializer.h:171
std::size_t getCapacity() const
Getter function of the specified array length for particle data arrays such as x, y...
Definition: initializer.h:472
double getInitParticleSpacing() const
Getter function of the specified initial inter-particle spacing.
Definition: initializer.h:326
std::string getDebugfileName() const
Getter function of the filename for printing debug information.
Definition: initializer.h:256
double * getVelocityW() const
Getter function of the array of velocity in z-coordinate of the initialized particles.
Definition: initializer.h:590
double * getVelocityU() const
Getter function of the array of velocity in x-coordinate of the initialized particles.
Definition: initializer.h:566
void setZmin(double zmin)
Setter function of the minimum value in z-coordinate of the bounding box.
Definition: initializer.h:164
std::size_t getNumCol1stOrder() const
Getter function of the theoretical minimum number of neighbours required in one direction of a partic...
Definition: initializer.h:413
int getDimension() const
Getter function of the specified dimension of simulation.
Definition: initializer.h:298
double * getPositionZ() const
Getter function of the array of z-coordinates of the initialized particles.
Definition: initializer.h:554
double getInvalidVolume() const
Getter function of the specified maximum/minimum volume value a particle can possibly attain...
Definition: initializer.h:439
std::size_t getMaxNeighbourNumInOneDir() const
Getter function of the specified maximum number of neighbours in one direction (eg. right-hand-side in the x-coordinate) of a particle.
Definition: initializer.h:373
const std::vector< BoundingBox * > & getFluidBoundingBox() const
Getter function of the bounding boxes for the initialized fluid objects.
Definition: initializer.h:655
size_t getStartIndex()
Getter function of the start index in the particle arrays of the fluid/boundary object inside this bo...
Definition: initializer.h:120
std::size_t getFluidNum() const
Getter function of the number of fluid particles initialized.
Definition: initializer.h:479
double getXmin()
Getter function of the minimum value in x-coordinate of the bounding box.
Definition: initializer.h:75
double getGravity() const
Getter function of the specified gravity value.
Definition: initializer.h:333
std::size_t getBoundaryNum() const
Getter function of the number of boundary particles initialized.
Definition: initializer.h:486
double * getPressure() const
Getter function of the array of pressure of the initialized particles.
Definition: initializer.h:614
std::size_t getFluidStartIndex() const
Getter function of the start index of fluid particles in the particle data arrays.
Definition: initializer.h:493
std::size_t getNumParticleWithinSearchRadius() const
Getter function of the number of particles located inside the specified radius of neighbour search at...
Definition: initializer.h:517
BoundingBox(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Constructor.
Definition: initializer.h:66
double getXmax()
Getter function of the maximum value in x-coordinate of the bounding box.
Definition: initializer.h:82
double * getVelocityV() const
Getter function of the array of velocity in y-coordinate of the initialized particles.
Definition: initializer.h:578
std::size_t getBoundaryStartIndex() const
Getter function of the start index of boundary particles in the particle data arrays.
Definition: initializer.h:500