CSol
Public Member Functions | List of all members
BF_Fire_Tile Class Reference

#include <bf/csol_bf.h>

Inheritance diagram for BF_Fire_Tile:
[legend]

Public Member Functions

 BF_Fire_Tile (CSol_Solver &, int, int, unsigned int, int, unsigned int, cl::Kernel &, cl::Kernel &, cl::Kernel &)
 Bushfire tile constructor. More...
 
 BF_Fire_Tile (const BF_Fire_Tile &)
 
 ~BF_Fire_Tile ()
 
void addUserBuffer (cl::Kernel &, QString, REAL)
 Add a user data buffer to the tile. More...
 
bool bufferToGridTile (GridScalar &, int)
 Read from padded tile buffer to grid. More...
 
bool buildUserArgumentList (std::list< QString > &)
 Build a correctly ordered user buffer argument list for program generation. More...
 
bool createEmptyRealCLBuffer (cl::Kernel &, cl::Buffer &, unsigned int, REAL, unsigned int layers=1)
 Empty REAL buffer creation Creates an empty OpenCL REAL buffer within the tile. More...
 
bool createEmptyUintCLBuffer (cl::Kernel &, cl::Buffer &, unsigned int, unsigned int, unsigned int layers=1)
 Empty integer buffer creation Creates an empty OpenCL integer buffer within the tile. More...
 
REAL get_fE_max ()
 Returns maximum front distance along east boundary. More...
 
REAL get_fE_min ()
 Returns minimum front distance along east boundary. More...
 
REAL get_fN_max ()
 Returns maximum front distance along north boundary. More...
 
REAL get_fN_min ()
 Returns minimum front distance along north boundary. More...
 
REAL get_fS_max ()
 Returns maximum front distance along south boundary. More...
 
REAL get_fS_min ()
 Returns minimum front distance along south boundary. More...
 
REAL get_fW_max ()
 Returns maximum front distance along west boundary. More...
 
REAL get_fW_min ()
 Returns minimum front distance along west boundary. More...
 
REAL get_idt ()
 Returns reciprocal of CFL timestep. More...
 
cl::Buffer *const get_pba ()
 Returns arrival time buffer. More...
 
cl::Buffer *const get_pbc ()
 Returns tile classification buffer. More...
 
cl::Buffer *const get_pbconst ()
 Returns tile constant buffer. More...
 
cl::Buffer *const get_pbdata ()
 Returns tile data buffer. More...
 
cl::Buffer *const get_pbf0 ()
 Returns tile front buffer. More...
 
cl::Buffer *const get_pbpoi ()
 Returns points-of-interest raster buffer. More...
 
cl::Buffer *const get_pbrand ()
 Returns tile random buffer. More...
 
cl::Buffer *const get_pbs ()
 Returns speed buffer. More...
 
cl::Buffer *const get_pbw_u ()
 Returns tile wind u (x-component) buffer. More...
 
cl::Buffer *const get_pbw_v ()
 Returns tile wind v (y-component) buffer. More...
 
cl::Buffer *const get_pbx ()
 Returns user buffers. More...
 
REAL get_s_max ()
 Returns maximum speed in tile. More...
 
REAL get_t_poi ()
 Returns maximum speed in tile. More...
 
bool getUserBuffer (QString &, cl::Buffer &)
 Access a named user data buffer in the tile. More...
 
bool init (cl::Kernel &)
 Run user initialisation code on the tile. More...
 
bool initBuffer (DataExecution::ObjectArray &, int)
 
bool initBuffer (GridScalar &, int)
 Write REAL Grid to OpenCL buffer. More...
 
void initFront (cl::Kernel &)
 Initialise the front buffer. More...
 
bool initUserBuffer (DataExecution::ObjectArray &, QString, REAL, int)
 Write REAL Grid to OpenCL user buffer. More...
 
bool limitUserBuffer (cl::Kernel &, QString, REAL, REAL)
 Apply limit to a user-defined data buffer. More...
 
bool LS_addPointSource (cl::Kernel &, REAL, REAL, REAL)
 Level set operation: Add point source. More...
 
bool LS_build (cl::Kernel &, REAL)
 Level set operation: Build speed values. More...
 
bool LS_calculateCurvature (cl::Kernel &)
 Level set operation: Calculate curvature. More...
 
bool LS_reinit (cl::Kernel &, bool)
 Level set operation: Single re-initialisation step. More...
 
bool LS_reinitWeighted (cl::Kernel &, bool)
 Level set operation: Single weighted re-initialisation step. More...
 
bool LS_setScalarBoundaries (cl::Kernel &, bool)
 Level set operation: Update boundary values from neighbouring tiles. More...
 
bool LS_setUserBoundaries (cl::Kernel &, QString)
 Level set operation: Update user boundary values from neighbouring tiles. More...
 
bool LS_update (cl::Kernel &, REAL, cl::Buffer &, uint)
 Level set operation: Update arrival times. More...
 
bool LS_updateRK (cl::Kernel &, REAL, cl::Buffer &, uint)
 Level set operation: Runge-Kutta timestep. More...
 
BF_Fire_Tileoperator= (const BF_Fire_Tile &)
 
bool randomiseUserBuffer (cl::Kernel &, QString, REAL)
 Add random variation to a user-defined data buffer. More...
 
template<typename T >
bool sampleArray (DataExecution::ObjectArray &, Grid< T > &, T, int)
 Sub-samples an array of Grids into a tile. More...
 
void set_dt (REAL dt_)
 Sets tile timestep. More...
 
bool updateUserBuffer (cl::Kernel &, QString, BF_User_Temporal &)
 Update the internal user buffer with new values from time-varying spatial data. More...
 
- Public Member Functions inherited from BF_Tile
 BF_Tile (CSol_Solver &, int, int)
 Bushfire tile constructor. More...
 
virtual ~BF_Tile ()
 
void deleteTile ()
 De-activates the tile. More...
 
REAL get_hx ()
 Returns tile spacing in x-direction. More...
 
REAL get_hy ()
 Returns tile spacing in y-direction. More...
 
bool get_isAlive ()
 Returns true if tile is active, false otherwise. More...
 
REAL get_ox ()
 Returns global tile offset in x-direction. More...
 
REAL get_oy ()
 Returns global tile offset in y-direction. More...
 
int get_size ()
 Returns tile dimensions. More...
 
int get_tx ()
 Returns integer tile offset in x-direction. More...
 
int get_ty ()
 Returns integer tile offset in y-direction. More...
 
bool hasNeighbourE ()
 Returns true if tile has a east neighbour, false otherwise. More...
 
bool hasNeighbourN ()
 Returns true if tile has a north neighbour, false otherwise. More...
 
bool hasNeighbourNE ()
 Returns true if tile has a north-east neighbour, false otherwise. More...
 
bool hasNeighbourNW ()
 Returns true if tile has a north-west neighbour, false otherwise. More...
 
bool hasNeighbourS ()
 Returns true if tile has a south neighbour, false otherwise. More...
 
bool hasNeighbourSE ()
 Returns true if tile has a south-east neighbour, false otherwise. More...
 
bool hasNeighbourSW ()
 Returns true if tile has a south-west neighbour, false otherwise. More...
 
bool hasNeighbourW ()
 Returns true if tile has a west neighbour, false otherwise. More...
 
void setNeighbourE (BF_Tile *pTile)
 Sets tile east neighbour. More...
 
void setNeighbourN (BF_Tile *pTile)
 Sets tile north neighbour. More...
 
void setNeighbourNE (BF_Tile *pTile)
 Sets tile north-east neighbour. More...
 
void setNeighbourNW (BF_Tile *pTile)
 Sets tile north-west neighbour. More...
 
void setNeighbours (std::map< BF::int64, BF_Tile * > &)
 Sets tile neighbours. More...
 
void setNeighbourS (BF_Tile *pTile)
 Sets tile south neighbour. More...
 
void setNeighbourSE (BF_Tile *pTile)
 Sets tile south-east neighbour. More...
 
void setNeighbourSW (BF_Tile *pTile)
 Sets tile south-west neighbour. More...
 
void setNeighbourW (BF_Tile *pTile)
 Sets tile west neighbour. More...
 

Additional Inherited Members

- Public Types inherited from BF_Tile
enum  bufferType {
  bFront, bClass, bArrival, bOut,
  bUser
}
 Tile buffer types. More...
 
enum  direction { North, South, West, East }
 Tile directions. More...
 
- Protected Attributes inherited from BF_Tile
cl::Context & context
 
REAL hx
 
REAL hy
 Cell spacing in world units. More...
 
bool isAlive
 Active flag. More...
 
int localSize
 OpenCL group size. More...
 
REAL ox
 
REAL oy
 Tile origin in world units. More...
 
BF_TilepTileE
 
BF_TilepTileN
 
BF_TilepTileNE
 
BF_TilepTileNW
 
BF_TilepTileS
 
BF_TilepTileSE
 
BF_TilepTileSW
 
BF_TilepTileW
 
cl::CommandQueue & queue
 
int tileSize
 Number of cells in each tile. More...
 
int tx
 
int ty
 Cell offset in tile world units. More...
 

Constructor & Destructor Documentation

BF_Fire_Tile ( CSol_Solver solver_,
int  tx_,
int  ty_,
unsigned int  seed,
int  constants_,
unsigned int  nxLayers_,
cl::Kernel &  fillUintBufferKernel,
cl::Kernel &  fillRealBufferKernel,
cl::Kernel &  initRandKernel 
)

Creates a two-dimensional computational tile for the bushfire solver. Each tile has equal x and y dimensions of 'tileSize' with x and y spacings of 'hx' and 'hy', respectively. Every tile is reference according to the first tile created in the simulation. This first tile has a integer location of (0, 0) along with a global offset from the lower-left corner which is passed to this constructor for each subsequent tile creation.

Parameters
solver_the parent solver instance.
tx_the integer x-location of the tile with respect to the first tile created.
ty_the integer y-location of the tile with respect to the first tile created.
seedthe random number seed for the tile.
constants_the number of user-defined constants required for the simulation.
fillUintBufferKernelthe OpenCL kernel to fill a buffer with an unsigned integer value.
fillRealBufferKernelthe OpenCL kernel to fill a buffer with an REAL value.
initRandKernelthe OpenCL kernel to initialise the random number generator.
~BF_Fire_Tile ( )
inline
BF_Fire_Tile ( const BF_Fire_Tile )

Member Function Documentation

void addUserBuffer ( cl::Kernel &  fillRealBufferKernel,
QString  userName,
REAL  externalVal 
)

Creates and adds a user-defined data buffer to the tile. This is inserted into a local map, identified by the given name of the user data buffer. The buffer is initialised to 'externalVal' on creation.

Parameters
fillRealBufferKernelthe OpenCL kernel to fill a buffer with an REAL value.
userNamethe name of the user buffer.
externalValthe initialisation value for the user buffer.
bool bufferToGridTile ( GridScalar g,
int  type 
)

Reads from internal OpenCL buffers to a Grid for downstream processing.

Parameters
gthe Grid to read data into.
typethe data type to read, given by bufferType.
bool buildUserArgumentList ( std::list< QString > &  userDataNames)
Parameters
userDataNameslist of user data sets referred to in user-defined programs.
bool createEmptyRealCLBuffer ( cl::Kernel &  fillRealBufferKernel,
cl::Buffer &  buffer,
unsigned int  tileSize,
REAL  v,
unsigned int  layers = 1 
)
Parameters
fillRealBufferKernelthe OpenCL kernel to fill a buffer with an REAL value.
bufferthe OpenCL buffer to fill.
tileSizethe number of tile cells in the x and y directions.
vthe REAL fill value.
bool createEmptyUintCLBuffer ( cl::Kernel &  fillUintBufferKernel,
cl::Buffer &  buffer,
unsigned int  tileSize,
unsigned int  v,
unsigned int  layers = 1 
)
Parameters
fillUintBufferKernelthe OpenCL kernel to fill a buffer with an unsigned integer value.
bufferthe OpenCL buffer to fill.
tileSizethe number of tile cells in the x and y directions.
vthe integer fill value.
REAL get_fE_max ( )
inline
REAL get_fE_min ( )
inline
REAL get_fN_max ( )
inline
REAL get_fN_min ( )
inline
REAL get_fS_max ( )
inline
REAL get_fS_min ( )
inline
REAL get_fW_max ( )
inline
REAL get_fW_min ( )
inline
REAL get_idt ( )
inline
cl::Buffer* const get_pba ( )
inline
cl::Buffer* const get_pbc ( )
inline
cl::Buffer* const get_pbconst ( )
inline
cl::Buffer* const get_pbdata ( )
inline
cl::Buffer* const get_pbf0 ( )
inline
cl::Buffer* const get_pbpoi ( )
inline
cl::Buffer* const get_pbrand ( )
inlinevirtual

Implements BF_Tile.

cl::Buffer* const get_pbs ( )
inline
cl::Buffer* const get_pbw_u ( )
inlinevirtual

Implements BF_Tile.

cl::Buffer* const get_pbw_v ( )
inlinevirtual

Implements BF_Tile.

cl::Buffer* const get_pbx ( )
inline
REAL get_s_max ( )
inline
REAL get_t_poi ( )
inline
bool getUserBuffer ( QString &  userName,
cl::Buffer &  buffer 
)
Parameters
userNamethe name of the user buffer.
bufferhandle to the user buffer.
bool init ( cl::Kernel &  initKernel)
Parameters
initKernelthe user-defined initialisation kernel.
bool initBuffer ( DataExecution::ObjectArray &  ,
int   
)
bool initBuffer ( GridScalar g,
int  type 
)

Grids are sampled into dimensions compatible with the tile before writing to the buffer, so the Grid passed to this function can be any dimension and contain null values. Any null or out-of-bounds values are replaced by an 'infinite' value for the front grid, or an 'unburnt' value for the arrival time grid. The global positions of the Grid and buffer are used for the sampling.

Parameters
gthe Grid to write to the internal OpenCL buffer.
typethe data type to write, given by bufferType.
void initFront ( cl::Kernel &  fillRealBufferKernel)
Parameters
fillRealBufferKernelthe OpenCL kernel to fill a buffer with an REAL value.
bool initUserBuffer ( DataExecution::ObjectArray &  ,
QString  ,
REAL  ,
int   
)

Grids are sampled into dimensions compatible with the tile before writing to the buffer, so the Grid passed to this function can be any dimension and contain null values. Any null or out-of-bounds values are replaced by 'externalVal'. The global positions of the Grid and buffer are used for the sampling.

Parameters
arrthe array of Grids to write to the internal OpenCL buffer.
userNamethe name of the user buffer.
externalValthe value to use for out-of-bounds or external values.
interpolationTypethe type of interpolation to use.
bool limitUserBuffer ( cl::Kernel &  limitKernel,
QString  userName,
REAL  max,
REAL  min 
)

Replaces any value over maximum value with the maximum, and any value under the minimum value with the minimum.

Parameters
limitKernelthe OpenCL kernel for limiting.
userNamethe name of the user buffer.
maxthe maximum value.
minthe minimum value.
bool LS_addPointSource ( cl::Kernel &  addPointSource,
REAL  dox,
REAL  doy,
REAL  r 
)

Adds a circular point source to the front. The radius of the point source should be at least two cells accross to esure correct resolution.

Parameters
addPointSourcepoint source kernel.
doxpoint source x-location.
doypoint source y-location.
rpoint source radius.
bool LS_build ( cl::Kernel &  buildKernel,
REAL  solverTime 
)

Calculates the speed at each point in the tile based on the user-input speed definition. The function also carries out a reduction operation to find the maximum speed in the tile for the CFL condition. The maximum and minium boundary values are also stored for detection of the front location, which is used for creating new tiles and deactivating existing tiles.

Parameters
buildKernelbuild kernel.
RKstepstep value: 0 for first Runge-Kutta step, 1 for second step.
bool LS_calculateCurvature ( cl::Kernel &  curvature)

Experimental curvature calculation.

Parameters
curvaturecurvature kernel.
bool LS_reinit ( cl::Kernel &  reinitKernel,
bool  flip 
)
Parameters
reinitKernelre-initialisation kernel.
fliptrue if the primary front grid is used, false if the secondary front grid is used.
bool LS_reinitWeighted ( cl::Kernel &  reinitWeightedKernel,
bool  flip 
)
Parameters
reinitWeightedKernelre-initialisation kernel with speed weighting.
fliptrue if the primary front grid is used, false if the secondary front grid is used.
bool LS_setScalarBoundaries ( cl::Kernel &  setScalarBoundariesKernel,
bool  flip 
)

This sets the external values around the boundaries of each tile to the values from the boundaries of neighbouring tiles (scatter operation).

Parameters
setScalarBoundariesKernelboundary kernel.
fliptrue if the primary front grid is used, false if the secondary front grid is used.
bool LS_setUserBoundaries ( cl::Kernel &  setScalarBoundariesKernel,
QString  userName 
)

This sets the external values for user-defined layers around the boundaries of each tile to the values from the boundaries of neighbouring tiles (scatter operation).

Parameters
setScalarBoundariesKernelboundary kernel.
userNamethe name of the user buffer.
bool LS_update ( cl::Kernel &  updateKernel,
REAL  solverTime,
cl::Buffer &  bpoi_out,
uint  npoi 
)

Updates the arrival times within each tile and runs post-processing.

Parameters
updateKernelupdate kernel.
solverTimecurrent solver time.
bpoi_outthe output buffer for the points-of-interest.
npoithe total number of points-of-interest.
bool LS_updateRK ( cl::Kernel &  updateRKKernel,
REAL  solverTime,
cl::Buffer &  bpoi_out,
uint  npoi 
)

Carries out a Runge-Kutta based as a second step, after an intial Euler step. This function also updates the arrival times within each tile, flags any points-of-interest (PoI) that have been touched by the front during the timestep and runs the user-defined output model for any cells which are currently ignited.

Parameters
updateRKKernelRunge-Kutta time intergration kernel.
solverTimecurrent solver time.
bpoi_outthe output buffer for the points-of-interest.
npoithe total number of points-of-interest.
BF_Fire_Tile& operator= ( const BF_Fire_Tile )
bool randomiseUserBuffer ( cl::Kernel &  randomiseKernel,
QString  userName,
REAL  stdev 
)

Replaces the value in the buffer with new value from a normal distribution. The initial value in the buffer is used as the mean, and a new value is selected from a normal distribution with a given standard distribution width 'stdev'.

Parameters
randomiseKernelthe OpenCL kernel for randomisation.
userNamethe name of the user buffer.
stdevthe standard deviation of the normal distribution.
bool sampleArray ( DataExecution::ObjectArray &  arr,
Grid< T > &  gTile,
fillValue,
int  interpolationType 
)
Parameters
arrthe array of Grids to sample.
gTilethe tile grid write.
void set_dt ( REAL  dt_)
inline
bool updateUserBuffer ( cl::Kernel &  interpolateKernel,
QString  userName,
BF_User_Temporal userData 
)
Parameters
interpolateKernelthe OpenCL kernel for trilinear interpolation.
userNamethe name of the user buffer.
userDatathe time-varying user data.