PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
grain_size_vostok.cc
Go to the documentation of this file.
1 /* Copyright (C) 2019, 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 <algorithm> // std::min, std::max
21 
22 #include "pism/rheology/grain_size_vostok.hh"
23 
24 namespace pism {
25 namespace rheology {
26 
27 // age in thousands of years
29  {0.0000e+00, 5.0000e+01, 1.0000e+02, 1.2500e+02, 1.5000e+02,
30  1.5800e+02, 1.6500e+02, 1.7000e+02, 1.8000e+02, 1.8800e+02,
31  2.0000e+02, 2.2500e+02, 2.4500e+02, 2.6000e+02, 3.0000e+02,
32  3.2000e+02, 3.5000e+02, 4.0000e+02, 5.0000e+02, 6.0000e+02,
33  8.0000e+02, 1.0000e+04};
34 
35 // grain size in meters
37  {1.8000e-03, 2.2000e-03, 3.0000e-03, 4.0000e-03, 4.3000e-03,
38  3.0000e-03, 3.0000e-03, 4.6000e-03, 3.4000e-03, 3.3000e-03,
39  5.9000e-03, 6.2000e-03, 5.4000e-03, 6.8000e-03, 3.5000e-03,
40  6.0000e-03, 8.0000e-03, 8.3000e-03, 3.6000e-03, 3.8000e-03,
41  9.5000e-03, 1.0000e-02};
43  m_acc = gsl_interp_accel_alloc();
44  m_spline = gsl_spline_alloc(gsl_interp_linear, m_N);
45  gsl_spline_init(m_spline, m_age, m_grain_size, m_N);
46 }
47 
49  gsl_spline_free(m_spline);
50  gsl_interp_accel_free(m_acc);
51 }
52 
53 double grain_size_vostok::operator()(double age) {
54  double age_ka = age / 1000.0;
55 
56  age_ka = std::max(age_ka, m_age[0]);
57  age_ka = std::min(age_ka, m_age[m_N - 1]);
58 
59  return gsl_spline_eval(m_spline, age_ka, m_acc);
60 }
61 
62 } // end of namespace rheology
63 } // end of namespace pism
static const double m_grain_size[m_N]
static const double m_age[m_N]
double max(const array::Scalar &input)
Finds maximum over all the values in an array::Scalar object. Ignores ghosts.
Definition: Scalar.cc:165
double min(const array::Scalar &input)
Finds minimum over all the values in an array::Scalar object. Ignores ghosts.
Definition: Scalar.cc:193