PISM, A Parallel Ice Sheet Model 2.2.1-cd005eec8 committed by Constantine Khrulev on 2025-03-07
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
28namespace pism {
29namespace stressbalance {
30
31SSB_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("m^2 s^-1");
54}
55
57}
58
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
76std::string SSB_Modifier::stdout_report() const {
77 return "";
78}
79
80std::shared_ptr<const rheology::FlowLaw> SSB_Modifier::flow_law() const {
81 return m_flow_law;
82}
83
87
88ConstantInColumn::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 */
105void 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):
128
129 // diffusive flux and maximum diffusivity
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 & long_name(const std::string &input)
VariableMetadata & units(const std::string &input)
VariableMetadata & standard_name(const std::string &input)
VariableMetadata & output_units(const std::string &input)
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:64
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:50
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:629
void update_ghosts()
Updates ghost points.
Definition Array.cc:615
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
Definition Array.cc:476
A class for storing and accessing internal staggered-grid 2D fields. Uses dof=2 storage....
Definition Staggered.hh:37
std::shared_ptr< FlowLaw > create()
ConstantInColumn(std::shared_ptr< const Grid > g)
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
SSB_Modifier(std::shared_ptr< const Grid > g)
const array::Staggered & diffusive_flux()
Get the diffusive (SIA) vertically-averaged flux on the staggered grid.
std::shared_ptr< const rheology::FlowLaw > flow_law() const
const array::Array3D & velocity_v() const
EnthalpyConverter::Ptr m_EC
double max_diffusivity() const
Get the max diffusivity (for the adaptive time-stepping).
virtual std::string stdout_report() const
std::shared_ptr< rheology::FlowLaw > m_flow_law
Shallow stress balance modifier (such as the non-sliding SIA).
static const double g
Definition exactTestP.cc:36