68 std::shared_ptr<units::System> unit_system,
Registration registration);
69 void report(
const Logger &log,
int threshold, std::shared_ptr<units::System> s)
const;
86 std::vector<double>
x;
88 std::vector<double>
y;
90 std::vector<double>
z;
123 Parameters(
const Context &ctx,
const std::string &filename,
const std::string &variable_name,
158 std::vector<double>
z;
202 operator bool()
const {
288 static std::shared_ptr<Grid>
Shallow(std::shared_ptr<const Context>
ctx,
double Lx,
double Ly,
289 double x0,
double y0,
unsigned int Mx,
unsigned int My,
292 static std::shared_ptr<Grid>
FromFile(std::shared_ptr<const Context>
ctx,
293 const std::string &filename,
294 const std::vector<std::string> &var_names,
297 static std::shared_ptr<Grid>
FromOptions(std::shared_ptr<const Context>
ctx);
299 std::shared_ptr<petsc::DM>
get_dm(
unsigned int dm_dof,
unsigned int stencil_width)
const;
304 int &i_left,
int &i_right,
305 int &j_bottom,
int &j_top)
const;
313 std::shared_ptr<const Context>
ctx()
const;
320 const std::vector<double>&
x()
const;
321 double x(
size_t i)
const;
323 const std::vector<double>&
y()
const;
324 double y(
size_t i)
const;
326 const std::vector<double>&
z()
const;
327 double z(
size_t i)
const;
333 unsigned int Mx()
const;
334 unsigned int My()
const;
335 unsigned int Mz()
const;
352 unsigned int size()
const;
363 return {*
this, stencil_width};
381 double radius(
const Grid &grid,
int i,
int j);
386 return (strip_width > 0.0 &&
387 (grid.
x(i) <= grid.
x(0) + strip_width ||
388 grid.
x(i) >= grid.
x(grid.
Mx()-1) - strip_width ||
389 grid.
y(j) <= grid.
y(0) + strip_width ||
390 grid.
y(j) >= grid.
y(grid.
My()-1) - strip_width));
397 return ((j == 0) or (j == (
int)grid.
My() - 1) or (i == 0) or (i == (
int)grid.
Mx() - 1));
A class for storing and accessing PISM configuration flags and parameters.
High-level PISM I/O class.
double y0() const
Y-coordinate of the center of the domain.
const std::vector< double > & x() const
X-coordinates.
const std::vector< double > & y() const
Y-coordinates.
unsigned int kBelowHeight(double height) const
Return the index k into zlevels[] so that zlevels[k] <= height < zlevels[k+1] and k < Mz.
unsigned int Mz() const
Number of vertical levels.
Grid & operator=(const Grid &)
double Ly() const
Half-width of the computational domain.
static std::shared_ptr< Grid > FromFile(std::shared_ptr< const Context > ctx, const std::string &filename, const std::vector< std::string > &var_names, grid::Registration r)
Create a grid using one of variables in var_names in file.
int ys() const
Global starting index of this processor's subset.
Grid(std::shared_ptr< const Context > context, const grid::Parameters &p)
Create a PISM distributed computational grid.
grid::Periodicity periodicity() const
Return grid periodicity.
int max_patch_size() const
double Lx() const
Half-width of the computational domain.
PointsWithGhosts points(unsigned int stencil_width=0) const
double dx() const
Horizontal grid spacing.
const std::vector< double > & z() const
Z-coordinates within the ice.
int rank() const
MPI rank.
static std::shared_ptr< Grid > Shallow(std::shared_ptr< const Context > ctx, double Lx, double Ly, double x0, double y0, unsigned int Mx, unsigned int My, grid::Registration r, grid::Periodicity p)
Initialize a uniform, shallow (3 z-levels) grid with half-widths (Lx,Ly) and Mx by My nodes.
Vars & variables()
Dictionary of variables (2D and 3D fields) associated with this grid.
std::shared_ptr< petsc::DM > get_dm(unsigned int dm_dof, unsigned int stencil_width) const
Get a PETSc DM ("distributed array manager") object for given dof (number of degrees of freedom per g...
unsigned int My() const
Total grid size in the Y direction.
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).
int pio_io_decomposition(int dof, int output_datatype) const
void report_parameters() const
Report grid parameters.
std::vector< double > interpolation_weights(double x, double y) const
Compute 4 interpolation weights necessary for linear interpolation from the current grid....
double x0() const
X-coordinate of the center of the domain.
grid::Registration registration() const
std::shared_ptr< const Context > ctx() const
Return execution context this grid corresponds to.
unsigned int Mx() const
Total grid size in the X direction.
const MappingInfo & get_mapping_info() const
unsigned int size() const
MPI communicator size.
std::vector< int > point_neighbors(double X, double Y) const
double Lz() const
Height of the computational domain.
double dz_min() const
Minimum vertical spacing.
double dz_max() const
Maximum vertical spacing.
double dy() const
Horizontal grid spacing.
int xs() const
Global starting index of this processor's subset.
void set_mapping_info(const MappingInfo &info)
static std::shared_ptr< Grid > FromOptions(std::shared_ptr< const Context > ctx)
Create a grid using command-line options and (possibly) an input file.
int xm() const
Width of this processor's sub-domain.
int ym() const
Width of this processor's sub-domain.
Describes the PISM grid and the distribution of data across processors.
PointsWithGhosts(const Grid &grid, unsigned int stencil_width=1)
A class for passing PISM variables from the core to other parts of the code (such as climate couplers...
Periodicity periodicity
Grid periodicity.
std::vector< double > z
Vertical levels.
void horizontal_extent_from_options(std::shared_ptr< units::System > unit_system)
Process -Lx, -Ly, -x0, -y0, -x_range, -y_range; set Lx, Ly, x0, y0.
void vertical_grid_from_options(std::shared_ptr< const Config > config)
Process -Mz and -Lz; set z;.
double y0
Domain center in the Y direction.
double x0
Domain center in the X direction.
std::vector< unsigned int > procs_y
Processor ownership ranges in the Y direction.
void ownership_ranges_from_options(unsigned int size)
Re-compute ownership ranges. Uses current values of Mx and My.
std::vector< unsigned int > procs_x
Processor ownership ranges in the X direction.
Registration registration
Grid registration.
void validate() const
Validate data members.
Parameters(const Config &config)
Initialize grid defaults from a configuration database.
unsigned int Mx
Number of grid points in the X direction.
double Ly
Domain half-width in the Y direction.
double Lx
Domain half-width in the X direction.
unsigned int My
Number of grid points in the Y direction.
void horizontal_size_from_options()
Process -Mx and -My; set Mx and My.
void init_from_file(const Context &ctx, const File &file, const std::string &variable_name, Registration r)
Grid parameters; used to collect defaults before an Grid is allocated.
double radius(const Grid &grid, int i, int j)
Returns the distance from the point (i,j) to the origin.
std::string periodicity_to_string(Periodicity p)
Convert Periodicity to a STL string.
VerticalSpacing string_to_spacing(const std::string &keyword)
Convert an STL string to SpacingType.
Registration string_to_registration(const std::string &keyword)
Periodicity string_to_periodicity(const std::string &keyword)
Convert a string to Periodicity.
bool in_null_strip(const Grid &grid, int i, int j, double strip_width)
Check if a point (i,j) is in the strip of stripwidth meters around the edge of the computational doma...
bool domain_edge(const Grid &grid, int i, int j)
std::string spacing_to_string(VerticalSpacing s)
Convert SpacingType to an STL string.
std::string registration_to_string(Registration registration)
std::vector< double > compute_vertical_levels(double new_Lz, unsigned int new_Mz, grid::VerticalSpacing spacing, double lambda)
Set the vertical levels in the ice according to values in Mz (number of levels), Lz (domain height),...
Internal structures of Grid.