PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
SIAFD_Regional.cc
Go to the documentation of this file.
1 /* Copyright (C) 2015, 2016, 2017, 2019, 2022, 2023 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 
24 namespace pism {
25 
26 namespace stressbalance {
27 
28 SIAFD_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 
37  SIAFD::init();
38 
39  m_log->message(2, " using the regional version of the SIA solver...\n");
40 }
41 
43  array::Staggered1 &h_x,
44  array::Staggered1 &h_y) {
45 
46  SIAFD::compute_surface_gradient(inputs, h_x, h_y);
47 
48  // this call updates ghosts of h_x_no_model and h_y_no_model
50  inputs.geometry->cell_type,
52 
53  const array::Scalar2 &no_model = *inputs.no_model_mask;
54 
55  const int Mx = m_grid->Mx(), My = m_grid->My();
56 
57  array::AccessScope list{&h_x, &h_y, &no_model, &m_h_x_no_model, &m_h_y_no_model};
58 
59  for (auto p = m_grid->points(1); p; p.next()) {
60  const int i = p.i(), j = p.j();
61 
62  auto M = no_model.box(i, j);
63 
64  // x-component, i-offset
65  if (M.c > 0.5 or M.e > 0.5) {
66 
67  if (i < 0 or i + 1 > Mx - 1) {
68  h_x(i, j, 0) = 0.0;
69  } else {
70  h_x(i, j, 0) = m_h_x_no_model(i, j, 0);
71  }
72  }
73 
74  // x-component, j-offset
75  if (M.nw > 0.5 or M.ne > 0.5 or M.w > 0.5 or M.e > 0.5) {
76 
77  if (i - 1 < 0 or j + 1 > My - 1 or i + 1 > Mx - 1) {
78  h_x(i, j, 1) = 0.0;
79  } else {
80  h_x(i, j, 1) = m_h_x_no_model(i, j, 1);
81  }
82 
83  }
84 
85  // y-component, i-offset
86  if (M.n > 0.5 or M.ne > 0.5 or M.s > 0.5 or M.se > 0.5) {
87 
88  if (i < 0 or j + 1 > My - 1 or i + 1 > Mx - 1 or j - 1 < 0) {
89  h_y(i, j, 0) = 0.0;
90  } else {
91  h_y(i, j, 0) = m_h_y_no_model(i, j, 0);
92  }
93 
94  }
95 
96  // y-component, j-offset
97  if (M.c > 0.5 or M.n > 0.5) {
98 
99  if (j < 0 or j + 1 > My - 1) {
100  h_y(i, j, 1) = 0.0;
101  } else {
102  h_y(i, j, 1) = m_h_y_no_model(i, j, 1);
103  }
104 
105  }
106  } // end of the loop over grid points
107 }
108 
109 } // end of namespace stressbalance
110 
111 } // 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
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition: Array.hh:65
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