22 #include "pism/util/IceGrid.hh"
23 #include "pism/util/error_handling.hh"
24 #include "pism/util/IceModelVec2CellType.hh"
25 #include "pism/util/IceModelVec2V.hh"
26 #include "pism/stressbalance/StressBalance.hh"
27 #include "pism/rheology/FlowLawFactory.hh"
28 #include "pism/rheology/FlowLaw.hh"
29 #include "pism/geometry/Geometry.hh"
30 #include "pism/util/Context.hh"
36 std::shared_ptr<const rheology::FlowLaw> flow_law)
38 m_calving_threshold(m_grid,
"vonmises_calving_threshold",
WITHOUT_GHOSTS),
42 if (
m_config->get_flag(
"calving.vonmises_calving.use_custom_flow_law")) {
50 "horizontal calving rate due to von Mises calving",
51 "m s-1",
"m year-1",
"", 0);
54 "threshold used by the 'von Mises' calving method",
64 "* Initializing the 'von Mises calving' mechanism...\n");
66 std::string threshold_file =
m_config->get_string(
"calving.vonmises_calving.threshold_file");
67 double sigma_max =
m_config->get_number(
"calving.vonmises_calving.sigma_max");
71 if (not threshold_file.empty()) {
73 " Reading von Mises calving threshold from file '%s'...\n",
74 threshold_file.c_str());
79 " von Mises calving threshold: %3.3f Pa.\n", sigma_max);
84 "-calving vonmises_calving using a non-square grid cell is not implemented (yet);\n"
85 "dx = %f, dy = %f, relative difference = %f",
119 const double *z = &
m_grid->z()[0];
121 double glen_exponent =
m_flow_law->exponent();
124 const int i = pt.i(), j = pt.j();
131 velocity_magnitude = 0.0,
139 for (
int p = -1; p < 2; p += 2) {
140 const int I = i + p * offset;
142 velocity_magnitude += ice_velocity(
I, j).magnitude();
144 double H = ice_thickness(
I, j);
145 unsigned int k =
m_grid->kBelowHeight(H);
154 for (
int q = -1; q < 2; q += 2) {
155 const int J = j + q * offset;
157 velocity_magnitude += ice_velocity(i,
J).magnitude();
159 double H = ice_thickness(i,
J);
160 unsigned int k =
m_grid->kBelowHeight(H);
173 velocity_magnitude /= N;
178 const double effective_tensile_strain_rate = sqrt(0.5 * (pow(
max(0.0, eigen1), 2) +
179 pow(
max(0.0, eigen2), 2)));
181 const double sigma_tilde = sqrt(3.0) * hardness * pow(effective_tensile_strain_rate,
182 1.0 / glen_exponent);
Makes sure that we call begin_access() and end_access() for all accessed IceModelVecs.
IceGrid::ConstPtr grid() const
const Config::ConstPtr m_config
configuration database used by this component
const Logger::ConstPtr m_log
logger (for easy access)
const IceGrid::ConstPtr m_grid
grid used by this component
static Ptr wrap(const T &input)
std::shared_ptr< EnthalpyConverter > Ptr
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
"Cell type" mask. Adds convenience methods to IceModelVec2Int.
void copy_from(const IceModelVec2S &source)
double * get_column(int i, int j)
A virtual class collecting methods common to ice and bedrock 3D fields.
void update_ghosts()
Updates ghost points.
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.
void regrid(const std::string &filename, RegriddingFlag flag, double default_value=0.0)
void set(double c)
Result: v[j] <- c for all j.
void set_time_independent(bool flag)
Set the time independent flag for all variables corresponding to this IceModelVec instance.
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
const int m_stencil_width
IceModelVec3 m_strain_rates
IceModelVec2S m_calving_rate
IceModelVec2CellType m_cell_type
An abstract class containing fields used by all stress-based calving methods.
std::shared_ptr< const rheology::FlowLaw > m_flow_law
IceModelVec2S m_calving_threshold
void update(const IceModelVec2CellType &cell_type, const IceModelVec2S &ice_thickness, const IceModelVec2V &ice_velocity, const IceModelVec3 &ice_enthalpy)
Uses principal strain rates to apply the "von Mises" calving method.
DiagnosticList diagnostics_impl() const
vonMisesCalving(IceGrid::ConstPtr grid, std::shared_ptr< const rheology::FlowLaw > flow_law)
const IceModelVec2S & threshold() const
std::shared_ptr< FlowLaw > create()
#define PISM_ERROR_LOCATION
double averaged_hardness(const FlowLaw &ice, double thickness, int kbelowH, const double *zlevels, const double *enthalpy)
Computes vertical average of B(E, p) ice hardness, namely .
void compute_2D_principal_strain_rates(const IceModelVec2V &V, const IceModelVec2CellType &mask, IceModelVec3 &result)
Compute eigenvalues of the horizontal, vertically-integrated strain rate tensor.
double max(const IceModelVec2S &input)
Finds maximum over all the values in an IceModelVec2S object. Ignores ghosts.
std::map< std::string, Diagnostic::Ptr > DiagnosticList
double min(const IceModelVec2S &input)
Finds minimum over all the values in an IceModelVec2S object. Ignores ghosts.