tAtmosphereModel.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
(HTM) git clone git://src.adamsgaard.dk/pism
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
tAtmosphereModel.hh (3866B)
---
1 // Copyright (C) 2008-2018 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 __AtmosphereModel
21 #define __AtmosphereModel
22
23 #include <vector>
24
25 #include "pism/util/Component.hh"
26
27 namespace pism {
28
29 class Geometry;
30 class IceModelVec2S;
31
32 //! @brief Atmosphere models and modifiers: provide precipitation and
33 //! temperature to a surface::SurfaceModel below
34 namespace atmosphere {
35 //! A purely virtual class defining the interface of a PISM Atmosphere Model.
36 class AtmosphereModel : public Component {
37 public:
38 AtmosphereModel(IceGrid::ConstPtr g);
39 AtmosphereModel(IceGrid::ConstPtr g, std::shared_ptr<AtmosphereModel> input);
40 virtual ~AtmosphereModel();
41
42 void init(const Geometry &geometry);
43
44 void update(const Geometry &geometry, double t, double dt);
45
46 //! \brief Sets result to the mean precipitation, in m/s ice equivalent.
47 const IceModelVec2S& mean_precipitation() const;
48
49 //! \brief Sets result to the mean annual near-surface air temperature, in degrees Kelvin.
50 const IceModelVec2S& mean_annual_temp() const;
51
52 void begin_pointwise_access() const;
53 void end_pointwise_access() const;
54 void init_timeseries(const std::vector<double> &ts) const;
55 //! \brief Sets a pre-allocated N-element array "result" to the time-series of
56 //! ice-equivalent precipitation (m/s) at the point i,j on the grid.
57 //!
58 //! See temp_time_series() for more.
59 void precip_time_series(int i, int j, std::vector<double> &result) const;
60
61 //! \brief Sets a pre-allocated N-element array "result" to the time-series
62 //! of near-surface air temperature (degrees Kelvin) at the point i,j on the
63 //! grid. Times (in years) are specified in ts. NB! Has to be surrounded by
64 //! begin_pointwise_access() and end_pointwise_access()
65 void temp_time_series(int i, int j, std::vector<double> &result) const;
66 protected:
67 virtual void init_impl(const Geometry &geometry) = 0;
68 virtual void update_impl(const Geometry &geometry, double t, double dt) = 0;
69 virtual void define_model_state_impl(const File &output) const;
70 virtual void write_model_state_impl(const File &output) const;
71
72 virtual MaxTimestep max_timestep_impl(double my_t) const;
73
74 virtual const IceModelVec2S& mean_precipitation_impl() const;
75 virtual const IceModelVec2S& mean_annual_temp_impl() const;
76
77 virtual void begin_pointwise_access_impl() const;
78 virtual void end_pointwise_access_impl() const;
79 virtual void init_timeseries_impl(const std::vector<double> &ts) const;
80 virtual void precip_time_series_impl(int i, int j, std::vector<double> &result) const;
81 virtual void temp_time_series_impl(int i, int j, std::vector<double> &result) const;
82
83 virtual DiagnosticList diagnostics_impl() const;
84 virtual TSDiagnosticList ts_diagnostics_impl() const;
85 protected:
86 mutable std::vector<double> m_ts_times;
87
88 std::shared_ptr<AtmosphereModel> m_input_model;
89
90 static IceModelVec2S::Ptr allocate_temperature(IceGrid::ConstPtr grid);
91 static IceModelVec2S::Ptr allocate_precipitation(IceGrid::ConstPtr grid);
92 };
93
94 } // end of namespace atmosphere
95 } // end of namespace pism
96
97 #endif // __AtmosphereModel