PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
SIAFD_Regional.cc
Go to the documentation of this file.
1/* Copyright (C) 2015, 2016, 2017, 2019, 2022, 2023, 2024, 2025 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/regional/SIAFD_Regional.hh"
21#include "pism/stressbalance/StressBalance.hh"
22#include "pism/geometry/Geometry.hh"
23#include "pism/util/Logger.hh"
24
25namespace pism {
26
27namespace stressbalance {
28
29SIAFD_Regional::SIAFD_Regional(std::shared_ptr<const Grid> grid)
30 : SIAFD(grid),
31 m_h_x_no_model(grid, "h_x_no_model"),
32 m_h_y_no_model(grid, "h_y_no_model") {
33 // empty
34}
35
37
39
40 m_log->message(2, " using the regional version of the SIA solver...\n");
41}
42
45 array::Staggered1 &h_y) {
46
47 SIAFD::compute_surface_gradient(inputs, h_x, h_y);
48
49 if (inputs.no_model_surface_elevation == nullptr) {
51 "no_model surface elevation was not provided to SIAFD_Regional");
52 }
53
54 // this call updates ghosts of h_x_no_model and h_y_no_model
56 inputs.geometry->cell_type,
58
59 const array::Scalar2 &no_model = *inputs.no_model_mask;
60
61 const int Mx = m_grid->Mx(), My = m_grid->My();
62
63 array::AccessScope list{&h_x, &h_y, &no_model, &m_h_x_no_model, &m_h_y_no_model};
64
65 for (auto p : m_grid->points_with_ghosts(1)) {
66 const int i = p.i(), j = p.j();
67
68 auto M = no_model.box(i, j);
69
70 // x-component, i-offset
71 if (M.c > 0.5 or M.e > 0.5) {
72
73 if (i < 0 or i + 1 > Mx - 1) {
74 h_x(i, j, 0) = 0.0;
75 } else {
76 h_x(i, j, 0) = m_h_x_no_model(i, j, 0);
77 }
78 }
79
80 // x-component, j-offset
81 if (M.nw > 0.5 or M.ne > 0.5 or M.w > 0.5 or M.e > 0.5) {
82
83 if (i - 1 < 0 or j + 1 > My - 1 or i + 1 > Mx - 1) {
84 h_x(i, j, 1) = 0.0;
85 } else {
86 h_x(i, j, 1) = m_h_x_no_model(i, j, 1);
87 }
88
89 }
90
91 // y-component, i-offset
92 if (M.n > 0.5 or M.ne > 0.5 or M.s > 0.5 or M.se > 0.5) {
93
94 if (i < 0 or j + 1 > My - 1 or i + 1 > Mx - 1 or j - 1 < 0) {
95 h_y(i, j, 0) = 0.0;
96 } else {
97 h_y(i, j, 0) = m_h_y_no_model(i, j, 0);
98 }
99
100 }
101
102 // y-component, j-offset
103 if (M.c > 0.5 or M.n > 0.5) {
104
105 if (j < 0 or j + 1 > My - 1) {
106 h_y(i, j, 1) = 0.0;
107 } else {
108 h_y(i, j, 1) = m_h_y_no_model(i, j, 1);
109 }
110
111 }
112 } // end of the loop over grid points
113}
114
115} // end of namespace stressbalance
116
117} // end of namespace pism
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::CellType2 cell_type
Definition Geometry.hh:55
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:66
stencils::Box< T > box(int i, int j) const
Definition Array2D.hh:121
const array::Scalar2 * no_model_surface_elevation
const array::Scalar2 * no_model_mask
void compute_surface_gradient(const Inputs &inputs, array::Staggered1 &h_x, array::Staggered1 &h_y)
Compute the ice surface gradient for the SIA.
SIAFD_Regional(std::shared_ptr< const Grid > g)
void init()
Initialize the SIA module.
virtual void compute_surface_gradient(const Inputs &inputs, array::Staggered1 &h_x, array::Staggered1 &h_y)
Compute the ice surface gradient for the SIA.
Definition SIAFD.cc:190
virtual void surface_gradient_haseloff(const array::Scalar2 &ice_surface_elevation, const array::CellType2 &cell_type, array::Staggered1 &h_x, array::Staggered1 &h_y)
Compute the ice surface gradient using a modification of Marianne Haseloff's approach.
Definition SIAFD.cc:362
virtual void init()
Initialize the SIA module.
Definition SIAFD.cc:105
#define PISM_ERROR_LOCATION