PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
FloatKill.cc
Go to the documentation of this file.
1 /* Copyright (C) 2013, 2014, 2015, 2016, 2017, 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/frontretreat/calving/FloatKill.hh"
21 
22 #include "pism/util/Mask.hh"
23 #include "pism/util/Grid.hh"
24 #include "pism/util/array/CellType.hh"
25 
26 namespace pism {
27 namespace calving {
28 
29 FloatKill::FloatKill(std::shared_ptr<const Grid> g)
30  : Component(g),
31  m_old_mask(m_grid, "old_mask") {
32  m_margin_only = m_config->get_flag("calving.float_kill.margin_only");
33  m_calve_near_grounding_line = m_config->get_flag("calving.float_kill.calve_near_grounding_line");
34 }
35 
37  m_log->message(2,
38  "* Initializing calving using the floatation criterion (float_kill)...\n");
39 
40  if (m_margin_only) {
41  m_log->message(2,
42  " [only cells at the ice margin are calved during a given time step]\n");
43  }
44 
46  m_log->message(2,
47  " [keeping floating cells near the grounding line]\n");
48  }
49 }
50 
51 /**
52  * Updates ice cover mask and the ice thickness using the calving rule
53  * removing all floating ice.
54  *
55  * @param[in,out] pism_mask ice cover (cell type) mask
56  * @param[in,out] ice_thickness ice thickness
57  *
58  * @return 0 on success
59  */
60 void FloatKill::update(array::Scalar &cell_type, array::Scalar &ice_thickness) {
61 
62  // this call fills ghosts of m_old_mask
63  m_old_mask.copy_from(cell_type);
64 
65  array::AccessScope list{&cell_type, &m_old_mask, &ice_thickness};
66 
67  const bool dont_calve_near_grounded_ice = not m_calve_near_grounding_line;
68 
69  for (auto p = m_grid->points(); p; p.next()) {
70  const int i = p.i(), j = p.j();
71 
72  if (m_old_mask.floating_ice(i, j)) {
74  continue;
75  }
76 
77  if (dont_calve_near_grounded_ice and m_old_mask.next_to_grounded_ice(i, j)) {
78  continue;
79  }
80 
81  ice_thickness(i, j) = 0.0;
82  cell_type(i, j) = MASK_ICE_FREE_OCEAN;
83  }
84  }
85 
86  cell_type.update_ghosts();
87  ice_thickness.update_ghosts();
88 }
89 
90 } // end of namespace calving
91 } // end of namespace pism
const Config::ConstPtr m_config
configuration database used by this component
Definition: Component.hh:158
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
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:65
void copy_from(const Array2D< T > &source)
Definition: Array2D.hh:73
void update_ghosts()
Updates ghost points.
Definition: Array.cc:693
bool next_to_grounded_ice(int i, int j) const
Definition: CellType.hh:96
bool next_to_ice_free_ocean(int i, int j) const
Definition: CellType.hh:106
bool floating_ice(int i, int j) const
Definition: CellType.hh:50
array::CellType1 m_old_mask
Definition: FloatKill.hh:43
virtual void init()
Definition: FloatKill.cc:36
FloatKill(std::shared_ptr< const Grid > g)
Definition: FloatKill.cc:29
void update(array::Scalar &cell_type, array::Scalar &ice_thickness)
Definition: FloatKill.cc:60
static const double g
Definition: exactTestP.cc:36
@ MASK_ICE_FREE_OCEAN
Definition: Mask.hh:35