20 #include "pism/coupler/FrontalMelt.hh"
21 #include "pism/util/iceModelVec.hh"
22 #include "pism/util/MaxTimestep.hh"
23 #include "pism/util/pism_utilities.hh"
24 #include "pism/geometry/Geometry.hh"
25 #include "pism/geometry/part_grid_threshold_thickness.hh"
26 #include "pism/util/Mask.hh"
36 namespace frontalmelt {
42 if (stencil_width > 0) {
48 result->set_attrs(
"diagnostic",
"frontal melt rate",
49 "m s-1",
"m day-1",
"", 0);
74 ice_density =
m_config->get_number(
"constants.ice.density"),
75 alpha = ice_density /
m_config->get_number(
"constants.sea_water.density");
78 &bed_elevation, &surface_elevation, &ice_thickness, &result};
83 const int i = p.i(), j = p.j();
87 bed = bed_elevation(i, j),
88 sea_level = sea_level_elevation(i, j);
90 auto H = ice_thickness.star(i, j);
91 auto h = surface_elevation.star(i, j);
92 auto M = cell_type.
star(i, j);
96 int m = gc.
mask(sea_level, bed, H_threshold);
100 alpha * H_threshold);
116 m_input_model(input),
117 m_retreat_rate(m_grid,
"retreat_rate_due_to_frontal_melt",
WITHOUT_GHOSTS)
120 "m s-1",
"m day-1",
"", 0);
189 namespace diagnostics {
202 "m second-1",
"m day-1", 0);
203 m_vars[0][
"cell_methods"] =
"time: mean";
210 return model->frontal_melt_rate();
224 set_attrs(
"retreat rate due to frontal melt",
"",
225 "m second-1",
"m year-1", 0);
226 m_vars[0][
"cell_methods"] =
"time: mean";
229 m_vars[0][
"comment"] =
"takes into account what part of the front is submerged";
234 return model->retreat_rate();
244 {
"frontal_melt_retreat_rate",
Diagnostic::Ptr(
new FrontalMeltRetreatRate(
this))}
Makes sure that we call begin_access() and end_access() for all accessed IceModelVecs.
const Config::ConstPtr m_config
configuration database used by this component
const IceGrid::ConstPtr m_grid
grid used by this component
DiagnosticList diagnostics() const
A class defining a common interface for most PISM sub-models.
IceModelVec2S m_accumulator
double m_fill_value
fill value (used often enough to justify storing it)
const units::System::Ptr m_sys
the unit system
double to_internal(double x) const
std::vector< SpatialVariableMetadata > m_vars
metadata corresponding to NetCDF variables
std::shared_ptr< Diagnostic > Ptr
void set_attrs(const std::string &long_name, const std::string &standard_name, const std::string &units, const std::string &glaciological_units, unsigned int N=0)
A method for setting common variable attributes.
High-level PISM I/O class.
int mask(double sea_level, double bed, double thickness) const
IceModelVec2S ice_surface_elevation
IceModelVec2CellType cell_type
IceModelVec2S bed_elevation
IceModelVec2S sea_level_elevation
IceModelVec2S ice_thickness
std::shared_ptr< const IceGrid > ConstPtr
bool next_to_ice(int i, int j) const
Ice-free margin (at least one of four neighbors has ice).
bool icy(int i, int j) const
bool ice_free_ocean(int i, int j) const
bool next_to_grounded_ice(int i, int j) const
bool grounded_ice(int i, int j) const
"Cell type" mask. Adds convenience methods to IceModelVec2Int.
stencils::Star< int > star(int i, int j) const
std::shared_ptr< IceModelVec2S > Ptr
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
void set_attrs(const std::string &pism_intent, const std::string &long_name, const std::string &units, const std::string &glaciological_units, const std::string &standard_name, unsigned int component)
Sets NetCDF attributes of an IceModelVec object.
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
FrontalMelt(IceGrid::ConstPtr g, std::shared_ptr< FrontalMelt > input)
void compute_retreat_rate(const Geometry &geometry, const IceModelVec2S &frontal_melt_rate, IceModelVec2S &result) const
virtual MaxTimestep max_timestep_impl(double t) const
bool apply(const IceModelVec2CellType &M, int i, int j)
void init(const Geometry &geometry)
void update(const FrontalMeltInputs &inputs, double t, double dt)
const IceModelVec2S & frontal_melt_rate() const
const IceModelVec2S & retreat_rate() const
std::shared_ptr< FrontalMelt > m_input_model
virtual DiagnosticList diagnostics_impl() const
virtual void update_impl(const FrontalMeltInputs &inputs, double t, double dt)
virtual const IceModelVec2S & frontal_melt_rate_impl() const =0
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
virtual TSDiagnosticList ts_diagnostics_impl() const
bool m_include_floating_ice
virtual void init_impl(const Geometry &geometry)
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
static IceModelVec2S::Ptr allocate_frontal_melt_rate(IceGrid::ConstPtr g, int stencil_width=0)
IceModelVec2S m_retreat_rate
A very rudimentary PISM frontal melt model.
FrontalMeltRate(const FrontalMelt *m)
const IceModelVec2S & model_input()
Report frontal melt rate.
FrontalMeltRetreatRate(const FrontalMelt *m)
const IceModelVec2S & model_input()
Report retreat rate due to frontal melt.
#define PISM_ERROR_LOCATION
bool grounded(int M)
Grounded cell (grounded ice or ice-free).
double max(const IceModelVec2S &input)
Finds maximum over all the values in an IceModelVec2S object. Ignores ghosts.
std::map< std::string, TSDiagnostic::Ptr > TSDiagnosticList
std::map< std::string, Diagnostic::Ptr > DiagnosticList
double part_grid_threshold_thickness(stencils::Star< int > M, stencils::Star< double > H, stencils::Star< double > h, double bed_elevation)
Compute threshold thickness used when deciding if a partially-filled cell should be considered 'full'...
T combine(const T &a, const T &b)