PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
Given.cc
Go to the documentation of this file.
1 /* Copyright (C) 2020, 2021, 2022, 2023 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 
23 namespace pism {
24 namespace bed {
25 
26 Given::Given(std::shared_ptr<const Grid> grid)
27  : BedDef(grid),
28  m_topg_reference(grid, "topg") {
29 
31  .long_name("reference bed elevation")
32  .units("meters")
33  .standard_name("bedrock_altitude");
34 
35  auto filename = m_config->get_string("bed_deformation.given.file");
36 
37  {
38  unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
39 
40  // periodic inputs are not supported
41  bool periodic = false;
42 
43  File file(m_grid->com, filename, io::PISM_NETCDF3, io::PISM_READONLY);
44 
45  m_topg_delta = std::make_shared<array::Forcing>(m_grid, file, "topg_delta",
46  "", // no standard name
47  buffer_size, periodic, LINEAR);
48  m_topg_delta->metadata(0)
49  .long_name("two-dimensional bed elevation changes")
50  .units("meters");
51  }
52 }
53 
54 void Given::init_impl(const InputOptions &opts, const array::Scalar &ice_thickness,
55  const array::Scalar &sea_level_elevation) {
56  (void) ice_thickness;
57  (void) sea_level_elevation;
58 
59  m_log->message(2,
60  "* Initializing the bed model using a given topography change history...\n");
61 
62  BedDef::init_impl(opts, ice_thickness, sea_level_elevation);
63 
64  {
65  auto reference_filename = m_config->get_string("bed_deformation.given.reference_file");
66  m_topg_reference.regrid(reference_filename, io::Default::Nil()); // fails if not found!
67  }
68 
69  {
70  auto filename = m_config->get_string("bed_deformation.given.file");
71  m_topg_delta->init(filename, false);
72  }
73 }
74 
75 void Given::update_impl(const array::Scalar &ice_thickness,
76  const array::Scalar &sea_level_elevation,
77  double t, double dt) {
78  (void) ice_thickness;
79  (void) sea_level_elevation;
80 
81  m_topg_delta->update(t, dt);
82  m_topg_delta->average(t, dt);
83 
85 
87  m_topg.add(1.0, *m_topg_delta);
88 
90 }
91 
92 } // end of namespace bed
93 } // end of namespace pism
const Config::ConstPtr m_config
configuration database used by this component
Definition: Component.hh:158
const Logger::ConstPtr m_log
logger (for easy access)
Definition: Component.hh:162
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition: Component.hh:156
High-level PISM I/O class.
Definition: File.hh:56
VariableMetadata & standard_name(const std::string &input)
VariableMetadata & long_name(const std::string &input)
VariableMetadata & units(const std::string &input)
void copy_from(const Array2D< T > &source)
Definition: Array2D.hh:73
void add(double alpha, const Array2D< T > &x)
Definition: Array2D.hh:65
void regrid(const std::string &filename, io::Default default_value)
Definition: Array.cc:814
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
Definition: Array.cc:553
array::Scalar2 m_topg_last
bed elevation at the time of the last update
Definition: BedDef.hh:83
array::Scalar2 m_topg
current bed elevation
Definition: BedDef.hh:80
virtual void init_impl(const InputOptions &opts, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
Initialize from the context (input file and the "variables" database).
Definition: BedDef.cc:105
array::Scalar m_uplift
bed uplift rate
Definition: BedDef.hh:86
void compute_uplift(const array::Scalar &bed, const array::Scalar &bed_last, double dt, array::Scalar &result)
Compute bed uplift (dt is in seconds).
Definition: BedDef.cc:167
PISM bed deformation model (base class).
Definition: BedDef.hh:39
void update_impl(const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation, double t, double dt)
Definition: Given.cc:75
array::Scalar m_topg_reference
Definition: Given.hh:43
std::shared_ptr< array::Forcing > m_topg_delta
Definition: Given.hh:45
Given(std::shared_ptr< const Grid > grid)
Definition: Given.cc:26
void init_impl(const InputOptions &opts, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
Initialize from the context (input file and the "variables" database).
Definition: Given.cc:54
static Default Nil()
Definition: IO_Flags.hh:97
@ PISM_NETCDF3
Definition: IO_Flags.hh:57
@ PISM_READONLY
open an existing file for reading only
Definition: IO_Flags.hh:72