lbm_reference
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lbm::LBM< T > Class Template Reference

Lattice Boltzmann Method fluid solver. More...

#include <lbm/LBM.h>

+ Inheritance diagram for lbm::LBM< T >:
+ Collaboration diagram for lbm::LBM< T >:

Public Member Functions

Vec3< TgetVelocity (T x, T y, T z)
 Get tri-linearly interpolated velocity at given position. More...
 
Vec3< TgetVelocity (const Vec3< T > &v)
 Get tri-linearly interpolated velocity at given position. More...
 
 LBM ()
 Default constructor. More...
 
 LBM (const std::string configFileName)
 Constructor. More...
 
 LBM (ConfBlock &base)
 Constructor. More...
 
void run ()
 Run the solver. More...
 
double runStep ()
 Perform a single LBM step. More...
 
void setup (ConfBlock &base)
 Setup the solver by processing configuration file. More...
 
virtual ~LBM ()
 Destructor. More...
 

Protected Member Functions

std::string calcMLUP (T time, int cells)
 
void collideStream (int x, int y, int z)
 Perform a collide-stream step without turbulence correction. More...
 
void collideStreamSmagorinsky (int x, int y, int z)
 Perform a collide-stream step with turbulence correction. More...
 
T getTime (timeval &start, timeval &end)
 Get the time difference between two measurements. More...
 
void moveSphere ()
 
void setupBoundary (ConfBlock &block, int x, int y, int z)
 Process a boundary block. More...
 
void treatCurved ()
 Treat the curved boundary cells. More...
 
void treatInflow ()
 Treat the inflow boundary cells. More...
 
void treatNoslip ()
 Treat the no-slip boundary cells. More...
 
void treatOutflow ()
 Treat the outflow boundary cells. More...
 
void treatPressure ()
 Treat the outflow boundary cells with fixed athmospheric pressure. More...
 
void treatStaircase ()
 
void treatVelocity ()
 Treat the boundary cells with fixed velocity. More...
 
void writePerformanceSummary ()
 
void writeVtkFile ()
 Write out the VTK file for a given timestep. More...
 
template<>
void writeVtkFile ()
 
template<>
void writeVtkFile ()
 
template<>
void writeVtkFile ()
 
template<>
void writeVtkFile ()
 

Protected Attributes

T cSmagoSqr_
 Squared Smagorinsky turbulence constant. More...
 
int curStep_
 Current time step. More...
 
std::vector< Vec3< int > > curvedCells_
 List with coordinates of all curved boundary cells. More...
 
std::vector< std::vector< T > > curvedDeltas_
 List with fluid fractions for all lattice links of curved boundary cells. More...
 
Grid< Flag, 1 > flag_
 Flag field. More...
 
Grid< T, Dim > * grid0_
 Distribution function field (switched with grid1_ after each time step) More...
 
Grid< T, Dim > * grid1_
 Distribution function field (switched with grid0_ after each time step) More...
 
std::vector< Vec3< int > > inflowCells_
 List with coordinates of all inflow cells. More...
 
std::vector< Vec3< T > > inflowVels_
 List with velocities for all inflow cells. More...
 
int maxSteps_
 Number of collide-stream steps to perform. More...
 
std::vector< Vec3< int > > noslipCells_
 List with coordinates of all noslip cells. More...
 
T nu_
 Lattice viscosity. More...
 
T omega_
 Inverse lattice velocity. More...
 
std::vector< Vec3< int > > outflowCells_
 List with coordinates of all outflow cells. More...
 
std::vector< int > outflowDFs_
 List with outflow directions for all outflow cells. More...
 
std::vector< Vec3< int > > pressureCells_
 List with coordinates of all pressure cells. More...
 
std::vector< int > pressureDFs_
 List with outflow directions for all pressure cells. More...
 
PerformanceData< Tprof_
 
Grid< T, 1 > rho_
 Density field. More...
 
std::vector< Sphere< T > > sphereObstacles_
 Vector holding all sphere obstacles. More...
 
std::vector< Vec3< int > > staircaseCells_
 
Grid< T, 3 > u_
 Velocity field. More...
 
std::vector< Vec3< int > > velocityCells_
 List with coordinates of all velocity cells. More...
 
std::vector< Vec3< T > > velocityVels_
 List with velocities for all velocity cells. More...
 
std::string vtkFileName_
 Path and base name of VTK files to write out. More...
 
int vtkStep_
 VTK files will be written out at multiples of this step size. More...
 

Detailed Description

template<typename T>
class lbm::LBM< T >

Lattice Boltzmann Method fluid solver.

Uses the BGK collision model and Smagorinsky turbulence correction. The coordinate system used is left-handed, i.e. screen coordinates

The following boundary conditions are implemented:

The constructor requires a configuration file in a ConfParser compatible format to be given, which must specify the following hierarchy of blocks:

Example configuration file:

domain {
sizeX 62;
sizeY 62;
sizeZ 62;
}
parameters {
omega 1.9;
cSmagorinsky 0.03;
maxSteps 1201;
}
vtk {
vtkFileName vtk/outflow_60_60_60_1.9_0.03_1201_25;
vtkStep 25;
}
boundaries {
top {
outflow {
xStart 1;
xEnd 60;
zStart 1;
zEnd 60;
}
}
bottom {
inflow {
xStart 26;
xEnd 35;
zStart 26;
zEnd 35;
u_x 0.0;
u_y 0.0;
u_z 0.1;
}
}
left {
inflow {
zStart 2;
zEnd 59;
yStart 2;
yEnd 59;
u_x 0.001;
u_y 0.0;
u_z 0.0;
}
}
right {
outflow {
zStart 2;
zEnd 59;
yStart 2;
yEnd 59;
}
}
back {
outflow {
xStart 1;
xEnd 60;
yStart 2;
yEnd 59;
}
}
front {
outflow {
xStart 1;
xEnd 60;
yStart 2;
yEnd 59;
}
}
}
Note
define the preprocessor symbol NSMAGO to disable turbulence correction

Definition at line 217 of file LBM.h.

Constructor & Destructor Documentation

template<typename T>
lbm::LBM< T >::LBM ( )
inline

Default constructor.

Does no initialization.

Definition at line 229 of file LBM.h.

template<typename T >
lbm::LBM< T >::LBM ( const std::string  configFileName)

Constructor.

Initializes the geometry of the domain and the boundaries according to the configuration file given.

Note
There is no default constructor available!
Parameters
[in]configFileNamePath to configuration file

Definition at line 32 of file LBM_def.h.

References lbm::LBM< T >::setup().

template<typename T>
lbm::LBM< T >::LBM ( ConfBlock &  base)

Constructor.

Initializes the geometry of the domain and the boundaries according to the configuration block given.

Note
There is no default constructor available!
Parameters
[in]baseRoot configuration block

Definition at line 46 of file LBM_def.h.

References lbm::LBM< T >::setup().

template<typename T >
lbm::LBM< T >::~LBM ( )
virtual

Destructor.

Deletes the grids of the distribution functions

Definition at line 51 of file LBM_def.h.

Member Function Documentation

template<typename T>
std::string lbm::LBM< T >::calcMLUP ( T  time,
int  cells 
)
protected

Definition at line 1357 of file LBM_def.h.

template<typename T >
void lbm::LBM< T >::collideStream ( int  x,
int  y,
int  z 
)
inlineprotected

Perform a collide-stream step without turbulence correction.

Parameters
[in]xCell coordinate for dimension x
[in]yCell coordinate for dimension y
[in]zCell coordinate for dimension z

Definition at line 889 of file LBM_def.h.

References lbm::Dim, lbm::ex, lbm::ey, lbm::ez, lbm::T, and lbm::w.

template<typename T >
void lbm::LBM< T >::collideStreamSmagorinsky ( int  x,
int  y,
int  z 
)
inlineprotected

Perform a collide-stream step with turbulence correction.

Parameters
[in]xCell coordinate for dimension x
[in]yCell coordinate for dimension y
[in]zCell coordinate for dimension z

Definition at line 933 of file LBM_def.h.

References lbm::Dim, lbm::ep, lbm::ex, lbm::ey, lbm::ez, and lbm::T.

template<typename T >
T lbm::LBM< T >::getTime ( timeval &  start,
timeval &  end 
)
inlineprotected

Get the time difference between two measurements.

Parameters
[in]startStart time of measurement as return by gettimeofday
[in]endEnd time of measurement as return by gettimeofday
Returns
Time difference end - start in seconds

Definition at line 883 of file LBM_def.h.

References lbm::T.

template<typename T>
Vec3< T > lbm::LBM< T >::getVelocity ( T  x,
T  y,
T  z 
)
inline

Get tri-linearly interpolated velocity at given position.

Parameters
[in]xx-coordinate of position to get velocity
[in]yy-coordinate of position to get velocity
[in]zz-coordinate of position to get velocity

Definition at line 226 of file LBM_def.h.

References lbm::T.

Referenced by particles::ParticleSystem::updateParticles().

template<typename T>
Vec3<T> lbm::LBM< T >::getVelocity ( const Vec3< T > &  v)
inline

Get tri-linearly interpolated velocity at given position.

Parameters
[in]v3-component vector (x,y,z) of position to get velocity

Definition at line 279 of file LBM.h.

template<typename T >
void lbm::LBM< T >::moveSphere ( )
inlineprotected

Definition at line 1214 of file LBM_def.h.

References lbm::Dim, DIST, lbm::ex, lbm::exn, lbm::ey, lbm::eyn, lbm::ez, lbm::ezn, lbm::finv, lbm::le, lbm::T, and lbm::w.

template<typename T >
void lbm::LBM< T >::run ( )

Run the solver.

The output will be written to a series of VTK files (legacy format)

Definition at line 58 of file LBM_def.h.

References lbm::T.

Referenced by main().

template<typename T >
double lbm::LBM< T >::runStep ( )

Perform a single LBM step.

The output will be written to a VTK file if appropriate (legacy format)

Definition at line 91 of file LBM_def.h.

References lbm::T.

Referenced by particles::ParticleSystem::run().

template<typename T>
void lbm::LBM< T >::setup ( ConfBlock &  base)

Setup the solver by processing configuration file.

Initializes the geometry of the domain and the boundaries according to the configuration given.

Parameters
[in]baseRoot block of parsed configuration file

Definition at line 265 of file LBM_def.h.

References lbm::Dim, lbm::ex, lbm::exn, lbm::ey, lbm::eyn, lbm::ez, lbm::ezn, lbm::FLUID, Grid< T, Cellsize >::init(), lbm::le, lbm::NOSLIP, lbm::T, lbm::UNDEFINED, and lbm::w.

Referenced by lbm::LBM< T >::LBM(), and particles::ParticleSystem::ParticleSystem().

template<typename T>
void lbm::LBM< T >::setupBoundary ( ConfBlock &  block,
int  x,
int  y,
int  z 
)
inlineprotected

Process a boundary block.

Parameters
[in]blockBoundary block to process (either bottom, top, back, front, right, left)
[in]xEither fixed value for x-coordinate or -1 to read range from configuration
[in]yEither fixed value for y-coordinate or -1 to read range from configuration
[in]zEither fixed value for z-coordinate or -1 to read range from configuration

Definition at line 712 of file LBM_def.h.

References lbm::Dim, lbm::ex, lbm::ey, lbm::ez, lbm::INFLOW, lbm::NOSLIP, lbm::OUTFLOW, lbm::PRESSURE, lbm::T, lbm::UNDEFINED, and lbm::VELOCITY.

template<typename T >
void lbm::LBM< T >::treatCurved ( )
inlineprotected

Treat the curved boundary cells.

Definition at line 1184 of file LBM_def.h.

References lbm::Dim, lbm::ex, lbm::ey, lbm::ez, lbm::finv, and lbm::T.

template<typename T >
void lbm::LBM< T >::treatInflow ( )
inlineprotected

Treat the inflow boundary cells.

Definition at line 1093 of file LBM_def.h.

References lbm::T.

template<typename T >
void lbm::LBM< T >::treatNoslip ( )
inlineprotected

Treat the no-slip boundary cells.

Definition at line 1020 of file LBM_def.h.

References lbm::Dim, lbm::ex, lbm::ey, lbm::ez, and lbm::finv.

template<typename T >
void lbm::LBM< T >::treatOutflow ( )
inlineprotected

Treat the outflow boundary cells.

Definition at line 1137 of file LBM_def.h.

References lbm::Dim, lbm::ex, lbm::ey, and lbm::ez.

template<typename T >
void lbm::LBM< T >::treatPressure ( )
inlineprotected

Treat the outflow boundary cells with fixed athmospheric pressure.

Definition at line 1158 of file LBM_def.h.

References lbm::ex, lbm::ey, lbm::ez, lbm::finv, lbm::T, and lbm::w.

template<typename T >
void lbm::LBM< T >::treatStaircase ( )
inlineprotected

Definition at line 1040 of file LBM_def.h.

References lbm::Dim, lbm::ex, lbm::ey, lbm::ez, and lbm::finv.

template<typename T >
void lbm::LBM< T >::treatVelocity ( )
inlineprotected

Treat the boundary cells with fixed velocity.

Definition at line 1060 of file LBM_def.h.

References lbm::Dim, lbm::ex, lbm::ey, lbm::ez, lbm::finv, lbm::T, and lbm::w.

template<typename T >
void lbm::LBM< T >::writePerformanceSummary ( )
protected

Definition at line 1301 of file LBM_def.h.

References lbm::T.

template<typename T>
void lbm::LBM< T >::writeVtkFile ( )
protected

Write out the VTK file for a given timestep.

Note
Output is in binary VTK legacy file format
template<>
void lbm::LBM< double >::writeVtkFile ( )
protected
Note
This is necessary as the type needs to be written to the VTK file in ASCII and there is no way to get an ASCII representation of the type of a template paramter
template<>
void lbm::LBM< float >::writeVtkFile ( )
protected
Note
This is necessary as the type needs to be written to the VTK file in ASCII and there is no way to get an ASCII representation of the type of a template paramter
template<>
void lbm::LBM< double >::writeVtkFile ( )
protected

Definition at line 1367 of file LBM_def.h.

References htobe32, and htobe64.

template<>
void lbm::LBM< float >::writeVtkFile ( )
protected

Definition at line 1435 of file LBM_def.h.

References htobe32.

Member Data Documentation

template<typename T>
T lbm::LBM< T >::cSmagoSqr_
protected

Squared Smagorinsky turbulence constant.

Definition at line 389 of file LBM.h.

template<typename T>
int lbm::LBM< T >::curStep_
protected

Current time step.

Definition at line 398 of file LBM.h.

template<typename T>
std::vector< Vec3<int> > lbm::LBM< T >::curvedCells_
protected

List with coordinates of all curved boundary cells.

Definition at line 472 of file LBM.h.

template<typename T>
std::vector< std::vector<T> > lbm::LBM< T >::curvedDeltas_
protected

List with fluid fractions for all lattice links of curved boundary cells.

Definition at line 476 of file LBM.h.

template<typename T>
Grid<Flag,1> lbm::LBM< T >::flag_
protected

Flag field.

Definition at line 427 of file LBM.h.

template<typename T>
Grid<T,Dim>* lbm::LBM< T >::grid0_
protected

Distribution function field (switched with grid1_ after each time step)

Definition at line 411 of file LBM.h.

template<typename T>
Grid<T,Dim>* lbm::LBM< T >::grid1_
protected

Distribution function field (switched with grid0_ after each time step)

Definition at line 415 of file LBM.h.

template<typename T>
std::vector< Vec3<int> > lbm::LBM< T >::inflowCells_
protected

List with coordinates of all inflow cells.

Definition at line 448 of file LBM.h.

template<typename T>
std::vector< Vec3<T> > lbm::LBM< T >::inflowVels_
protected

List with velocities for all inflow cells.

Definition at line 452 of file LBM.h.

template<typename T>
int lbm::LBM< T >::maxSteps_
protected

Number of collide-stream steps to perform.

Definition at line 394 of file LBM.h.

template<typename T>
std::vector< Vec3<int> > lbm::LBM< T >::noslipCells_
protected

List with coordinates of all noslip cells.

Definition at line 435 of file LBM.h.

template<typename T>
T lbm::LBM< T >::nu_
protected

Lattice viscosity.

Definition at line 385 of file LBM.h.

template<typename T>
T lbm::LBM< T >::omega_
protected

Inverse lattice velocity.

Definition at line 380 of file LBM.h.

template<typename T>
std::vector< Vec3<int> > lbm::LBM< T >::outflowCells_
protected

List with coordinates of all outflow cells.

Definition at line 456 of file LBM.h.

template<typename T>
std::vector< int > lbm::LBM< T >::outflowDFs_
protected

List with outflow directions for all outflow cells.

Definition at line 460 of file LBM.h.

template<typename T>
std::vector< Vec3<int> > lbm::LBM< T >::pressureCells_
protected

List with coordinates of all pressure cells.

Definition at line 464 of file LBM.h.

template<typename T>
std::vector< int > lbm::LBM< T >::pressureDFs_
protected

List with outflow directions for all pressure cells.

Definition at line 468 of file LBM.h.

template<typename T>
PerformanceData<T> lbm::LBM< T >::prof_
protected

Definition at line 478 of file LBM.h.

template<typename T>
Grid<T,1> lbm::LBM< T >::rho_
protected

Density field.

Definition at line 423 of file LBM.h.

template<typename T>
std::vector< Sphere<T> > lbm::LBM< T >::sphereObstacles_
protected

Vector holding all sphere obstacles.

Definition at line 431 of file LBM.h.

template<typename T>
std::vector< Vec3<int> > lbm::LBM< T >::staircaseCells_
protected

Definition at line 436 of file LBM.h.

template<typename T>
Grid<T,3> lbm::LBM< T >::u_
protected

Velocity field.

Definition at line 419 of file LBM.h.

template<typename T>
std::vector< Vec3<int> > lbm::LBM< T >::velocityCells_
protected

List with coordinates of all velocity cells.

Definition at line 440 of file LBM.h.

template<typename T>
std::vector< Vec3<T> > lbm::LBM< T >::velocityVels_
protected

List with velocities for all velocity cells.

Definition at line 444 of file LBM.h.

template<typename T>
std::string lbm::LBM< T >::vtkFileName_
protected

Path and base name of VTK files to write out.

Will be appended by .currentStep.vtk

Definition at line 407 of file LBM.h.

template<typename T>
int lbm::LBM< T >::vtkStep_
protected

VTK files will be written out at multiples of this step size.

Definition at line 402 of file LBM.h.


The documentation for this class was generated from the following files: