PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
SSB_Modifier.cc
Go to the documentation of this file.
1 // Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2022, 2023 Constantine Khroulev and Ed Bueler
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 "pism/stressbalance/SSB_Modifier.hh"
20 #include "pism/rheology/FlowLawFactory.hh"
21 #include "pism/rheology/FlowLaw.hh"
22 #include "pism/util/Grid.hh"
23 #include "pism/util/ConfigInterface.hh"
24 #include "pism/stressbalance/StressBalance.hh"
25 #include "pism/util/array/Vector.hh"
26 #include "pism/util/Context.hh"
27 
28 namespace pism {
29 namespace stressbalance {
30 
31 SSB_Modifier::SSB_Modifier(std::shared_ptr<const Grid> g)
32  : Component(g),
33  m_EC(g->ctx()->enthalpy_converter()),
34  m_diffusive_flux(m_grid, "diffusive_flux"),
35  m_u(m_grid, "uvel", array::WITH_GHOSTS, m_grid->z()),
36  m_v(m_grid, "vvel", array::WITH_GHOSTS, m_grid->z()) {
37  m_D_max = 0.0;
38 
39  m_u.metadata(0)
40  .long_name("horizontal velocity of ice in the X direction")
41  .units("m s-1")
42  .output_units("m year-1")
43  .standard_name("land_ice_x_velocity");
44 
45  m_v.metadata(0)
46  .long_name("horizontal velocity of ice in the Y direction")
47  .units("m s-1")
48  .output_units("m year-1")
49  .standard_name("land_ice_y_velocity");
50 
52  .long_name("diffusive (SIA) flux components on the staggered grid")
53  .units("m2 s-1");
54 }
55 
57 }
58 
60  return m_diffusive_flux;
61 }
62 
63 //! \brief Get the max diffusivity (for the adaptive time-stepping).
65  return m_D_max;
66 }
67 
69  return m_u;
70 }
71 
73  return m_v;
74 }
75 
76 std::string SSB_Modifier::stdout_report() const {
77  return "";
78 }
79 
80 std::shared_ptr<const rheology::FlowLaw> SSB_Modifier::flow_law() const {
81  return m_flow_law;
82 }
83 
86 }
87 
88 ConstantInColumn::ConstantInColumn(std::shared_ptr<const Grid> g)
89  : SSB_Modifier(g) {
90  rheology::FlowLawFactory ice_factory("stress_balance.sia.", m_config, m_EC);
91 
92  m_flow_law = ice_factory.create();
93 }
94 
95 
96 //! \brief Distribute the input velocity throughout the column.
97 /*!
98  * Things to update:
99  * - 3D-distributed horizontal velocity
100  * - maximum horizontal velocity
101  * - diffusive ice flux
102  * - maximum diffusivity
103  * - strain heating (strain_heating)
104  */
105 void ConstantInColumn::update(const array::Vector &sliding_velocity,
106  const Inputs &inputs,
107  bool full_update) {
108 
109  (void) inputs;
110 
111  if (not full_update) {
112  return;
113  }
114 
115  // horizontal velocity and its maximum:
116  array::AccessScope list{&m_u, &m_v, &sliding_velocity};
117 
118  for (auto p = m_grid->points(); p; p.next()) {
119  const int i = p.i(), j = p.j();
120 
121  m_u.set_column(i,j, sliding_velocity(i,j).u);
122  m_v.set_column(i,j, sliding_velocity(i,j).v);
123  }
124 
125  // Communicate to get ghosts (needed to compute w):
126  m_u.update_ghosts();
127  m_v.update_ghosts();
128 
129  // diffusive flux and maximum diffusivity
130  m_diffusive_flux.set(0.0);
131  m_D_max = 0.0;
132 }
133 
134 } // end of namespace stressbalance
135 } // end of namespace pism
const Config::ConstPtr m_config
configuration database used by this component
Definition: Component.hh:158
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition: Component.hh:156
A class defining a common interface for most PISM sub-models.
Definition: Component.hh:118
VariableMetadata & standard_name(const std::string &input)
VariableMetadata & long_name(const std::string &input)
VariableMetadata & output_units(const std::string &input)
VariableMetadata & units(const std::string &input)
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition: Array.hh:65
void set_column(int i, int j, double c)
Set all values of scalar quantity to given a single value in a particular column.
Definition: Array3D.cc:49
A virtual class collecting methods common to ice and bedrock 3D fields.
Definition: Array3D.hh:33
void set(double c)
Result: v[j] <- c for all j.
Definition: Array.cc:707
void update_ghosts()
Updates ghost points.
Definition: Array.cc:693
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
Definition: Array.cc:553
A class for storing and accessing internal staggered-grid 2D fields. Uses dof=2 storage....
Definition: Staggered.hh:35
std::shared_ptr< FlowLaw > create()
ConstantInColumn(std::shared_ptr< const Grid > g)
Definition: SSB_Modifier.cc:88
virtual void update(const array::Vector &sliding_velocity, const Inputs &inputs, bool full_update)
Distribute the input velocity throughout the column.
const array::Array3D & velocity_u() const
Definition: SSB_Modifier.cc:68
SSB_Modifier(std::shared_ptr< const Grid > g)
Definition: SSB_Modifier.cc:31
const array::Staggered & diffusive_flux()
Get the diffusive (SIA) vertically-averaged flux on the staggered grid.
Definition: SSB_Modifier.cc:59
std::shared_ptr< const rheology::FlowLaw > flow_law() const
Definition: SSB_Modifier.cc:80
const array::Array3D & velocity_v() const
Definition: SSB_Modifier.cc:72
EnthalpyConverter::Ptr m_EC
Definition: SSB_Modifier.hh:66
double max_diffusivity() const
Get the max diffusivity (for the adaptive time-stepping).
Definition: SSB_Modifier.cc:64
virtual std::string stdout_report() const
Definition: SSB_Modifier.cc:76
std::shared_ptr< rheology::FlowLaw > m_flow_law
Definition: SSB_Modifier.hh:65
array::Staggered1 m_diffusive_flux
Definition: SSB_Modifier.hh:68
Shallow stress balance modifier (such as the non-sliding SIA).
Definition: SSB_Modifier.hh:39
@ WITH_GHOSTS
Definition: Array.hh:62
static const double g
Definition: exactTestP.cc:36