20 #include "pism/energy/EnergyModel.hh"
21 #include "pism/energy/utilities.hh"
22 #include "pism/stressbalance/StressBalance.hh"
23 #include "pism/util/MaxTimestep.hh"
24 #include "pism/util/Profiling.hh"
25 #include "pism/util/Vars.hh"
26 #include "pism/util/array/CellType.hh"
27 #include "pism/util/error_handling.hh"
28 #include "pism/util/io/File.hh"
29 #include "pism/util/pism_utilities.hh"
91 auto H = thickness.
box(i, j);
93 return ((H.e < threshold) or (H.ne < threshold) or (H.n < threshold) or (H.nw < threshold) or
94 (H.w < threshold) or (H.sw < threshold) or (H.s < threshold) or (H.se < threshold));
107 std::shared_ptr<const stressbalance::StressBalance> stress_balance)
109 m_ice_enthalpy(m_grid,
"enthalpy", array::
WITH_GHOSTS, m_grid->z(),
110 m_config->get_number(
"grid.max_stencil_width")),
111 m_work(m_grid,
"work_vector", array::
WITHOUT_GHOSTS, m_grid->z()),
112 m_basal_melt_rate(m_grid,
"basal_melt_rate_grounded"),
113 m_stress_balance(stress_balance) {
117 .
long_name(
"ice enthalpy (includes sensible heat, latent heat, pressure)")
124 "ice basal melt rate from energy conservation, in ice thickness per time (valid in grounded areas)")
157 temp.
read(input_file, record);
161 const array::Scalar &ice_thickness = *
m_grid->variables().get_2d_scalar(
"land_ice_thickness");
167 liqfrac.metadata(0).
set_name(
"liqfrac");
168 liqfrac.metadata(0).
long_name(
"ice liquid water fraction").
units(
"1");
173 liqfrac.read(input_file, record);
180 " - Computing enthalpy using ice temperature,"
181 " liquid water fraction and thickness...\n");
185 " - Computing enthalpy using ice temperature and thickness "
186 "and assuming zero liquid water fraction...\n");
191 "neither enthalpy nor temperature was found in '%s'.\n",
202 auto regrid_filename =
m_config->get_string(
"input.regrid.file");
206 if (regrid_filename.empty()) {
212 if (regrid_vars.empty() or
member(enthalpy_name, regrid_vars)) {
229 ice_thickness, surface_temperature,
230 climatic_mass_balance, basal_heat_flux);
241 climatic_mass_balance,
265 const double reporting_threshold = 5.0;
267 if (reduced_accuracy_percentage > reporting_threshold and
m_log->get_threshold() > 2) {
287 "EnergyModel: no stress balance provided."
288 " Cannot compute max. time step.");
319 "rate of ice loss due to liquefaction, averaged over the reporting interval";
320 m_variable[
"comment"] =
"positive means ice loss";
326 return model->stats().liquified_ice_volume;
const Config::ConstPtr m_config
configuration database used by this component
const Logger::ConstPtr m_log
logger (for easy access)
const std::shared_ptr< const Grid > m_grid
grid used by this component
const Profiling & profiling() const
A class defining a common interface for most PISM sub-models.
static Ptr wrap(const T &input)
VariableLookupData find_variable(const std::string &short_name, const std::string &std_name) const
Find a variable using its standard name and/or short name.
std::string filename() const
High-level PISM I/O class.
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
void begin(const char *name) const
void end(const char *name) const
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
const EnergyModel * model
void set_units(const std::string &units, const std::string &output_units)
VariableMetadata m_variable
std::shared_ptr< TSDiagnostic > Ptr
Scalar diagnostic reporting a "flux".
stencils::Box< T > box(int i, int j) const
void copy_from(const Array3D &input)
A virtual class collecting methods common to ice and bedrock 3D fields.
void read(const std::string &filename, unsigned int time)
void set_name(const std::string &name)
Sets the variable name to name.
void regrid(const std::string &filename, io::Default default_value)
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
Abstract class for reading, writing, allocating, and accessing a DA-based PETSc Vec (2D and 3D fields...
EnergyModelStats & operator+=(const EnergyModelStats &other)
unsigned int reduced_accuracy_counter
double liquified_ice_volume
unsigned int low_temperature_counter
unsigned int bulge_counter
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,...
const EnergyModelStats & stats() const
void update(double t, double dt, const Inputs &inputs)
const array::Array3D & enthalpy() const
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.
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).
virtual MaxTimestep max_timestep_impl(double t) const
std::shared_ptr< const stressbalance::StressBalance > m_stress_balance
const std::string & stdout_flags() const
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)
virtual void restart_impl(const File &input_file, int record)=0
virtual DiagnosticList diagnostics_impl() const
const array::Scalar & basal_melt_rate() const
Basal melt rate in grounded areas. (It is set to zero elsewhere.)
array::Array3D m_ice_enthalpy
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)
std::string m_stdout_flags
virtual void update_impl(double t, double dt, const Inputs &inputs)=0
virtual TSDiagnosticList ts_diagnostics_impl() const
array::Scalar m_basal_melt_rate
void regrid_enthalpy()
Regrid enthalpy from the -regrid_file.
LiquifiedIceFlux(const EnergyModel *m)
Ice loss "flux" due to ice liquefaction.
#define PISM_ERROR_LOCATION
static void check_input(const array::Array *ptr, const char *name)
bool marginal(const array::Scalar1 &thickness, int i, int j, double threshold)
void compute_enthalpy_cold(const array::Array3D &temperature, const array::Scalar &ice_thickness, array::Array3D &result)
Compute ice enthalpy from temperature temperature by assuming the ice has zero liquid fraction.
void compute_enthalpy(const array::Array3D &temperature, const array::Array3D &liquid_water_fraction, const array::Scalar &ice_thickness, array::Array3D &result)
Compute result (enthalpy) from temperature and liquid fraction.
@ PISM_READONLY
open an existing file for reading only
std::map< std::string, TSDiagnostic::Ptr > TSDiagnosticList
std::string printf(const char *format,...)
std::map< std::string, Diagnostic::Ptr > DiagnosticList
std::set< std::string > set_split(const std::string &input, char separator)
Transform a separator-separated list (a string) into a set of strings.
bool member(const std::string &string, const std::set< std::string > &set)
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)