PISM, A Parallel Ice Sheet Model
stable v2.0.6 committed by Constantine Khrulev on 2023-01-23 15:14:38 -0900
|
Describes the PISM grid and the distribution of data across processors. More...
#include <IceGrid.hh>
Classes | |
struct | Impl |
Internal structures of IceGrid. More... | |
Public Types | |
typedef std::shared_ptr< IceGrid > | Ptr |
typedef std::shared_ptr< const IceGrid > | ConstPtr |
Public Member Functions | |
~IceGrid () | |
IceGrid (std::shared_ptr< const Context > ctx, const GridParameters &p) | |
Create a PISM distributed computational grid. More... | |
std::shared_ptr< petsc::DM > | get_dm (int dm_dof, int stencil_width) const |
Get a PETSc DM ("distributed array manager") object for given dof (number of degrees of freedom per grid point) and stencil width. More... | |
void | report_parameters () const |
Report grid parameters. More... | |
void | compute_point_neighbors (double X, double Y, int &i_left, int &i_right, int &j_bottom, int &j_top) const |
Computes indices of grid points to the lower left and upper right from (X,Y). More... | |
std::vector< int > | compute_point_neighbors (double X, double Y) const |
std::vector< double > | compute_interp_weights (double x, double y) const |
Compute 4 interpolation weights necessary for linear interpolation from the current grid. See compute_point_neighbors for the ordering of neighbors. More... | |
unsigned int | kBelowHeight (double height) const |
Return the index k into zlevels[] so that zlevels[k] <= height < zlevels[k+1] and k < Mz . More... | |
std::shared_ptr< const Context > | ctx () const |
Return execution context this grid corresponds to. More... | |
int | xs () const |
Global starting index of this processor's subset. More... | |
int | xm () const |
Width of this processor's sub-domain. More... | |
int | ys () const |
Global starting index of this processor's subset. More... | |
int | ym () const |
Width of this processor's sub-domain. More... | |
const std::vector< double > & | x () const |
X-coordinates. More... | |
double | x (size_t i) const |
Get a particular x coordinate. More... | |
const std::vector< double > & | y () const |
Y-coordinates. More... | |
double | y (size_t i) const |
Get a particular y coordinate. More... | |
const std::vector< double > & | z () const |
Z-coordinates within the ice. More... | |
double | z (size_t i) const |
Get a particular z coordinate. More... | |
double | dx () const |
Horizontal grid spacing. More... | |
double | dy () const |
Horizontal grid spacing. More... | |
double | cell_area () const |
unsigned int | Mx () const |
Total grid size in the X direction. More... | |
unsigned int | My () const |
Total grid size in the Y direction. More... | |
unsigned int | Mz () const |
Number of vertical levels. More... | |
double | Lx () const |
Half-width of the computational domain. More... | |
double | Ly () const |
Half-width of the computational domain. More... | |
double | Lz () const |
Height of the computational domain. More... | |
double | x0 () const |
X-coordinate of the center of the domain. More... | |
double | y0 () const |
Y-coordinate of the center of the domain. More... | |
const MappingInfo & | get_mapping_info () const |
void | set_mapping_info (const MappingInfo &info) |
double | dz_min () const |
Minimum vertical spacing. More... | |
double | dz_max () const |
Maximum vertical spacing. More... | |
Periodicity | periodicity () const |
Return grid periodicity. More... | |
GridRegistration | registration () const |
unsigned int | size () const |
MPI communicator size. More... | |
int | rank () const |
MPI rank. More... | |
Vars & | variables () |
Dictionary of variables (2D and 3D fields) associated with this grid. More... | |
const Vars & | variables () const |
Dictionary of variables (2D and 3D fields) associated with this grid. More... | |
int | pio_io_decomposition (int dof, int output_datatype) const |
Static Public Member Functions | |
static std::vector< double > | compute_vertical_levels (double new_Lz, unsigned int new_Mz, SpacingType spacing, double Lambda=0.0) |
Set the vertical levels in the ice according to values in Mz (number of levels), Lz (domain height), spacing (quadratic or equal) and lambda (quadratic spacing parameter). More... | |
static Ptr | Shallow (std::shared_ptr< const Context > ctx, double Lx, double Ly, double x0, double y0, unsigned int Mx, unsigned int My, GridRegistration r, Periodicity p) |
Initialize a uniform, shallow (3 z-levels) grid with half-widths (Lx,Ly) and Mx by My nodes. More... | |
static Ptr | FromFile (std::shared_ptr< const Context > ctx, const File &file, const std::string &var_name, GridRegistration r) |
Create a grid from a file, get information from variable var_name . More... | |
static Ptr | FromFile (std::shared_ptr< const Context > ctx, const std::string &file, const std::vector< std::string > &var_names, GridRegistration r) |
Create a grid using one of variables in var_names in file . More... | |
static Ptr | FromOptions (std::shared_ptr< const Context > ctx) |
Create a grid using command-line options and (possibly) an input file. More... | |
Public Attributes | |
const MPI_Comm | com |
Static Public Attributes | |
static const int | max_dm_dof = 10000 |
Maximum number of degrees of freedom supported by PISM. More... | |
static const int | max_stencil_width = 10000 |
Maximum stencil width supported by PISM. More... | |
Private Member Functions | |
IceGrid (const IceGrid &) | |
IceGrid & | operator= (const IceGrid &) |
Private Attributes | |
Impl * | m_impl |
Describes the PISM grid and the distribution of data across processors.
This class holds parameters describing the grid, including the vertical spacing and which part of the horizontal grid is owned by the processor. It contains the dimensions of the PISM (4-dimensional, x*y*z*time) computational box. The vertical spacing can be quite arbitrary.
It creates and destroys a two dimensional PETSc
DA
(distributed array). The creation of this DA
is the point at which PISM gets distributed across multiple processors.
PISM uses the class IceGrid to manage computational grids and their parameters.
Computational grids PISM can use are
Each processor "owns" a rectangular patch of xm
times ym
grid points with indices starting at xs
and ys
in the X and Y directions respectively.
The typical code performing a point-wise computation will look like
For finite difference (and some other) computations we often need to know values at map-plane neighbors of a grid point.
We say that a patch owned by a processor is surrounded by a strip of "ghost" grid points belonging to patches next to the one in question. This lets us to access (read) values at all the eight neighbors of a grid point for all the grid points, including ones at an edge of a processor patch and at an edge of a computational domain.
All the values written to ghost points will be lost next time ghost values are updated.
Sometimes it is beneficial to update ghost values locally (for instance when a computation A uses finite differences to compute derivatives of a quantity produced using a purely local (point-wise) computation B). In this case the loop above can be modified to look like
Definition at line 228 of file IceGrid.hh.