Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Mask.cc
Go to the documentation of this file.
1// Copyright (C) 2011, 2014, 2015, 2016, 2017, 2018, 2022, 2023 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 "pism/util/Mask.hh"
22#include "pism/util/Grid.hh"
23#include "pism/util/array/Scalar.hh"
24
25namespace pism {
26
28 const array::Scalar& bed,
29 const array::Scalar& thickness,
30 array::Scalar& out_mask,
31 array::Scalar& out_surface) const {
32 compute_mask(sea_level, bed, thickness, out_mask);
33 compute_surface(sea_level, bed, thickness, out_surface);
34}
35
37 const array::Scalar &bed,
38 const array::Scalar &thickness,
39 array::Scalar &result) const {
40 array::AccessScope list{&sea_level, &bed, &thickness, &result};
41
42 const Grid &grid = *bed.grid();
43
44 const unsigned int stencil = result.stencil_width();
45 assert(sea_level.stencil_width() >= stencil);
46 assert(bed.stencil_width() >= stencil);
47 assert(thickness.stencil_width() >= stencil);
48
49 for (auto p = grid.points(stencil); p; p.next()) {
50 const int i = p.i(), j = p.j();
51
52 result(i,j) = this->mask(sea_level(i, j), bed(i, j), thickness(i, j));
53 }
54}
55
57 const array::Scalar &bed,
58 const array::Scalar &thickness,
59 array::Scalar &result) const {
60 array::AccessScope list{&sea_level, &bed, &thickness, &result};
61
62 const Grid &grid = *bed.grid();
63
64 const unsigned int stencil = result.stencil_width();
65 assert(sea_level.stencil_width() >= stencil);
66 assert(bed.stencil_width() >= stencil);
67 assert(thickness.stencil_width() >= stencil);
68
69 for (auto p = grid.points(stencil); p; p.next()) {
70 const int i = p.i(), j = p.j();
71
72 result(i,j) = this->surface(sea_level(i, j), bed(i, j), thickness(i, j));
73 }
74}
75
76} // end of namespace pism
void compute_mask(const array::Scalar &sea_level, const array::Scalar &bed, const array::Scalar &thickness, array::Scalar &result) const
Definition Mask.cc:36
int mask(double sea_level, double bed, double thickness) const
Definition Mask.hh:138
double surface(double sea_level, double bed, double thickness) const
Definition Mask.hh:144
void compute(const array::Scalar &sea_level, const array::Scalar &bed, const array::Scalar &thickness, array::Scalar &out_mask, array::Scalar &out_surface) const
Definition Mask.cc:27
void compute_surface(const array::Scalar &sea_level, const array::Scalar &bed, const array::Scalar &thickness, array::Scalar &result) const
Definition Mask.cc:56
Describes the PISM grid and the distribution of data across processors.
Definition Grid.hh:290
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:64
std::shared_ptr< const Grid > grid() const
Definition Array.cc:131
unsigned int stencil_width() const
Get the stencil width of the current Array. Returns 0 if ghosts are not available.
Definition Array.cc:302