PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
PrecipitationScaling.cc
Go to the documentation of this file.
1// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2020, 2021, 2022, 2023, 2024, 2025 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#include <cmath> // exp()
19
20#include "pism/coupler/atmosphere/PrecipitationScaling.hh"
21
22#include "pism/util/ScalarForcing.hh"
23#include "pism/util/Config.hh"
24#include "pism/util/Logger.hh"
25
26namespace pism {
27namespace atmosphere {
28
29PrecipitationScaling::PrecipitationScaling(std::shared_ptr<const Grid> grid,
30 std::shared_ptr<AtmosphereModel> in)
31 : AtmosphereModel(grid, in) {
32
33 m_forcing.reset(new ScalarForcing(*grid->ctx(),
34 "atmosphere.precip_scaling",
35 "delta_T",
36 "kelvin",
37 "kelvin",
38 "air temperature offsets"));
39
40 m_exp_factor = m_config->get_number("atmosphere.precip_exponential_factor_for_temperature");
41
43}
44
46 m_input_model->init(geometry);
47
48 m_log->message(2,
49 "* Initializing precipitation scaling"
50 " using temperature offsets...\n");
51}
52
53void PrecipitationScaling::init_timeseries_impl(const std::vector<double> &ts) const {
55
56 m_scaling_values.resize(ts.size());
57 for (unsigned int k = 0; k < ts.size(); ++k) {
58 m_scaling_values[k] = exp(m_exp_factor * m_forcing->value(ts[k]));
59 }
60}
61
62void PrecipitationScaling::update_impl(const Geometry &geometry, double t, double dt) {
63 m_input_model->update(geometry, t, dt);
64
65 m_precipitation->copy_from(m_input_model->precipitation());
66 m_precipitation->scale(exp(m_exp_factor * m_forcing->value(t + 0.5 * dt)));
67}
68
72
73void PrecipitationScaling::precip_time_series_impl(int i, int j, std::vector<double> &result) const {
74 m_input_model->precip_time_series(i, j, result);
75
76 for (unsigned int k = 0; k < m_scaling_values.size(); ++k) {
77 result[k] *= m_scaling_values[k];
78 }
79}
80
81} // end of namespace atmosphere
82} // end of namespace pism
std::shared_ptr< const Grid > grid() const
Definition Component.cc:107
std::shared_ptr< const Config > m_config
configuration database used by this component
Definition Component.hh:160
std::shared_ptr< const Logger > m_log
logger (for easy access)
Definition Component.hh:164
virtual void init_timeseries_impl(const std::vector< double > &ts) const
std::shared_ptr< AtmosphereModel > m_input_model
static std::shared_ptr< array::Scalar > allocate_precipitation(std::shared_ptr< const Grid > grid)
A purely virtual class defining the interface of a PISM Atmosphere Model.
std::shared_ptr< ScalarForcing > m_forcing
void init_timeseries_impl(const std::vector< double > &ts) const
void update_impl(const Geometry &geometry, double t, double dt)
void precip_time_series_impl(int i, int j, std::vector< double > &values) const
PrecipitationScaling(std::shared_ptr< const Grid > g, std::shared_ptr< AtmosphereModel > in)
const array::Scalar & precipitation_impl() const
std::shared_ptr< array::Scalar > m_precipitation
void init_impl(const Geometry &geometry)
static const double k
Definition exactTestP.cc:42