PISM, A Parallel Ice Sheet Model  stable v1.2 committed by Constantine Khrulev on 2020-02-11 20:24:05 -0900
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
pism::IceModelVec2T Class Reference

A class for storing and accessing 2D time-series (for climate forcing) More...

#include <iceModelVec2T.hh>

+ Inheritance diagram for pism::IceModelVec2T:

Public Types

typedef std::shared_ptr< IceModelVec2TPtr
 
- Public Types inherited from pism::IceModelVec2S
typedef std::shared_ptr< IceModelVec2SPtr
 
typedef std::shared_ptr< const IceModelVec2SConstPtr
 
- Public Types inherited from pism::IceModelVec2
typedef std::shared_ptr< IceModelVec2Ptr
 
typedef std::shared_ptr< const IceModelVec2ConstPtr
 
- Public Types inherited from pism::IceModelVec
typedef std::shared_ptr< IceModelVecPtr
 
typedef std::shared_ptr< const IceModelVecConstPtr
 
typedef pism::AccessList AccessList
 

Public Member Functions

 IceModelVec2T (IceGrid::ConstPtr grid, const std::string &short_name, unsigned int n_records, unsigned int n_evaluations_per_year, InterpolationType interpolation_type=PIECEWISE_CONSTANT)
 
virtual ~IceModelVec2T ()
 
unsigned int n_records ()
 
void init (const std::string &filename, unsigned int period, double reference_time)
 
void init_constant (double value)
 Initialize as constant in time and space. More...
 
void update (double t, double dt)
 Read some data to make sure that the interval (t, t + dt) is covered. More...
 
MaxTimestep max_timestep (double t) const
 Given the time t determines the maximum possible time-step this IceModelVec2T allows. More...
 
void interp (double t)
 
void interp (int i, int j, std::vector< double > &results)
 Compute values of the time-series using precomputed indices (and piecewise-constant interpolation). More...
 
void average (double t, double dt)
 
void begin_access () const
 Checks if an IceModelVec is allocated and calls DAVecGetArray. More...
 
void end_access () const
 Checks if an IceModelVec is allocated and calls DAVecRestoreArray. More...
 
void init_interpolation (const std::vector< double > &ts)
 Compute weights for the piecewise-constant interpolation. This is used both for time-series and "snapshots". More...
 
- Public Member Functions inherited from pism::IceModelVec2S
 IceModelVec2S ()
 
 IceModelVec2S (IceGrid::ConstPtr grid, const std::string &name, IceModelVecKind ghostedp, int width=1)
 
double interpolate (double x, double y) const
 
void create (IceGrid::ConstPtr grid, const std::string &name, IceModelVecKind ghostedp, int width=1)
 
virtual void copy_from (const IceModelVec &source)
 Result: v <- source. Leaves metadata alone but copies values in Vec. Uses VecCopy. More...
 
double ** get_array ()
 
virtual void set_to_magnitude (const IceModelVec2S &v_x, const IceModelVec2S &v_y)
 Sets an IceModelVec2 to the magnitude of a 2D vector field with components v_x and v_y. More...
 
virtual void set_to_magnitude (const IceModelVec2V &input)
 
virtual void mask_by (const IceModelVec2S &M, double fill=0.0)
 Masks out all the areas where $ M \le 0 $ by setting them to fill. More...
 
virtual void add (double alpha, const IceModelVec &x)
 Result: v <- v + alpha * x. Calls VecAXPY. More...
 
virtual void add (double alpha, const IceModelVec &x, IceModelVec &result) const
 
virtual double sum () const
 Sums up all the values in an IceModelVec2S object. Ignores ghosts. More...
 
virtual double min () const
 Finds minimum over all the values in an IceModelVec2S object. Ignores ghosts. More...
 
virtual double max () const
 Finds maximum over all the values in an IceModelVec2S object. Ignores ghosts. More...
 
virtual double absmax () const
 Finds maximum over all the absolute values in an IceModelVec2S object. Ignores ghosts. More...
 
virtual double diff_x (int i, int j) const
 Returns the x-derivative at i,j approximated using centered finite differences. More...
 
virtual double diff_y (int i, int j) const
 Returns the y-derivative at i,j approximated using centered finite differences. More...
 
virtual double diff_x_p (int i, int j) const
 Returns the x-derivative at i,j approximated using centered finite differences. Respects grid periodicity and uses one-sided FD at grid edges if necessary. More...
 
virtual double diff_y_p (int i, int j) const
 Returns the y-derivative at i,j approximated using centered finite differences. Respects grid periodicity and uses one-sided FD at grid edges if necessary. More...
 
doubleoperator() (int i, int j)
 Provides access (both read and write) to the internal double array. More...
 
const doubleoperator() (int i, int j) const
 
StarStencil< doublestar (int i, int j) const
 
BoxStencil< doublebox (int i, int j) const
 
void create (IceGrid::ConstPtr grid, const std::string &short_name, IceModelVecKind ghostedp, unsigned int stencil_width, int dof)
 
- Public Member Functions inherited from pism::IceModelVec2
 IceModelVec2 ()
 
 IceModelVec2 (IceGrid::ConstPtr grid, const std::string &short_name, IceModelVecKind ghostedp, unsigned int stencil_width, int dof)
 
virtual void view (int viewer_size) const
 View a 2D field. More...
 
virtual void view (petsc::Viewer::Ptr v1, petsc::Viewer::Ptr v2) const
 View a 2D vector field using existing PETSc viewers. More...
 
virtual void get_component (unsigned int n, IceModelVec2S &result) const
 
virtual void set_component (unsigned int n, const IceModelVec2S &source)
 
doubleoperator() (int i, int j, int k)
 
const doubleoperator() (int i, int j, int k) const
 
void create (IceGrid::ConstPtr grid, const std::string &short_name, IceModelVecKind ghostedp, unsigned int stencil_width, int dof)
 
- Public Member Functions inherited from pism::IceModelVec
 IceModelVec ()
 
virtual ~IceModelVec ()
 
virtual bool was_created () const
 Returns true if create() was called and false otherwise. More...
 
IceGrid::ConstPtr grid () const
 
unsigned int ndims () const
 Returns the grid type of an IceModelVec. (This is the way to figure out if an IceModelVec is 2D or 3D). More...
 
std::vector< intshape () const
 
unsigned int ndof () const
 Returns the number of degrees of freedom per grid point. More...
 
unsigned int stencil_width () const
 Get the stencil width of the current IceModelVec. Returns 0 if ghosts are not available. More...
 
std::vector< doublelevels () const
 
virtual Range range () const
 Result: min <- min(v[j]), max <- max(v[j]). More...
 
double norm (int n) const
 Computes the norm of an dof==1 IceModelVec by calling PETSc VecNorm. More...
 
std::vector< doublenorm_all (int n) const
 Computes the norm of all components. More...
 
virtual void squareroot ()
 Result: v <- sqrt(v), elementwise. Calls VecSqrt(v). More...
 
virtual void shift (double alpha)
 Result: v[j] <- v[j] + alpha for all j. Calls VecShift. More...
 
virtual void scale (double alpha)
 Result: v <- v * alpha. Calls VecScale. More...
 
void copy_to_vec (petsc::DM::Ptr destination_da, Vec destination) const
 Copies v to a global vector 'destination'. Ghost points are discarded. More...
 
void copy_from_vec (Vec source)
 Copies data from a Vec source to this IceModelVec. Updates ghost points if necessary. More...
 
Vec vec ()
 
petsc::DM::Ptr dm () const
 
virtual void set_name (const std::string &name)
 Sets the variable name to name. More...
 
const std::string & get_name () const
 Get the name of an IceModelVec object. More...
 
void set_attrs (const std::string &pism_intent, const std::string &long_name, const std::string &units, const std::string &glaciological_units, const std::string &standard_name, unsigned int component)
 Sets NetCDF attributes of an IceModelVec object. More...
 
virtual void read_attributes (const std::string &filename, int component=0)
 Read attributes from the corresponding variable in filename. More...
 
virtual void define (const File &nc, IO_Type default_type=PISM_DOUBLE) const
 Define variables corresponding to an IceModelVec in a file opened using file. More...
 
void read (const std::string &filename, unsigned int time)
 
void read (const File &nc, unsigned int time)
 
void write (const std::string &filename) const
 
void write (const File &nc) const
 
void regrid (const std::string &filename, RegriddingFlag flag, double default_value=0.0)
 
void regrid (const File &nc, RegriddingFlag flag, double default_value=0.0)
 
virtual void update_ghosts ()
 Updates ghost points. More...
 
virtual void update_ghosts (IceModelVec &destination) const
 Scatters ghost points to IceModelVec destination. More...
 
petsc::Vec::Ptr allocate_proc0_copy () const
 
void put_on_proc0 (Vec onp0) const
 Puts a local IceModelVec2S on processor 0. More...
 
void get_from_proc0 (Vec onp0)
 Gets a local IceModelVec2 from processor 0. More...
 
void set (double c)
 Result: v[j] <- c for all j. More...
 
SpatialVariableMetadatametadata (unsigned int N=0)
 Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N. More...
 
const SpatialVariableMetadatametadata (unsigned int N=0) const
 
int state_counter () const
 Get the object state counter. More...
 
void inc_state_counter ()
 Increment the object state counter. More...
 
void set_time_independent (bool flag)
 Set the time independent flag for all variables corresponding to this IceModelVec instance. More...
 
void dump (const char filename[]) const
 Dumps a variable to a file, overwriting this file's contents (for debugging). More...
 
uint64_t fletcher64 () const
 
std::string checksum () const
 
void print_checksum (const char *prefix="") const
 
- Public Member Functions inherited from pism::PetscAccessible
virtual ~PetscAccessible ()
 

Static Public Member Functions

static Ptr ForcingField (IceGrid::ConstPtr grid, const File &file, const std::string &short_name, const std::string &standard_name, int max_buffer_size, int evaluations_per_year, bool periodic, InterpolationType interpolation_type=PIECEWISE_CONSTANT)
 
- Static Public Member Functions inherited from pism::IceModelVec2S
static Ptr To2DScalar (IceModelVec::Ptr input)
 
- Static Public Member Functions inherited from pism::IceModelVec2
static Ptr To2D (IceModelVec::Ptr input)
 

Private Member Functions

double *** get_array3 ()
 
void update (unsigned int start)
 Update by reading at most n_records records from the file. More...
 
void discard (int N)
 Discard the first N records, shifting the rest of them towards the "beginning". More...
 
double average (int i, int j)
 Finds the average value at i,j over the interval (t, t + dt) using the rectangle rule. More...
 
void set_record (int n)
 Sets the record number n to the contents of the (internal) Vec v. More...
 
void get_record (int n)
 Sets the (internal) Vec v to the contents of the nth record. More...
 

Private Attributes

std::vector< doublem_time
 all the times available in filename More...
 
std::vector< doublem_time_bounds
 time bounds More...
 
std::string m_filename
 file to read (regrid) from More...
 
petsc::DM::Ptr m_da3
 
petsc::Vec m_v3
 a 3D Vec used to store records More...
 
void *** m_array3
 
unsigned int m_n_records
 maximum number of records to store in memory More...
 
unsigned int m_N
 number of records kept in memory More...
 
unsigned int m_n_evaluations_per_year
 number of evaluations per year used to compute temporal averages More...
 
int m_first
 
InterpolationType m_interp_type
 
std::shared_ptr< Interpolationm_interp
 
unsigned int m_period
 
double m_reference_time
 

Additional Inherited Members

- Protected Member Functions inherited from pism::IceModelVec2
virtual void read_impl (const File &nc, const unsigned int time)
 Reads appropriate NetCDF variable(s) into an IceModelVec. More...
 
virtual void regrid_impl (const File &nc, RegriddingFlag flag, double default_value=0.0)
 Gets an IceModelVec from a file file, interpolating onto the current grid. More...
 
virtual void write_impl (const File &nc) const
 Writes an IceModelVec to a NetCDF file. More...
 
- Protected Member Functions inherited from pism::IceModelVec
void global_to_local (petsc::DM::Ptr dm, Vec source, Vec destination) const
 
virtual void checkCompatibility (const char *function, const IceModelVec &other) const
 Checks if two IceModelVecs have compatible sizes, dimensions and numbers of degrees of freedom. More...
 
void check_array_indices (int i, int j, unsigned int k) const
 Check the array indices and warn if they are out of range. More...
 
void reset_attrs (unsigned int N)
 Resets most IceModelVec attributes. More...
 
NormType int_to_normtype (int input) const
 
void get_dof (petsc::DM::Ptr da_result, Vec result, unsigned int n, unsigned int count=1) const
 
void set_dof (petsc::DM::Ptr da_source, Vec source, unsigned int n, unsigned int count=1)
 
void put_on_proc0 (Vec parallel, Vec onp0) const
 
void get_from_proc0 (Vec onp0, Vec parallel)
 
- Protected Attributes inherited from pism::IceModelVec
bool m_report_range
 If true, report range when regridding. More...
 
std::vector< doublem_zlevels
 
petsc::Vec m_v
 Internal storage. More...
 
std::string m_name
 
std::vector< SpatialVariableMetadatam_metadata
 stores metadata (NetCDF variable attributes) More...
 
IceGrid::ConstPtr m_grid
 
unsigned int m_dof
 number of "degrees of freedom" per grid point More...
 
unsigned int m_da_stencil_width
 stencil width supported by the DA More...
 
bool m_has_ghosts
 m_has_ghosts == true means "has ghosts" More...
 
petsc::DM::Ptr m_da
 distributed mesh manager (DM) More...
 
bool m_begin_end_access_use_dof
 
std::map< std::string, petsc::Viewer::Ptrm_map_viewers
 
void * m_array
 
int m_access_counter
 
int m_state_counter
 Internal IceModelVec "revision number". More...
 
InterpolationType m_interpolation_type
 

Detailed Description

A class for storing and accessing 2D time-series (for climate forcing)

This class was created to read time-dependent and spatially-varying climate forcing data, in particular snow temperatures and precipitation.

If requests (calls to update()) go in sequence, every records should be read only once.

Note that this class is optimized for use with a PDD scheme – it stores records so that data corresponding to a grid point are stored in adjacent memory locations.

IceModelVec2T is always global (i.e. has no ghosts).

Both versions of interp() use piecewise-constant interpolation and extrapolate (by a constant) outside the available range.

Definition at line 43 of file iceModelVec2T.hh.


The documentation for this class was generated from the following files: