PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
WeatherStation.hh
Go to the documentation of this file.
1 /* Copyright (C) 2014, 2015, 2016, 2017, 2018, 2021 PISM Authors
2  *
3  * This file is part of PISM.
4  *
5  * PISM is free software; you can redistribute it and/or modify it under the
6  * terms of the GNU General Public License as published by the Free Software
7  * Foundation; either version 3 of the License, or (at your option) any later
8  * version.
9  *
10  * PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with PISM; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef PISM_WEATHER_STATION_HH
21 #define PISM_WEATHER_STATION_HH
22 
23 #include "pism/coupler/AtmosphereModel.hh"
24 
25 #include <memory> // std::shared_ptr
26 
27 
28 namespace pism {
29 
30 class ScalarForcing;
31 
32 namespace atmosphere {
33 
34 /** This class implements an atmosphere model corresponding to *one* weather station.
35  *
36  * It reads scalar (but time-dependent) near-surface air temperature
37  * and precipitation data from a provided file. Resulting climate
38  * fields are constant in time.
39  *
40  * This model should be used with a modifier such as `lapse_rate` to
41  * create spatial variability.
42  */
44 public:
45  WeatherStation(std::shared_ptr<const Grid> g);
46  virtual ~WeatherStation() = default;
47 
48 protected:
49  void init_impl(const Geometry &geometry);
50  void update_impl(const Geometry &geometry, double t, double dt);
51 
52  const array::Scalar& precipitation_impl() const;
53  const array::Scalar& air_temperature_impl() const;
54 
55  void begin_pointwise_access_impl() const;
56  void end_pointwise_access_impl() const;
57  void init_timeseries_impl(const std::vector<double> &ts) const;
58  void precip_time_series_impl(int i, int j, std::vector<double> &values) const;
59  void temp_time_series_impl(int i, int j, std::vector<double> &values) const;
60 
61  MaxTimestep max_timestep_impl(double t) const;
62 protected:
63 
64  std::shared_ptr<ScalarForcing> m_precipitation_timeseries;
65  std::shared_ptr<ScalarForcing> m_air_temp_timeseries;
66 
67  mutable std::vector<double> m_precip_values, m_air_temp_values;
68 
69  std::shared_ptr<array::Scalar> m_temperature;
70  std::shared_ptr<array::Scalar> m_precipitation;
71 };
72 
73 } // end of namespace atmosphere
74 } // end of namespace pism
75 
76 #endif /* PISM_WEATHER_STATION_HH */
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
Definition: MaxTimestep.hh:31
A purely virtual class defining the interface of a PISM Atmosphere Model.
std::shared_ptr< ScalarForcing > m_precipitation_timeseries
std::shared_ptr< array::Scalar > m_temperature
void temp_time_series_impl(int i, int j, std::vector< double > &values) const
void update_impl(const Geometry &geometry, double t, double dt)
WeatherStation(std::shared_ptr< const Grid > g)
void init_impl(const Geometry &geometry)
std::vector< double > m_air_temp_values
void init_timeseries_impl(const std::vector< double > &ts) const
virtual ~WeatherStation()=default
const array::Scalar & air_temperature_impl() const
const array::Scalar & precipitation_impl() const
MaxTimestep max_timestep_impl(double t) const
std::shared_ptr< ScalarForcing > m_air_temp_timeseries
std::vector< double > m_precip_values
std::shared_ptr< array::Scalar > m_precipitation
void precip_time_series_impl(int i, int j, std::vector< double > &values) const
static const double g
Definition: exactTestP.cc:36