21 #include "pism/energy/BedThermalUnit.hh"
22 #include "pism/util/ConfigInterface.hh"
23 #include "pism/util/Grid.hh"
24 #include "pism/util/io/File.hh"
26 #include "pism/energy/BTU_Full.hh"
27 #include "pism/energy/BTU_Minimal.hh"
33 Mbz = (
unsigned int) ctx->config()->get_number(
"grid.Mbz");
34 Lbz = ctx->config()->get_number(
"grid.Lbz");
53 result.
Mbz = info.
z.size();
64 result.
Mbz = config->get_number(
"grid.Mbz");
65 result.
Lbz = config->get_number(
"grid.Lbz");
67 if (result.
Mbz == 1) {
80 std::shared_ptr<const Context> ctx) {
84 if (bedrock_grid.Mbz > 1) {
85 return std::make_shared<energy::BTU_Full>(
grid, bedrock_grid);
88 return std::make_shared<energy::BTU_Minimal>(
grid);
94 m_bottom_surface_flux(m_grid,
"bheatflx"),
95 m_top_surface_flux(m_grid,
"heat_flux_from_bedrock") {
99 .
long_name(
"upward geothermal flux at the top bedrock surface")
102 .
standard_name(
"upward_geothermal_heat_flux_at_ground_level_in_land_ice");
108 .
long_name(
"upward geothermal flux at the bottom bedrock surface")
122 auto input_file =
m_config->get_string(
"energy.bedrock_thermal.file");
124 if (not input_file.empty()) {
125 m_log->message(2,
" - Reading geothermal flux from '%s' ...\n",
131 " - Parameter %s is not set. Reading geothermal flux from '%s'...\n",
132 "energy.bedrock_thermal.file",
141 "bootstrapping.defaults.geothermal_flux")));
153 const double heat_flux =
m_config->get_number(
"bootstrapping.defaults.geothermal_flux");
155 m_log->message(2,
" using constant geothermal flux %f W m-2 ...\n",
195 if (
m_config->get_flag(
"output.ISMIP6")) {
202 double t,
double dt) {
217 auto ismip6 =
m_config->get_flag(
"output.ISMIP6");
218 m_vars = { {
m_sys, ismip6 ?
"hfgeoubed" :
"heat_flux_from_bedrock" } };
220 .long_name(
"upward geothermal flux at the top bedrock surface")
221 .standard_name((ismip6 ?
"upward_geothermal_heat_flux_in_land_ice" :
222 "upward_geothermal_heat_flux_at_ground_level_in_land_ice"))
224 .output_units(
"mW m-2");
225 m_vars[0][
"comment"] =
"positive values correspond to an upward flux";
229 auto result = std::make_shared<array::Scalar>(
m_grid,
"hfgeoubed");
230 result->metadata() =
m_vars[0];
232 result->copy_from(
model->flux_through_top_surface());
std::shared_ptr< const Grid > grid() const
const Config::ConstPtr m_config
configuration database used by this component
const Logger::ConstPtr m_log
logger (for easy access)
@ REGRID_WITHOUT_REGRID_VARS
void regrid(const std::string &module_name, array::Array &variable, RegriddingFlag flag=NO_REGRID_WITHOUT_REGRID_VARS)
A class defining a common interface for most PISM sub-models.
std::shared_ptr< const Config > ConstPtr
const BedThermalUnit * model
A template derived from Diagnostic, adding a "Model".
static Ptr wrap(const T &input)
const units::System::Ptr m_sys
the unit system
std::vector< SpatialVariableMetadata > m_vars
metadata corresponding to NetCDF variables
std::shared_ptr< Diagnostic > Ptr
std::shared_ptr< const Grid > m_grid
the grid
const Config::ConstPtr m_config
Configuration flags and parameters.
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.
High-level PISM I/O class.
void read(const std::string &filename, unsigned int time)
void define(const File &file, io::Type default_type) const
Define variables corresponding to an Array in a file opened using file.
void write(const std::string &filename) const
void set(double c)
Result: v[j] <- c for all j.
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.
BTU_geothermal_flux_at_ground_level(const BedThermalUnit *m)
virtual std::shared_ptr< array::Array > compute_impl() const
BedThermalUnit(std::shared_ptr< const Grid > g)
virtual void initialize_bottom_surface_flux()
void update(const array::Scalar &bedrock_top_temperature, double t, double dt)
const array::Scalar & flux_through_top_surface() const
Return the upward heat flux through the top surface of the bedrock thermal layer.
array::Scalar m_bottom_surface_flux
upward heat flux through the bottom surface of the bed thermal layer
virtual void init_impl(const InputOptions &opts)
Initialize the bedrock thermal unit.
void init(const InputOptions &opts)
virtual double depth_impl() const =0
static std::shared_ptr< BedThermalUnit > FromOptions(std::shared_ptr< const Grid > g, std::shared_ptr< const Context > ctx)
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
virtual double vertical_spacing_impl() const =0
virtual DiagnosticList diagnostics_impl() const
virtual unsigned int Mz_impl() const =0
double vertical_spacing() const
const array::Scalar & flux_through_bottom_surface() const
Return the upward heat flux through the bottom surface of the bedrock thermal layer.
array::Scalar m_top_surface_flux
upward heat flux through the top surface of the bed thermal layer
virtual void update_impl(const array::Scalar &bedrock_top_temperature, double t, double dt)=0
Given the temperature of the top of the bedrock, for the duration of one time-step,...
@ PISM_READONLY
open an existing file for reading only
InputOptions process_input_options(MPI_Comm com, Config::ConstPtr config)
std::map< std::string, Diagnostic::Ptr > DiagnosticList
static BTUGrid FromOptions(std::shared_ptr< const Context > ctx)
BTUGrid(std::shared_ptr< const Context > ctx)