PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
SurfaceModel.hh
Go to the documentation of this file.
1 // Copyright (C) 2008-2018, 2021, 2023 Ed Bueler, Constantine Khroulev, Ricarda Winkelmann,
2 // Gudfinna Adalgeirsdottir and Andy Aschwanden
3 //
4 // This file is part of PISM.
5 //
6 // PISM is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3 of the License, or (at your option) any later
9 // version.
10 //
11 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with PISM; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef __PISMSurfaceModel_hh
21 #define __PISMSurfaceModel_hh
22 
23 /*!
24  * This file should contain the class definition and nothing else.
25  * Implementations should go in separate files.
26  */
27 
28 #include "pism/util/Component.hh"
29 
30 namespace pism {
31 
32 namespace atmosphere {
33 class AtmosphereModel;
34 }
35 
36 //! @brief Surface models and modifiers: provide top-surface
37 //! temperature, mass flux, liquid water fraction, mass and thickness of the surface
38 //! layer.
39 namespace surface {
40 
41 //! \brief The interface of PISM's surface models.
42 class SurfaceModel : public Component {
43 public:
44  SurfaceModel(std::shared_ptr<const Grid> g);
45  SurfaceModel(std::shared_ptr<const Grid> g, std::shared_ptr<SurfaceModel> input);
46  SurfaceModel(std::shared_ptr<const Grid> g, std::shared_ptr<atmosphere::AtmosphereModel> atmosphere);
47 
48  virtual ~SurfaceModel() = default;
49 
50  void init(const Geometry &geometry);
51 
52  // the interface:
53  void update(const Geometry &geometry, double t, double dt);
54 
55  const array::Scalar& accumulation() const;
56  const array::Scalar& layer_mass() const;
57  const array::Scalar& layer_thickness() const;
58  const array::Scalar& liquid_water_fraction() const;
59  const array::Scalar& mass_flux() const;
60  const array::Scalar& melt() const;
61  const array::Scalar& runoff() const;
62  const array::Scalar& temperature() const;
63 
64 protected:
65 
66  virtual const array::Scalar& accumulation_impl() const;
67  virtual const array::Scalar& layer_mass_impl() const;
68  virtual const array::Scalar& layer_thickness_impl() const;
69  virtual const array::Scalar& liquid_water_fraction_impl() const;
70  virtual const array::Scalar& mass_flux_impl() const;
71  virtual const array::Scalar& melt_impl() const;
72  virtual const array::Scalar& runoff_impl() const;
73  virtual const array::Scalar& temperature_impl() const;
74 
75  virtual void init_impl(const Geometry &geometry);
76  virtual void update_impl(const Geometry &geometry, double t, double dt);
77 
78  virtual void define_model_state_impl(const File &output) const;
79  virtual void write_model_state_impl(const File &output) const;
80 
81  virtual MaxTimestep max_timestep_impl(double my_t) const;
82 
83  virtual DiagnosticList diagnostics_impl() const;
84  virtual TSDiagnosticList ts_diagnostics_impl() const;
85 
86  void dummy_accumulation(const array::Scalar& smb, array::Scalar& result);
87  void dummy_melt(const array::Scalar& smb, array::Scalar& result);
88  void dummy_runoff(const array::Scalar& smb, array::Scalar& result);
89 
90  static std::shared_ptr<array::Scalar> allocate_layer_mass(std::shared_ptr<const Grid> grid);
91  static std::shared_ptr<array::Scalar> allocate_layer_thickness(std::shared_ptr<const Grid> grid);
92  static std::shared_ptr<array::Scalar> allocate_liquid_water_fraction(std::shared_ptr<const Grid> grid);
93  static std::shared_ptr<array::Scalar> allocate_mass_flux(std::shared_ptr<const Grid> grid);
94  static std::shared_ptr<array::Scalar> allocate_temperature(std::shared_ptr<const Grid> grid);
95  static std::shared_ptr<array::Scalar> allocate_accumulation(std::shared_ptr<const Grid> grid);
96  static std::shared_ptr<array::Scalar> allocate_melt(std::shared_ptr<const Grid> grid);
97  static std::shared_ptr<array::Scalar> allocate_runoff(std::shared_ptr<const Grid> grid);
98 
99 
100  std::shared_ptr<array::Scalar> m_liquid_water_fraction;
101  std::shared_ptr<array::Scalar> m_layer_mass;
102  std::shared_ptr<array::Scalar> m_layer_thickness;
103  std::shared_ptr<array::Scalar> m_accumulation;
104  std::shared_ptr<array::Scalar> m_melt;
105  std::shared_ptr<array::Scalar> m_runoff;
106 
107  std::shared_ptr<SurfaceModel> m_input_model;
108  std::shared_ptr<atmosphere::AtmosphereModel> m_atmosphere;
109 };
110 
111 } // end of namespace surface
112 } // end of namespace pism
113 
114 #endif // __PISMSurfaceModel_hh
std::shared_ptr< const Grid > grid() const
Definition: Component.cc:105
A class defining a common interface for most PISM sub-models.
Definition: Component.hh:118
High-level PISM I/O class.
Definition: File.hh:56
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
Definition: MaxTimestep.hh:31
const array::Scalar & melt() const
Returns melt.
static std::shared_ptr< array::Scalar > allocate_runoff(std::shared_ptr< const Grid > grid)
virtual const array::Scalar & layer_mass_impl() const
const array::Scalar & liquid_water_fraction() const
Returns the liquid water fraction of the ice at the top ice surface.
const array::Scalar & layer_mass() const
Returns mass held in the surface layer.
void update(const Geometry &geometry, double t, double dt)
std::shared_ptr< atmosphere::AtmosphereModel > m_atmosphere
static std::shared_ptr< array::Scalar > allocate_mass_flux(std::shared_ptr< const Grid > grid)
Definition: SurfaceModel.cc:73
virtual DiagnosticList diagnostics_impl() const
void dummy_accumulation(const array::Scalar &smb, array::Scalar &result)
virtual void update_impl(const Geometry &geometry, double t, double dt)
std::shared_ptr< array::Scalar > m_melt
void init(const Geometry &geometry)
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
std::shared_ptr< array::Scalar > m_layer_thickness
const array::Scalar & mass_flux() const
static std::shared_ptr< array::Scalar > allocate_temperature(std::shared_ptr< const Grid > grid)
Definition: SurfaceModel.cc:92
virtual const array::Scalar & accumulation_impl() const
const array::Scalar & accumulation() const
Returns accumulation.
virtual const array::Scalar & liquid_water_fraction_impl() const
static std::shared_ptr< array::Scalar > allocate_accumulation(std::shared_ptr< const Grid > grid)
virtual MaxTimestep max_timestep_impl(double my_t) const
static std::shared_ptr< array::Scalar > allocate_melt(std::shared_ptr< const Grid > grid)
SurfaceModel(std::shared_ptr< const Grid > g)
std::shared_ptr< array::Scalar > m_runoff
static std::shared_ptr< array::Scalar > allocate_layer_thickness(std::shared_ptr< const Grid > grid)
Definition: SurfaceModel.cc:47
void dummy_melt(const array::Scalar &smb, array::Scalar &result)
std::shared_ptr< SurfaceModel > m_input_model
static std::shared_ptr< array::Scalar > allocate_layer_mass(std::shared_ptr< const Grid > grid)
Definition: SurfaceModel.cc:35
virtual ~SurfaceModel()=default
const array::Scalar & temperature() const
std::shared_ptr< array::Scalar > m_layer_mass
virtual const array::Scalar & mass_flux_impl() const
virtual TSDiagnosticList ts_diagnostics_impl() const
virtual const array::Scalar & runoff_impl() const
std::shared_ptr< array::Scalar > m_accumulation
std::shared_ptr< array::Scalar > m_liquid_water_fraction
virtual void init_impl(const Geometry &geometry)
const array::Scalar & layer_thickness() const
Returns thickness of the surface layer. Could be used to compute surface elevation as a sum of elevat...
const array::Scalar & runoff() const
Returns runoff.
virtual const array::Scalar & melt_impl() const
virtual const array::Scalar & layer_thickness_impl() const
void dummy_runoff(const array::Scalar &smb, array::Scalar &result)
virtual const array::Scalar & temperature_impl() const
static std::shared_ptr< array::Scalar > allocate_liquid_water_fraction(std::shared_ptr< const Grid > grid)
Definition: SurfaceModel.cc:60
The interface of PISM's surface models.
Definition: SurfaceModel.hh:42
static const double g
Definition: exactTestP.cc:36
std::map< std::string, TSDiagnostic::Ptr > TSDiagnosticList
Definition: Diagnostic.hh:343
std::map< std::string, Diagnostic::Ptr > DiagnosticList
Definition: Diagnostic.hh:125