PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
PyOceanModel.cc
Go to the documentation of this file.
1 /* Copyright (C) 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/coupler/ocean/PyOceanModel.hh"
21 
22 #include "pism/util/MaxTimestep.hh"
23 
24 #include <exception>
25 #include <memory>
26 
27 namespace pism {
28 namespace ocean {
29 
30 void PyOceanModel::allocate(std::shared_ptr<const Grid> grid) {
34 }
35 
37  (void) t;
38  return {};
39 }
40 
41 void PyOceanModel::init(const Geometry &geometry) {
42  (void) geometry;
43  throw RuntimeError(PISM_ERROR_LOCATION, "PyOceanModel.init(geometry) is not implemented");
44 }
45 
46 void PyOceanModel::update(const Geometry &geometry, double t, double dt) {
47  (void) geometry;
48  (void) t;
49  (void) dt;
50  throw RuntimeError(PISM_ERROR_LOCATION, "PyOceanModel.update(geometry, t, dt) is not implemented");
51 }
52 
53 void PyOceanModel::define_model_state(const File &output) const {
54  (void) output;
55  // empty
56 }
57 
58 void PyOceanModel::write_model_state(const File &output) const {
59  (void) output;
60  // empty
61 }
62 
63 PyOceanModelAdapter::PyOceanModelAdapter(std::shared_ptr<const Grid> grid,
64  std::shared_ptr<PyOceanModel> implementation)
65  : CompleteOceanModel(grid), m_impl(implementation) {
66 
67  m_impl->shelf_base_mass_flux = m_shelf_base_mass_flux;
68  m_impl->shelf_base_temperature = m_shelf_base_temperature;
69  m_impl->water_column_pressure = m_water_column_pressure;
70 }
71 
73  return m_impl->max_timestep(t);
74 }
75 
76 void PyOceanModelAdapter::update_impl(const Geometry &geometry, double t, double dt) {
77  m_impl->update(geometry, t, dt);
78 }
79 
81  m_impl->init(geometry);
82 }
83 
84 
86  m_impl->define_model_state(output);
87 }
88 
90  m_impl->write_model_state(output);
91 }
92 
93 } // namespace ocean
94 } // namespace pism
High-level PISM I/O class.
Definition: File.hh:56
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
Definition: MaxTimestep.hh:31
std::shared_ptr< array::Scalar > m_shelf_base_mass_flux
std::shared_ptr< array::Scalar > m_shelf_base_temperature
std::shared_ptr< array::Scalar > m_water_column_pressure
Definition: OceanModel.hh:73
static std::shared_ptr< array::Scalar > allocate_shelf_base_temperature(std::shared_ptr< const Grid > g)
Definition: OceanModel.cc:31
static std::shared_ptr< array::Scalar > allocate_shelf_base_mass_flux(std::shared_ptr< const Grid > g)
Definition: OceanModel.cc:39
static std::shared_ptr< array::Scalar > allocate_water_column_pressure(std::shared_ptr< const Grid > g)
Definition: OceanModel.cc:49
void update_impl(const Geometry &geometry, double my_t, double my_dt)
Definition: PyOceanModel.cc:76
void init_impl(const Geometry &geometry)
Definition: PyOceanModel.cc:80
PyOceanModelAdapter(std::shared_ptr< const Grid > grid, std::shared_ptr< PyOceanModel > implementation)
Definition: PyOceanModel.cc:63
MaxTimestep max_timestep_impl(double t) const
Definition: PyOceanModel.cc:72
void write_model_state_impl(const File &output) const
The default (empty implementation).
Definition: PyOceanModel.cc:89
void define_model_state_impl(const File &output) const
The default (empty implementation).
Definition: PyOceanModel.cc:85
std::shared_ptr< PyOceanModel > m_impl
Definition: PyOceanModel.hh:92
virtual void init(const Geometry &geometry)
Definition: PyOceanModel.cc:41
virtual void write_model_state(const File &output) const
Definition: PyOceanModel.cc:58
virtual void update(const Geometry &geometry, double t, double dt)
Definition: PyOceanModel.cc:46
virtual MaxTimestep max_timestep(double t) const
Definition: PyOceanModel.cc:36
std::shared_ptr< pism::array::Scalar > shelf_base_temperature
Definition: PyOceanModel.hh:35
virtual void define_model_state(const File &output) const
Definition: PyOceanModel.cc:53
std::shared_ptr< array::Scalar > water_column_pressure
Definition: PyOceanModel.hh:37
std::shared_ptr< array::Scalar > shelf_base_mass_flux
Definition: PyOceanModel.hh:36
void allocate(std::shared_ptr< const Grid > grid)
Definition: PyOceanModel.cc:30
#define PISM_ERROR_LOCATION
bool ocean(int M)
An ocean cell (floating ice or ice-free).
Definition: Mask.hh:40