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
SIAFD_Regional.cc
Go to the documentation of this file.
1/* Copyright (C) 2015, 2016, 2017, 2019, 2022, 2023, 2024 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
24namespace pism {
25
26namespace stressbalance {
27
28SIAFD_Regional::SIAFD_Regional(std::shared_ptr<const Grid> grid)
29 : SIAFD(grid),
30 m_h_x_no_model(grid, "h_x_no_model"),
31 m_h_y_no_model(grid, "h_y_no_model") {
32 // empty
33}
34
36
38
39 m_log->message(2, " using the regional version of the SIA solver...\n");
40}
41
44 array::Staggered1 &h_y) {
45
46 SIAFD::compute_surface_gradient(inputs, h_x, h_y);
47
48 if (inputs.no_model_surface_elevation == nullptr) {
50 "no_model surface elevation was not provided to SIAFD_Regional");
51 }
52
53 // this call updates ghosts of h_x_no_model and h_y_no_model
55 inputs.geometry->cell_type,
57
58 const array::Scalar2 &no_model = *inputs.no_model_mask;
59
60 const int Mx = m_grid->Mx(), My = m_grid->My();
61
62 array::AccessScope list{&h_x, &h_y, &no_model, &m_h_x_no_model, &m_h_y_no_model};
63
64 for (auto p = m_grid->points(1); p; p.next()) {
65 const int i = p.i(), j = p.j();
66
67 auto M = no_model.box(i, j);
68
69 // x-component, i-offset
70 if (M.c > 0.5 or M.e > 0.5) {
71
72 if (i < 0 or i + 1 > Mx - 1) {
73 h_x(i, j, 0) = 0.0;
74 } else {
75 h_x(i, j, 0) = m_h_x_no_model(i, j, 0);
76 }
77 }
78
79 // x-component, j-offset
80 if (M.nw > 0.5 or M.ne > 0.5 or M.w > 0.5 or M.e > 0.5) {
81
82 if (i - 1 < 0 or j + 1 > My - 1 or i + 1 > Mx - 1) {
83 h_x(i, j, 1) = 0.0;
84 } else {
85 h_x(i, j, 1) = m_h_x_no_model(i, j, 1);
86 }
87
88 }
89
90 // y-component, i-offset
91 if (M.n > 0.5 or M.ne > 0.5 or M.s > 0.5 or M.se > 0.5) {
92
93 if (i < 0 or j + 1 > My - 1 or i + 1 > Mx - 1 or j - 1 < 0) {
94 h_y(i, j, 0) = 0.0;
95 } else {
96 h_y(i, j, 0) = m_h_y_no_model(i, j, 0);
97 }
98
99 }
100
101 // y-component, j-offset
102 if (M.c > 0.5 or M.n > 0.5) {
103
104 if (j < 0 or j + 1 > My - 1) {
105 h_y(i, j, 1) = 0.0;
106 } else {
107 h_y(i, j, 1) = m_h_y_no_model(i, j, 1);
108 }
109
110 }
111 } // end of the loop over grid points
112}
113
114} // end of namespace stressbalance
115
116} // end of namespace pism
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
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:64
stencils::Box< T > box(int i, int j) const
Definition Array2D.hh:93
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:188
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:360
virtual void init()
Initialize the SIA module.
Definition SIAFD.cc:103
#define PISM_ERROR_LOCATION