23 #include "pism/frontretreat/calving/vonMisesCalving.hh"
25 #include "pism/util/Grid.hh"
26 #include "pism/util/error_handling.hh"
27 #include "pism/util/array/CellType.hh"
28 #include "pism/util/array/Vector.hh"
29 #include "pism/stressbalance/StressBalance.hh"
30 #include "pism/rheology/FlowLawFactory.hh"
31 #include "pism/rheology/FlowLaw.hh"
32 #include "pism/geometry/Geometry.hh"
33 #include "pism/util/Context.hh"
39 std::shared_ptr<const rheology::FlowLaw> flow_law)
41 m_calving_threshold(m_grid,
"vonmises_calving_threshold"),
45 if (
m_config->get_flag(
"calving.vonmises_calving.use_custom_flow_law")) {
53 .
long_name(
"horizontal calving rate due to von Mises calving")
58 .
long_name(
"threshold used by the 'von Mises' calving method")
66 "* Initializing the 'von Mises calving' mechanism...\n");
68 std::string threshold_file =
m_config->get_string(
"calving.vonmises_calving.threshold_file");
69 double sigma_max =
m_config->get_number(
"calving.vonmises_calving.sigma_max");
73 if (not threshold_file.empty()) {
75 " Reading von Mises calving threshold from file '%s'...\n",
76 threshold_file.c_str());
81 " von Mises calving threshold: %3.3f Pa.\n", sigma_max);
85 const double eps = 1e-2;
88 "-calving vonmises_calving using a non-square grid cell is not implemented (yet);\n"
89 "dx = %f, dy = %f, relative difference = %f",
123 const double *z =
m_grid->z().data();
125 double glen_exponent =
m_flow_law->exponent();
127 for (
auto pt =
m_grid->points(); pt; pt.next()) {
128 const int i = pt.i(), j = pt.j();
135 velocity_magnitude = 0.0,
143 for (
int p = -1; p < 2; p += 2) {
144 const int I = i + p * offset;
146 velocity_magnitude += ice_velocity(
I, j).magnitude();
148 double H = ice_thickness(
I, j);
149 auto k =
m_grid->kBelowHeight(H);
158 for (
int q = -1; q < 2; q += 2) {
159 const int J = j + q * offset;
161 velocity_magnitude += ice_velocity(i,
J).magnitude();
163 double H = ice_thickness(i,
J);
164 auto k =
m_grid->kBelowHeight(H);
177 velocity_magnitude /= N;
182 const double effective_tensile_strain_rate = sqrt(0.5 * (pow(
max(0.0, eigen1), 2) +
183 pow(
max(0.0, eigen2), 2)));
185 const double sigma_tilde = sqrt(3.0) * hardness * pow(effective_tensile_strain_rate,
186 1.0 / glen_exponent);
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)
const std::shared_ptr< const Grid > m_grid
grid used by this component
static Ptr wrap(const T &input)
std::shared_ptr< EnthalpyConverter > Ptr
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void copy_from(const Array2D< T > &source)
double * get_column(int i, int j)
A virtual class collecting methods common to ice and bedrock 3D fields.
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.
bool next_to_ice(int i, int j) const
Ice-free margin (at least one of four neighbors has ice).
bool ice_free_ocean(int i, int j) const
bool icy(int i, int j) const
const int m_stencil_width
array::Array2D< stressbalance::PrincipalStrainRates > m_strain_rates
array::Scalar m_calving_rate
array::CellType1 m_cell_type
An abstract class containing fields used by all stress-based calving methods.
std::shared_ptr< const rheology::FlowLaw > m_flow_law
vonMisesCalving(std::shared_ptr< const Grid > grid, std::shared_ptr< const rheology::FlowLaw > flow_law)
array::Scalar m_calving_threshold
DiagnosticList diagnostics_impl() const
const array::Scalar & threshold() const
void update(const array::CellType1 &cell_type, const array::Scalar &ice_thickness, const array::Vector1 &ice_velocity, const array::Array3D &ice_enthalpy)
Uses principal strain rates to apply the "von Mises" calving method.
std::shared_ptr< FlowLaw > create()
#define PISM_ERROR_LOCATION
double max(const array::Scalar &input)
Finds maximum over all the values in an array::Scalar object. Ignores ghosts.
double min(const array::Scalar &input)
Finds minimum over all the values in an array::Scalar object. Ignores ghosts.
double averaged_hardness(const FlowLaw &ice, double thickness, unsigned 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 array::Vector1 &V, const array::CellType1 &mask, array::Array2D< PrincipalStrainRates > &result)
Compute eigenvalues of the horizontal, vertically-integrated strain rate tensor.
std::map< std::string, Diagnostic::Ptr > DiagnosticList