tIceModelVec2CellType.hh - 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
---
tIceModelVec2CellType.hh (3490B)
---
1 /* Copyright (C) 2016, 2019 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 #ifndef ICEMODELVEC2CELLTYPE_H
21 #define ICEMODELVEC2CELLTYPE_H
22
23 #include "iceModelVec.hh"
24 #include "Mask.hh"
25
26 namespace pism {
27
28 //! "Cell type" mask. Adds convenience methods to IceModelVec2Int.
29 class IceModelVec2CellType : public IceModelVec2Int {
30 public:
31
32 typedef std::shared_ptr<IceModelVec2CellType> Ptr;
33 typedef std::shared_ptr<const IceModelVec2CellType> ConstPtr;
34 IceModelVec2CellType()
35 : IceModelVec2Int() {
36 // empty
37 }
38
39 IceModelVec2CellType(IceGrid::ConstPtr grid, const std::string &name,
40 IceModelVecKind ghostedp, int width = 1)
41 : IceModelVec2Int(grid, name, ghostedp, width) {
42 // empty
43 }
44
45 inline bool ocean(int i, int j) const {
46 return mask::ocean(as_int(i, j));
47 }
48
49 inline bool grounded(int i, int j) const {
50 return mask::grounded(as_int(i, j));
51 }
52
53 inline bool icy(int i, int j) const {
54 return mask::icy(as_int(i, j));
55 }
56
57 inline bool grounded_ice(int i, int j) const {
58 return mask::grounded_ice(as_int(i, j));
59 }
60
61 inline bool floating_ice(int i, int j) const {
62 return mask::floating_ice(as_int(i, j));
63 }
64
65 inline bool ice_free(int i, int j) const {
66 return mask::ice_free(as_int(i, j));
67 }
68
69 inline bool ice_free_ocean(int i, int j) const {
70 return mask::ice_free_ocean(as_int(i, j));
71 }
72
73 inline bool ice_free_land(int i, int j) const {
74 return mask::ice_free_land(as_int(i, j));
75 }
76
77 //! \brief Ice margin (ice-filled with at least one of four neighbors ice-free).
78 inline bool ice_margin(int i, int j) const {
79 return icy(i, j) and (ice_free(i + 1, j) or ice_free(i - 1, j) or
80 ice_free(i, j + 1) or ice_free(i, j - 1));
81 }
82
83 //! \brief Ice-free margin (at least one of four neighbors has ice).
84 inline bool next_to_ice(int i, int j) const {
85 return (icy(i + 1, j) or icy(i - 1, j) or icy(i, j + 1) or icy(i, j - 1));
86 }
87
88 inline bool next_to_floating_ice(int i, int j) const {
89 return (floating_ice(i + 1, j) or floating_ice(i - 1, j) or
90 floating_ice(i, j + 1) or floating_ice(i, j - 1));
91 }
92
93 inline bool next_to_grounded_ice(int i, int j) const {
94 return (grounded_ice(i + 1, j) or grounded_ice(i - 1, j) or
95 grounded_ice(i, j + 1) or grounded_ice(i, j - 1));
96 }
97
98 inline bool next_to_ice_free_land(int i, int j) const {
99 return (ice_free_land(i + 1, j) or ice_free_land(i - 1, j) or
100 ice_free_land(i, j + 1) or ice_free_land(i, j - 1));
101 }
102
103 inline bool next_to_ice_free_ocean(int i, int j) const {
104 return (ice_free_ocean(i + 1, j) or ice_free_ocean(i - 1, j) or
105 ice_free_ocean(i, j + 1) or ice_free_ocean(i, j - 1));
106 }
107 };
108
109 } // end of namespace pism
110
111
112 #endif /* ICEMODELVEC2CELLTYPE_H */