PISM, A Parallel Ice Sheet Model
stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
|
Class representing diagnostic computations in PISM. More...
#include <Diagnostic.hh>
Public Types | |
typedef std::shared_ptr< Diagnostic > | Ptr |
Public Member Functions | |
Diagnostic (std::shared_ptr< const Grid > g) | |
virtual | ~Diagnostic ()=default |
void | update (double dt) |
void | reset () |
std::shared_ptr< array::Array > | compute () const |
Compute a diagnostic quantity and return a pointer to a newly-allocated Array. More... | |
unsigned int | n_variables () const |
Get the number of NetCDF variables corresponding to a diagnostic quantity. More... | |
SpatialVariableMetadata & | metadata (unsigned int N=0) |
Get a metadata object corresponding to variable number N. More... | |
void | define (const File &file, io::Type default_type) const |
void | init (const File &input, unsigned int time) |
void | define_state (const File &output) const |
void | write_state (const File &output) const |
Static Public Member Functions | |
template<typename T > | |
static Ptr | wrap (const T &input) |
Protected Member Functions | |
virtual void | define_impl (const File &file, io::Type default_type) const |
Define NetCDF variables corresponding to a diagnostic quantity. More... | |
virtual void | init_impl (const File &input, unsigned int time) |
virtual void | define_state_impl (const File &output) const |
virtual void | write_state_impl (const File &output) const |
virtual void | update_impl (double dt) |
virtual void | reset_impl () |
virtual std::shared_ptr< array::Array > | compute_impl () const =0 |
double | to_internal (double x) const |
double | to_external (double x) const |
template<typename T > | |
std::shared_ptr< T > | allocate (const std::string &name) const |
Protected Attributes | |
std::shared_ptr< const Grid > | m_grid |
the grid More... | |
const units::System::Ptr | m_sys |
the unit system More... | |
const Config::ConstPtr | m_config |
Configuration flags and parameters. More... | |
std::vector< SpatialVariableMetadata > | m_vars |
metadata corresponding to NetCDF variables More... | |
double | m_fill_value |
fill value (used often enough to justify storing it) More... | |
Class representing diagnostic computations in PISM.
The main goal of this abstraction is to allow accessing metadata corresponding to a diagnostic quantity before it is computed.
Another goal is to create an interface for computing diagnostics without knowing which PISM module is responsible for the computation.
Technical note: to compute some diagnostic quantities we need access to protected members of classes. C++ forbids obtaining pointers to non-static methods of a class, but it is possible to define a (friend) function
which is the same as creating a method Foo::compute_bar()
, but you can get a pointer to it.
Diagnostic creates a common interface for all these compute_bar functions.
Definition at line 60 of file Diagnostic.hh.