PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
PrescribedRetreat.cc
Go to the documentation of this file.
1/* Copyright (C) 2019, 2021, 2022, 2023, 2025, 2026 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#include <cmath> // std::round
21
22#include "pism/frontretreat/PrescribedRetreat.hh"
23#include "pism/coupler/util/options.hh"
24#include "pism/util/array/Forcing.hh"
25#include "pism/util/Logger.hh"
26#include "pism/util/io/IO_Flags.hh"
27
28namespace pism {
29
30PrescribedRetreat::PrescribedRetreat(std::shared_ptr<const Grid> grid)
31 : Component(grid) {
32 ForcingOptions opt(*m_grid->ctx(), "geometry.front_retreat.prescribed");
33 {
34 unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
35
37
39 std::make_shared<array::Forcing>(m_grid, file, "land_ice_area_fraction_retreat",
40 "", // no standard name
41 buffer_size, opt.periodic);
42 m_retreat_mask->metadata(0)
43 .long_name("maximum ice extent mask")
44 .units("1");
45 }
46}
47
49
50 ForcingOptions opt(*m_grid->ctx(), "geometry.front_retreat.prescribed");
51
52 m_log->message(2,
53 "* Initializing the prescribed front retreat mechanism\n"
54 " using a time-dependent ice extent mask '%s' in '%s'...\n",
55 m_retreat_mask->get_name().c_str(), opt.filename.c_str());
56
57 m_retreat_mask->init(opt.filename, opt.periodic);
58}
59
60void PrescribedRetreat::update(double t, double dt, array::Scalar &ice_thickness,
61 array::Scalar &ice_area_specific_volume) {
62 m_retreat_mask->update(t, dt);
63 m_retreat_mask->average(t, dt);
64
65 // Scaling factor used to round f to 1/1000:
66 double A = 1000.0;
67
68 array::AccessScope list{ m_retreat_mask.get(), &ice_thickness, &ice_area_specific_volume };
69
70 for (auto p : m_grid->points()) {
71 const int i = p.i(), j = p.j();
72
73 double f = (*m_retreat_mask)(i, j);
74
75 // round to the nearest 2^(-10) to avoid interpolation artifacts:
76 f = std::round(A * f) / A;
77
78 if (f <= 0.0) {
79 ice_area_specific_volume(i, j) = 0.0;
80 ice_thickness(i, j) = 0.0;
81 } else if (f < 1.0) {
82 ice_area_specific_volume(i, j) = ice_thickness(i, j) * f;
83 ice_thickness(i, j) = 0.0;
84 } else {
85 // M == 1.0: do nothing
86 }
87 }
88}
89
91 auto dt = m_retreat_mask->max_timestep(t);
92
93 if (dt.finite()) {
94 return MaxTimestep(dt.value(), "prescribed ice retreat");
95 }
96 return MaxTimestep("prescribed ice retreat");
97}
98
99} // end of namespace pism
std::shared_ptr< const Config > m_config
configuration database used by this component
Definition Component.hh:160
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition Component.hh:158
std::shared_ptr< const Logger > m_log
logger (for easy access)
Definition Component.hh:164
A class defining a common interface for most PISM sub-models.
Definition Component.hh:118
High-level PISM I/O class.
Definition File.hh:57
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
std::shared_ptr< array::Forcing > m_retreat_mask
PrescribedRetreat(std::shared_ptr< const Grid > grid)
void update(double t, double dt, array::Scalar &ice_thickness, array::Scalar &ice_area_specific_volume)
MaxTimestep max_timestep_impl(double t) const
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:66
@ PISM_NETCDF3
Definition IO_Flags.hh:58
@ PISM_READONLY
open an existing file for reading only
Definition IO_Flags.hh:69
std::string filename
Definition options.hh:33