tConstant.cc - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tConstant.cc (2394B)
---
1 // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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 "Constant.hh"
20
21 #include "pism/util/ConfigInterface.hh"
22 #include "pism/util/IceGrid.hh"
23 #include "pism/util/iceModelVec.hh"
24 #include "pism/util/MaxTimestep.hh"
25 #include "pism/geometry/Geometry.hh"
26
27 namespace pism {
28 namespace frontalmelt {
29
30 Constant::Constant(IceGrid::ConstPtr g)
31 : FrontalMelt(g) {
32 m_frontal_melt_rate = allocate_frontal_melt_rate(g);
33 }
34
35 Constant::~Constant() {
36 // empty
37 }
38
39 void Constant::update_impl(const FrontalMeltInputs &inputs, double t, double dt) {
40 (void) t;
41 (void) dt;
42
43 const IceModelVec2CellType &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 IceModelVec::AccessList list{&cell_type, m_frontal_melt_rate.get()};
49
50 for (Points p(*m_grid); p; p.next()) {
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
61 const IceModelVec2S& Constant::frontal_melt_rate_impl() const {
62 return *m_frontal_melt_rate;
63 }
64
65 void 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
74 MaxTimestep Constant::max_timestep_impl(double t) const {
75 (void) t;
76 return MaxTimestep("frontal_melt constant");
77 }
78
79
80 } // end of namespape frontalmelt
81 } // end of namespace pism