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"
34 m_bootstrapping_needed(false) {
36 m_k =
m_config->get_number(
"energy.bedrock_thermal.conductivity");
39 rho =
m_config->get_number(
"energy.bedrock_thermal.density"),
40 c =
m_config->get_number(
"energy.bedrock_thermal.specific_heat_capacity");
45 if (
grid.Lbz <= 0.0) {
60 std::vector<double> z(
m_Mbz);
62 for (
unsigned int k = 0;
k <
m_Mbz; ++
k) {
69 auto &z_dim =
m_temp->metadata(0).z();
71 z_dim.set_name(
"zb").long_name(
"Z-coordinate in bedrock").units(
"m");
73 z_dim[
"positive"] =
"up";
77 .long_name(
"lithosphere (bedrock) temperature, in BTU_Full")
79 m_temp->metadata(0)[
"valid_min"] = {0.0};
89 m_log->message(2,
"* Initializing the bedrock thermal unit...\n");
97 const int temp_revision =
m_temp->state_counter();
111 if (
m_temp->state_counter() == temp_revision) {
157 double t,
double dt) {
173 for (
auto p =
m_grid->points(); p; p.next()) {
174 const int i = p.i(), j = p.j();
176 double *T =
m_temp->get_column(i, j);
183 for (
unsigned int k = 0;
k <
m_Mbz; ++
k) {
186 "invalid bedrock temperature: %f Kelvin at %d,%d,%d",
218 const int k0 =
m_Mbz - 1;
224 for (
auto p =
m_grid->points(); p; p.next()) {
225 const int i = p.i(), j = p.j();
227 const double *Tb =
m_temp->get_column(i, j);
233 for (
auto p =
m_grid->points(); p; p.next()) {
234 const int i = p.i(), j = p.j();
236 const double *Tb =
m_temp->get_column(i, j);
254 " bootstrapping to fill lithosphere temperatures in the bedrock thermal layer\n"
255 " using temperature at the top bedrock surface and geothermal flux\n"
256 " (bedrock temperature is linear in depth)...\n");
259 const int k0 =
m_Mbz - 1;
262 for (
auto p =
m_grid->points(); p; p.next()) {
263 const int i = p.i(), j = p.j();
265 double *Tb =
m_temp->get_column(i, j);
267 Tb[k0] = bedrock_top_temperature(i, j);
268 for (
int k = k0-1;
k >= 0;
k--) {
273 m_temp->inc_state_counter();
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
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)
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.
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 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
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 void write_model_state_impl(const File &output) const
The default (empty implementation).
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 double depth_impl() const
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
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)
virtual void update_impl(const array::Scalar &bedrock_top_temperature, double t, double dt)=0
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
@ PISM_READONLY
open an existing file for reading only