three_d_grid.hΒΆ
A header file containing the code objects for generic template 3D data structures and for the grid vertices which will use them.
- struct GridVertex
- #include <three_d_grid.h>
Container for coordinates and values at grid vertex i.e. cell centre
Public Members
- double x_mid
x-coordinate of cell centre
- double y_mid
y-coordinate of cell centre
- double z_mid
z-coordinate of cell centre
- DynamicArray< double > N
array holding weighted ‘number’ of particles at gridpoint (for each type)
- DynamicArray< double > properties
array holding the smoothed property values at the cell centre
- template <typename T>
- class ThreeDGrid
Template class describing a 3D grid of arbitrary data type, used principally as the grid upon which smoothed properties are calculated
Public Functions
- ThreeDGrid()
Default constructor.
- ThreeDGrid(int num_z_dim, int num_y_dim, int num_x_dim)
Parametrised constructor.
- Parameters
- num_z_idx -
desired number of cells in the z direction
- num_y_idx -
desired number of cells in the y direction
- num_x_idx -
desired number of cells in the x direction
- num_z_idx -
- T & operator()(int z_idx, int y_idx, int x_idx)
Accesses a 3D grid of arbitrary member data type, three input indices are mapped to the underlying data structure.
- Return
- address of target variable
- Parameters
- z_idx -
target z index
- y_idx -
target y index
- x_idx -
target x index
- z_idx -
- void Initialise(int num_z_dim, int num_y_dim, int num_x_dim)
Initialises initially empty existing grid structure, allocating the memory for the vertices.
- See
- SwapMemoryLocation()
- Parameters
- num_z_idx -
desired number of cells in the z direction
- num_y_idx -
desired number of cells in the y direction
- num_x_idx -
desired number of cells in the x direction
- num_z_idx -
- bool Exist(void) const
Tests if the grid exists by checking if the underlying data stucture has been allocated.
- Return
- The test results (boolean)
Private Functions
- void SwapMemoryLocation(ThreeDGrid & target)
Performs a swap of the pointers to the data arrays within two ThreeDGrid objects.
- Parameters
- target -
target object with which the swap takes place
- target -
Private Members
- T *** data_
root pointer to data holding 3D array
- int num_x_
number of cells in x dimension
- int num_y_
number of cells in y dimension
- int num_z_
number of cells in z dimension