MGH_STAGGER Name
MGH_STAGGER Purpose
This function is designed to be used for calculations on staggered
rectangular grids of arbitrary dimension. It interpolates or
extrapolates scalar values between cell centres, faces and vertices.
Category
Finite-diffeence grids.
Calling Sequence
Result = MGH_STAGGER(X, DELTA=delta])
Positional Parameters
X (input, numeric array)
An array representing values on the grid.
Keyword Parameters
DELTA (input, integer scalar or vector)
An integer specifying the amount by which each dimension is to
be contracted or expanded. If DELTA is scalar, the same
expansion/contraction is applied to every dimension. If DELTA is
a vector, the number of elements must be greater than or equal to the
number of dimensions in the input (greater being permitted to allow
for omitted trailing unit dimensions).
Return Value
The function returns a numeric array of floating, double or
complex type, with each dimension in the input unchanged or
expanded/contracted according to the corresponding element in
DELTA. Procedure
Linear interpolation & extrapolation.
PERFORMANCE:
Time is propertional to number of elements and number of dimensions.
On my Pentium 3 800 MHz machine, MGH_STAGGER times for a 2D 1-million
element array are:
DELTA Time (s)
-2 0.19
-1 0.61
0 0.06
1 0.88
2 0.29 To Do
Generalise so that DELTA can take any integer value?
###########################################################################
This software is provided subject to the following conditions:
1. NIWA makes no representations or warranties regarding the
accuracy of the software, the use to which the software may
be put or the results to be obtained from the use of the
software. Accordingly NIWA accepts no liability for any loss
or damage (whether direct of indirect) incurred by any person
through the use of or reliance on the software.
2. NIWA is to be acknowledged as the original author of the
software where the software is used or presented in any form.
###########################################################################
Modification History
Mark Hadfield, 1998-09:
Written for a single dimension only.
Mark Hadfield, 2000-12:
Extended to multiple dimensions.
Mark Hadfield, 2002-02:
Fixed bug: expanding a dimension of size 2 gives wrong
answers.
Mark Hadfield, 2002-06:
* DELTA can now take values in the range [-2,2].
* Now allowing scalar DELTA to apply to all dimensions
Mark Hadfield, 2002-07:
Speeded code up by removing [*] subscripts from
LHS of assignments. This improves speed by 25-50 % where
applicable but readability suffers a bit.
Mark Hadfield, 2002-08:
DELTA now allowed to have more elements than the number of
dimensions in the input.
Mark Hadfield, 2007-02:
Computations are now in double precision. I should really do
this in a more flexible way!