19#include "pism/energy/BTU_Full.hh"
21#include "pism/util/io/File.hh"
22#include "pism/util/error_handling.hh"
23#include "pism/util/MaxTimestep.hh"
24#include "pism/util/array/Array3D.hh"
25#include "pism/energy/BedrockColumn.hh"
27#include "pism/util/Logger.hh"
28#include "pism/util/io/IO_Flags.hh"
36 m_bootstrapping_needed(false) {
38 m_k =
m_config->get_number(
"energy.bedrock_thermal.conductivity");
41 rho =
m_config->get_number(
"energy.bedrock_thermal.density"),
42 c =
m_config->get_number(
"energy.bedrock_thermal.specific_heat_capacity");
47 if (
grid.Lbz <= 0.0) {
62 std::vector<double> z(
m_Mbz);
64 for (
unsigned int k = 0;
k <
m_Mbz; ++
k) {
71 auto &z_dim =
m_temp->metadata(0).dimension(
"z");
73 z_dim.set_name(
"zb").long_name(
"Z-coordinate in bedrock").units(
"m");
75 z_dim[
"positive"] =
"up";
79 .long_name(
"lithosphere (bedrock) temperature, in BTU_Full")
81 m_temp->metadata(0)[
"valid_min"] = {0.0};
91 m_log->message(2,
"* Initializing the bedrock thermal unit...\n");
99 const int temp_revision =
m_temp->state_counter();
113 if (
m_temp->state_counter() == temp_revision) {
158 double t,
double dt) {
174 for (
auto p :
m_grid->points()) {
175 const int i = p.i(), j = p.j();
177 double *T =
m_temp->get_column(i, j);
184 for (
unsigned int k = 0;
k <
m_Mbz; ++
k) {
187 "invalid bedrock temperature: %f kelvin at %d,%d,%d",
219 const int k0 =
m_Mbz - 1;
225 for (
auto p :
m_grid->points()) {
226 const int i = p.i(), j = p.j();
228 const double *Tb =
m_temp->get_column(i, j);
234 for (
auto p :
m_grid->points()) {
235 const int i = p.i(), j = p.j();
237 const double *Tb =
m_temp->get_column(i, j);
255 " bootstrapping to fill lithosphere temperatures in the bedrock thermal layer\n"
256 " using temperature at the top bedrock surface and geothermal flux\n"
257 " (bedrock temperature is linear in depth)...\n");
260 const int k0 =
m_Mbz - 1;
263 for (
auto p :
m_grid->points()) {
264 const int i = p.i(), j = p.j();
266 double *Tb =
m_temp->get_column(i, j);
268 Tb[k0] = bedrock_top_temperature(i, j);
269 for (
int k = k0-1;
k >= 0;
k--) {
274 m_temp->inc_state_counter();
std::shared_ptr< const Grid > grid() const
std::shared_ptr< const Config > m_config
configuration database used by this component
@ REGRID_WITHOUT_REGRID_VARS
const std::shared_ptr< const Grid > m_grid
grid used by this component
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)
bool variable_exists(const std::string &short_name) const
Checks if a variable exists.
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 failed()
Indicates a failure of a parallel section.
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void copy_from(const Array2D< T > &source)
A virtual class collecting methods common to ice and bedrock 3D fields.
void write(const OutputFile &file) const
virtual MaxTimestep max_timestep_impl(double my_t) const
const array::Array3D & temperature() const
Bedrock thermal layer temperature field.
unsigned int m_Mbz
number of vertical levels within the bedrock
void update_flux_through_top_surface()
std::shared_ptr< array::Array3D > m_temp
virtual unsigned int Mz_impl() const
double m_Lbz
thickness of the bedrock layer, in meters
virtual std::set< VariableMetadata > state_impl() const
virtual void update_impl(const array::Scalar &bedrock_top_temperature, double t, double dt)
std::shared_ptr< BedrockColumn > m_column
bool m_bootstrapping_needed
true if the model needs to "bootstrap" the temperature field during the first time step
virtual void write_state_impl(const OutputFile &output) const
The default (empty implementation).
virtual double depth_impl() const
virtual double vertical_spacing_impl() const
virtual void bootstrap(const array::Scalar &bedrock_top_temperature)
BTU_Full(std::shared_ptr< const Grid > g, const BTUGrid &vertical_grid)
double m_D
diffusivity of the heat flow within the bedrock layer
virtual void init_impl(const InputOptions &opts)
Initialize the bedrock thermal unit.
double m_k
bedrock thermal conductivity
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.
double vertical_spacing() const
array::Scalar m_top_surface_flux
upward heat flux through the top surface of the bed thermal layer
Given the temperature of the top of the bedrock, for the duration of one time-step,...
#define PISM_ERROR_LOCATION
std::set< VariableMetadata > metadata(std::initializer_list< const Array * > vecs)
@ PISM_READONLY
open an existing file for reading only