PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
fracture_density.cc
Go to the documentation of this file.
1 // Copyright (C) 2011-2020, 2023 Torsten Albrecht and Constantine Khroulev
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 2 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 "pism/icemodel/IceModel.hh"
20 
21 #include "pism/energy/EnergyModel.hh"
22 #include "pism/stressbalance/ShallowStressBalance.hh"
23 #include "pism/fracturedensity/FractureDensity.hh"
24 
25 namespace pism {
26 
28  // generate the BC mask for the fracture density model
29  //
30  // This mask contains ones at the in-flow boundary according to the SSA Dirichlet BC
31  // mask (if it is used) and at grounded grid points if
32  // fracture_density.include_grounded_ice is not set.
33  auto &bc_mask = *m_work2d[0];
34  {
35  bool do_fracground = m_config->get_flag("fracture_density.include_grounded_ice");
36  const bool dirichlet_bc = m_config->get_flag("stress_balance.ssa.dirichlet_bc");
37 
38  bc_mask.set(0.0);
39 
40  array::AccessScope list{&bc_mask, &m_geometry.cell_type};
41 
42  if (dirichlet_bc) {
43  list.add(m_velocity_bc_mask);
44  list.add(m_velocity_bc_values);
45  }
46 
47  for (auto p = m_grid->points(); p; p.next()) {
48  const int i = p.i(), j = p.j();
49 
50  if (m_geometry.cell_type.grounded(i, j) and not do_fracground) {
51  bc_mask(i, j) = 1.0;
52  }
53 
54  if (dirichlet_bc) {
55  if (m_velocity_bc_mask(i, j) > 0.5 and
56  (m_velocity_bc_values(i, j).u != 0.0 or
57  m_velocity_bc_values(i, j).v != 0.0)) {
58  bc_mask(i, j) = 1.0;
59  }
60  }
61  } // end of the loop over grid points
62  }
63 
64  // compute the vertically-averaged ice hardness
65  auto &hardness = *m_work2d[1];
66  {
67  rheology::averaged_hardness_vec(*m_stress_balance->shallow()->flow_law(),
69  m_energy_model->enthalpy(),
70  hardness);
71  }
72 
73  // This model has the same time-step restriction as the mass transport code so we don't
74  // check if this time step is short enough.
75  m_fracture->update(m_dt, m_geometry,
76  m_stress_balance->shallow()->velocity(),
77  hardness, bc_mask);
78 }
79 
80 } // end of namespace pism
array::CellType2 cell_type
Definition: Geometry.hh:55
array::Scalar2 ice_thickness
Definition: Geometry.hh:51
std::shared_ptr< stressbalance::StressBalance > m_stress_balance
Definition: IceModel.hh:397
const Config::Ptr m_config
Configuration flags and parameters.
Definition: IceModel.hh:243
std::shared_ptr< FractureDensity > m_fracture
Definition: IceModel.hh:306
Geometry m_geometry
Definition: IceModel.hh:295
std::vector< std::shared_ptr< array::Scalar2 > > m_work2d
Definition: IceModel.hh:393
array::Scalar2 m_velocity_bc_mask
mask to determine Dirichlet boundary locations for the sliding velocity
Definition: IceModel.hh:309
array::Vector2 m_velocity_bc_values
Dirichlet boundary velocities.
Definition: IceModel.hh:311
virtual void update_fracture_density()
double m_dt
mass continuity time step, s
Definition: IceModel.hh:318
std::shared_ptr< energy::EnergyModel > m_energy_model
Definition: IceModel.hh:267
const std::shared_ptr< Grid > m_grid
Computational grid.
Definition: IceModel.hh:241
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition: Array.hh:65
void add(double alpha, const Array2D< T > &x)
Definition: Array2D.hh:65
bool grounded(int i, int j) const
Definition: CellType.hh:38
void averaged_hardness_vec(const FlowLaw &ice, const array::Scalar &thickness, const array::Array3D &enthalpy, array::Scalar &result)
Definition: FlowLaw.cc:181