URI:
       tFloatKill.cc - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
  HTML git clone git://src.adamsgaard.dk/pism
   DIR Log
   DIR Files
   DIR Refs
   DIR LICENSE
       ---
       tFloatKill.cc (2722B)
       ---
            1 /* Copyright (C) 2013, 2014, 2015, 2016, 2017 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 "FloatKill.hh"
           21 
           22 #include "pism/util/Mask.hh"
           23 #include "pism/util/iceModelVec.hh"
           24 #include "pism/util/IceGrid.hh"
           25 #include "pism/util/pism_utilities.hh"
           26 #include "pism/util/IceModelVec2CellType.hh"
           27 
           28 namespace pism {
           29 namespace calving {
           30 
           31 FloatKill::FloatKill(IceGrid::ConstPtr g)
           32   : Component(g) {
           33   m_margin_only = m_config->get_flag("calving.float_kill.margin_only");
           34   m_calve_near_grounding_line = m_config->get_flag("calving.float_kill.calve_near_grounding_line");
           35 }
           36 
           37 FloatKill::~FloatKill() {
           38   // empty
           39 }
           40 
           41 void FloatKill::init() {
           42   m_log->message(2,
           43                  "* Initializing calving using the floatation criterion (float_kill)...\n");
           44 
           45   if (m_margin_only) {
           46     m_log->message(2,
           47                    "  [only cells at the ice margin are calved during a given time step]\n");
           48   }
           49 
           50   if (not m_calve_near_grounding_line) {
           51     m_log->message(2,
           52                    "  [keeping floating cells near the grounding line]\n");
           53   }
           54 }
           55 
           56 /**
           57  * Updates ice cover mask and the ice thickness using the calving rule
           58  * removing all floating ice.
           59  *
           60  * @param[in,out] pism_mask ice cover (cell type) mask
           61  * @param[in,out] ice_thickness ice thickness
           62  *
           63  * @return 0 on success
           64  */
           65 void FloatKill::update(IceModelVec2CellType &mask, IceModelVec2S &ice_thickness) {
           66 
           67   IceModelVec::AccessList list{&mask, &ice_thickness};
           68 
           69   const bool dont_calve_near_grounded_ice = not m_calve_near_grounding_line;
           70 
           71   for (Points p(*m_grid); p; p.next()) {
           72     const int i = p.i(), j = p.j();
           73 
           74     if (mask.floating_ice(i, j)) {
           75       if (m_margin_only and not mask.next_to_ice_free_ocean(i, j)) {
           76         continue;
           77       }
           78 
           79       if (dont_calve_near_grounded_ice and mask.next_to_grounded_ice(i, j)) {
           80         continue;
           81       }
           82 
           83       ice_thickness(i, j) = 0.0;
           84       mask(i, j)          = MASK_ICE_FREE_OCEAN;
           85     }
           86   }
           87 
           88   mask.update_ghosts();
           89   ice_thickness.update_ghosts();
           90 }
           91 
           92 } // end of namespace calving
           93 } // end of namespace pism