PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
Delta_MBP.cc
Go to the documentation of this file.
1 /* Copyright (C) 2021, 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/Delta_MBP.hh"
21 #include "pism/util/ScalarForcing.hh"
22 #include "pism/geometry/Geometry.hh"
23 
24 namespace pism {
25 namespace ocean {
26 
27 Delta_MBP::Delta_MBP(std::shared_ptr<const Grid> g, std::shared_ptr<OceanModel> in)
28  : OceanModel(g, in) {
29 
30  m_forcing.reset(new ScalarForcing(*g->ctx(),
31  "ocean.delta_MBP",
32  "delta_MBP",
33  "Pa", "Pa",
34  "melange back pressure"));
35 
37 }
38 
40  // empty
41 }
42 
43 void Delta_MBP::init_impl(const Geometry &geometry) {
44 
45  m_input_model->init(geometry);
46 
47  m_log->message(2,
48  "* Initializing melange back pressure forcing using scalar offsets...\n");
49 }
50 
51 void Delta_MBP::update_impl(const Geometry &geometry, double t, double dt) {
52  m_input_model->update(geometry, t, dt);
53 
54  double
55  melange_thickness = m_config->get_number("ocean.delta_MBP.melange_thickness"),
56  dP_melange = m_forcing->value(t + 0.5 * dt);
57 
58  const auto &P = m_input_model->average_water_column_pressure();
59  const auto &H = geometry.ice_thickness;
60  auto &P_new = *m_water_column_pressure;
61  array::AccessScope list{&P, &H, &P_new};
62 
63  for (auto p = m_grid->points(); p; p.next()) {
64  const int i = p.i(), j = p.j();
65 
66  double dP = H(i, j) > 0.0 ? (melange_thickness * dP_melange) / H(i, j) : 0.0;
67 
68  P_new(i, j) = P(i, j) + dP;
69  }
70 }
71 
74 }
75 
76 
77 } // end of namespace ocean
78 } // 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
array::Scalar2 ice_thickness
Definition: Geometry.hh:51
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition: Array.hh:65
void update_impl(const Geometry &geometry, double t, double dt)
Definition: Delta_MBP.cc:51
const array::Scalar & average_water_column_pressure_impl() const
Definition: Delta_MBP.cc:72
Delta_MBP(std::shared_ptr< const Grid > g, std::shared_ptr< OceanModel > in)
Definition: Delta_MBP.cc:27
void init_impl(const Geometry &geometry)
Definition: Delta_MBP.cc:43
std::unique_ptr< ScalarForcing > m_forcing
Definition: Delta_MBP.hh:47
std::shared_ptr< OceanModel > m_input_model
Definition: OceanModel.hh:72
std::shared_ptr< array::Scalar > m_water_column_pressure
Definition: OceanModel.hh:73
static std::shared_ptr< array::Scalar > allocate_water_column_pressure(std::shared_ptr< const Grid > g)
Definition: OceanModel.cc:49
A very rudimentary PISM ocean model.
Definition: OceanModel.hh:33
bool ocean(int M)
An ocean cell (floating ice or ice-free).
Definition: Mask.hh:40
static const double g
Definition: exactTestP.cc:36