A curvilinear grid is very similar to a Rectilinear Grid with one important distinction. A rectilinear grid enforces that the mapping between I and X, and J and Y, are completely independent of the other variables. In a curvilinear grid, the X coordinate of a point is dependent on both I and J (and K in 3-D).
This creates several differences from rectilinear and Cartesian grids.
- No Directional Uniformity - The direction from Cell(I,J,K) to Cell (I+1,J,K) varies for all I, J, and K.
- No Distance Uniformity - The distance between Cell (I,J,K) and Cell (I+1,J,K) varies for all I, J, and K.
- No Volume Uniformity - Cells are of varying volumes, depending on their I,J,K location.
- Unique Boundary Conditions - It is possible that some boundaries may not be hard edges, but rather "wraparounds." This is common in curvilinear grids around cylindrical structures where Cell (0,J,K) shares an edge with Cell (IMax,J,K).
However, the curvilinear grid is the only structured grid with support for non-rectangular spaces. The grid can now wrap around cylindrical or spherical shapes, correctly representing their form into the visualization or simulation. Because of this they are frequently found in CFD work.
Due to the "almost rectangular" nature of the grid, most visualization algorithms (Interpolations, Marching Cubes) can still be performed quickly in IJK space and then transformed into XYZ space. Some algorithms, like Streamlines, must be modified to handle the fact that the direction between neighboring cells is no longer uniform.
Another way to look at a curvilinear grid is to think of a Cartesian Grid, which is a uniform grid in all three dimensions. Mentally draw a Cartesian grid on a sponge, then wrap the sponge around a cylinder. As the sponge is distorted around the cylinder, the normally orthogonal lines drawn on the sponge become distorted. The logical, lattice structure of the grid is still maintained (the computational space - I, J, and K) even while the coordinate space (X, Y, and Z) is distorted. If this sponge analogy works for a simple 3-D object like a cylinder, then it can work for more complicated surfaces. One can imagine that as the surface becomes more complex that the grid will become more distorted to the point of being useless. In those cases, several curvilinear grids may be used, which is the impetus for MultiBlock Grids.
The following is an example of a Structured Grid using the legacy VTK format.
# vtk DataFile Version 3.0 Wedge Flow ASCII DATASET STRUCTURED_GRID DIMENSIONS 32 32 1 POINTS 1024 float -0.696922 -0.048225 0.000000 : :
The code for to write out a 2-D structured grid is found in the C Code to write VTK Stuctured Grid tutorial.