PISM, A Parallel Ice Sheet Model  stable v2.0.5 committed by Constantine Khrulev on 2022-10-14 09:56:26 -0800
IceModelVec2CellType.hh
Go to the documentation of this file.
1 /* Copyright (C) 2016, 2019, 2020 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.
30 public:
31 
32  typedef std::shared_ptr<IceModelVec2CellType> Ptr;
33  typedef std::shared_ptr<const IceModelVec2CellType> ConstPtr;
34 
35  IceModelVec2CellType(IceGrid::ConstPtr grid, const std::string &name,
36  IceModelVecKind ghostedp, int width = 1)
37  : IceModelVec2Int(grid, name, ghostedp, width) {
38  // empty
39  }
40 
41  inline bool ocean(int i, int j) const {
42  return mask::ocean(as_int(i, j));
43  }
44 
45  inline bool grounded(int i, int j) const {
46  return mask::grounded(as_int(i, j));
47  }
48 
49  inline bool icy(int i, int j) const {
50  return mask::icy(as_int(i, j));
51  }
52 
53  inline bool grounded_ice(int i, int j) const {
54  return mask::grounded_ice(as_int(i, j));
55  }
56 
57  inline bool floating_ice(int i, int j) const {
58  return mask::floating_ice(as_int(i, j));
59  }
60 
61  inline bool ice_free(int i, int j) const {
62  return mask::ice_free(as_int(i, j));
63  }
64 
65  inline bool ice_free_ocean(int i, int j) const {
66  return mask::ice_free_ocean(as_int(i, j));
67  }
68 
69  inline bool ice_free_land(int i, int j) const {
70  return mask::ice_free_land(as_int(i, j));
71  }
72 
73  //! \brief Ice margin (ice-filled with at least one of four neighbors ice-free).
74  inline bool ice_margin(int i, int j) const {
75  return icy(i, j) and (ice_free(i + 1, j) or ice_free(i - 1, j) or
76  ice_free(i, j + 1) or ice_free(i, j - 1));
77  }
78 
79  //! \brief Ice-free margin (at least one of four neighbors has ice).
80  inline bool next_to_ice(int i, int j) const {
81  return (icy(i + 1, j) or icy(i - 1, j) or icy(i, j + 1) or icy(i, j - 1));
82  }
83 
84  inline bool next_to_floating_ice(int i, int j) const {
85  return (floating_ice(i + 1, j) or floating_ice(i - 1, j) or
86  floating_ice(i, j + 1) or floating_ice(i, j - 1));
87  }
88 
89  inline bool next_to_grounded_ice(int i, int j) const {
90  return (grounded_ice(i + 1, j) or grounded_ice(i - 1, j) or
91  grounded_ice(i, j + 1) or grounded_ice(i, j - 1));
92  }
93 
94  inline bool next_to_ice_free_land(int i, int j) const {
95  return (ice_free_land(i + 1, j) or ice_free_land(i - 1, j) or
96  ice_free_land(i, j + 1) or ice_free_land(i, j - 1));
97  }
98 
99  inline bool next_to_ice_free_ocean(int i, int j) const {
100  return (ice_free_ocean(i + 1, j) or ice_free_ocean(i - 1, j) or
101  ice_free_ocean(i, j + 1) or ice_free_ocean(i, j - 1));
102  }
103 };
104 
105 } // end of namespace pism
106 
107 
108 #endif /* ICEMODELVEC2CELLTYPE_H */
std::shared_ptr< const IceGrid > ConstPtr
Definition: IceGrid.hh:233
bool ice_margin(int i, int j) const
Ice margin (ice-filled with at least one of four neighbors ice-free).
bool next_to_ice(int i, int j) const
Ice-free margin (at least one of four neighbors has ice).
bool next_to_ice_free_ocean(int i, int j) const
IceModelVec2CellType(IceGrid::ConstPtr grid, const std::string &name, IceModelVecKind ghostedp, int width=1)
bool ice_free_land(int i, int j) const
bool icy(int i, int j) const
bool next_to_floating_ice(int i, int j) const
bool ice_free_ocean(int i, int j) const
bool next_to_ice_free_land(int i, int j) const
bool ocean(int i, int j) const
bool grounded(int i, int j) const
bool floating_ice(int i, int j) const
bool next_to_grounded_ice(int i, int j) const
std::shared_ptr< const IceModelVec2CellType > ConstPtr
bool ice_free(int i, int j) const
bool grounded_ice(int i, int j) const
std::shared_ptr< IceModelVec2CellType > Ptr
"Cell type" mask. Adds convenience methods to IceModelVec2Int.
int as_int(int i, int j) const
A simple class "hiding" the fact that the mask is stored as floating-point scalars (instead of intege...
Definition: iceModelVec.hh:389
IceGrid::ConstPtr grid() const
Definition: iceModelVec.cc:128
bool icy(int M)
Ice-filled cell (grounded or floating).
Definition: Mask.hh:47
bool grounded_ice(int M)
Definition: Mask.hh:50
bool ice_free_land(int M)
Definition: Mask.hh:63
bool ice_free_ocean(int M)
Definition: Mask.hh:60
bool grounded(int M)
Grounded cell (grounded ice or ice-free).
Definition: Mask.hh:43
bool ice_free(int M)
Ice-free cell (grounded or ocean).
Definition: Mask.hh:57
bool floating_ice(int M)
Definition: Mask.hh:53
bool ocean(int M)
An ocean cell (floating ice or ice-free).
Definition: Mask.hh:39
IceModelVecKind
What "kind" of a vector to create: with or without ghosts.
Definition: iceModelVec.hh:49