PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
PicoGeometry.hh
Go to the documentation of this file.
1 /* Copyright (C) 2018, 2020, 2021, 2022, 2023 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 PICOGEOMETRY_H
21 #define PICOGEOMETRY_H
22 
23 #include <map>
24 #include <set>
25 
26 #include "pism/util/Component.hh"
27 #include "pism/util/array/Scalar.hh"
28 
29 namespace pism {
30 namespace ocean {
31 
32 void eikonal_equation(array::Scalar1 &mask);
33 
34 /*!
35  * This class isolates geometric computations performed by the PICO ocean model.
36  */
37 class PicoGeometry : public Component {
38 public:
39  PicoGeometry(std::shared_ptr<const Grid> grid);
40  virtual ~PicoGeometry() = default;
41 
42  void init();
43  void update(const array::Scalar &bed_elevation,
44  const array::CellType1 &cell_type);
45 
47  const array::Scalar &box_mask() const;
48  const array::Scalar &ice_shelf_mask() const;
49  const array::Scalar &ice_rise_mask() const;
50  const array::Scalar &basin_mask() const;
51 
52  enum IceRiseMask { OCEAN = 0, RISE = 1, CONTINENTAL = 2, FLOATING = 3 };
53 
54 private:
55  void compute_ice_rises(const array::CellType &cell_type,
56  bool exclude_ice_rises, array::Scalar &result);
57  void compute_lakes(const array::CellType &cell_type, array::Scalar &result);
58  void compute_ocean_mask(const array::CellType &cell_type, array::Scalar &result);
59  void compute_continental_shelf_mask(const array::Scalar &bed_elevation,
61  double bed_elevation_threshold,
62  array::Scalar &result);
64  const array::Scalar &lake_mask,
65  array::Scalar &result);
66 
67  std::vector<std::set<int> > basin_neighbors(const array::CellType1 &cell_type,
68  const array::Scalar1 &basin_mask);
69 
72  const array::Scalar &shelf_mask,
73  int n_shelves,
74  std::vector<int> &most_shelf_cells_in_basin,
75  std::vector<int> &cfs_in_basins_per_shelf);
76 
77  void split_ice_shelves(const array::CellType &cell_type,
79  const std::vector<std::set<int> > &basin_neighbors,
80  const std::vector<int> &most_shelf_cells_in_basin,
81  const std::vector<int> &cfs_in_basins_per_shelf,
82  int n_shelves,
83  array::Scalar &shelf_mask);
84 
85  void compute_distances_cf(const array::Scalar1 &ocean_mask,
86  const array::Scalar &ice_rises,
87  bool exclude_ice_rises,
88  array::Scalar1 &result);
89 
90  void compute_distances_gl(const array::Scalar &ocean_mask,
91  const array::Scalar1 &ice_rises,
92  bool exclude_ice_rises,
93  array::Scalar1 &result);
94 
95  void compute_box_mask(const array::Scalar &D_gl,
96  const array::Scalar &D_cf,
97  const array::Scalar &shelf_mask,
98  int max_number_of_boxes,
99  array::Scalar &result);
100 
102 
103  // storage for outputs
108 
109  // storage for intermediate fields
115 
116  // temporary storage
118  std::shared_ptr<petsc::Vec> m_tmp_p0;
119 
121  std::vector<std::set<int> > m_basin_neighbors;
122 };
123 
124 } // end of namespace ocean
125 } // end of namespace pism
126 
127 #endif /* PICOGEOMETRY_H */
std::shared_ptr< const Grid > grid() const
Definition: Component.cc:105
A class defining a common interface for most PISM sub-models.
Definition: Component.hh:118
"Cell type" mask. Adds convenience methods to array::Scalar.
Definition: CellType.hh:30
const array::Scalar & continental_shelf_mask() const
Definition: PicoGeometry.cc:69
void split_ice_shelves(const array::CellType &cell_type, const array::Scalar &basin_mask, const std::vector< std::set< int > > &basin_neighbors, const std::vector< int > &most_shelf_cells_in_basin, const std::vector< int > &cfs_in_basins_per_shelf, int n_shelves, array::Scalar &shelf_mask)
array::Scalar m_continental_shelf
std::shared_ptr< petsc::Vec > m_tmp_p0
void compute_box_mask(const array::Scalar &D_gl, const array::Scalar &D_cf, const array::Scalar &shelf_mask, int max_number_of_boxes, array::Scalar &result)
array::Scalar1 m_ice_rises
PicoGeometry(std::shared_ptr< const Grid > grid)
Definition: PicoGeometry.cc:33
void compute_ocean_mask(const array::CellType &cell_type, array::Scalar &result)
const array::Scalar & ice_shelf_mask() const
Definition: PicoGeometry.cc:77
array::Scalar1 m_distance_gl
void compute_distances_gl(const array::Scalar &ocean_mask, const array::Scalar1 &ice_rises, bool exclude_ice_rises, array::Scalar1 &result)
void compute_distances_cf(const array::Scalar1 &ocean_mask, const array::Scalar &ice_rises, bool exclude_ice_rises, array::Scalar1 &result)
std::vector< std::set< int > > basin_neighbors(const array::CellType1 &cell_type, const array::Scalar1 &basin_mask)
const array::Scalar & ice_rise_mask() const
Definition: PicoGeometry.cc:81
void compute_ice_shelf_mask(const array::Scalar &ice_rise_mask, const array::Scalar &lake_mask, array::Scalar &result)
array::Scalar1 m_basin_mask
void compute_ice_rises(const array::CellType &cell_type, bool exclude_ice_rises, array::Scalar &result)
array::Scalar1 m_ocean_mask
std::vector< std::set< int > > m_basin_neighbors
void compute_lakes(const array::CellType &cell_type, array::Scalar &result)
void relabel_by_size(array::Scalar &mask)
void update(const array::Scalar &bed_elevation, const array::CellType1 &cell_type)
void compute_continental_shelf_mask(const array::Scalar &bed_elevation, const array::Scalar &ice_rise_mask, double bed_elevation_threshold, array::Scalar &result)
const array::Scalar & basin_mask() const
Definition: PicoGeometry.cc:85
const array::Scalar & box_mask() const
Definition: PicoGeometry.cc:73
array::Scalar1 m_distance_cf
void identify_calving_front_connection(const array::CellType1 &cell_type, const array::Scalar &basin_mask, const array::Scalar &shelf_mask, int n_shelves, std::vector< int > &most_shelf_cells_in_basin, std::vector< int > &cfs_in_basins_per_shelf)
virtual ~PicoGeometry()=default
bool ocean(int M)
An ocean cell (floating ice or ice-free).
Definition: Mask.hh:40
void eikonal_equation(array::Scalar1 &mask)