Updated - Tue. March 5
Description
- Problem: Linear advection, rotational flow
(for hand-in problem. Extra credit may differ).
- Method: Lax-Wendroff, automatic grid
nest placement (but fixed size)
- Due date: 2:00 PM Wednesday
March 27
- Problem handout: PDF
Nesting and plot routines for Program #4
The following are provided to you. They are available
dointerp handles
interpolation between the coarse and nested grids;
feedback; and nested grid boundary conditions
nestwind
provides the nested grid analytical wind field, given
the nest location in coarse grid coordinates
test_interp
a short program showing you how to call dointerp to set
BCs, create a "nest", and do feedback.
README
-- describes how to compile the test_interp program.
How to use dointerp for a "passive nest"
centered on the cone center - not real nesting
- Put your rotational flow initial condition back into
program 3.
- In your main program, you will need some extra
variables - see below.
- In your main time step loop, after you call advection
for the coarse grid but before you call update:
- find the center of the cone in the coarse grid
(Not sure how to do this? See me)
- call dointerp to place the nest
centered on the cone (see details below - the test_interp
code should help)
- call contr to draw contours for your
nested grid array that dointerp filled in
with interpolated coarse-grid values.
If the nest is centered and called OK, you'll see a
"cone" at the nest center - and appearing much
larger than on the coarse grid.
- change your call contr for the coarse
grid to include the nest location variables nestX1,
etc. You probably used 0,0,0,0 before.
- If this all worked, learn how to use dointerp and
nestwind to help add nesting to your code.
Calling dointerp:
See the test_interp routine in the Fortran or C
directory for examples of how to call dointerp
and nestwind.
In Fortran, you call dointerp routine in this
way:
call dointerp(q1,
q1nest, nx,ny, bcwidth, nestX1, nestX2, nestY1, nestY2
n,ratio,flag, nestX1old, nestX2old, nestY1old,
nestY2old)
Variables:
- q1 - name
of the coarse grid. Pass the whole array -
including ghost points - to dointerp.
- q1nest - name of
the nested grid. Pass the whole array -
including ghost points - to dointerp.
- nx,ny -
dimensions of the grid (not including ghost points
for Fortran) (so this really IS just nx,ny)
- bcwidth - number of ghost points
you are using.
- nestX1 ... nestY2 - four integers defining the nest
position -
- IF you are first placing the nest
OR you are setting nest BCs OR
you are doing feedback,
then these four integer variables define the current
position of the nest on the
coarse grid ...
and the variables nestX1old,nestX2old,nestY1old,nestY2old
are ignored by dointerp.
- IF you are moving the nest, these
are the (future) coordinates of where
the nest should be moved, and
nestX1old,nestX2old etc. define the current position
of the nest on the coarse grid.
- n
- the time step counter, used by print statements
inside the routine. Pass 0 if you wish.
This is an integer.
- ratio -
nest refinement factor, an integer such as 3
- flag
- a key variable (an integer) telling dointerp what
to do.
- when flag = -1, dointerp will move the
nest, from old (nestX1old, etc.) to new (nestX1,
etc) positions
- when flag = 1, dointerp will place
the nest: interpolate coarse > nest.
We do this only once.
- when flag = 10, dointerp will set nested
grid boundary values. Nest interior
values are unchanged.
- when flag = 2, dointerp will do
feedback - to the coarse grid from the
nest.
- nestX1old...nestY2old are ignored except
in the case when the nest is being moved.
- When the nest is being moved, nestX1old
... nestY2old are the current (soon to be old!)
position of the nest,
and the variables nestX1 ... nestY2 contain the
new nest position you want.
- When calling dointerp for cases other
than moving the nest, just pass 0,0,0,0
for these four variables.
How to set these variables in our passive
nest test (not the
full code run with truncation error!!)
to put the nest over the cone after calling
the initial condition:
- Figure out the center of the nest in coarse-grid
coordinates - find largest value on the grid and save
the i,j location of it.
- Set i_center = ( the I
coordinate of the cone center )
- Set j_center = ( the J
coordinate of the cone center )
- Now set the nested grid bounds
(nestX1, nestY1,
nestX2, nestY2 are integers, so division will
truncate any fractional numbers, which is correct!)
- nestsize = (nx-1)/ratio
this is the width and
height of the nest in coarse-grid-point
coordinates
- nestX1 =
i_center - nestsize/2 this is the I-coordinate of the
left edge of the nest, in coarse-grid coordinates
- nestX2 = nestX1
+ nestsize this is the I-coordinate
of the right edge of the nest, in coarse-grid
coordinates
- nestY1 =
j_center - nestsize/2 this is the J-coordinate
of the bottom edge of the nest, in coarse-grid
coordinates
- nestY2 = nestX1
+ nestsize this is the J-coordinate
of the top edge of the nest, in coarse-grid
coordinates
Given these settings, you can then call dointerp to
create a "nest", and plot it with contr.
And - when you call contr for the coarse grid,
as usual - pass those grid "coordinates"
(nestX1 etc) in the call to contr
so it shows where your passive "nest" would be located.
Remember, in the full nesting problem you will
place (and move) the nest based on truncation
error. You won't just place (or move) the
nest based on the cone center position. Do the
above to make sure you can call dointerp and
plot the nest results and see it looks OK.
Rotational flow
test case results:
Settings:
- Cone width is 0.075
- Nest time/space refinement ratio = 3
- Nest moved every 5 time steps
- Grid dimensions are 106x106; dx = 1.0/real(nx-1) as
before.
- Time step = pi / 360; run for 360 steps
Test case results:
|