21#include "pism/earth/BedDef.hh"
22#include "pism/util/ConfigInterface.hh"
23#include "pism/util/Context.hh"
24#include "pism/util/Grid.hh"
25#include "pism/util/MaxTimestep.hh"
26#include "pism/util/Time.hh"
32BedDef::BedDef(std::shared_ptr<const Grid> grid,
const std::string &model_name)
34 m_topg(m_grid,
"topg"),
35 m_topg_last(m_grid,
"topg"),
36 m_load(grid,
"bed_def_load"),
37 m_load_accumulator(grid,
"bed_def_load_accumulator"),
38 m_uplift(m_grid,
"dbdt"),
39 m_t_last(time().current()),
40 m_model_name(model_name)
52 .
long_name(
"bedrock surface elevation after the previous update (used to compute uplift)")
57 .
long_name(
"load on the bed expressed as ice-equivalent thickness")
62 .
long_name(
"accumulated load on the bed expressed as the time integral of ice-equivalent thickness")
32BedDef::BedDef(std::shared_ptr<const Grid> grid,
const std::string &model_name) {
…}
88 "time of the last update of the Lingle-Clark bed deformation model");
115 m_log->message(2,
"* Initializing the %s bed deformation model...\n",
131 m_log->message(2,
" reading bed topography and uplift from %s ... \n",
158 auto uplift_file =
m_config->get_string(
"bed_deformation.bed_uplift_file");
159 if (not uplift_file.empty()) {
160 m_log->message(2,
" reading bed uplift from %s ... \n", uplift_file.c_str());
164 auto correction_file =
m_config->get_string(
"bed_deformation.bed_topography_delta_file");
165 if (not correction_file.empty()) {
166 m_log->message(2,
" Adding a bed topography correction read in from '%s'...\n",
167 correction_file.c_str());
172 this->
init_impl(opts, ice_thickness, sea_level_elevation);
188 this->
bootstrap_impl(bed_elevation, bed_uplift, ice_thickness, sea_level_elevation);
199 double t,
double dt) {
201 double t_final = t + dt;
210 if (std::abs(t_next - t_final) <
m_t_eps) {
212 double dt_beddef = t_final -
m_t_last;
242 "time %f is less than the previous time %f",
280 bed_topography.
add(1.0, topg_delta);
284 double ice_density,
double ocean_density) {
287 ice_load = ice_thickness,
288 ocean_depth = std::max(sea_level - bed, 0.0),
289 ocean_load = (ocean_density / ice_density) * ocean_depth;
292 return ice_load > ocean_load ? ice_load : 0.0;
306 const double ice_density = config->get_number(
"constants.ice.density"),
307 ocean_density = config->get_number(
"constants.sea_water.density");
309 array::AccessScope list{ &bed_elevation, &ice_thickness, &sea_level_elevation, &result };
311 for (
auto p = result.
grid()->points(); p; p.next()) {
312 const int i = p.i(), j = p.j();
314 result(i, j) += C *
compute_load(bed_elevation(i, j), ice_thickness(i, j), sea_level_elevation(i, j),
315 ice_density, ocean_density);
const Time & time() const
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)
A class defining a common interface for most PISM sub-models.
std::shared_ptr< const Config > ConstPtr
static Ptr wrap(const T &input)
void read_variable(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, double *ip) const
bool variable_exists(const std::string &short_name) const
Checks if a variable exists.
void write_variable(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const double *op) const
void define_variable(const std::string &name, io::Type nctype, const std::vector< std::string > &dims) const
Define a variable.
void write_attribute(const std::string &var_name, const std::string &att_name, io::Type nctype, const std::vector< double > &values) const
Write a multiple-valued double attribute.
High-level PISM I/O class.
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
double current() const
Current time, in seconds.
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void copy_from(const Array2D< T > &source)
void add(double alpha, const Array2D< T > &x)
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 scale(double alpha)
Result: v <- v * alpha. Calls VecScale.
std::shared_ptr< const Grid > grid() 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.
std::string m_time_name
Name of the variable used to store the last update time.
array::Scalar m_load_accumulator
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
virtual DiagnosticList diagnostics_impl() const
array::Scalar m_topg_last
bed elevation at the time of the last update
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
virtual void update_impl(const array::Scalar &load, double t, double dt)=0
void init(const InputOptions &opts, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
virtual MaxTimestep max_timestep_impl(double t) const
void update(const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation, double t, double dt)
double m_update_interval
Update interval in seconds.
void bootstrap(const array::Scalar &bed_elevation, const array::Scalar &bed_uplift, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
Initialize using provided bed elevation and uplift.
array::Scalar2 m_topg
current bed elevation
virtual void bootstrap_impl(const array::Scalar &bed_elevation, const array::Scalar &bed_uplift, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)=0
BedDef(std::shared_ptr< const Grid > g, const std::string &model_name)
array::Scalar m_uplift
bed uplift rate
const array::Scalar & uplift() const
const array::Scalar & bed_elevation() const
virtual void init_impl(const InputOptions &opts, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)=0
double m_t_last
time of the last bed deformation update
static void apply_topg_offset(const std::string &filename, array::Scalar &bed_topography)
double m_t_eps
Temporal resolution to use when checking whether it's time to update.
#define PISM_ERROR_LOCATION
void accumulate_load(const array::Scalar &bed_elevation, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation, double C, array::Scalar &result)
double compute_load(double bed, double ice_thickness, double sea_level, double ice_density, double ocean_density)
@ PISM_READONLY
open an existing file for reading only
std::map< std::string, Diagnostic::Ptr > DiagnosticList
static std::string calendar(const File *input_file, const Config &config, const Logger &log)