tSIAFD_diagnostics.cc - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tSIAFD_diagnostics.cc (6841B)
---
1 // Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 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 "SIAFD_diagnostics.hh"
20 #include "BedSmoother.hh"
21 #include "pism/util/Vars.hh"
22
23 namespace pism {
24 namespace stressbalance {
25
26 DiagnosticList SIAFD::diagnostics_impl() const {
27 DiagnosticList result = {
28 {"diffusivity", Diagnostic::Ptr(new SIAFD_diffusivity(this))},
29 {"diffusivity_staggered", Diagnostic::Ptr(new SIAFD_diffusivity_staggered(this))},
30 {"schoofs_theta", Diagnostic::Ptr(new SIAFD_schoofs_theta(this))},
31 {"thksmooth", Diagnostic::Ptr(new SIAFD_thksmooth(this))},
32 {"topgsmooth", Diagnostic::Ptr(new SIAFD_topgsmooth(this))},
33 {"h_x", Diagnostic::Ptr(new SIAFD_h_x(this))},
34 {"h_y", Diagnostic::Ptr(new SIAFD_h_y(this))}
35 };
36 return result;
37 }
38
39 SIAFD_schoofs_theta::SIAFD_schoofs_theta(const SIAFD *m)
40 : Diag<SIAFD>(m) {
41
42 // set metadata:
43 m_vars = {SpatialVariableMetadata(m_sys, "schoofs_theta")};
44
45 set_attrs("multiplier 'theta' in Schoof's (2003) theory of bed roughness in SIA", "",
46 "1", "", 0);
47 m_vars[0].set_number("valid_min", 0);
48 m_vars[0].set_number("valid_max", 1);
49 }
50
51 IceModelVec::Ptr SIAFD_schoofs_theta::compute_impl() const {
52 const IceModelVec2S *surface = m_grid->variables().get_2d_scalar("surface_altitude");
53
54 IceModelVec2S::Ptr result(new IceModelVec2S(m_grid, "schoofs_theta", WITHOUT_GHOSTS));
55 result->metadata(0) = m_vars[0];
56
57 model->bed_smoother().theta(*surface, *result);
58
59 return result;
60 }
61
62
63 SIAFD_topgsmooth::SIAFD_topgsmooth(const SIAFD *m)
64 : Diag<SIAFD>(m) {
65
66 // set metadata:
67 m_vars = {SpatialVariableMetadata(m_sys, "topgsmooth")};
68 set_attrs("smoothed bed elevation in Schoof's (2003) theory of bed roughness in SIA",
69 "", "m", "m", 0);
70 }
71
72 IceModelVec::Ptr SIAFD_topgsmooth::compute_impl() const {
73
74 IceModelVec2S::Ptr result(new IceModelVec2S(m_grid, "topgsmooth", WITHOUT_GHOSTS));
75 result->metadata() = m_vars[0];
76
77 result->copy_from(model->bed_smoother().smoothed_bed());
78
79 return result;
80 }
81
82 SIAFD_thksmooth::SIAFD_thksmooth(const SIAFD *m)
83 : Diag<SIAFD>(m) {
84
85 // set metadata:
86 m_vars = {SpatialVariableMetadata(m_sys, "thksmooth")};
87 set_attrs("thickness relative to smoothed bed elevation in Schoof's (2003) theory of bed roughness in SIA",
88 "", "m", "m", 0);
89 }
90
91 IceModelVec::Ptr SIAFD_thksmooth::compute_impl() const {
92
93 const IceModelVec2S &surface = *m_grid->variables().get_2d_scalar("surface_altitude");
94 const IceModelVec2S &thickness = *m_grid->variables().get_2d_scalar("land_ice_thickness");
95 const IceModelVec2CellType &mask = *m_grid->variables().get_2d_cell_type("mask");
96
97 IceModelVec2S::Ptr result(new IceModelVec2S(m_grid, "thksmooth", WITHOUT_GHOSTS));
98 result->metadata(0) = m_vars[0];
99
100 model->bed_smoother().smoothed_thk(surface, thickness, mask,
101 *result);
102 return result;
103 }
104
105
106
107 SIAFD_diffusivity::SIAFD_diffusivity(const SIAFD *m)
108 : Diag<SIAFD>(m) {
109
110 // set metadata:
111 m_vars = {SpatialVariableMetadata(m_sys, "diffusivity")};
112
113 set_attrs("diffusivity of SIA mass continuity equation", "",
114 "m2 s-1", "m2 s-1", 0);
115 }
116
117 IceModelVec::Ptr SIAFD_diffusivity::compute_impl() const {
118 IceModelVec2S::Ptr result(new IceModelVec2S(m_grid, "diffusivity", WITHOUT_GHOSTS));
119 result->metadata() = m_vars[0];
120
121 model->diffusivity().staggered_to_regular(*result);
122
123 return result;
124 }
125
126 SIAFD_diffusivity_staggered::SIAFD_diffusivity_staggered(const SIAFD *m)
127 : Diag<SIAFD>(m) {
128
129 // set metadata:
130 m_vars = {SpatialVariableMetadata(m_sys, "diffusivity_i"),
131 SpatialVariableMetadata(m_sys, "diffusivity_j")};
132
133 set_attrs("diffusivity of SIA mass continuity equation on the staggered grid (i-offset)", "",
134 "m2 s-1", "m2 s-1", 0);
135 set_attrs("diffusivity of SIA mass continuity equation on the staggered grid (j-offset)", "",
136 "m2 s-1", "m2 s-1", 1);
137 }
138
139 static void copy_staggered_vec(const IceModelVec2Stag &input, IceModelVec2Stag &output) {
140 IceGrid::ConstPtr grid = output.grid();
141
142 IceModelVec::AccessList list{ &input, &output };
143
144 for (Points p(*grid); p; p.next()) {
145 const int i = p.i(), j = p.j();
146
147 output(i, j, 0) = input(i, j, 0);
148 output(i, j, 1) = input(i, j, 1);
149 }
150 }
151
152 IceModelVec::Ptr SIAFD_diffusivity_staggered::compute_impl() const {
153 IceModelVec2Stag::Ptr result(new IceModelVec2Stag);
154 result->create(m_grid, "diffusivity", WITHOUT_GHOSTS);
155 result->metadata(0) = m_vars[0];
156 result->metadata(1) = m_vars[1];
157
158 copy_staggered_vec(model->diffusivity(), *result.get());
159
160 return result;
161 }
162
163 SIAFD_h_x::SIAFD_h_x(const SIAFD *m)
164 : Diag<SIAFD>(m) {
165
166 // set metadata:
167 m_vars = {SpatialVariableMetadata(m_sys, "h_x_i"),
168 SpatialVariableMetadata(m_sys, "h_x_j")};
169
170 set_attrs("the x-component of the surface gradient, i-offset", "",
171 "", "", 0);
172 set_attrs("the x-component of the surface gradient, j-offset", "",
173 "", "", 1);
174 }
175
176 IceModelVec::Ptr SIAFD_h_x::compute_impl() const {
177
178 IceModelVec2Stag::Ptr result(new IceModelVec2Stag);
179 result->create(m_grid, "h_x", WITHOUT_GHOSTS);
180 result->metadata(0) = m_vars[0];
181 result->metadata(1) = m_vars[1];
182
183 copy_staggered_vec(model->surface_gradient_x(), *result.get());
184
185 return result;
186 }
187
188 SIAFD_h_y::SIAFD_h_y(const SIAFD *m)
189 : Diag<SIAFD>(m) {
190
191 // set metadata:
192 m_vars = {SpatialVariableMetadata(m_sys, "h_y_i"),
193 SpatialVariableMetadata(m_sys, "h_y_j")};
194
195 set_attrs("the y-component of the surface gradient, i-offset", "",
196 "", "", 0);
197 set_attrs("the y-component of the surface gradient, j-offset", "",
198 "", "", 1);
199 }
200
201 IceModelVec::Ptr SIAFD_h_y::compute_impl() const {
202
203 IceModelVec2Stag::Ptr result(new IceModelVec2Stag);
204 result->create(m_grid, "h_y", WITHOUT_GHOSTS);
205 result->metadata(0) = m_vars[0];
206 result->metadata(1) = m_vars[1];
207
208 copy_staggered_vec(model->surface_gradient_y(), *result.get());
209
210 return result;
211 }
212
213 } // end of namespace stressbalance
214 } // end of namespace pism