Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pism::Diagnostic Class Referenceabstract

Class representing diagnostic computations in PISM. More...

#include <Diagnostic.hh>

+ Inheritance diagram for pism::Diagnostic:

Public Types

typedef std::shared_ptr< DiagnosticPtr
 

Public Member Functions

 Diagnostic (std::shared_ptr< const Grid > g)
 
virtual ~Diagnostic ()=default
 
void update (double dt)
 
void reset ()
 
std::shared_ptr< array::Arraycompute () const
 Compute a diagnostic quantity and return a pointer to a newly-allocated Array.
 
unsigned int n_variables () const
 Get the number of NetCDF variables corresponding to a diagnostic quantity.
 
SpatialVariableMetadatametadata (unsigned int N=0)
 Get a metadata object corresponding to variable number N.
 
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.
 
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::Arraycompute_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 Gridm_grid
 the grid
 
const units::System::Ptr m_sys
 the unit system
 
const Config::ConstPtr m_config
 Configuration flags and parameters.
 
std::vector< SpatialVariableMetadatam_vars
 metadata corresponding to NetCDF variables
 
double m_fill_value
 fill value (used often enough to justify storing it)
 

Detailed Description

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

std::shared_ptr<array::Array> compute_bar(Foo* model, ...);

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.


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