19#include "pism/basalstrength/OptTillphiYieldStress.hh"
21#include "pism/basalstrength/MohrCoulombYieldStress.hh"
22#include "pism/geometry/Geometry.hh"
23#include "pism/util/Grid.hh"
24#include "pism/util/array/CellType.hh"
25#include "pism/util/MaxTimestep.hh"
26#include "pism/util/Time.hh"
27#include "pism/util/error_handling.hh"
28#include "pism/util/io/File.hh"
29#include "pism/util/pism_utilities.hh"
30#include "pism/util/Logger.hh"
31#include "pism/util/io/IO_Flags.hh"
32#include "pism/util/io/io_helpers.hh"
42 m_mask(m_grid,
"diff_mask"),
43 m_usurf_difference(m_grid,
"usurf_difference"),
44 m_usurf_target(m_grid,
"usurf"),
45 m_time_name(m_config->get_string(
"time.dimension_name") +
"_tillphi_opt")
51 m_name =
"Iterative optimization of the till friction angle for the Mohr-Coulomb yield stress model";
54 .
long_name(
"target surface elevation for tillphi optimization")
59 .
long_name(
"difference between modeled and target surface elevations")
66 "one if the till friction angle was updated by the last iteration, zero otherwise ");
69 m_mask.
metadata()[
"flag_meanings"] =
"no_update updated_during_last_iteration";
73 m_dhdt_min =
m_config->get_number(
"basal_yield_stress.mohr_coulomb.tillphi_opt.dhdt_min",
"m / s");
76 m_dphi_scale =
m_config->get_number(
"basal_yield_stress.mohr_coulomb.tillphi_opt.dphi_scale",
"degree / m");
78 m_dphi_max =
m_config->get_number(
"basal_yield_stress.mohr_coulomb.tillphi_opt.dphi_max");
81 m_phi0_min =
m_config->get_number(
"basal_yield_stress.mohr_coulomb.tillphi_opt.phi0_min");
82 m_phi0_max =
m_config->get_number(
"basal_yield_stress.mohr_coulomb.tillphi_opt.phi0_max");
83 m_topg_min =
m_config->get_number(
"basal_yield_stress.mohr_coulomb.tillphi_opt.topg_min");
84 m_topg_max =
m_config->get_number(
"basal_yield_stress.mohr_coulomb.tillphi_opt.topg_max");
86 m_phi_max =
m_config->get_number(
"basal_yield_stress.mohr_coulomb.tillphi_opt.phi_max");
90 "basal_yield_stress.mohr_coulomb.tillphi_opt: phi0_min >= phi_max");
95 "basal_yield_stress.mohr_coulomb.tillphi_opt: topg_min >= topg_max");
106 " Using iterative optimization of the till friction angle.\n"
107 " Lower bound phi0 of the till friction angle is a piecewise-linear function of bed elevation (b):\n"
108 " / %5.2f for b < %.f\n"
109 " phi0 = | %5.2f + (b - (%.f)) * (%.2f / %.f) for %.f < b < %.f\n"
110 " \\ %5.2f for %.f < b\n",
123 auto t_last = t_length > 0 ? t_length - 1 : 0;
135 auto filename =
m_config->get_string(
"basal_yield_stress.mohr_coulomb.tillphi_opt.file");
137 if (not filename.empty()) {
140 m_log->message(2,
"* No file set to read target surface elevation from... using '%s'\n",
141 input_file.
name().c_str());
173 "not implemented: till friction angle optimization "
174 "cannot be initialized without an input file");
182 "time %f is less than the previous time %f",
203 return std::min(dt_max, dt_mohr_coulomb);
207 double t,
double dt) {
217 if (std::abs(t_next - t_final) <
m_t_eps) {
233 m_log->message(2,
"* Updating till friction angle...\n");
242 for (
auto p :
m_grid->points()) {
243 const int i = p.i(), j = p.j();
250 }
else if (bed_topography(i, j) <=
m_topg_max) {
274 }
else if (cell_type.
ocean(i, j)) {
286 T.
long_name(
"time of the last update of the till friction angle")
const units::System::Ptr m_sys
unit system used by this component
const Time & time() const
std::shared_ptr< const Config > m_config
configuration database used by this component
const std::shared_ptr< const Grid > m_grid
grid used by this component
std::set< VariableMetadata > state() const
std::shared_ptr< const Logger > m_log
logger (for easy access)
static Ptr wrap(const T &input)
unsigned int nrecords() const
Get the number of records. Uses the length of an unlimited dimension.
bool variable_exists(const std::string &short_name) const
Checks if a variable exists.
High-level PISM I/O class.
array::Scalar2 ice_surface_elevation
array::CellType2 cell_type
array::Scalar2 bed_elevation
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
DiagnosticList spatial_diagnostics_impl() const
void restart_impl(const File &input_file, int record)
void update_impl(const YieldStressInputs &inputs, double t, double dt)
MaxTimestep max_timestep_impl(double t) const
void bootstrap_impl(const File &input_file, const YieldStressInputs &inputs)
Initialize the pseudo-plastic till mechanical model.
void write_state_impl(const OutputFile &output) const
The default (empty implementation).
PISM's default basal yield stress model which applies the Mohr-Coulomb model of deformable,...
MaxTimestep max_timestep_impl(double t) const
void bootstrap_impl(const File &input_file, const YieldStressInputs &inputs)
void init_t_last(const File &input_file)
void write_state_impl(const OutputFile &output) const
The default (empty implementation).
array::Scalar1 m_usurf_target
void init_impl(const YieldStressInputs &inputs)
std::set< VariableMetadata > state_impl() const
double m_update_interval
Update interval in seconds.
array::Scalar1 m_usurf_difference
DiagnosticList spatial_diagnostics_impl() const
double m_t_last
time of the last till friction angle update
void update_tillphi(const array::Scalar &ice_surface_elevation, const array::Scalar &bed_topography, const array::CellType &mask)
OptTillphiYieldStress(std::shared_ptr< const Grid > g)
void restart_impl(const File &input_file, int record)
std::string m_time_name
Name of the variable used to store the last update time.
double m_t_eps
Temporal resolution to use when checking whether it's time to update.
void update_impl(const YieldStressInputs &inputs, double t, double dt)
void init_usurf_target(const File &input_file)
void write_timeseries(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const std::vector< double > &input) const
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.
std::string calendar() const
Returns the calendar string.
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
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.
bool grounded_ice(int i, int j) const
bool ocean(int i, int j) const
"Cell type" mask. Adds convenience methods to array::Scalar.
#define PISM_ERROR_LOCATION
std::vector< double > read_timeseries_variable(const File &file, const std::string &variable_name, const std::string &units, std::shared_ptr< units::System > unit_system, size_t start, size_t count)
std::map< std::string, Diagnostic::Ptr > DiagnosticList
T combine(const T &a, const T &b)