PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
RegionalYieldStress.cc
Go to the documentation of this file.
1/* Copyright (C) 2015, 2016, 2017, 2018, 2019, 2022, 2023, 2024, 2025, 2026 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#include "pism/regional/RegionalYieldStress.hh"
21#include "pism/util/pism_utilities.hh" // pism::combine()
22#include "pism/util/MaxTimestep.hh"
23#include "pism/util/array/Scalar.hh"
24#include "pism/util/Interpolation1D.hh"
25
26namespace pism {
27
28RegionalYieldStress::RegionalYieldStress(std::shared_ptr<YieldStress> input)
29 : YieldStress(input->grid()), m_input(input) {
30
31 m_high_tauc = m_config->get_number("regional.no_model_yield_stress", "Pa");
32
33 m_name = "regional " + m_input->name();
34}
35
36/*!
37 * Set `basal_yield_stress` to `tauc` in areas indicated using `mask`.
38 */
39static void set_no_model_yield_stress(double tauc,
40 const array::Scalar &mask,
41 array::Scalar &basal_yield_stress) {
42 auto grid = mask.grid();
43
44 array::AccessScope list{&mask, &basal_yield_stress};
45
46 for (auto p : grid->points()) {
47 const int i = p.i(), j = p.j();
48
49 if (mask(i, j) > 0.5) {
50 basal_yield_stress(i, j) = tauc;
51 }
52 }
53}
54
55void RegionalYieldStress::restart_impl(const File &input_file, int record) {
56 m_input->restart(input_file, record);
57
58 // m_basal_yield_stress is a part of the model state for all yield stress models, so the
59 // call above should read it in.
60 m_basal_yield_stress.copy_from(m_input->basal_material_yield_stress());
61
62 array::Scalar no_model_mask(m_grid, "no_model_mask");
63 no_model_mask.set_interpolation_type(NEAREST);
64 no_model_mask.metadata(0)
65 .long_name(
66 "mask: zeros (modeling domain) and ones (no-model buffer near grid edges)"); // no units and no standard name
67 // We are re-starting a simulation, so the input file has to contain no_model_mask.
68 no_model_mask.read(input_file, record);
69 // However, the used can set "-regrid_vars no_model_mask,...", so we have to try this,
70 // too.
71 regrid(name(), no_model_mask);
72
74}
75
76void RegionalYieldStress::bootstrap_impl(const File &input_file, const YieldStressInputs &inputs) {
77 m_input->bootstrap(input_file, inputs);
78
79 m_basal_yield_stress.copy_from(m_input->basal_material_yield_stress());
80
82}
83
85 m_input->init(inputs);
86
87 m_basal_yield_stress.copy_from(m_input->basal_material_yield_stress());
88
90}
91
93 double t, double dt) {
94 m_input->update(inputs, t, dt);
95
96 m_basal_yield_stress.copy_from(m_input->basal_material_yield_stress());
97
99}
100
101std::set<VariableMetadata> RegionalYieldStress::state_impl() const {
102 auto variables = array::metadata({&m_basal_yield_stress});
103
104 return pism::combine(variables, m_input->state());
105}
106
108 m_input->write_state(output);
109 // Write basal yield stress that includes the modification containing high yield stress
110 // in "no model" areas, overwriting the field written by m_input.
112}
113
115 // Override the tauc diagnostic with the one that includes the regional modification
117 m_input->spatial_diagnostics());
118}
119
121 auto dt = m_input->max_timestep(t);
122
123 if (dt.finite()) {
124 return MaxTimestep(dt.value(), name());
125 }
126
127 return MaxTimestep(name());
128}
129
131 return m_input->scalar_diagnostics();
132}
133
134} // end of namespace pism
std::shared_ptr< const Config > m_config
configuration database used by this component
Definition Component.hh:160
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition Component.hh:158
void regrid(const std::string &module_name, array::Array &variable, RegriddingFlag flag=NO_REGRID_WITHOUT_REGRID_VARS)
Definition Component.cc:152
static Ptr wrap(const T &input)
High-level PISM I/O class.
Definition File.hh:57
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
void write_state_impl(const OutputFile &output) const
The default (empty implementation).
std::shared_ptr< YieldStress > m_input
TSDiagnosticList scalar_diagnostics_impl() const
MaxTimestep max_timestep_impl(double t) const
void update_impl(const YieldStressInputs &inputs, double t, double dt)
void restart_impl(const File &input_file, int record)
RegionalYieldStress(std::shared_ptr< YieldStress > input)
void bootstrap_impl(const File &input_file, const YieldStressInputs &inputs)
void init_impl(const YieldStressInputs &inputs)
std::set< VariableMetadata > state_impl() const
DiagnosticList spatial_diagnostics_impl() const
VariableMetadata & long_name(const std::string &input)
const array::Scalar * no_model_mask
std::string m_name
std::string name() const
array::Scalar2 m_basal_yield_stress
The PISM basal yield stress model interface (virtual base class)
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:66
void copy_from(const Array2D< T > &source)
Definition Array2D.hh:101
void read(const std::string &filename, unsigned int time)
Definition Array.cc:753
void set_interpolation_type(InterpolationType type)
Definition Array.cc:181
void write(const OutputFile &file) const
Definition Array.cc:859
std::shared_ptr< const Grid > grid() const
Definition Array.cc:134
VariableMetadata & metadata(unsigned int N=0)
Returns a reference to the VariableMetadata object containing metadata for the compoment N.
Definition Array.cc:467
std::set< VariableMetadata > metadata(std::initializer_list< const Array * > vecs)
Definition Array.cc:1244
static void set_no_model_yield_stress(double tauc, const array::Scalar &mask, array::Scalar &basal_yield_stress)
std::map< std::string, TSDiagnostic::Ptr > TSDiagnosticList
std::map< std::string, Diagnostic::Ptr > DiagnosticList
T combine(const T &a, const T &b)