PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
Delta_SL_2D.cc
Go to the documentation of this file.
1 // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 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 #include "pism/coupler/ocean/sea_level/Delta_SL_2D.hh"
20 
21 #include "pism/util/Grid.hh"
22 #include "pism/coupler/util/options.hh"
23 #include "pism/util/array/Forcing.hh"
24 
25 namespace pism {
26 namespace ocean {
27 namespace sea_level {
28 
29 Delta_SL_2D::Delta_SL_2D(std::shared_ptr<const Grid> grid, std::shared_ptr<SeaLevel> in)
30  : SeaLevel(grid, in) {
31 
32  ForcingOptions opt(*m_grid->ctx(), "ocean.delta_sl_2d");
33 
34  {
35  unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
36 
38 
39  m_forcing = std::make_shared<array::Forcing>(m_grid,
40  file,
41  "delta_SL",
42  "", // no standard name
43  buffer_size,
44  opt.periodic,
45  LINEAR);
46  m_forcing->metadata(0)
47  .long_name("two-dimensional sea level offsets")
48  .units("meters");
49  }
50 }
51 
52 void Delta_SL_2D::init_impl(const Geometry &geometry) {
53 
54  m_input_model->init(geometry);
55 
56  ForcingOptions opt(*m_grid->ctx(), "ocean.delta_sl_2d");
57 
58  m_log->message(2, "* Initializing 2D sea level forcing...\n");
59  m_log->message(2, " reading anomalies from %s ...\n", opt.filename.c_str());
60 
61  m_forcing->init(opt.filename, opt.periodic);
62 }
63 
64 void Delta_SL_2D::update_impl(const Geometry &geometry, double t, double dt) {
65  m_input_model->update(geometry, t, dt);
66 
67  m_forcing->update(t, dt);
68  m_forcing->average(t, dt);
69 
70  m_input_model->elevation().add(1.0, *m_forcing, m_sea_level);
71 }
72 
73 } // end of namespace sea_level
74 } // end of namespace ocean
75 } // 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
void init_impl(const Geometry &geometry)
Definition: Delta_SL_2D.cc:52
Delta_SL_2D(std::shared_ptr< const Grid > g, std::shared_ptr< SeaLevel > in)
Definition: Delta_SL_2D.cc:29
std::shared_ptr< array::Forcing > m_forcing
Definition: Delta_SL_2D.hh:44
void update_impl(const Geometry &geometry, double t, double dt)
Definition: Delta_SL_2D.cc:64
std::shared_ptr< SeaLevel > m_input_model
Definition: SeaLevel.hh:61
@ PISM_NETCDF3
Definition: IO_Flags.hh:57
@ PISM_READONLY
open an existing file for reading only
Definition: IO_Flags.hh:72
bool ocean(int M)
An ocean cell (floating ice or ice-free).
Definition: Mask.hh:40
std::string filename
Definition: options.hh:33