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/util/Context.hh"
33#include "pism/util/Logger.hh"
34#include "pism/util/io/IO_Flags.hh"
40 std::shared_ptr<const rheology::FlowLaw> flow_law)
42 m_calving_threshold(m_grid,
"vonmises_calving_threshold"),
46 if (
m_config->get_flag(
"calving.vonmises_calving.use_custom_flow_law")) {
49 m_config->get_number(
"calving.vonmises_calving.Glen_exponent"));
54 .
long_name(
"horizontal calving rate due to von Mises calving")
59 .
long_name(
"threshold used by the 'von Mises' calving method")
67 "* Initializing the 'von Mises calving' mechanism...\n");
69 std::string threshold_file =
m_config->
get_string(
"calving.vonmises_calving.threshold_file");
70 double sigma_max =
m_config->get_number(
"calving.vonmises_calving.sigma_max");
74 if (not threshold_file.empty()) {
76 " Reading von Mises calving threshold from file '%s'...\n",
77 threshold_file.c_str());
82 " von Mises calving threshold: %3.3f Pa.\n", sigma_max);
86 const double eps = 1e-2;
89 "-calving vonmises_calving using a non-square grid cell is not implemented (yet);\n"
90 "dx = %f, dy = %f, relative difference = %f",
124 const double *z = ice_enthalpy.
levels().data();
126 double glen_exponent =
m_flow_law->exponent();
128 for (
auto pt :
m_grid->points()) {
129 const int i = pt.i(), j = pt.j();
136 velocity_magnitude = 0.0,
144 for (
int p = -1; p < 2; p += 2) {
145 const int I = i + p * offset;
147 velocity_magnitude += ice_velocity(I, j).magnitude();
149 double H = ice_thickness(I, j);
150 auto k =
m_grid->kBelowHeight(H);
159 for (
int q = -1; q < 2; q += 2) {
160 const int J = j + q * offset;
162 velocity_magnitude += ice_velocity(i, J).magnitude();
164 double H = ice_thickness(i, J);
165 auto k =
m_grid->kBelowHeight(H);
178 velocity_magnitude /= N;
183 const double effective_tensile_strain_rate = sqrt(0.5 * (pow(max(0.0, eigen1), 2) +
184 pow(max(0.0, eigen2), 2)));
186 const double sigma_tilde = sqrt(3.0) * hardness * pow(effective_tensile_strain_rate,
187 1.0 / glen_exponent);
std::shared_ptr< const Grid > grid() 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::shared_ptr< const Logger > m_log
logger (for easy access)
static Ptr wrap(const T &input)
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.
const std::vector< double > & levels() const
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 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
DiagnosticList spatial_diagnostics_impl() const
vonMisesCalving(std::shared_ptr< const Grid > grid, std::shared_ptr< const rheology::FlowLaw > flow_law)
array::Scalar m_calving_threshold
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(const std::string &type_name, double exponent)
#define PISM_ERROR_LOCATION
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