PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
SIAFD_diagnostics.cc
Go to the documentation of this file.
1// Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2020, 2021, 2022, 2023, 2025 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/stressbalance/sia/SIAFD_diagnostics.hh"
20#include "pism/stressbalance/sia/BedSmoother.hh"
21#include "pism/util/Vars.hh"
22#include "pism/util/array/CellType.hh"
23
24namespace pism {
25namespace stressbalance {
26
28 DiagnosticList result = {
29 {"diffusivity", Diagnostic::Ptr(new SIAFD_diffusivity(this))},
30 {"diffusivity_staggered", Diagnostic::Ptr(new SIAFD_diffusivity_staggered(this))},
31 {"schoofs_theta", Diagnostic::Ptr(new SIAFD_schoofs_theta(this))},
32 {"thksmooth", Diagnostic::Ptr(new SIAFD_thksmooth(this))},
33 {"topgsmooth", Diagnostic::Ptr(new SIAFD_topgsmooth(this))},
34 {"h_x", Diagnostic::Ptr(new SIAFD_h_x(this))},
35 {"h_y", Diagnostic::Ptr(new SIAFD_h_y(this))}
36 };
37 return result;
38}
39
41 m_vars = { { m_sys, "schoofs_theta", *m_grid } };
42
43 m_vars[0]
44 .long_name("multiplier 'theta' in Schoof's (2003) theory of bed roughness in SIA")
45 .units("1");
46 m_vars[0]["valid_range"] = { 0.0, 1.0 };
47}
48
49std::shared_ptr<array::Array> SIAFD_schoofs_theta::compute_impl() const {
50 const array::Scalar *surface = m_grid->variables().get_2d_scalar("surface_altitude");
51 auto result = allocate<array::Scalar>("schoofs_theta");
52
53 model->bed_smoother().theta(*surface, *result);
54
55 return result;
56}
57
58
60 m_vars = { { m_sys, "topgsmooth", *m_grid } };
61 m_vars[0]
62 .long_name("smoothed bed elevation in Schoof's (2003) theory of bed roughness in SIA")
63 .units("m");
64}
65
66std::shared_ptr<array::Array> SIAFD_topgsmooth::compute_impl() const {
67 auto result = allocate<array::Scalar>("topgsmooth");
68
69 result->copy_from(model->bed_smoother().smoothed_bed());
70
71 return result;
72}
73
75 : Diag<SIAFD>(m) {
76
77 m_vars = { { m_sys, "thksmooth", *m_grid } };
78 m_vars[0]
79 .long_name(
80 "thickness relative to smoothed bed elevation in Schoof's (2003) theory of bed roughness in SIA")
81 .units("m");
82}
83
84std::shared_ptr<array::Array> SIAFD_thksmooth::compute_impl() const {
85
86 const auto &surface = *m_grid->variables().get_2d_scalar("surface_altitude");
87 const auto &thickness = *m_grid->variables().get_2d_scalar("land_ice_thickness");
88
89 array::CellType2 cell_type(m_grid, "cell_type");
90 {
91 const auto &mask = *m_grid->variables().get_2d_cell_type("mask");
92 cell_type.copy_from(mask);
93 }
94
95 auto result = allocate<array::Scalar>("thksmooth");
96
97 model->bed_smoother().smoothed_thk(surface, thickness, cell_type,
98 *result);
99 return result;
100}
101
102
103
105 : Diag<SIAFD>(m) {
106
107 m_vars = { { m_sys, "diffusivity", *m_grid } };
108 m_vars[0].long_name("diffusivity of SIA mass continuity equation").units("m^2 s^-1");
109}
110
111std::shared_ptr<array::Array> SIAFD_diffusivity::compute_impl() const {
112 auto result_ptr = allocate<array::Scalar>("diffusivity");
113
114 const auto &D = model->diffusivity();
115 auto &result = *result_ptr;
116
117 array::AccessScope list{ &D, &result };
118
119 for (auto p : result.grid()->points()) {
120 const int i = p.i(), j = p.j();
121
122 result(i, j) = std::max(D(i, j, 0), D(i, j, 1));
123 }
124
125 return result_ptr;
126}
127
129 : Diag<SIAFD>(m) {
130
131 m_vars = { { m_sys, "diffusivity_i", *m_grid }, { m_sys, "diffusivity_j", *m_grid } };
132 m_vars[0]
133 .long_name("diffusivity of SIA mass continuity equation on the staggered grid (i-offset)")
134 .units("m^2 s^-1");
135 m_vars[1]
136 .long_name("diffusivity of SIA mass continuity equation on the staggered grid (j-offset)")
137 .units("m^2 s^-1");
138}
139
140static void copy_staggered_vec(const array::Staggered &input, array::Staggered &output) {
141 auto grid = output.grid();
142
143 array::AccessScope list{ &input, &output };
144
145 for (auto p : grid->points()) {
146 const int i = p.i(), j = p.j();
147
148 output(i, j, 0) = input(i, j, 0);
149 output(i, j, 1) = input(i, j, 1);
150 }
151}
152
153std::shared_ptr<array::Array> SIAFD_diffusivity_staggered::compute_impl() const {
154 auto result = allocate<array::Staggered>("diffusivity");
155
156 copy_staggered_vec(model->diffusivity(), *result);
157
158 return result;
159}
160
162 : Diag<SIAFD>(m) {
163
164 m_vars = { { m_sys, "h_x_i", *m_grid }, { m_sys, "h_x_j", *m_grid } };
165 m_vars[0].long_name("the x-component of the surface gradient, i-offset").units("1");
166 m_vars[1].long_name("the x-component of the surface gradient, j-offset").units("1");
167}
168
169std::shared_ptr<array::Array> SIAFD_h_x::compute_impl() const {
170 auto result = allocate<array::Staggered>("h_x");
171
172 copy_staggered_vec(model->surface_gradient_x(), *result);
173
174 return result;
175}
176
178 : Diag<SIAFD>(m) {
179
180 m_vars = { { m_sys, "h_y_i", *m_grid }, { m_sys, "h_y_j", *m_grid } };
181 m_vars[0].long_name("the y-component of the surface gradient, i-offset").units("1");
182 m_vars[1].long_name("the y-component of the surface gradient, j-offset").units("1");
183}
184
185std::shared_ptr<array::Array> SIAFD_h_y::compute_impl() const {
186
187 auto result = allocate<array::Staggered>("h_y");
188
189 copy_staggered_vec(model->surface_gradient_y(), *result);
190
191 return result;
192}
193
194} // end of namespace stressbalance
195} // end of namespace pism
const SIAFD * model
A template derived from Diagnostic, adding a "Model".
std::vector< VariableMetadata > m_vars
metadata corresponding to NetCDF variables
const units::System::Ptr m_sys
the unit system
std::shared_ptr< Diagnostic > Ptr
Definition Diagnostic.hh:67
std::shared_ptr< const Grid > m_grid
the grid
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:66
void copy_from(const Array2D< T > &source)
Definition Array2D.hh:101
std::shared_ptr< const Grid > grid() const
Definition Array.cc:134
A class for storing and accessing internal staggered-grid 2D fields. Uses dof=2 storage....
Definition Staggered.hh:37
virtual std::shared_ptr< array::Array > compute_impl() const
Compute diffusivity of the SIA flow (on the staggered grid).
virtual std::shared_ptr< array::Array > compute_impl() const
Compute diffusivity of the SIA flow.
virtual std::shared_ptr< array::Array > compute_impl() const
Reports the x-component of the ice surface gradient on the staggered grid as computed by SIAFD.
virtual std::shared_ptr< array::Array > compute_impl() const
Reports the y-component of the ice surface gradient on the staggered grid as computed by SIAFD.
virtual std::shared_ptr< array::Array > compute_impl() const
Computes the multiplier in Schoof's (2003) theory of the effect of bed roughness on the diffusivity ...
virtual std::shared_ptr< array::Array > compute_impl() const
Computes the thickness relative to the smoothed bed elevation in Schoof's (2003) theory of the effect...
virtual std::shared_ptr< array::Array > compute_impl() const
Computes the smoothed bed elevation from Schoof's (2003) theory of the effect of bed roughness on the...
virtual DiagnosticList spatial_diagnostics_impl() const
static void copy_staggered_vec(const array::Staggered &input, array::Staggered &output)
std::map< std::string, Diagnostic::Ptr > DiagnosticList