Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PrescribedRetreat.cc
Go to the documentation of this file.
1/* Copyright (C) 2019, 2021, 2022, 2023 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 "pism/frontretreat/PrescribedRetreat.hh"
21#include "pism/coupler/util/options.hh"
22#include "pism/util/array/Forcing.hh"
23
24namespace pism {
25
26PrescribedRetreat::PrescribedRetreat(std::shared_ptr<const Grid> grid)
27 : Component(grid) {
28 ForcingOptions opt(*m_grid->ctx(), "geometry.front_retreat.prescribed");
29 {
30 unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
31
33
35 std::make_shared<array::Forcing>(m_grid, file, "land_ice_area_fraction_retreat",
36 "", // no standard name
37 buffer_size, opt.periodic);
38 m_retreat_mask->metadata(0)
39 .long_name("maximum ice extent mask")
40 .units("1");
41 }
42}
43
45
46 ForcingOptions opt(*m_grid->ctx(), "geometry.front_retreat.prescribed");
47
48 m_log->message(2,
49 "* Initializing the prescribed front retreat mechanism\n"
50 " using a time-dependent ice extent mask '%s' in '%s'...\n",
51 m_retreat_mask->get_name().c_str(), opt.filename.c_str());
52
53 m_retreat_mask->init(opt.filename, opt.periodic);
54}
55
56void PrescribedRetreat::update(double t, double dt, array::Scalar &ice_thickness,
57 array::Scalar &ice_area_specific_volume) {
58 m_retreat_mask->update(t, dt);
59 m_retreat_mask->average(t, dt);
60
61 double eps = 1e-12;
62
63 array::AccessScope list{ m_retreat_mask.get(), &ice_thickness, &ice_area_specific_volume };
64
65 for (auto p = m_grid->points(); p; p.next()) {
66 const int i = p.i(), j = p.j();
67
68 double f = (*m_retreat_mask)(i, j);
69
70 if (f <= 0.0) {
71 ice_area_specific_volume(i, j) = 0.0;
72 ice_thickness(i, j) = 0.0;
73 } else if (f < 1.0 - eps) {
74 ice_area_specific_volume(i, j) = ice_thickness(i, j) * f;
75 ice_thickness(i, j) = 0.0;
76 } else {
77 // M == 1.0: do nothing
78 }
79 }
80}
81
83 auto dt = m_retreat_mask->max_timestep(t);
84
85 if (dt.finite()) {
86 return MaxTimestep(dt.value(), "prescribed ice retreat");
87 }
88 return MaxTimestep("prescribed ice retreat");
89}
90
91} // end of namespace pism
const Config::ConstPtr m_config
configuration database used by this component
Definition Component.hh:158
const Logger::ConstPtr m_log
logger (for easy access)
Definition Component.hh:162
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition Component.hh:156
A class defining a common interface for most PISM sub-models.
Definition Component.hh:118
High-level PISM I/O class.
Definition File.hh:55
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:64
@ PISM_NETCDF3
Definition IO_Flags.hh:57
@ PISM_READONLY
open an existing file for reading only
Definition IO_Flags.hh:68
std::string filename
Definition options.hh:33