tEnergyModel.hh - 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
---
tEnergyModel.hh (5097B)
---
1 /* Copyright (C) 2016, 2017, 2018 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 #ifndef ENERGYMODEL_H
21 #define ENERGYMODEL_H
22
23 #include "pism/util/Component.hh"
24
25 #include "pism/util/iceModelVec.hh"
26
27 namespace pism {
28
29 namespace stressbalance {
30 class StressBalance;
31 }
32
33 class IceModelVec2CellType;
34
35 namespace energy {
36
37 class Inputs {
38 public:
39 Inputs();
40 void check() const;
41
42 const IceModelVec2CellType *cell_type;
43 const IceModelVec2S *basal_frictional_heating;
44 const IceModelVec2S *basal_heat_flux;
45 const IceModelVec2S *ice_thickness;
46 const IceModelVec2S *surface_liquid_fraction;
47 const IceModelVec2S *shelf_base_temp;
48 const IceModelVec2S *surface_temp;
49 const IceModelVec2S *till_water_thickness;
50
51 const IceModelVec3 *volumetric_heating_rate;
52 const IceModelVec3 *u3;
53 const IceModelVec3 *v3;
54 const IceModelVec3 *w3;
55
56 // inputs used by regional models
57 const IceModelVec2Int *no_model_mask;
58 };
59
60 class EnergyModelStats {
61 public:
62 EnergyModelStats();
63
64 EnergyModelStats& operator+=(const EnergyModelStats &other);
65
66 void sum(MPI_Comm com);
67
68 unsigned int bulge_counter;
69 unsigned int reduced_accuracy_counter;
70 unsigned int low_temperature_counter;
71 double liquified_ice_volume;
72 };
73
74 class EnergyModel : public Component {
75 public:
76 EnergyModel(IceGrid::ConstPtr grid, stressbalance::StressBalance *stress_balance);
77
78 void restart(const File &input_file, int record);
79
80 /*! @brief Bootstrapping using heuristics. */
81 /*!
82 * Bootstrap by reading 2d fields (currently the basal melt rate) from a file and filling 3D
83 * fields using heuristics.
84 */
85 void bootstrap(const File &input_file,
86 const IceModelVec2S &ice_thickness,
87 const IceModelVec2S &surface_temperature,
88 const IceModelVec2S &climatic_mass_balance,
89 const IceModelVec2S &basal_heat_flux);
90
91 /*! @brief Initialize using formulas (for runs using synthetic data). */
92 void initialize(const IceModelVec2S &basal_melt_rate,
93 const IceModelVec2S &ice_thickness,
94 const IceModelVec2S &surface_temperature,
95 const IceModelVec2S &climatic_mass_balance,
96 const IceModelVec2S &basal_heat_flux);
97
98 void update(double t, double dt, const Inputs &inputs);
99
100 const EnergyModelStats& stats() const;
101
102 const IceModelVec3 & enthalpy() const;
103 const IceModelVec2S & basal_melt_rate() const;
104
105 const std::string& stdout_flags() const;
106 protected:
107
108 virtual MaxTimestep max_timestep_impl(double t) const;
109
110 virtual void restart_impl(const File &input_file, int record) = 0;
111
112 virtual void bootstrap_impl(const File &input_file,
113 const IceModelVec2S &ice_thickness,
114 const IceModelVec2S &surface_temperature,
115 const IceModelVec2S &climatic_mass_balance,
116 const IceModelVec2S &basal_heat_flux) = 0;
117
118 virtual void initialize_impl(const IceModelVec2S &basal_melt_rate,
119 const IceModelVec2S &ice_thickness,
120 const IceModelVec2S &surface_temperature,
121 const IceModelVec2S &climatic_mass_balance,
122 const IceModelVec2S &basal_heat_flux) = 0;
123
124 virtual void update_impl(double t, double dt, const Inputs &inputs) = 0;
125
126 virtual void define_model_state_impl(const File &output) const = 0;
127 virtual void write_model_state_impl(const File &output) const = 0;
128
129 virtual DiagnosticList diagnostics_impl() const;
130 virtual TSDiagnosticList ts_diagnostics_impl() const;
131
132 /*! @brief Initialize enthalpy by reading it from a file, or by reading temperature and liquid
133 water fraction, or by reading the temperature field alone. */
134 void init_enthalpy(const File &input_file, bool regrid, int record);
135
136 /*! @brief Regrid enthalpy from the -regrid_file. */
137 void regrid_enthalpy();
138 protected:
139 IceModelVec3 m_ice_enthalpy;
140 IceModelVec3 m_work;
141 IceModelVec2S m_basal_melt_rate;
142
143 EnergyModelStats m_stats;
144
145 private:
146 std::string m_stdout_flags;
147 stressbalance::StressBalance *m_stress_balance;
148 };
149
150 /*!
151 * Return true if the grid point (i,j) is near the margin of the ice.
152 */
153 bool marginal(const IceModelVec2S &thickness, int i, int j, double threshold);
154
155 } // end of namespace energy
156 } // end of namespace pism
157
158
159 #endif /* ENERGYMODEL_H */