21#include "pism/energy/BedThermalUnit.hh"
22#include "pism/util/Config.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"
28#include "pism/util/Logger.hh"
29#include "pism/util/pism_utilities.hh"
30#include "pism/util/io/IO_Flags.hh"
36 Mbz = (
unsigned int) ctx->config()->get_number(
"grid.Mbz");
37 Lbz = ctx->config()->get_number(
"grid.Lbz");
44 auto config = ctx->config();
56 result.
Mbz = info.
z.size();
67 result.
Mbz = config->get_number(
"grid.Mbz");
68 result.
Lbz = config->get_number(
"grid.Lbz");
70 if (result.
Mbz == 1) {
83 std::shared_ptr<const Context> ctx) {
87 if (bedrock_grid.Mbz > 1) {
88 return std::make_shared<energy::BTU_Full>(
grid, bedrock_grid);
91 return std::make_shared<energy::BTU_Minimal>(
grid);
97 m_bottom_surface_flux(m_grid,
"bheatflx"),
98 m_top_surface_flux(m_grid,
"heat_flux_from_bedrock") {
102 .
long_name(
"upward geothermal flux at the top bedrock surface")
105 .
standard_name(
"upward_geothermal_heat_flux_at_ground_level_in_land_ice");
111 .
long_name(
"upward geothermal flux at the bottom bedrock surface")
125 auto input_file =
m_config->get_string(
"energy.bedrock_thermal.file");
127 if (not input_file.empty()) {
128 m_log->message(2,
" - Reading geothermal flux from '%s' ...\n",
134 " - Parameter %s is not set. Reading geothermal flux from '%s'...\n",
135 "energy.bedrock_thermal.file",
144 "bootstrapping.defaults.geothermal_flux")));
156 const double heat_flux =
m_config->get_number(
"bootstrapping.defaults.geothermal_flux");
158 m_log->message(2,
" using constant geothermal flux %f W m-2 ...\n",
198 if (
m_config->get_flag(
"output.ISMIP6")) {
205 double t,
double dt) {
220 auto ismip6 =
m_config->get_flag(
"output.ISMIP6");
221 m_vars = { {
m_sys, ismip6 ?
"hfgeoubed" :
"heat_flux_from_bedrock", *
m_grid } };
223 .long_name(
"upward geothermal flux at the top bedrock surface")
224 .standard_name((ismip6 ?
"upward_geothermal_heat_flux_in_land_ice" :
225 "upward_geothermal_heat_flux_at_ground_level_in_land_ice"))
227 .output_units(
"mW m^-2");
228 m_vars[0][
"comment"] =
"positive values correspond to an upward flux";
232 auto result = std::make_shared<array::Scalar>(
m_grid,
"hfgeoubed");
233 result->metadata() =
m_vars[0];
235 result->copy_from(
model->flux_through_top_surface());
std::shared_ptr< const Grid > grid() const
std::shared_ptr< const Config > m_config
configuration database used by this component
@ REGRID_WITHOUT_REGRID_VARS
void regrid(const std::string &module_name, array::Array &variable, RegriddingFlag flag=NO_REGRID_WITHOUT_REGRID_VARS)
std::shared_ptr< const Logger > m_log
logger (for easy access)
A class defining a common interface for most PISM sub-models.
const BedThermalUnit * model
A template derived from Diagnostic, adding a "Model".
std::vector< VariableMetadata > m_vars
metadata corresponding to NetCDF variables
static Ptr wrap(const T &input)
const units::System::Ptr m_sys
the unit system
std::shared_ptr< const Config > m_config
Configuration flags and parameters.
std::shared_ptr< Diagnostic > Ptr
std::shared_ptr< const Grid > m_grid
the grid
bool variable_exists(const std::string &short_name) const
Checks if a variable exists.
High-level PISM I/O class.
void read(const std::string &filename, unsigned int time)
void write(const OutputFile &file) const
void set(double c)
Result: v[j] <- c for all j.
void regrid(const std::string &filename, io::Default default_value)
VariableMetadata & metadata(unsigned int N=0)
Returns a reference to the VariableMetadata 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 double vertical_spacing_impl() const =0
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.
virtual DiagnosticList spatial_diagnostics_impl() const
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
virtual std::set< VariableMetadata > state_impl() const
virtual void write_state_impl(const OutputFile &output) const
The default (empty implementation).
Given the temperature of the top of the bedrock, for the duration of one time-step,...
std::set< VariableMetadata > metadata(std::initializer_list< const Array * > vecs)
@ PISM_READONLY
open an existing file for reading only
std::map< std::string, Diagnostic::Ptr > DiagnosticList
double vector_min(const std::vector< double > &input)
InputOptions process_input_options(MPI_Comm com, std::shared_ptr< const Config > config)
static BTUGrid FromOptions(std::shared_ptr< const Context > ctx)
BTUGrid(std::shared_ptr< const Context > ctx)