19 #include "pism/frontretreat/FrontRetreat.hh"
21 #include "pism/util/array/CellType.hh"
22 #include "pism/util/MaxTimestep.hh"
23 #include "pism/util/pism_utilities.hh"
24 #include "pism/geometry/part_grid_threshold_thickness.hh"
25 #include "pism/geometry/Geometry.hh"
26 #include "pism/util/Context.hh"
32 m_cell_type(m_grid,
"cell_type"),
33 m_tmp(m_grid,
"temporary_storage") {
48 const int Mx =
m_grid->Mx();
49 const int My =
m_grid->My();
53 for (
auto p =
m_grid->points(1); p; p.next()) {
54 const int i = p.i(), j = p.j();
56 if (i < 0 or i >= Mx or j < 0 or j >= My) {
59 output(i, j) = input(i, j);
76 auto sys =
grid->ctx()->unit_system();
81 double dt_min =
convert(sys, 0.001,
"years",
"seconds");
84 retreat_rate_max = 0.0,
85 retreat_rate_mean = 0.0;
90 for (
auto pt =
grid->points(); pt; pt.next()) {
91 const int i = pt.i(), j = pt.j();
95 bc_mask(i, j) < 0.5) {
98 const double C = retreat_rate(i, j);
101 retreat_rate_mean +=
C;
102 retreat_rate_max =
std::max(
C, retreat_rate_max);
111 retreat_rate_mean /= N_cells;
113 retreat_rate_mean = 0.0;
116 double denom = retreat_rate_max /
grid->dx();
117 const double epsilon =
convert(sys, 0.001 / (
grid->dx() +
grid->dy()),
"seconds",
"years");
119 double dt = 1.0 / (denom + epsilon);
122 " frontal retreat: maximum rate = %.2f m/year gives dt=%.5f years\n"
123 " mean rate = %.2f m/year over %d cells\n",
124 convert(
m_sys, retreat_rate_max,
"m second-1",
"m year-1"),
126 convert(
m_sys, retreat_rate_mean,
"m second-1",
"m year-1"),
154 if (
m_config->get_flag(
"geometry.front_retreat.wrap_around")) {
162 const double dx =
m_grid->dx();
171 for (
auto pt =
m_grid->points(); pt; pt.next()) {
172 const int i = pt.i(), j = pt.j();
177 bc_mask(i, j) < 0.5) {
181 rate = retreat_rate(i, j),
182 Href_old = Href(i, j);
186 ice_thickness.
star(i, j),
187 surface_elevation.
star(i, j),
191 const double Href_change = -dt * rate * H_threshold / dx;
193 if (Href_old + Href_change >= 0.0) {
195 Href(i, j) = Href_old + Href_change;
212 sl = sea_level.
star(i, j);
229 m_tmp(i, j) = (Href_old + Href_change) / (
double)N;
242 for (
auto p =
m_grid->points(); p; p.next()) {
243 const int i = p.i(), j = p.j();
246 if (bc_mask.
as_int(i, j) == 0 and
250 const double delta_H = (
m_tmp(i + 1, j) +
m_tmp(i - 1, j) +
254 Href(i, j) = ice_thickness(i, j) + delta_H;
255 ice_thickness(i, j) = 0.0;
259 if (Href(i, j) < 0.0) {
const units::System::Ptr m_sys
unit system used by this component
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
A class defining a common interface for most PISM sub-models.
void update_geometry(double dt, const Geometry &geometry, const array::Scalar1 &bc_mask, const array::Scalar &retreat_rate, array::Scalar &Href, array::Scalar1 &ice_thickness)
array::CellType1 m_cell_type
MaxTimestep max_timestep(const array::CellType1 &cell_type, const array::Scalar &bc_mask, const array::Scalar &retreat_rate) const
FrontRetreat(std::shared_ptr< const Grid > g)
void compute_modified_mask(const array::CellType1 &input, array::CellType1 &output) const
array::Scalar1 sea_level_elevation
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...
void failed()
Indicates a failure of a parallel section.
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void copy_from(const Array2D< T > &source)
stencils::Star< T > star(int i, int j) const
std::shared_ptr< const Grid > grid() const
void set(double c)
Result: v[j] <- c for all j.
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.
bool next_to_ice(int i, int j) const
Ice-free margin (at least one of four neighbors has ice).
stencils::Star< int > star_int(int i, int j) const
bool floating_ice(int i, int j) const
bool ice_free_ocean(int i, int j) const
bool grounded_ice(int i, int j) const
stencils::Star< int > star_int(int i, int j) const
int as_int(int i, int j) const
double max(const array::Scalar &input)
Finds maximum over all the values in an array::Scalar object. Ignores ghosts.
double convert(System::Ptr system, double input, const std::string &spec1, const std::string &spec2)
Convert a quantity from unit1 to unit2.
void GlobalMax(MPI_Comm comm, double *local, double *result, int count)
double part_grid_threshold_thickness(stencils::Star< int > cell_type, stencils::Star< double > ice_thickness, stencils::Star< double > surface_elevation, double bed_elevation)
Compute threshold thickness used when deciding if a partially-filled cell should be considered 'full'...
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)