URI:
       tMask.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
       ---
       tMask.cc (2893B)
       ---
            1 // Copyright (C) 2011, 2014, 2015, 2016, 2017, 2018 Constantine Khroulev and David Maxwell
            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 #include <cassert>
           20 
           21 #include "Mask.hh"
           22 #include "IceGrid.hh"
           23 
           24 namespace pism {
           25 
           26 void GeometryCalculator::compute(const IceModelVec2S& sea_level,
           27                                  const IceModelVec2S& bed,
           28                                  const IceModelVec2S& thickness,
           29                                  IceModelVec2Int& out_mask,
           30                                  IceModelVec2S& out_surface) const {
           31   compute_mask(sea_level, bed, thickness, out_mask);
           32   compute_surface(sea_level, bed, thickness, out_surface);
           33 }
           34 
           35 void GeometryCalculator::compute_mask(const IceModelVec2S &sea_level,
           36                                       const IceModelVec2S &bed,
           37                                       const IceModelVec2S &thickness,
           38                                       IceModelVec2Int &result) const {
           39   IceModelVec::AccessList list{&sea_level, &bed, &thickness, &result};
           40 
           41   const IceGrid &grid = *bed.grid();
           42 
           43   const unsigned int stencil = result.stencil_width();
           44   assert(sea_level.stencil_width() >= stencil);
           45   assert(bed.stencil_width()       >= stencil);
           46   assert(thickness.stencil_width() >= stencil);
           47 
           48   for (PointsWithGhosts p(grid, stencil); p; p.next()) {
           49     const int i = p.i(), j = p.j();
           50 
           51     result(i,j) = this->mask(sea_level(i, j), bed(i, j), thickness(i, j));
           52   }
           53 }
           54 
           55 void GeometryCalculator::compute_surface(const IceModelVec2S &sea_level,
           56                                          const IceModelVec2S &bed,
           57                                          const IceModelVec2S &thickness,
           58                                          IceModelVec2S &result) const {
           59   IceModelVec::AccessList list{&sea_level, &bed, &thickness, &result};
           60 
           61   const IceGrid &grid = *bed.grid();
           62 
           63   const unsigned int stencil = result.stencil_width();
           64   assert(sea_level.stencil_width() >= stencil);
           65   assert(bed.stencil_width()       >= stencil);
           66   assert(thickness.stencil_width() >= stencil);
           67 
           68   for (PointsWithGhosts p(grid, stencil); p; p.next()) {
           69     const int i = p.i(), j = p.j();
           70 
           71     result(i,j) = this->surface(sea_level(i, j), bed(i, j), thickness(i, j));
           72   }
           73 }
           74 
           75 } // end of namespace pism