The "local interpolation context" describes the processor's part of the source NetCDF file (for regridding). More...
#include <LocalInterpCtx.hh>
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] |
| double * | a |
| temporary buffer | |
| int | a_len |
| the size of the buffer | |
| int | nz |
| number of z-levels | |
| int | nzb |
| number of zb-levels | |
| double * | zlevs |
| double * | zblevs |
| 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. | |
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
with spacing
so there are
interior cells, indexed by
. The local processor owns a range
. Suppose the netCDF file has domain
, spacing
, and
cells. In order to interpolate onto these points, we need the indices
of the netCDF file so that
In the code, xbdy. We have obtained the netCDF bounds ![$[2] = \{x(i_m), x(i_{m'})\}$](form_410.png)
and
in the bdy array and the number of elements
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:
is called start
is count - 1
is called fstart
is called delta 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
.
Definition at line 74 of file LocalInterpCtx.hh.
| 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.
| 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 | ( | ) |
| 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.
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().
| bool no_regrid_bedrock |
Definition at line 83 of file LocalInterpCtx.hh.
Referenced by LocalInterpCtx(), IceModel.regrid(), and PISMIO.regrid_var().
| bool no_regrid_ice |
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().
| bool report_range |
Definition at line 83 of file LocalInterpCtx.hh.
Referenced by IceModelVec2T.init(), LocalInterpCtx(), and NCSpatialVariable.regrid().
| int start[5] |
Definition at line 77 of file LocalInterpCtx.hh.
Referenced by LocalInterpCtx(), printGrid(), PISMIO.regrid_var(), and IceModelVec2T.update().
Definition at line 82 of file LocalInterpCtx.hh.
Referenced by kbBelowHeight(), LocalInterpCtx(), printGrid(), PISMIO.regrid_var(), and ~LocalInterpCtx().
Definition at line 82 of file LocalInterpCtx.hh.
Referenced by kBelowHeight(), LocalInterpCtx(), printGrid(), PISMIO.regrid_var(), and ~LocalInterpCtx().
1.6.2-20100124