19 #include "pism/earth/LingleClark.hh"
21 #include "pism/util/io/File.hh"
22 #include "pism/util/Time.hh"
23 #include "pism/util/Grid.hh"
24 #include "pism/util/ConfigInterface.hh"
25 #include "pism/util/error_handling.hh"
26 #include "pism/util/Vars.hh"
27 #include "pism/util/MaxTimestep.hh"
28 #include "pism/util/pism_utilities.hh"
29 #include "pism/util/fftw_utilities.hh"
30 #include "pism/earth/LingleClarkSerial.hh"
31 #include "pism/util/Context.hh"
39 m_total_displacement(m_grid,
"bed_displacement"),
40 m_relief(m_grid,
"bed_relief"),
41 m_load_thickness(grid,
"load_thickness"),
42 m_elastic_displacement(grid,
"elastic_bed_displacement") {
51 "invalid bed_deformation.lc.update_interval = %f seconds",
59 "total (viscous and elastic) displacement in the Lingle-Clark bed deformation model")
65 .
long_name(
"bed relief relative to the modeled bed displacement")
68 bool use_elastic_model =
m_config->get_flag(
"bed_deformation.lc.elastic_model");
72 "elastic part of the displacement in the Lingle-Clark bed deformation model; see :cite:`BLKfastearth`")
79 Z =
m_config->get_number(
"bed_deformation.lc.grid_size_factor"),
91 std::make_shared<array::Scalar>(
m_extended_grid,
"viscous_bed_displacement");
94 "bed displacement in the viscous half-space bed deformation model; see BuelerLingleBrown")
108 if (
m_grid->rank() == 0) {
153 if (
m_grid->rank() == 0) {
154 PetscErrorCode ierr = 0;
195 auto lrm0 = result->allocate_proc0_copy();
200 if (
m_grid->rank() == 0) {
201 std::vector<std::complex<double> > array(Nx * Ny);
203 m_serial_model->compute_load_response_matrix((fftw_complex*)array.data());
205 get_real_part((fftw_complex*)array.data(), 1.0, Nx, Ny, Nx, Ny, 0, 0, *lrm0);
213 result->get_from_proc0(*lrm0);
229 m_log->message(2,
"* Initializing the Lingle-Clark bed deformation model...\n");
260 regrid(
"Lingle-Clark bed deformation model",
262 regrid(
"Lingle-Clark bed deformation model",
276 if (
m_grid->rank() == 0) {
277 PetscErrorCode ierr = 0;
300 "time %f is less than the previous time %f",
349 if (
m_grid->rank() == 0) {
350 PetscErrorCode ierr = 0;
389 double t,
double dt) {
399 if (std::abs(t_next - t_final) <
m_t_eps) {
400 double dt_beddef = t_final -
m_t_last;
401 step(ice_thickness, sea_level_elevation, dt_beddef);
415 "time of the last update of the Lingle-Clark bed deformation model");
const Time & time() 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)
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
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.
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.
static std::shared_ptr< Grid > Shallow(std::shared_ptr< const Context > ctx, double Lx, double Ly, double x0, double y0, unsigned int Mx, unsigned int My, grid::Registration r, grid::Periodicity p)
Initialize a uniform, shallow (3 z-levels) grid with half-widths (Lx,Ly) and Mx by My nodes.
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
double current() const
Current time, in seconds.
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 get_from_proc0(petsc::Vec &onp0)
Gets a local Array2 from processor 0.
void write(const std::string &filename) const
void inc_state_counter()
Increment the object state counter.
std::shared_ptr< petsc::Vec > allocate_proc0_copy() const
void put_on_proc0(petsc::Vec &onp0) const
Puts a local array::Scalar on processor 0.
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
virtual DiagnosticList diagnostics_impl() const
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
array::Scalar2 m_topg_last
bed elevation at the time of the last update
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 init_impl(const InputOptions &opts, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
Initialize from the context (input file and the "variables" database).
array::Scalar m_uplift
bed uplift rate
const array::Scalar & bed_elevation() const
void compute_uplift(const array::Scalar &bed, const array::Scalar &bed_last, double dt, array::Scalar &result)
Compute bed uplift (dt is in seconds).
PISM bed deformation model (base class).
Class implementing the bed deformation model described in [BLKfastearth].
void step(const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation, double dt)
std::shared_ptr< petsc::Vec > m_elastic_displacement0
rank 0 storage for the elastic displacement
MaxTimestep max_timestep_impl(double t) const
void bootstrap_impl(const array::Scalar &bed_elevation, const array::Scalar &bed_uplift, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
void init_impl(const InputOptions &opts, const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation)
double m_t_eps
Temporal resolution to use when checking whether it's time to update.
std::shared_ptr< petsc::Vec > m_work0
array::Scalar m_elastic_displacement
Elastic bed displacement (part of the model state)
const array::Scalar & elastic_displacement() const
std::shared_ptr< Grid > m_extended_grid
extended grid for the viscous plate displacement
std::string m_time_name
Name of the variable used to store the last update time.
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
std::shared_ptr< array::Scalar > m_viscous_displacement
Viscous displacement on the extended grid (part of the model state).
double m_t_last
time of the last bed deformation update
array::Scalar m_relief
Bed relief relative to the bed displacement.
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
std::shared_ptr< petsc::Vec > m_viscous_displacement0
rank 0 storage using the extended grid
const array::Scalar & relief() const
LingleClark(std::shared_ptr< const Grid > g)
DiagnosticList diagnostics_impl() const
std::unique_ptr< LingleClarkSerial > m_serial_model
Serial viscoelastic bed deformation model.
const array::Scalar & total_displacement() const
array::Scalar m_total_displacement
Total (viscous and elastic) bed displacement.
const array::Scalar & viscous_displacement() const
void update_impl(const array::Scalar &ice_thickness, const array::Scalar &sea_level_elevation, double t, double dt)
Update the Lingle-Clark bed deformation model.
double m_update_interval
Update interval in seconds.
std::shared_ptr< array::Scalar > elastic_load_response_matrix() const
array::Scalar m_load_thickness
Ice-equivalent load thickness.
#define PISM_CHK(errcode, name)
#define PISM_ERROR_LOCATION
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)
T combine(const T &a, const T &b)
void get_real_part(fftw_complex *input, double normalization, int Mx, int My, int Nx, int Ny, int i0, int j0, petsc::Vec &output)
Get the real part of input and put it in output.