PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
CosineYearlyCycle.cc
Go to the documentation of this file.
1// Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2021, 2023, 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
19#include "pism/coupler/atmosphere/CosineYearlyCycle.hh"
20#include "pism/util/Config.hh"
21#include "pism/util/Grid.hh"
22
23#include "pism/util/error_handling.hh"
24#include "pism/util/MaxTimestep.hh"
25
26#include "pism/util/ScalarForcing.hh"
27#include "pism/util/Logger.hh"
28#include "pism/util/io/IO_Flags.hh"
29
30namespace pism {
31namespace atmosphere {
32
33CosineYearlyCycle::CosineYearlyCycle(std::shared_ptr<const Grid> grid)
34 : YearlyCycle(grid) {
35
36 auto scaling_file = m_config->get_string("atmosphere.yearly_cycle.scaling.file");
37
38 if (not scaling_file.empty()) {
39 m_A.reset(new ScalarForcing(*grid->ctx(),
40 "atmosphere.yearly_cycle.scaling",
41 "amplitude_scaling",
42 "1", "1",
43 "temperature amplitude scaling"));
44 }
45}
46
48 (void) geometry;
49
50 m_log->message(2,
51 "* Initializing the 'cosine yearly cycle' atmosphere model...\n");
52
53 auto input_file = m_config->get_string("atmosphere.yearly_cycle.file");
54
55 if (input_file.empty()) {
57 "Please specify an '-atmosphere yearly_cycle' input file\n"
58 "using atmosphere.yearly_cycle.file or a command-line option.");
59 }
60
61 m_log->message(2,
62 " Reading mean annual air temperature, mean July air temperature, and\n"
63 " precipitation fields from '%s'...\n", input_file.c_str());
64
68}
69
71 (void) t;
72 return MaxTimestep("atmosphere cosine_yearly_cycle");
73}
74
75void CosineYearlyCycle::update_impl(const Geometry &geometry, double t, double dt) {
76 (void) geometry;
77 (void) t;
78 (void) dt;
79 // an implementation is necessary because the base class does not define this
80}
81
82void CosineYearlyCycle::init_timeseries_impl(const std::vector<double> &ts) const {
83
85
86 if (m_A) {
87 for (unsigned int k = 0; k < ts.size(); ++k) {
88 m_cosine_cycle[k] *= m_A->value(ts[k]);
89 }
90 }
91}
92
93} // end of namespace atmosphere
94} // 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
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
void regrid(const std::string &filename, io::Default default_value)
Definition Array.cc:758
std::shared_ptr< ScalarForcing > m_A
virtual void init_impl(const Geometry &geometry)
Reads in the precipitation data from the input file.
virtual MaxTimestep max_timestep_impl(double t) const
virtual void init_timeseries_impl(const std::vector< double > &ts) const
CosineYearlyCycle(std::shared_ptr< const Grid > g)
virtual void update_impl(const Geometry &geometry, double t, double dt)
array::Scalar m_air_temp_mean_summer
std::vector< double > m_cosine_cycle
virtual void init_timeseries_impl(const std::vector< double > &ts) const
array::Scalar m_air_temp_mean_annual
static Default Nil()
Definition IO_Flags.hh:94
#define PISM_ERROR_LOCATION
static const double k
Definition exactTestP.cc:42