Grid Generation
Preamble
This page is meant for the discretization of geometrically simple
domains, specifically rectangles and radial annulii. For more
complicated domains you will need to use a more sophisticated grid
generator like CUBIT
or other such programs. CUBIT can be licensed free (at least
to US institutions) for educational purposes. In case you do use CUBIT,
please refer to Kate Hedstrom's
manual
Grid Generation and manipulation
There are a number of program to generate simple spectral element grids.
These programs are written in fortran, the executable is created by saying
"make programname". The programs are the following:
-
rectelem: produces a spectral element grid for rectangular
domains. It can also be used to produce a cubed-sphere mesh.
-
radelem: produces a spectral element grid for annular type domains
-
ablockmesh2: uses algebraic mapping to generate curved spectral element grids.
The element partitioning is still structured.
-
periodize: takes a rectangular spectral element produced by "rectelem" and
eliminate duplicated nodes.
-
stretch: takes a rectangular spectral element and stretches by a constant
factor in the horizontal and a linearly changing factor in the vertical.
This is useful to create linearly sloping bottoms.
Creating the executable
Here is the gzipped and tarred file for
simple-domain grid generation. Follow the directions below
to generate a grid:
- Uncompress and untar the file. This will create a
directory called Rect.
- Edit the Makefile to set the right compiler and its flags.
The code is written in F90.
- Build the executables
make rectelem
make radelem
- Run the code, for example "rectelem < rectelem.in".
The grid is written to a file called fort.8; its format
is explained in the grid section. By default, the boundary
conditions listed are of type Dirichlet all around the domain
boundaries. The format of the rectelem.in file is described
below.
rectelem usage
"rectelem" accepts a few options; example of usage are
-
rectelem -h produces a short description of options
-
rectelem < rectelem.in to produce a SE in rectangular domains
-
rectelem -cs < rectelem.in to produce the 6 faces of a cubed sphere SE grid using the default equidistant mapping
-
rectelem -cs -ea < rectelem.in to produce the 6 faces of a cubed sphere SE grid using the equiangle mapping
-
rectelem -tr < rectelem.in to produce the 6 faces of a cubed sphere SE grid using the equiangle mapping
Format of rectelem.in
The file should have the following information:
nx ny npts ! line1
xc(1) xc(2) ... xc(nx) ! nx x-coordinates of element corners
yc(1) yc(2) ... yc(ny) ! ny y-coordinates of element corners
The example above will create a grid with (nx-1) elements in
the x-direction, (ny-1) elements in the y-direction, and each
element will have npts*npts collocation points at the
Gauss-Lobatto roots of the Legendre polynomial of degree
(npts-1). If a staggered pressure grid file needs to be
generated the code can be run again with npts replaced by
npts-2.
The format of the radelem.in file is the same except that
the x-direction refers now to the radial direction, and the
y-direction to the azimuthal direction. The coordinates in the
azimuthal direction are in degrees. Do not duplicate the first
and last node in the azimuthal direction since the domain is assumed
periodic azimuthally. Notice that the elements are curved in
this case, and care must taken to make sure the shape of the
element can be well represented by the isoparametric mapping,
i.e. the spectral expansion is high enough to represent the
distortion (in general the mapping is tolerant of some pretty
distorted elements).
The picture shows the elemental grid created
with radelem.in. The element number is shown inside each
element and the interior collocation points are omitted. This
figure was created with a drawcoast script
.
The cubed sphere
The cubed sphere can be tiled using a combination of programs available
here. First one needs to generate a single face of the cubed sphere. This single
face is then projected on the 6 faces of the cubed sphere to produce their
lon-lat coordinates (the output is stored in fort.8_n for
face n). The program merge_grid is then used to merge these 6 lon-lat
spectral element grids into a single one (the output is in fort.8_all).
Since the process is fairly simple but requires the user to pipe the output
from one program to the input of another.
Luckily the process can be automated through the bash script cubedsh. This script takes two input arguments, the
number of elements in the x-direction and the spectral truncation and
produces at the end a lon-lat spectral element grid in file fort.8_all. It
requires the programs "rectelem" and "merge_grid". The grid can be
visualized through the NCAR graphics program "drawcoast" or through the
matlab script segdrawm.m.