PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
Elevation.cc
Go to the documentation of this file.
1// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2022, 2023, 2024, 2025 Andy Aschwanden and Constantine Khroulev
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/surface/Elevation.hh"
20
21#include "pism/util/Grid.hh"
22#include "pism/util/Config.hh"
23#include "pism/util/error_handling.hh"
24#include "pism/util/pism_options.hh"
25#include "pism/util/MaxTimestep.hh"
26#include "pism/geometry/Geometry.hh"
27#include "pism/util/Logger.hh"
28
29namespace pism {
30namespace surface {
31
32///// Elevation-dependent temperature and surface mass balance.
33Elevation::Elevation(std::shared_ptr<const Grid> grid, std::shared_ptr<atmosphere::AtmosphereModel> input)
34 : SurfaceModel(grid) {
35 (void) input;
36
39}
40
41void Elevation::init_impl(const Geometry &geometry) {
42 (void) geometry;
43
44 bool limits_set = false;
45
46 m_log->message(2,
47 "* Initializing the constant-in-time surface processes model Elevation. Setting...\n");
48
49 {
50 // ice surface temperature
51 {
52 m_T_min = m_config->get_number("surface.elevation_dependent.T_min", "kelvin");
53 m_T_max = m_config->get_number("surface.elevation_dependent.T_max", "kelvin");
54 m_z_T_min = m_config->get_number("surface.elevation_dependent.z_T_min");
55 m_z_T_max = m_config->get_number("surface.elevation_dependent.z_T_max");
56 }
57
58 // climatic mass balance
59 {
60 m_M_min = m_config->get_number("surface.elevation_dependent.M_min", "m s^-1");
61 m_M_max = m_config->get_number("surface.elevation_dependent.M_max", "m s^-1");
62 m_z_M_min = m_config->get_number("surface.elevation_dependent.z_M_min");
63 m_z_ELA = m_config->get_number("surface.elevation_dependent.z_ELA");
64 m_z_M_max = m_config->get_number("surface.elevation_dependent.z_M_max");
65 }
66
67 // limits of the climatic mass balance
68 {
69 m_M_limit_min = m_config->get_number("surface.elevation_dependent.M_limit_min", "m s^-1");
70 m_M_limit_max = m_config->get_number("surface.elevation_dependent.M_limit_max", "m s^-1");
71
72 double eps = 1e-16;
73 if (std::fabs(m_M_limit_min - m_M_limit_max) < eps) {
76 }
77 }
78 }
79
80 units::Converter meter_per_year(m_sys, "m second^-1", "m year^-1");
81 m_log->message(3,
82 " temperature at %.0f m a.s.l. = %.2f deg C\n"
83 " temperature at %.0f m a.s.l. = %.2f deg C\n"
84 " mass balance below %.0f m a.s.l. = %.2f m year-1\n"
85 " mass balance at %.0f m a.s.l. = %.2f m year-1\n"
86 " mass balance at %.0f m a.s.l. = %.2f m year-1\n"
87 " mass balance above %.0f m a.s.l. = %.2f m year-1\n"
88 " equilibrium line altitude z_ELA = %.2f m a.s.l.\n",
91 m_z_M_min, meter_per_year(m_M_limit_min),
93 m_z_M_max, meter_per_year(m_M_max),
94 m_z_M_max, meter_per_year(m_M_limit_max),
95 m_z_ELA);
96
97 // parameterizing the ice surface temperature 'ice_surface_temp'
98 m_log->message(2, " - parameterizing the ice surface temperature 'ice_surface_temp' ... \n");
99 m_log->message(2,
100 " ice temperature at the ice surface (T = ice_surface_temp) is piecewise-linear function\n"
101 " of surface altitude (usurf):\n"
102 " / %2.2f K for usurf < %.f m\n"
103 " T = | %5.2f K + %5.3f * (usurf - %.f m) for %.f m < usurf < %.f m\n"
104 " \\ %5.2f K for %.f m < usurf\n",
108
109 // parameterizing the ice surface mass balance 'climatic_mass_balance'
110 m_log->message(2,
111
112 " - parameterizing the ice surface mass balance 'climatic_mass_balance' ... \n");
113
114 if (limits_set) {
115 m_log->message(2,
116 " - option '-climatic_mass_balance_limits' seen, limiting upper and lower bounds ... \n");
117 }
118
119 m_log->message(2,
120 " surface mass balance (M = climatic_mass_balance) is piecewise-linear function\n"
121 " of surface altitue (usurf):\n"
122 " / %5.2f m year-1 for usurf < %3.f m\n"
123 " M = | %5.3f 1/a * (usurf-%.0f m) for %3.f m < usurf < %3.f m\n"
124 " \\ %5.3f 1/a * (usurf-%.0f m) for %3.f m < usurf < %3.f m\n"
125 " \\ %5.2f m year-1 for %3.f m < usurf\n",
126 meter_per_year(m_M_limit_min), m_z_M_min,
127 meter_per_year(-m_M_min)/(m_z_ELA - m_z_M_min), m_z_ELA, m_z_M_min, m_z_ELA,
128 meter_per_year(m_M_max)/(m_z_M_max - m_z_ELA), m_z_ELA, m_z_ELA, m_z_M_max,
129 meter_per_year(m_M_limit_max), m_z_M_max);
130}
131
133 (void) t;
134 return MaxTimestep("surface 'elevation'");
135}
136
137void Elevation::update_impl(const Geometry &geometry, double t, double dt) {
138 (void) t;
139 (void) dt;
140
143
147
148}
149
151 return *m_mass_flux;
152}
153
155 return *m_temperature;
156}
157
161
163 return *m_melt;
164}
165
167 return *m_runoff;
168}
169
170void Elevation::compute_mass_flux(const array::Scalar &surface, array::Scalar &result) const {
171 double dabdz = -m_M_min/(m_z_ELA - m_z_M_min);
172 double dacdz = m_M_max/(m_z_M_max - m_z_ELA);
173
174 array::AccessScope list{&result, &surface};
175
176 ParallelSection loop(m_grid->com);
177 try {
178 for (auto p : m_grid->points()) {
179 const int i = p.i(), j = p.j();
180
181 double z = surface(i, j);
182
183 if (z < m_z_M_min) {
184 result(i, j) = m_M_limit_min;
185 }
186 else if ((z >= m_z_M_min) and (z < m_z_ELA)) {
187 result(i, j) = dabdz * (z - m_z_ELA);
188 }
189 else if ((z >= m_z_ELA) and (z <= m_z_M_max)) {
190 result(i, j) = dacdz * (z - m_z_ELA);
191 }
192 else if (z > m_z_M_max) {
193 result(i, j) = m_M_limit_max;
194 }
195 else {
197 "Elevation::compute_mass_flux: HOW DID I GET HERE?");
198 }
199 }
200 } catch (...) {
201 loop.failed();
202 }
203 loop.check();
204
205 // convert from m second-1 ice equivalent to kg m-2 s-1:
206 result.scale(m_config->get_number("constants.ice.density"));
207}
208
209void Elevation::compute_temperature(const array::Scalar &surface, array::Scalar &result) const {
210
211 array::AccessScope list{&result, &surface};
212
213 double dTdz = (m_T_max - m_T_min)/(m_z_T_max - m_z_T_min);
214 ParallelSection loop(m_grid->com);
215 try {
216 for (auto p : m_grid->points()) {
217 const int i = p.i(), j = p.j();
218
219 double z = surface(i, j);
220
221 if (z <= m_z_T_min) {
222 result(i, j) = m_T_min;
223 }
224 else if ((z > m_z_T_min) and (z < m_z_T_max)) {
225 result(i, j) = m_T_min + dTdz * (z - m_z_T_min);
226 }
227 else if (z >= m_z_T_max) {
228 result(i, j) = m_T_max;
229 }
230 else {
232 "Elevation::compute_temperature: HOW DID I GET HERE?");
233 }
234 }
235 } catch (...) {
236 loop.failed();
237 }
238 loop.check();
239}
240
241} // end of namespace surface
242} // end of namespace pism
const units::System::Ptr m_sys
unit system used by this component
Definition Component.hh:162
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
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
array::Scalar2 ice_surface_elevation
Definition Geometry.hh:57
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
void failed()
Indicates a failure of a parallel section.
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:66
void scale(double alpha)
Result: v <- v * alpha. Calls VecScale.
Definition Array.cc:227
void compute_temperature(const array::Scalar &surface, array::Scalar &result) const
Definition Elevation.cc:209
const array::Scalar & temperature_impl() const
Definition Elevation.cc:154
void compute_mass_flux(const array::Scalar &surface, array::Scalar &result) const
Definition Elevation.cc:170
void init_impl(const Geometry &geometry)
Definition Elevation.cc:41
std::shared_ptr< array::Scalar > m_mass_flux
Definition Elevation.hh:53
void update_impl(const Geometry &geometry, double t, double dt)
Definition Elevation.cc:137
Elevation(std::shared_ptr< const Grid > grid, std::shared_ptr< atmosphere::AtmosphereModel > input)
Definition Elevation.cc:33
virtual const array::Scalar & accumulation_impl() const
Definition Elevation.cc:158
std::shared_ptr< array::Scalar > m_temperature
Definition Elevation.hh:54
virtual const array::Scalar & runoff_impl() const
Definition Elevation.cc:166
virtual const array::Scalar & melt_impl() const
Definition Elevation.cc:162
const array::Scalar & mass_flux_impl() const
Definition Elevation.cc:150
MaxTimestep max_timestep_impl(double t) const
Definition Elevation.cc:132
static std::shared_ptr< array::Scalar > allocate_mass_flux(std::shared_ptr< const Grid > grid)
void dummy_accumulation(const array::Scalar &smb, array::Scalar &result)
std::shared_ptr< array::Scalar > m_melt
static std::shared_ptr< array::Scalar > allocate_temperature(std::shared_ptr< const Grid > grid)
std::shared_ptr< array::Scalar > m_runoff
void dummy_melt(const array::Scalar &smb, array::Scalar &result)
std::shared_ptr< array::Scalar > m_accumulation
void dummy_runoff(const array::Scalar &smb, array::Scalar &result)
The interface of PISM's surface models.
#define PISM_ERROR_LOCATION