66 std::shared_ptr<units::System> unit_system,
68 void report(
const Logger &log,
int threshold, std::shared_ptr<units::System> s)
const;
87 std::vector<double>
x;
89 std::vector<double>
y;
91 std::vector<double>
z;
119 const std::string &filename,
120 const std::string &variable_name,
125 const std::string &variable_name,
157 std::vector<double>
z;
165 const std::string &variable_name,
232 typedef std::shared_ptr<IceGrid>
Ptr;
241 double Lx,
double Ly,
242 double x0,
double y0,
243 unsigned int Mx,
unsigned int My,
248 const File &file,
const std::string &var_name,
252 const std::string &file,
const std::vector<std::string> &var_names,
257 std::shared_ptr<petsc::DM>
get_dm(
int dm_dof,
int stencil_width)
const;
262 int &i_left,
int &i_right,
263 int &j_bottom,
int &j_top)
const;
269 std::shared_ptr<const Context>
ctx()
const;
276 const std::vector<double>&
x()
const;
277 double x(
size_t i)
const;
279 const std::vector<double>&
y()
const;
280 double y(
size_t i)
const;
282 const std::vector<double>&
z()
const;
283 double z(
size_t i)
const;
289 unsigned int Mx()
const;
290 unsigned int My()
const;
291 unsigned int Mz()
const;
308 unsigned int size()
const;
340 return (strip_width > 0.0 &&
341 (grid.
x(i) <= grid.
x(0) + strip_width ||
342 grid.
x(i) >= grid.
x(grid.
Mx()-1) - strip_width ||
343 grid.
y(j) <= grid.
y(0) + strip_width ||
344 grid.
y(j) >= grid.
y(grid.
My()-1) - strip_width));
351 return ((j == 0) or (j == (
int)grid.
My() - 1) or
352 (i == 0) or (i == (
int)grid.
Mx() - 1));
365 m_i_last =
g.xs() +
g.xm() + stencil_width - 1;
367 m_j_last =
g.ys() +
g.ym() + stencil_width - 1;
394 operator bool()
const {
High-level PISM I/O class.
void init_from_file(std::shared_ptr< const Context > ctx, const File &file, const std::string &variable_name, GridRegistration r)
double x0
Domain center in the X 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_y
Processor ownership ranges in the Y direction.
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.
double Ly
Domain half-width in the Y direction.
Periodicity periodicity
Grid periodicity.
std::vector< double > z
Vertical levels.
GridRegistration registration
Grid registration.
double Lx
Domain half-width in the X direction.
GridParameters(std::shared_ptr< const Config > config)
Initialize grid defaults from a configuration database.
void init_from_config(std::shared_ptr< const Config > config)
Initialize from a configuration database. Does not try to compute ownership ranges.
GridParameters()
Create an uninitialized GridParameters instance.
double y0
Domain center in the Y direction.
void vertical_grid_from_options(std::shared_ptr< const Config > config)
Process -Mz and -Lz; set z;.
unsigned int Mx
Number of grid points in the X direction.
void validate() const
Validate data members.
std::vector< unsigned int > procs_x
Processor ownership ranges in the X direction.
void horizontal_size_from_options()
Process -Mx and -My; set Mx and My.
unsigned int My
Number of grid points in the Y direction.
Grid parameters; used to collect defaults before an IceGrid is allocated.
IceGrid & operator=(const IceGrid &)
const std::vector< double > & y() const
Y-coordinates.
IceGrid(std::shared_ptr< const Context > ctx, const GridParameters &p)
Create a PISM distributed computational grid.
double y0() const
Y-coordinate of the center of the domain.
GridRegistration registration() const
Vars & variables()
Dictionary of variables (2D and 3D fields) associated with this grid.
int rank() const
MPI rank.
Periodicity periodicity() const
Return grid periodicity.
double Lx() const
Half-width of the computational domain.
static const int max_dm_dof
Maximum number of degrees of freedom supported by PISM.
const std::vector< double > & x() const
X-coordinates.
int ys() const
Global starting index of this processor's subset.
std::shared_ptr< IceGrid > Ptr
unsigned int Mx() const
Total grid size in the X direction.
static Ptr FromOptions(std::shared_ptr< const Context > ctx)
Create a grid using command-line options and (possibly) an input file.
std::vector< double > compute_interp_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.
unsigned int Mz() const
Number of vertical levels.
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.
int xm() const
Width of this processor's sub-domain.
void set_mapping_info(const MappingInfo &info)
static const int max_stencil_width
Maximum stencil width supported by PISM.
std::shared_ptr< const Context > ctx() const
Return execution context this grid corresponds to.
double dz_max() const
Maximum vertical spacing.
int pio_io_decomposition(int dof, int output_datatype) const
int xs() const
Global starting index of this processor's subset.
std::shared_ptr< const IceGrid > ConstPtr
unsigned int kBelowHeight(double height) const
Return the index k into zlevels[] so that zlevels[k] <= height < zlevels[k+1] and k < Mz.
double dx() const
Horizontal grid spacing.
double dy() const
Horizontal grid spacing.
const std::vector< double > & z() const
Z-coordinates within the ice.
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).
const MappingInfo & get_mapping_info() const
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.
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),...
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 g...
void report_parameters() const
Report grid parameters.
double Lz() const
Height of the computational domain.
double dz_min() const
Minimum vertical spacing.
int ym() const
Width of this processor's sub-domain.
unsigned int size() const
MPI communicator size.
unsigned int My() const
Total grid size in the Y direction.
double Ly() const
Half-width of the computational domain.
Describes the PISM grid and the distribution of data across processors.
PointsWithGhosts(const IceGrid &g, unsigned int stencil_width=1)
A class for passing PISM variables from the core to other parts of the code (such as climate couplers...
double Ly
domain half-height
double Lx
domain half-width
double z_min
minimal value of the z dimension
double time
current time (seconds)
grid_info(const File &file, const std::string &variable, std::shared_ptr< units::System > unit_system, GridRegistration registration)
std::vector< double > z
z coordinates
void report(const Logger &log, int threshold, std::shared_ptr< units::System > s) const
std::vector< double > x
x coordinates
double x0
x-coordinate of the domain center
double y0
y-coordinate of the domain center
double z_max
maximal value of the z dimension
std::vector< double > y
y coordinates
Contains parameters of an input file grid.
std::string periodicity_to_string(Periodicity p)
Convert Periodicity to a STL string.
double radius(const IceGrid &grid, int i, int j)
Returns the distance from the point (i,j) to the origin.
std::string spacing_to_string(SpacingType s)
Convert SpacingType to an STL string.
Periodicity string_to_periodicity(const std::string &keyword)
Convert a string to Periodicity.
std::string registration_to_string(GridRegistration registration)
SpacingType string_to_spacing(const std::string &keyword)
Convert an STL string to SpacingType.
bool in_null_strip(const IceGrid &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...
GridRegistration string_to_registration(const std::string &keyword)
bool grid_edge(const IceGrid &grid, int i, int j)
Internal structures of IceGrid.