PISM, A Parallel Ice Sheet Model 2.3.2-fa1174726 committed by Constantine Khrulev on 2026-04-08
Loading...
Searching...
No Matches
Given.cc
Go to the documentation of this file.
1/* Copyright (C) 2020, 2021, 2022, 2023, 2024, 2025 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/earth/Given.hh"
21#include "pism/util/array/Forcing.hh"
22#include "pism/util/io/IO_Flags.hh"
23
24namespace pism {
25namespace bed {
26
27Given::Given(std::shared_ptr<const Grid> grid)
28 : BedDef(grid, "'prescribed topography change history'"),
29 m_topg_reference(grid, "topg") {
30
32 .long_name("reference bed elevation")
33 .units("meters")
34 .standard_name("bedrock_altitude");
35
36 auto filename = m_config->get_string("bed_deformation.given.file");
37
38 {
39 unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
40
41 // periodic inputs are not supported
42 bool periodic = false;
43
44 File file(m_grid->com, filename, io::PISM_NETCDF3, io::PISM_READONLY);
45
46 m_topg_delta = std::make_shared<array::Forcing>(m_grid, file, "topg_delta",
47 "", // no standard name
48 buffer_size, periodic, LINEAR);
49 m_topg_delta->metadata(0)
50 .long_name("two-dimensional bed elevation changes")
51 .units("meters");
52 }
53}
54
55void Given::init_impl(const InputOptions & /*opts*/, const array::Scalar & /*ice_thickness*/,
56 const array::Scalar & /*sea_level_elevation*/) {
57 {
58 auto reference_filename = m_config->get_string("bed_deformation.given.reference_file");
59 m_topg_reference.regrid(reference_filename, io::Default::Nil()); // fails if not found!
60 }
61
62 {
63 auto filename = m_config->get_string("bed_deformation.given.file");
64 bool periodic_p = false;
65 m_topg_delta->init(filename, periodic_p);
66 }
67}
68
69void Given::bootstrap_impl(const array::Scalar & /*bed_elevation*/,
70 const array::Scalar & /*bed_uplift*/,
71 const array::Scalar & /*ice_thickness*/,
72 const array::Scalar & /*sea_level_elevation*/) {
73 // empty
74}
75
76void Given::update_impl(const array::Scalar & /*load*/, double t, double dt) {
77 m_topg_delta->update(t, dt);
78 m_topg_delta->average(t, dt);
79
81
82 // mark m_topg as "modified"
84}
85
86} // end of namespace bed
87} // 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
High-level PISM I/O class.
Definition File.hh:57
VariableMetadata & long_name(const std::string &input)
VariableMetadata & units(const std::string &input)
VariableMetadata & standard_name(const std::string &input)
std::string get_string(const std::string &name) const
Get a string attribute.
void add(double alpha, const Array2D< T > &x)
Definition Array2D.hh:93
void inc_state_counter()
Increment the object state counter.
Definition Array.cc:153
void regrid(const std::string &filename, io::Default default_value)
Definition Array.cc:758
VariableMetadata & metadata(unsigned int N=0)
Returns a reference to the VariableMetadata object containing metadata for the compoment N.
Definition Array.cc:467
array::Scalar2 m_topg
current bed elevation
Definition BedDef.hh:78
PISM bed deformation model (base class).
Definition BedDef.hh:37
void bootstrap_impl(const array::Scalar &bed_elevation, const array::Scalar &bed_uplift, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
Definition Given.cc:69
array::Scalar m_topg_reference
Definition Given.hh:46
void update_impl(const array::Scalar &load, double t, double dt)
Definition Given.cc:76
std::shared_ptr< array::Forcing > m_topg_delta
Definition Given.hh:48
Given(std::shared_ptr< const Grid > grid)
Definition Given.cc:27
void init_impl(const InputOptions &opts, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
Definition Given.cc:55
static Default Nil()
Definition IO_Flags.hh:94
@ PISM_NETCDF3
Definition IO_Flags.hh:58
@ PISM_READONLY
open an existing file for reading only
Definition IO_Flags.hh:69