Grid file structure¶
Cgcam uses a structured data representation for the computational grid where the points x(i,j,k), y(i,j,k), and z(i,j,k); i=1:Nx+1, j=1:Ny+1, k=1:Nz+1 represent the vertices of the grid cells. These vertices generate Nx x Ny x Nz grid cells, each of which forms a small control volume where the conservation laws are enforced in the finite-volume scheme. The coordinate information is stored in double precision in the pure binary file grid.dat. Various grid grid topologies can be specified and the respective coordinates coordinates for each grid type are stored efficiently taking advantage of any symmetries inherent in the chosen topology.
Supported grid topologies¶
Cgcam currently support four different grid topologies, and these are specified using the input parameter i_grid as follows
i_grid=0 - General curvilinear structured grid.
i_grid=1 - Cartesian grid.
i_grid=2 - General curvilinear grid in two directions, Cartesian in
the third.
i_grid=3 - Grid for simulations including terrain at the lower boundary.
General curvilinear grid (i_grid=0)¶
The file grid.dat for a general curvilinear grid contains the arrays x(i,j,k), y(i,j,k), and z(i,j,k) for i=1:Nx+1, j=1:Ny+1, k=1:Nz+1. The arrays are written in double precision binary format, in fortran order (sequential on i, stride of Nx+1 for j, stride of (Nx+1)*(Ny+1) for k. General curvilinear grids are usually not used for atmospheric simulations and thus cgcam does not contain any grid generation programs for this topology.
Cartesian grid (i_grid=1)¶
The file grid.dat for a Cartesian grid contains the arrays x(i), y(j), and z(k) for i=1:Nx+1, j=1:Ny+1, k=1:Nz+1. The arrays are written in double precision binary format. Cartesian grids can be generated with the program cart_mesh as described in section Constructing a Cartesian mesh.
General curvilinear grid in two directions, Cartesian in the third (i_grid=2)¶
The file grid.dat for a Cartesian grid contains the arrays x(i,k), z(i,k), y(j) for i=1:Nx+1, j=1:Ny+1, k=1:Nz+1. The arrays are written in double precision binary format in fortran order (sequential on i, stride Nx+1 on k). This grid type is usually not used for atmospheric simulations and thus cgcam does not contain any grid generation programs for this topology.
Cartesian grid plus terrain (i_grid=3)¶
The file grid.dat for a Cartesian grid contains the arrays x(i), y(j), z(k), zb(i,j) for i=1:Nx+1, j=1:Ny+1, k=1:Nz+1. The arrays are written in double precision binary format in fortran order (sequential on i, stride of Nx+1 on j). Here zb(i,j) contains the elevation for each grid point in the horizontal directions. Cgcam uses this information to builds a distorted grid that conforms to the terrain at the lower boundary. It does this by starting with a pure Cartesian grid, but then adjusts the vertical coordinates for the first grid layer to match the terrain (i.e. z(i,j,k=1)=zb(i,j); i=1:Nx+1, j=1:Ny+1). Subsequent grid layers are distorted similarly, but with diminishing amplitude with increasing k, up to the specified altitude z1_fade, where the grid returns to a pure Cartesian state. The x and y grid coordinates retain a Cartesian structure for all altitudes. Terrain grids can be generated with the program terrain_mesh as described in section Constructing a Terrain Mesh.