215
201
virtual ~LbmFsgrSolver();
216
//! id string of solver
217
virtual string getIdString();
218
//! dimension of solver
219
virtual int getDimension();
221
203
//! initilize variables fom attribute list
222
204
virtual void parseAttrList();
223
205
//! Initialize omegas and forces on all levels (for init/timestep change)
224
206
void initLevelOmegas();
225
//! finish the init with config file values (allocate arrays...)
226
virtual bool initializeSolver(); //( ntlTree* /*tree*/, vector<ntlGeometryObject*>* /*objects*/ );
208
// multi step solver init
209
/*! finish the init with config file values (allocate arrays...) */
210
virtual bool initializeSolverMemory();
211
/*! init solver arrays */
212
virtual bool initializeSolverGrids();
213
/*! prepare actual simulation start, setup viz etc */
214
virtual bool initializeSolverPostinit();
216
//! notify object that dump is in progress (e.g. for field dump)
217
virtual void notifySolverOfDump(int dumptype, int frameNr,char *frameNrStr,string outfilename);
228
219
#if LBM_USE_GUI==1
229
220
//! show simulation info (implement LbmSolverInterface pure virtual func)
230
virtual void debugDisplay(fluidDispSettings *set);
221
virtual void debugDisplay(int set);
234
224
// implement CellIterator<UniformFsgrCellIdentifier> interface
235
typedef UniformFsgrCellIdentifier<typename D::LbmCellContents> stdCellId;
225
typedef UniformFsgrCellIdentifier stdCellId;
236
226
virtual CellIdentifierInterface* getFirstCell( );
237
227
virtual void advanceCell( CellIdentifierInterface* );
238
228
virtual bool noEndCell( CellIdentifierInterface* );
467
461
LbmFloat* debRACPNT(int level, int ii,int ij,int ik, int is );
468
462
LbmFloat& debRAC(LbmFloat* s,int l);
469
463
# endif // FSGR_STRICT_DEBUG==1
467
public: // former LbmModelLBGK functions
468
// relaxation funtions - implemented together with relax macros
469
static inline LbmFloat getVelVecLen(int l, LbmFloat ux,LbmFloat uy,LbmFloat uz);
470
static inline LbmFloat getCollideEq(int l, LbmFloat rho, LbmFloat ux, LbmFloat uy, LbmFloat uz);
471
inline LbmFloat getLesNoneqTensorCoeff( LbmFloat df[], LbmFloat feq[] );
472
inline LbmFloat getLesOmega(LbmFloat omega, LbmFloat csmago, LbmFloat Qo);
473
inline void collideArrays( int i, int j, int k, // position - more for debugging
474
LbmFloat df[], LbmFloat &outrho, // out only!
475
// velocity modifiers (returns actual velocity!)
476
LbmFloat &mux, LbmFloat &muy, LbmFloat &muz,
477
LbmFloat omega, LbmVec gravity, LbmFloat csmago,
478
LbmFloat *newOmegaRet, LbmFloat *newQoRet);
484
//! shorten static const definitions
485
#define STCON static const
489
//! id string of solver
490
virtual string getIdString() { return string("FreeSurfaceFsgrSolver[BGK_D3Q19]"); }
492
//! how many dimensions? UNUSED? replace by LBMDIM?
493
STCON int cDimension;
495
// Wi factors for collide step
496
STCON LbmFloat cCollenZero;
497
STCON LbmFloat cCollenOne;
498
STCON LbmFloat cCollenSqrtTwo;
500
//! threshold value for filled/emptied cells
501
STCON LbmFloat cMagicNr2;
502
STCON LbmFloat cMagicNr2Neg;
503
STCON LbmFloat cMagicNr;
504
STCON LbmFloat cMagicNrNeg;
506
//! size of a single set of distribution functions
508
//! direction vector contain vecs for all spatial dirs, even if not used for LBM model
511
//! distribution functions directions
536
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
537
* 0, 0, 0, 1,-1, 0, 0, 1,-1, 1,-1, 0, 0, 0, 0, 1, 1,-1,-1, 1,-1, 1,-1, 1,-1, 1,-1
538
* 0, 1,-1, 0, 0, 0, 0, 1, 1,-1,-1, 1, 1,-1,-1, 0, 0, 0, 0, 1, 1,-1,-1, 1, 1,-1,-1
539
* 0, 0, 0, 0, 0, 1,-1, 0, 0, 0, 0, 1,-1, 1,-1, 1,-1, 1,-1, 1, 1, 1, 1, -1,-1,-1,-1
542
/*! name of the dist. function
543
only for nicer output */
544
STCON char* dfString[ 19 ];
546
/*! index of normal dist func, not used so far?... */
547
STCON int dfNorm[ 19 ];
549
/*! index of inverse dist func, not fast, but useful... */
550
STCON int dfInv[ 19 ];
552
/*! index of x reflected dist func for free slip, not valid for all DFs... */
553
STCON int dfRefX[ 19 ];
554
/*! index of x reflected dist func for free slip, not valid for all DFs... */
555
STCON int dfRefY[ 19 ];
556
/*! index of x reflected dist func for free slip, not valid for all DFs... */
557
STCON int dfRefZ[ 19 ];
559
/*! dist func vectors */
560
STCON int dfVecX[ 27 ];
561
STCON int dfVecY[ 27 ];
562
STCON int dfVecZ[ 27 ];
564
/*! arrays as before with doubles */
565
STCON LbmFloat dfDvecX[ 27 ];
566
STCON LbmFloat dfDvecY[ 27 ];
567
STCON LbmFloat dfDvecZ[ 27 ];
569
/*! principal directions */
570
STCON int princDirX[ 2*3 ];
571
STCON int princDirY[ 2*3 ];
572
STCON int princDirZ[ 2*3 ];
574
/*! vector lengths */
575
STCON LbmFloat dfLength[ 19 ];
577
/*! equilibrium distribution functions, precalculated = getCollideEq(i, 0,0,0,0) */
578
static LbmFloat dfEquil[ 19 ];
580
/*! arrays for les model coefficients */
581
static LbmFloat lesCoeffDiag[ (3-1)*(3-1) ][ 27 ];
582
static LbmFloat lesCoeffOffdiag[ 3 ][ 27 ];
584
#else // end LBMDIM==3 , LBMDIM==2
586
//! id string of solver
587
virtual string getIdString() { return string("FreeSurfaceFsgrSolver[BGK_D2Q9]"); }
589
//! how many dimensions?
590
STCON int cDimension;
592
//! Wi factors for collide step
593
STCON LbmFloat cCollenZero;
594
STCON LbmFloat cCollenOne;
595
STCON LbmFloat cCollenSqrtTwo;
597
//! threshold value for filled/emptied cells
598
STCON LbmFloat cMagicNr2;
599
STCON LbmFloat cMagicNr2Neg;
600
STCON LbmFloat cMagicNr;
601
STCON LbmFloat cMagicNrNeg;
603
//! size of a single set of distribution functions
607
//! distribution functions directions
623
* 0, 0,0, 1,-1, 1,-1,1,-1
624
* 0, 1,-1, 0,0, 1,1,-1,-1 */
626
/* name of the dist. function
627
only for nicer output */
628
STCON char* dfString[ 9 ];
630
/* index of normal dist func, not used so far?... */
631
STCON int dfNorm[ 9 ];
633
/* index of inverse dist func, not fast, but useful... */
634
STCON int dfInv[ 9 ];
636
/* index of x reflected dist func for free slip, not valid for all DFs... */
637
STCON int dfRefX[ 9 ];
638
/* index of x reflected dist func for free slip, not valid for all DFs... */
639
STCON int dfRefY[ 9 ];
640
/* index of x reflected dist func for free slip, not valid for all DFs... */
641
STCON int dfRefZ[ 9 ];
643
/* dist func vectors */
644
STCON int dfVecX[ 9 ];
645
STCON int dfVecY[ 9 ];
646
/* Z, 2D values are all 0! */
647
STCON int dfVecZ[ 9 ];
649
/* arrays as before with doubles */
650
STCON LbmFloat dfDvecX[ 9 ];
651
STCON LbmFloat dfDvecY[ 9 ];
652
/* Z, 2D values are all 0! */
653
STCON LbmFloat dfDvecZ[ 9 ];
655
/*! principal directions */
656
STCON int princDirX[ 2*2 ];
657
STCON int princDirY[ 2*2 ];
658
STCON int princDirZ[ 2*2 ];
661
STCON LbmFloat dfLength[ 9 ];
663
/* equilibrium distribution functions, precalculated = getCollideEq(i, 0,0,0,0) */
664
static LbmFloat dfEquil[ 9 ];
666
/*! arrays for les model coefficients */
667
static LbmFloat lesCoeffDiag[ (2-1)*(2-1) ][ 9 ];
668
static LbmFloat lesCoeffOffdiag[ 2 ][ 9 ];
474
676
/*****************************************************************************/
495
697
//! flag array acces macro
496
698
#define _RFLAG(level,xx,yy,zz,set) mLevel[level].mprsFlags[set][ LBMGI((level),(xx),(yy),(zz),(set)) ]
497
#define _RFLAG_NB(level,xx,yy,zz,set, dir) mLevel[level].mprsFlags[set][ LBMGI((level),(xx)+D::dfVecX[dir],(yy)+D::dfVecY[dir],(zz)+D::dfVecZ[dir],set) ]
498
#define _RFLAG_NBINV(level,xx,yy,zz,set, dir) mLevel[level].mprsFlags[set][ LBMGI((level),(xx)+D::dfVecX[D::dfInv[dir]],(yy)+D::dfVecY[D::dfInv[dir]],(zz)+D::dfVecZ[D::dfInv[dir]],set) ]
500
// array data layouts
501
// standard array layout -----------------------------------------------------------------------------------------------
502
#define ALSTRING "Standard Array Layout"
699
#define _RFLAG_NB(level,xx,yy,zz,set, dir) mLevel[level].mprsFlags[set][ LBMGI((level),(xx)+this->dfVecX[dir],(yy)+this->dfVecY[dir],(zz)+this->dfVecZ[dir],set) ]
700
#define _RFLAG_NBINV(level,xx,yy,zz,set, dir) mLevel[level].mprsFlags[set][ LBMGI((level),(xx)+this->dfVecX[this->dfInv[dir]],(yy)+this->dfVecY[this->dfInv[dir]],(zz)+this->dfVecZ[this->dfInv[dir]],set) ]
702
// array handling -----------------------------------------------------------------------------------------------
503
704
//#define _LBMQI(level, ii,ij,ik, is, lunused) ( ((is)*mLevel[level].lOffsz) + (mLevel[level].lOffsy*(ik)) + (mLevel[level].lOffsx*(ij)) + (ii) )
504
705
#define _LBMQI(level, ii,ij,ik, is, lunused) ( (mLevel[level].lOffsy*(ik)) + (mLevel[level].lOffsx*(ij)) + (ii) )
505
706
#define _QCELL(level,xx,yy,zz,set,l) (mLevel[level].mprsCells[(set)][ LBMQI((level),(xx),(yy),(zz),(set), l)*dTotalNum +(l)])
506
#define _QCELL_NB(level,xx,yy,zz,set, dir,l) (mLevel[level].mprsCells[(set)][ LBMQI((level),(xx)+D::dfVecX[dir],(yy)+D::dfVecY[dir],(zz)+D::dfVecZ[dir],set, l)*dTotalNum +(l)])
507
#define _QCELL_NBINV(level,xx,yy,zz,set, dir,l) (mLevel[level].mprsCells[(set)][ LBMQI((level),(xx)+D::dfVecX[D::dfInv[dir]],(yy)+D::dfVecY[D::dfInv[dir]],(zz)+D::dfVecZ[D::dfInv[dir]],set, l)*dTotalNum +(l)])
707
#define _QCELL_NB(level,xx,yy,zz,set, dir,l) (mLevel[level].mprsCells[(set)][ LBMQI((level),(xx)+this->dfVecX[dir],(yy)+this->dfVecY[dir],(zz)+this->dfVecZ[dir],set, l)*dTotalNum +(l)])
708
#define _QCELL_NBINV(level,xx,yy,zz,set, dir,l) (mLevel[level].mprsCells[(set)][ LBMQI((level),(xx)+this->dfVecX[this->dfInv[dir]],(yy)+this->dfVecY[this->dfInv[dir]],(zz)+this->dfVecZ[this->dfInv[dir]],set, l)*dTotalNum +(l)])
509
710
#define QCELLSTEP dTotalNum
510
711
#define _RACPNT(level, ii,ij,ik, is ) &QCELL(level,ii,ij,ik,is,0)
819
/******************************************************************************/
820
/*! equilibrium functions */
821
/******************************************************************************/
823
/*! calculate length of velocity vector */
824
inline LbmFloat LbmFsgrSolver::getVelVecLen(int l, LbmFloat ux,LbmFloat uy,LbmFloat uz) {
825
return ((ux)*dfDvecX[l]+(uy)*dfDvecY[l]+(uz)*dfDvecZ[l]);
828
/*! calculate equilibrium DF for given values */
829
inline LbmFloat LbmFsgrSolver::getCollideEq(int l, LbmFloat rho, LbmFloat ux, LbmFloat uy, LbmFloat uz) {
830
#if FSGR_STRICT_DEBUG==1
831
if((l<0)||(l>LBM_DFNUM)) { errFatal("LbmFsgrSolver::getCollideEq","Invalid DFEQ call "<<l, SIMWORLD_PANIC ); /* no access to mPanic here */ }
832
#endif // FSGR_STRICT_DEBUG==1
833
LbmFloat tmp = getVelVecLen(l,ux,uy,uz);
834
return( dfLength[l] *(
835
+ rho - (3.0/2.0*(ux*ux + uy*uy + uz*uz))
837
+ 9.0/2.0 *(tmp*tmp) )
620
841
/*****************************************************************************/
621
842
/* init a given cell with flag, density, mass and equilibrium dist. funcs */
624
void LbmFsgrSolver<D>::changeFlag(int level, int xx,int yy,int zz,int set,CellFlagType newflag) {
844
void LbmFsgrSolver::changeFlag(int level, int xx,int yy,int zz,int set,CellFlagType newflag) {
625
845
CellFlagType pers = RFLAG(level,xx,yy,zz,set) & CFPersistMask;
626
846
RFLAG(level,xx,yy,zz,set) = newflag | pers;
631
LbmFsgrSolver<D>::initEmptyCell(int level, int i,int j,int k, CellFlagType flag, LbmFloat rho, LbmFloat mass) {
850
LbmFsgrSolver::initEmptyCell(int level, int i,int j,int k, CellFlagType flag, LbmFloat rho, LbmFloat mass) {
632
851
/* init eq. dist funcs */
634
853
int workSet = mLevel[level].setCurr;
636
855
ecel = RACPNT(level, i,j,k, workSet);
637
FORDF0 { RAC(ecel, l) = D::dfEquil[l] * rho; }
856
FORDF0 { RAC(ecel, l) = this->dfEquil[l] * rho; }
638
857
RAC(ecel, dMass) = mass;
639
858
RAC(ecel, dFfrac) = mass/rho;
640
859
RAC(ecel, dFlux) = FLUX_INIT;