PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
EnergyModel.hh
Go to the documentation of this file.
1 /* Copyright (C) 2016, 2017, 2018, 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 
20 #ifndef ENERGYMODEL_H
21 #define ENERGYMODEL_H
22 
23 #include "pism/util/Component.hh"
24 
25 #include "pism/util/array/Scalar.hh"
26 #include "pism/util/array/Array3D.hh"
27 #include "pism/util/array/CellType.hh"
28 #include <memory>
29 
30 namespace pism {
31 
32 namespace stressbalance {
33 class StressBalance;
34 }
35 
36 namespace energy {
37 
38 class Inputs {
39 public:
40  Inputs();
41  void check() const;
42 
51 
56 
57  // inputs used by regional models
59 };
60 
62 public:
64 
66 
67  void sum(MPI_Comm com);
68 
69  unsigned int bulge_counter;
73 };
74 
75 class EnergyModel : public Component {
76 public:
77  EnergyModel(std::shared_ptr<const Grid> grid,
78  std::shared_ptr<const stressbalance::StressBalance> stress_balance);
79 
80  void restart(const File &input_file, int record);
81 
82  /*! @brief Bootstrapping using heuristics. */
83  /*!
84  * Bootstrap by reading 2d fields (currently the basal melt rate) from a file and filling 3D
85  * fields using heuristics.
86  */
87  void bootstrap(const File &input_file,
88  const array::Scalar &ice_thickness,
89  const array::Scalar &surface_temperature,
90  const array::Scalar &climatic_mass_balance,
91  const array::Scalar &basal_heat_flux);
92 
93  /*! @brief Initialize using formulas (for runs using synthetic data). */
95  const array::Scalar &ice_thickness,
96  const array::Scalar &surface_temperature,
97  const array::Scalar &climatic_mass_balance,
98  const array::Scalar &basal_heat_flux);
99 
100  void update(double t, double dt, const Inputs &inputs);
101 
102  const EnergyModelStats& stats() const;
103 
104  const array::Array3D & enthalpy() const;
105  const array::Scalar & basal_melt_rate() const;
106 
107  const std::string& stdout_flags() const;
108 protected:
109 
110  virtual MaxTimestep max_timestep_impl(double t) const;
111 
112  virtual void restart_impl(const File &input_file, int record) = 0;
113 
114  virtual void bootstrap_impl(const File &input_file,
115  const array::Scalar &ice_thickness,
116  const array::Scalar &surface_temperature,
117  const array::Scalar &climatic_mass_balance,
118  const array::Scalar &basal_heat_flux) = 0;
119 
121  const array::Scalar &ice_thickness,
122  const array::Scalar &surface_temperature,
123  const array::Scalar &climatic_mass_balance,
124  const array::Scalar &basal_heat_flux) = 0;
125 
126  virtual void update_impl(double t, double dt, const Inputs &inputs) = 0;
127 
128  virtual void define_model_state_impl(const File &output) const = 0;
129  virtual void write_model_state_impl(const File &output) const = 0;
130 
131  virtual DiagnosticList diagnostics_impl() const;
132  virtual TSDiagnosticList ts_diagnostics_impl() const;
133 
134  /*! @brief Initialize enthalpy by reading it from a file, or by reading temperature and liquid
135  water fraction, or by reading the temperature field alone. */
136  void init_enthalpy(const File &input_file, bool regrid, int record);
137 
138  /*! @brief Regrid enthalpy from the -regrid_file. */
139  void regrid_enthalpy();
140 protected:
144 
146 
147 private:
148  std::string m_stdout_flags;
149  std::shared_ptr<const stressbalance::StressBalance> m_stress_balance;
150 };
151 
152 /*!
153  * Return true if the grid point (i,j) is near the margin of the ice.
154  */
155 bool marginal(const array::Scalar1 &thickness, int i, int j, double threshold);
156 
157 } // end of namespace energy
158 } // end of namespace pism
159 
160 
161 #endif /* ENERGYMODEL_H */
std::shared_ptr< const Grid > grid() const
Definition: Component.cc:105
void regrid(const std::string &module_name, array::Array &variable, RegriddingFlag flag=NO_REGRID_WITHOUT_REGRID_VARS)
Definition: Component.cc:159
A class defining a common interface for most PISM sub-models.
Definition: Component.hh:118
High-level PISM I/O class.
Definition: File.hh:56
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
Definition: MaxTimestep.hh:31
A virtual class collecting methods common to ice and bedrock 3D fields.
Definition: Array3D.hh:33
"Cell type" mask. Adds convenience methods to array::Scalar.
Definition: CellType.hh:30
EnergyModelStats & operator+=(const EnergyModelStats &other)
Definition: EnergyModel.cc:81
unsigned int reduced_accuracy_counter
Definition: EnergyModel.hh:70
unsigned int low_temperature_counter
Definition: EnergyModel.hh:71
void init_enthalpy(const File &input_file, bool regrid, int record)
Initialize enthalpy by reading it from a file, or by reading temperature and liquid water fraction,...
Definition: EnergyModel.cc:135
const EnergyModelStats & stats() const
Definition: EnergyModel.cc:298
void update(double t, double dt, const Inputs &inputs)
Definition: EnergyModel.cc:245
const array::Array3D & enthalpy() const
Definition: EnergyModel.cc:302
void bootstrap(const File &input_file, const array::Scalar &ice_thickness, const array::Scalar &surface_temperature, const array::Scalar &climatic_mass_balance, const array::Scalar &basal_heat_flux)
Bootstrapping using heuristics.
Definition: EnergyModel.cc:223
void initialize(const array::Scalar &basal_melt_rate, const array::Scalar &ice_thickness, const array::Scalar &surface_temperature, const array::Scalar &climatic_mass_balance, const array::Scalar &basal_heat_flux)
Initialize using formulas (for runs using synthetic data).
Definition: EnergyModel.cc:233
virtual MaxTimestep max_timestep_impl(double t) const
Definition: EnergyModel.cc:281
EnergyModelStats m_stats
Definition: EnergyModel.hh:145
virtual void define_model_state_impl(const File &output) const =0
The default (empty implementation).
std::shared_ptr< const stressbalance::StressBalance > m_stress_balance
Definition: EnergyModel.hh:149
const std::string & stdout_flags() const
Definition: EnergyModel.cc:294
virtual void initialize_impl(const array::Scalar &basal_melt_rate, const array::Scalar &ice_thickness, const array::Scalar &surface_temperature, const array::Scalar &climatic_mass_balance, const array::Scalar &basal_heat_flux)=0
void restart(const File &input_file, int record)
Definition: EnergyModel.cc:219
virtual void restart_impl(const File &input_file, int record)=0
virtual DiagnosticList diagnostics_impl() const
Definition: EnergyModel.cc:330
const array::Scalar & basal_melt_rate() const
Basal melt rate in grounded areas. (It is set to zero elsewhere.)
Definition: EnergyModel.cc:307
array::Array3D m_ice_enthalpy
Definition: EnergyModel.hh:141
virtual void bootstrap_impl(const File &input_file, const array::Scalar &ice_thickness, const array::Scalar &surface_temperature, const array::Scalar &climatic_mass_balance, const array::Scalar &basal_heat_flux)=0
EnergyModel(std::shared_ptr< const Grid > grid, std::shared_ptr< const stressbalance::StressBalance > stress_balance)
Definition: EnergyModel.cc:106
virtual void write_model_state_impl(const File &output) const =0
The default (empty implementation).
virtual void update_impl(double t, double dt, const Inputs &inputs)=0
virtual TSDiagnosticList ts_diagnostics_impl() const
Definition: EnergyModel.cc:339
array::Scalar m_basal_melt_rate
Definition: EnergyModel.hh:143
void regrid_enthalpy()
Regrid enthalpy from the -regrid_file.
Definition: EnergyModel.cc:200
const array::Scalar * surface_liquid_fraction
Definition: EnergyModel.hh:47
const array::Scalar1 * ice_thickness
Definition: EnergyModel.hh:46
const array::Array3D * w3
Definition: EnergyModel.hh:55
void check() const
Definition: EnergyModel.cc:58
const array::Array3D * v3
Definition: EnergyModel.hh:54
const array::Scalar * shelf_base_temp
Definition: EnergyModel.hh:48
const array::Scalar * basal_heat_flux
Definition: EnergyModel.hh:45
const array::Scalar * basal_frictional_heating
Definition: EnergyModel.hh:44
const array::Scalar * till_water_thickness
Definition: EnergyModel.hh:50
const array::Scalar * no_model_mask
Definition: EnergyModel.hh:58
const array::Array3D * u3
Definition: EnergyModel.hh:53
const array::Scalar * surface_temp
Definition: EnergyModel.hh:49
const array::CellType * cell_type
Definition: EnergyModel.hh:43
const array::Array3D * volumetric_heating_rate
Definition: EnergyModel.hh:52
bool marginal(const array::Scalar1 &thickness, int i, int j, double threshold)
Definition: EnergyModel.cc:90
std::map< std::string, TSDiagnostic::Ptr > TSDiagnosticList
Definition: Diagnostic.hh:343
std::map< std::string, Diagnostic::Ptr > DiagnosticList
Definition: Diagnostic.hh:125