PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
Constant.cc
Go to the documentation of this file.
1// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2022, 2023, 2025 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/Config.hh"
22#include "pism/util/Grid.hh"
23#include "pism/util/MaxTimestep.hh"
24#include "pism/geometry/Geometry.hh"
25#include "pism/util/Logger.hh"
26
27namespace pism {
28namespace frontalmelt {
29
30Constant::Constant(std::shared_ptr<const Grid> g)
31 : FrontalMelt(g) {
32 m_frontal_melt_rate = std::make_shared<array::Scalar>(g, "frontal_melt_rate");
33 m_frontal_melt_rate->metadata(0)
34 .long_name("frontal melt rate")
35 .units("m s^-1")
36 .output_units("m day^-1");
37}
38
39void Constant::update_impl(const FrontalMeltInputs &inputs, double t, double dt) {
40 (void) t;
41 (void) dt;
42
43 const auto &cell_type = inputs.geometry->cell_type;
44
45 const double
46 melt_rate = m_config->get_number("frontal_melt.constant.melt_rate", "m second-1");
47
48 array::AccessScope list{&cell_type, m_frontal_melt_rate.get()};
49
50 for (auto p : m_grid->points()) {
51 const int i = p.i(), j = p.j();
52
53 if (apply(cell_type, i, j)) {
54 (*m_frontal_melt_rate)(i, j) = melt_rate;
55 } else {
56 (*m_frontal_melt_rate)(i, j) = 0.0;
57 }
58 }
59}
60
64
65void Constant::init_impl(const Geometry &geometry) {
66 (void) geometry;
67
68 m_log->message(2,
69 "* Initializing the constant frontal melt model...\n"
70 " Frontal melt rate set to %f m/year.\n",
71 m_config->get_number("frontal_melt.constant.melt_rate", "m year-1"));
72}
73
75 (void) t;
76 return MaxTimestep("frontal_melt constant");
77}
78
79
80} // end of namespape frontalmelt
81} // end of namespace pism
std::shared_ptr< const Config > m_config
configuration database used by this component
Definition Component.hh:160
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition Component.hh:158
std::shared_ptr< const Logger > m_log
logger (for easy access)
Definition Component.hh:164
const Geometry * geometry
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...
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:66
MaxTimestep max_timestep_impl(double t) const
Definition Constant.cc:74
void init_impl(const Geometry &geometry)
Definition Constant.cc:65
const array::Scalar & frontal_melt_rate_impl() const
Definition Constant.cc:61
void update_impl(const FrontalMeltInputs &inputs, double t, double dt)
Definition Constant.cc:39
std::shared_ptr< array::Scalar > m_frontal_melt_rate
Definition Constant.hh:43
Constant(std::shared_ptr< const Grid > g)
Definition Constant.cc:30
bool apply(const array::CellType1 &M, int i, int j) const
A very rudimentary PISM frontal melt model.
static const double g
Definition exactTestP.cc:36