LocalInterpCtx Class Reference

The "local interpolation context" describes the processor's part of the source NetCDF file (for regridding). More...

#include <LocalInterpCtx.hh>

List of all members.

Public Member Functions

 LocalInterpCtx (grid_info g, const double zlevsIN[], const double zblevsIN[], IceGrid &grid)
 Construct a local interpolation context from arrays of parameters.
 ~LocalInterpCtx ()
 Deallocate memory.
int kBelowHeight (const double height)
 Get the index for the source grid below a given vertical elevation within the ice.
int kbBelowHeight (const double elevation)
 Get the index for the source grid below a given vertical elevation within the bedrock.
PetscErrorCode printGrid ()
 Print out the grid information stored in the local interpolation context.
PetscErrorCode printArray ()
 Print out the actual array information stored in the local interpolation context.

Public Attributes

double fstart [3]
double delta [3]
int start [5]
int count [5]
doublea
 temporary buffer
int a_len
 the size of the buffer
int nz
 number of z-levels
int nzb
 number of zb-levels
doublezlevs
doublezblevs
bool no_regrid_ice
bool no_regrid_bedrock
bool report_range
MPI_Comm com
 MPI Communicator (for printing, mostly).
PetscMPIInt rank
 MPI rank, to allocate a_raw on proc 0 only.

Detailed Description

The "local interpolation context" describes the processor's part of the source NetCDF file (for regridding).

The local interpolation context contains the details of how the processor's block of the new computational domain fits into the domain of the netCDF file. Note that each vertical column of the grid is owned by exactly one processor.

For any particular dimension, we have a new computational domain $[a,b]$ with spacing $h$ so there are $n = (b - a) / h$ interior cells, indexed by $\{i_0, \dots, i_n\}$. The local processor owns a range $\{i_m, \dots, i_{m'}\}$. Suppose the netCDF file has domain $[A,B]$, spacing $H$, and $N = (B - A) / H$ cells. In order to interpolate onto these points, we need the indices $\{I_m, \dots, I_{m'}\}$ of the netCDF file so that

\[ [x(i_m), x(i_{m'})] \quad \text{is a subset of} \quad [x(I_m), x(I_{m'})] \]

In the code, xbdy$[2] = \{x(i_m), x(i_{m'})\}$. We have obtained the netCDF bounds $x(I_0)$ and $x(I_N)$ in the bdy array and the number of elements $N+1$ in the dim array.

This is a summary of the fields of a LocalInterpCtx, and a translation between scalars in the previous paragraphs and the fields:

delta and fstart are not used in the vertical dimension because the spacing is not generally equal. Rather, zlevs and zblevs contain the needed information.

The arrays start and count have 5 integer entries, corresponding to the dimensions $t, x, y, z, zb$.

Definition at line 74 of file LocalInterpCtx.hh.


Constructor & Destructor Documentation

LocalInterpCtx ( grid_info  g,
const double  zlevsIN[],
const double  zblevsIN[],
IceGrid grid 
)

Construct a local interpolation context from arrays of parameters.

This method constructs a class from existing information already read from a NetCDF file and stored in arrays.

The essential quantities to compute are where each processor should start within the NetCDF file grid (start[]) and how many grid points, from the starting place, the processor has. The resulting portion of the grid is stored in array a (a field of the LocalInterCtx).

We make conservative choices about start[] and count[]. In particular, the portions owned by processors must overlap at one point in the NetCDF file grid, but they may overlap more than that (as computed here).

Note this constructor doesn't extract new information from the NetCDF file or do communication. The information from the NetCDF file must already be extracted, validly stored in a grid_info structure g and preallocated arrays zlevsIN[], zblevsIN[], and each processor must have the same values for all of them.

The IceGrid is used to determine what ranges of the target arrays (i.e. Vecs into which NetCDF information will be interpolated) are owned by each processor.

Definition at line 49 of file LocalInterpCtx.cc.

References a, a_len, IceGrid.com, com, count, delta, IceGrid.dx, IceGrid.dy, e, fstart, IceGrid.Lbz, grid_info.Lx, IceGrid.Lx, grid_info.Ly, IceGrid.Ly, Ly, IceGrid.Lz, no_regrid_bedrock, no_regrid_ice, nz, nzb, grid_info.print(), IceGrid.rank, rank, report_range, start, grid_info.t_len, grid_info.time, verbPrintf(), check_stationarity.X, grid_info.x0, IceGrid.x0, grid_info.x_len, grid_info.x_max, grid_info.x_min, IceGrid.xm, IceGrid.xs, grid_info.y0, IceGrid.y0, grid_info.y_len, grid_info.y_max, grid_info.y_min, IceGrid.ym, IceGrid.ys, grid_info.z_len, grid_info.z_max, grid_info.zb_len, grid_info.zb_min, zblevs, and zlevs.

~LocalInterpCtx (  ) 

Deallocate memory.

Definition at line 237 of file LocalInterpCtx.cc.

References a, zblevs, and zlevs.


Member Function Documentation

int kbBelowHeight ( const double  elevation  ) 

Get the index for the source grid below a given vertical elevation within the bedrock.

Definition at line 320 of file LocalInterpCtx.cc.

References com, e, and zblevs.

Referenced by PISMIO.regrid_var().

int kBelowHeight ( const double  height  ) 

Get the index for the source grid below a given vertical elevation within the ice.

This code duplicates that in IceGrid.kBelowHeight().

Definition at line 297 of file LocalInterpCtx.cc.

References com, e, nz, and zlevs.

Referenced by PISMIO.regrid_var().

PetscErrorCode printArray (  ) 

Print out the actual array information stored in the local interpolation context.

Every processor in the communicator com must call this for it to work, I think.

Definition at line 280 of file LocalInterpCtx.cc.

References a, a_len, com, and rank.

PetscErrorCode printGrid (  ) 

Print out the grid information stored in the local interpolation context.

Every processor in the communicator com must call this for it to work, I think.

Definition at line 248 of file LocalInterpCtx.cc.

References com, count, delta, fstart, nz, nzb, rank, start, check_stationarity.X, zblevs, and zlevs.


Member Data Documentation

temporary buffer

Definition at line 78 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), printArray(), PISMIO.regrid_var(), and ~LocalInterpCtx().

int a_len

the size of the buffer

Definition at line 79 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), printArray(), and PISMIO.regrid_var().

MPI_Comm com

MPI Communicator (for printing, mostly).

Definition at line 84 of file LocalInterpCtx.hh.

Referenced by kbBelowHeight(), kBelowHeight(), LocalInterpCtx(), printArray(), and printGrid().

int count[5]

Definition at line 77 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), printGrid(), and PISMIO.regrid_var().

Definition at line 76 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), printGrid(), and PISMIO.regrid_var().

Definition at line 76 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), printGrid(), and PISMIO.regrid_var().

Definition at line 83 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), IceModel.regrid(), and PISMIO.regrid_var().

Definition at line 83 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), IceModel.regrid(), and PISMIO.regrid_var().

int nz

number of z-levels

Definition at line 80 of file LocalInterpCtx.hh.

Referenced by kBelowHeight(), LocalInterpCtx(), and printGrid().

int nzb

number of zb-levels

Definition at line 80 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), and printGrid().

PetscMPIInt rank

MPI rank, to allocate a_raw on proc 0 only.

Definition at line 85 of file LocalInterpCtx.hh.

Referenced by LocalInterpCtx(), printArray(), and printGrid().

Definition at line 83 of file LocalInterpCtx.hh.

Referenced by IceModelVec2T.init(), LocalInterpCtx(), and NCSpatialVariable.regrid().

int start[5]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Defines
Generated by  doxygen 1.6.2-20100124