Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.1-cd005eec8 committed by Constantine Khrulev on 2025-03-07
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IcebergRemover.cc
Go to the documentation of this file.
1/* Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 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/frontretreat/util/IcebergRemover.hh"
21#include "pism/util/connected_components/label_components.hh"
22#include "pism/util/Mask.hh"
23#include "pism/util/error_handling.hh"
24#include "pism/util/Grid.hh"
25#include "pism/util/array/CellType.hh"
26#include "pism/util/petscwrappers/Vec.hh"
27
28namespace pism {
29namespace calving {
30
31IcebergRemover::IcebergRemover(std::shared_ptr<const Grid> g)
32 : Component(g), m_iceberg_mask(m_grid, "iceberg_mask") {
33}
34
35/**
36 * Use PISM's ice cover mask to update ice thickness, removing "icebergs".
37 *
38 * @param[in,out] pism_mask PISM's ice cover mask
39 * @param[in,out] ice_thickness ice thickness
40 */
42 array::CellType1 &cell_type,
43 array::Scalar &ice_thickness) {
44 update_impl(bc_mask, cell_type, ice_thickness);
45}
46
48 array::CellType1 &cell_type,
49 array::Scalar &ice_thickness) {
50 const int
51 mask_grounded_ice = 1,
52 mask_floating_ice = 2;
53
54 // prepare the mask that will be handed to the connected component
55 // labeling code:
56 {
58
59 array::AccessScope list{&cell_type, &m_iceberg_mask, &bc_mask};
60
61 for (auto p = m_grid->points(); p; p.next()) {
62 const int i = p.i(), j = p.j();
63
64 if (cell_type.grounded_ice(i,j)) {
65 m_iceberg_mask(i,j) = mask_grounded_ice;
66 } else if (cell_type.floating_ice(i,j)) {
67 m_iceberg_mask(i,j) = mask_floating_ice;
68 }
69 }
70
71 // Mark icy Dirichlet B.C. cells as "grounded" because we don't want them removed.
72 for (auto p = m_grid->points(); p; p.next()) {
73 const int i = p.i(), j = p.j();
74
75 if (bc_mask(i, j) > 0.5 and cell_type.icy(i, j)) {
76 m_iceberg_mask(i, j) = mask_grounded_ice;
77 }
78 }
79 }
80
82
83 // correct ice thickness and the cell type mask using the resulting
84 // "iceberg" mask:
85 {
86 array::AccessScope list{&ice_thickness, &cell_type, &m_iceberg_mask, &bc_mask};
87
88 for (auto p = m_grid->points(); p; p.next()) {
89 const int i = p.i(), j = p.j();
90
91 if (m_iceberg_mask(i,j) > 0.5 && bc_mask(i,j) < 0.5) {
92 ice_thickness(i,j) = 0.0;
93 cell_type(i,j) = MASK_ICE_FREE_OCEAN;
94 }
95 }
96 }
97
98 // update ghosts of the cell_type and the ice thickness (then surface
99 // elevation can be updated redundantly)
100 cell_type.update_ghosts();
101 ice_thickness.update_ghosts();
102}
103
104} // end of namespace calving
105} // end of namespace pism
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition Component.hh:156
A class defining a common interface for most PISM sub-models.
Definition Component.hh:118
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:64
void set(double c)
Result: v[j] <- c for all j.
Definition Array.cc:629
void update_ghosts()
Updates ghost points.
Definition Array.cc:615
bool floating_ice(int i, int j) const
Definition CellType.hh:50
bool grounded_ice(int i, int j) const
Definition CellType.hh:46
bool icy(int i, int j) const
Definition CellType.hh:42
virtual void update_impl(const array::Scalar &bc_mask, array::CellType1 &cell_type, array::Scalar &ice_thickness)
void update(const array::Scalar &bc_mask, array::CellType1 &cell_type, array::Scalar &ice_thickness)
IcebergRemover(std::shared_ptr< const Grid > g)
void label_isolated(array::Scalar1 &mask, int reachable)
static const double g
Definition exactTestP.cc:36
@ MASK_ICE_FREE_OCEAN
Definition Mask.hh:35