PISM, A Parallel Ice Sheet Model
stable v2.0.6 committed by Constantine Khrulev on 2023-01-23 15:14:38 -0900
|
A class for storing and accessing 2D time-series (for climate forcing) More...
#include <iceModelVec2T.hh>
Classes | |
struct | Data |
Public Member Functions | |
IceModelVec2T (IceGrid::ConstPtr grid, const std::string &short_name, unsigned int buffer_size, InterpolationType interpolation_type=PIECEWISE_CONSTANT) | |
virtual | ~IceModelVec2T () |
unsigned int | buffer_size () |
void | init (const std::string &filename, bool periodic) |
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 piece-wise constant or piece-wise linear 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... | |
![]() | |
IceModelVec2S (IceGrid::ConstPtr grid, const std::string &name, IceModelVecKind ghostedp, int width=1) | |
void | copy_from (const IceModelVec2S &source) |
double ** | array () |
double const *const * | array () const |
void | add (double alpha, const IceModelVec2S &x) |
void | add (double alpha, const IceModelVec2S &x, IceModelVec2S &result) const |
double & | operator() (int i, int j) |
Provides access (both read and write) to the internal double array. More... | |
const double & | operator() (int i, int j) const |
stencils::Star< double > | star (int i, int j) const |
stencils::Box< double > | box (int i, int j) const |
![]() | |
virtual | ~IceModelVec () |
IceGrid::ConstPtr | grid () const |
unsigned int | ndims () const |
Returns the number of spatial dimensions. More... | |
std::vector< int > | shape () 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< double > | levels () const |
std::array< double, 2 > | range () const |
Result: min <- min(v[j]), max <- max(v[j]). More... | |
std::vector< double > | norm (int n) const |
Computes the norm of all the components of an IceModelVec. More... | |
void | add (double alpha, const IceModelVec &x) |
Result: v <- v + alpha * x. Calls VecAXPY. More... | |
void | shift (double alpha) |
Result: v[j] <- v[j] + alpha for all j. Calls VecShift. More... | |
void | scale (double alpha) |
Result: v <- v * alpha. Calls VecScale. More... | |
petsc::Vec & | vec () const |
std::shared_ptr< petsc::DM > | dm () const |
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... | |
void | define (const File &file, 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 &file, unsigned int time) |
void | write (const std::string &filename) const |
void | write (const File &file) const |
void | regrid (const std::string &filename, RegriddingFlag flag, double default_value=0.0) |
void | regrid (const File &file, RegriddingFlag flag, double default_value=0.0) |
void | update_ghosts () |
Updates ghost points. More... | |
std::shared_ptr< petsc::Vec > | allocate_proc0_copy () const |
void | put_on_proc0 (petsc::Vec &onp0) const |
Puts a local IceModelVec2S on processor 0. More... | |
void | get_from_proc0 (petsc::Vec &onp0) |
Gets a local IceModelVec2 from processor 0. More... | |
void | set (double c) |
Result: v[j] <- c for all j. More... | |
SpatialVariableMetadata & | metadata (unsigned int N=0) |
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N. More... | |
const SpatialVariableMetadata & | metadata (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 | view (std::vector< std::shared_ptr< petsc::Viewer > > viewers) const |
View a 2D vector field using existing PETSc viewers. More... | |
void | dump (const char filename[]) const |
Dumps a variable to a file, overwriting this file's contents (for debugging). More... | |
uint64_t | fletcher64_serial () const |
uint64_t | fletcher64 () const |
std::string | checksum (bool serial) const |
void | print_checksum (const char *prefix="", bool serial=false) const |
![]() | |
virtual | ~PetscAccessible ()=default |
Static Public Member Functions | |
static std::shared_ptr< IceModelVec2T > | ForcingField (IceGrid::ConstPtr grid, const File &file, const std::string &short_name, const std::string &standard_name, int max_buffer_size, bool periodic, InterpolationType interpolation_type=PIECEWISE_CONSTANT) |
static std::shared_ptr< IceModelVec2T > | Constant (IceGrid::ConstPtr grid, const std::string &short_name, double value) |
![]() | |
template<class T > | |
static T::Ptr | cast (IceModelVec::Ptr input) |
dynamic_pointer_cast wrapper that checks if the cast succeeded. More... | |
Private Member Functions | |
double *** | array3 () |
void | update (unsigned int start) |
Update by reading at most buffer_size records from the file. More... | |
void | discard (int N) |
Discard the first N records, shifting the rest of them towards the "beginning". More... | |
void | set_record (int n) |
Sets the record number n to the contents of the (internal) Vec v. More... | |
void | init_periodic_data (const File &file) |
Private Attributes | |
Data * | m_data |
Additional Inherited Members | |
![]() | |
typedef std::shared_ptr< IceModelVec2S > | Ptr |
typedef std::shared_ptr< const IceModelVec2S > | ConstPtr |
![]() | |
typedef std::shared_ptr< IceModelVec > | Ptr |
typedef std::shared_ptr< const IceModelVec > | ConstPtr |
typedef pism::AccessList | AccessList |
![]() | |
IceModelVec (IceGrid::ConstPtr grid, const std::string &name, IceModelVecKind ghostedp, size_t dof, size_t stencil_width, const std::vector< double > &zlevels) | |
void | set_begin_access_use_dof (bool flag) |
void | read_impl (const File &file, unsigned int time) |
Reads appropriate NetCDF variable(s) into an IceModelVec. More... | |
void | regrid_impl (const File &file, RegriddingFlag flag, double default_value=0.0) |
Gets an IceModelVec from a file file , interpolating onto the current grid. More... | |
void | write_impl (const File &file) const |
Writes an IceModelVec to a NetCDF file. More... | |
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 array indices and warn if they are out of range. More... | |
void | copy_to_vec (std::shared_ptr< petsc::DM > destination_da, petsc::Vec &destination) const |
Copies v to a global vector 'destination'. Ghost points are discarded. More... | |
void | get_dof (std::shared_ptr< petsc::DM > da_result, petsc::Vec &result, unsigned int start, unsigned int count=1) const |
void | set_dof (std::shared_ptr< petsc::DM > da_source, petsc::Vec &source, unsigned int start, unsigned int count=1) |
void | put_on_proc0 (petsc::Vec ¶llel, petsc::Vec &onp0) const |
void | get_from_proc0 (petsc::Vec &onp0, petsc::Vec ¶llel) const |
![]() | |
Impl * | m_impl |
void * | m_array |
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 44 of file iceModelVec2T.hh.