PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
Constant.cc
Go to the documentation of this file.
1 // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 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/frontalmelt/Constant.hh"
20 
21 #include "pism/util/ConfigInterface.hh"
22 #include "pism/util/Grid.hh"
23 #include "pism/util/MaxTimestep.hh"
24 #include "pism/geometry/Geometry.hh"
25 
26 namespace pism {
27 namespace frontalmelt {
28 
29 Constant::Constant(std::shared_ptr<const Grid> g)
30  : FrontalMelt(g) {
31  m_frontal_melt_rate = std::make_shared<array::Scalar>(g, "frontal_melt_rate");
32  m_frontal_melt_rate->metadata(0)
33  .long_name("frontal melt rate")
34  .units("m s-1")
35  .output_units("m day-1");
36 }
37 
38 void Constant::update_impl(const FrontalMeltInputs &inputs, double t, double dt) {
39  (void) t;
40  (void) dt;
41 
42  const auto &cell_type = inputs.geometry->cell_type;
43 
44  const double
45  melt_rate = m_config->get_number("frontal_melt.constant.melt_rate", "m second-1");
46 
47  array::AccessScope list{&cell_type, m_frontal_melt_rate.get()};
48 
49  for (auto p = m_grid->points(); p; p.next()) {
50  const int i = p.i(), j = p.j();
51 
52  if (apply(cell_type, i, j)) {
53  (*m_frontal_melt_rate)(i, j) = melt_rate;
54  } else {
55  (*m_frontal_melt_rate)(i, j) = 0.0;
56  }
57  }
58 }
59 
61  return *m_frontal_melt_rate;
62 }
63 
64 void Constant::init_impl(const Geometry &geometry) {
65  (void) geometry;
66 
67  m_log->message(2,
68  "* Initializing the constant frontal melt model...\n"
69  " Frontal melt rate set to %f m/year.\n",
70  m_config->get_number("frontal_melt.constant.melt_rate", "m year-1"));
71 }
72 
74  (void) t;
75  return MaxTimestep("frontal_melt constant");
76 }
77 
78 
79 } // end of namespape frontalmelt
80 } // 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
const Geometry * geometry
Definition: FrontalMelt.hh:32
array::CellType2 cell_type
Definition: Geometry.hh:55
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
Definition: MaxTimestep.hh:31
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition: Array.hh:65
MaxTimestep max_timestep_impl(double t) const
Definition: Constant.cc:73
void init_impl(const Geometry &geometry)
Definition: Constant.cc:64
const array::Scalar & frontal_melt_rate_impl() const
Definition: Constant.cc:60
void update_impl(const FrontalMeltInputs &inputs, double t, double dt)
Definition: Constant.cc:38
std::shared_ptr< array::Scalar > m_frontal_melt_rate
Definition: Constant.hh:43
Constant(std::shared_ptr< const Grid > g)
Definition: Constant.cc:29
bool apply(const array::CellType1 &M, int i, int j) const
Definition: FrontalMelt.cc:246
A very rudimentary PISM frontal melt model.
Definition: FrontalMelt.hh:43
static const double g
Definition: exactTestP.cc:36