31#include "pism/util/Interpolation1D.hh"
38class InputInterpolation;
71 std::shared_ptr<units::System> unit_system,
Registration registration);
73 void report(
const Logger &log,
int threshold, std::shared_ptr<units::System> s)
const;
91 std::vector<double>
x;
93 std::vector<double>
y;
95 std::vector<double>
z;
132 Parameters(std::shared_ptr<units::System> unit_system,
const File &file,
165 std::vector<double>
z;
296 static std::shared_ptr<Grid>
Shallow(std::shared_ptr<const Context>
ctx,
double Lx,
double Ly,
297 double x0,
double y0,
unsigned int Mx,
unsigned int My,
300 static std::shared_ptr<Grid>
FromFile(std::shared_ptr<const Context>
ctx,
302 const std::vector<std::string> &var_names,
305 static std::shared_ptr<Grid>
FromOptions(std::shared_ptr<const Context>
ctx);
307 std::shared_ptr<petsc::DM>
get_dm(
unsigned int dm_dof,
unsigned int stencil_width)
const;
309 std::shared_ptr<InputInterpolation>
get_interpolation(
const std::vector<double> &levels,
310 const File &input_file,
311 const std::string &variable_name,
319 int &i_left,
int &i_right,
320 int &j_bottom,
int &j_top)
const;
328 std::shared_ptr<const Context>
ctx()
const;
335 const std::vector<double>&
x()
const;
336 double x(
size_t i)
const;
338 const std::vector<double>&
y()
const;
339 double y(
size_t i)
const;
341 const std::vector<double>&
z()
const;
342 double z(
size_t i)
const;
348 unsigned int Mx()
const;
349 unsigned int My()
const;
350 unsigned int Mz()
const;
367 unsigned int size()
const;
376 return {*
this, stencil_width};
399 return (strip_width > 0.0 &&
400 (grid.x(i) <= grid.x(0) + strip_width ||
401 grid.x(i) >= grid.x(grid.Mx()-1) - strip_width ||
402 grid.y(j) <= grid.y(0) + strip_width ||
403 grid.y(j) >= grid.y(grid.My()-1) - strip_width));
410 return ((j == 0) or (j == (
int)grid.My() - 1) or (i == 0) or (i == (
int)grid.Mx() - 1));
413std::array<unsigned, 2>
nprocs(
unsigned int size,
unsigned int Mx,
416std::vector<unsigned int>
ownership_ranges(
unsigned int Mx,
unsigned int Nx);
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.
double Ly() const
Half-width of the computational domain.
int ys() const
Global starting index of this processor's subset.
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 > FromFile(std::shared_ptr< const Context > ctx, const File &file, const std::vector< std::string > &var_names, grid::Registration r)
Create a grid using one of variables in var_names in file.
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).
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::shared_ptr< InputInterpolation > get_interpolation(const std::vector< double > &levels, const File &input_file, const std::string &variable_name, InterpolationType type) const
std::vector< int > point_neighbors(double X, double Y) const
Grid & operator=(const Grid &)
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.
void forget_interpolations()
Describes the PISM grid and the distribution of data across processors.
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.
std::string variable_name
Name of the variable used to initialize the instance (empty if not used)
void vertical_grid_from_options(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(const Config &config, 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.
void horizontal_size_and_extent_from_options(const Config &config)
Process -Lx, -Ly, -x0, -y0; set Lx, Ly, x0, y0.
Registration registration
Grid registration.
static Parameters FromGridDefinition(std::shared_ptr< units::System > unit_system, const File &file, const std::string &variable_name, Registration registration)
void validate() const
Validate data members.
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.
Grid parameters; used to collect defaults before an Grid is allocated.
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.
std::vector< unsigned int > ownership_ranges(unsigned int Mx, unsigned int Nx)
Computes processor ownership ranges corresponding to equal area distribution among processors.
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::vector< double > compute_vertical_levels(double new_Lz, size_t 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),...
std::string registration_to_string(Registration registration)
std::array< unsigned, 2 > nprocs(unsigned int size, unsigned int Mx, unsigned int My)
Computes the number of processors in the X- and Y-directions.
std::shared_ptr< Grid > grid(std::shared_ptr< Context > ctx, char testname)
Internal structures of Grid.