20 #include "pism/stressbalance/timestepping.hh"
21 #include "pism/util/Grid.hh"
22 #include "pism/util/array/Array3D.hh"
23 #include "pism/util/array/Scalar.hh"
24 #include "pism/util/array/CellType.hh"
25 #include "pism/util/array/Vector.hh"
26 #include "pism/util/pism_utilities.hh"
27 #include "pism/util/Context.hh"
50 auto grid = ice_thickness.
grid();
53 double dt_max = config->get_number(
"time_stepping.maximum_time_step",
"seconds");
59 one_over_dx = 1.0 / grid->dx(),
60 one_over_dy = 1.0 / grid->dy();
62 double u_max = 0.0, v_max = 0.0, w_max = 0.0;
65 for (
auto p = grid->points(); p; p.next()) {
66 const int i = p.i(), j = p.j();
68 if (cell_type.
icy(i, j)) {
69 const int ks = grid->kBelowHeight(ice_thickness(i, j));
75 for (
int k = 0;
k <= ks; ++
k) {
81 const double denom = fabs(u_abs * one_over_dx) + fabs(v_abs * one_over_dy);
83 dt_max =
std::min(dt_max, 1.0 / denom);
87 for (
int k = 0;
k <= ks; ++
k) {
121 auto grid = ice_thickness.
grid();
124 double dt_max = config->get_number(
"time_stepping.maximum_time_step",
"seconds");
132 double u_max = 0.0, v_max = 0.0;
133 for (
auto p = grid->points(); p; p.next()) {
134 const int i = p.i(), j = p.j();
136 if (cell_type.
icy(i, j)) {
138 u_abs = fabs(velocity(i, j).u),
139 v_abs = fabs(velocity(i, j).v);
144 const double denom = u_abs / dx + v_abs / dy;
146 dt_max =
std::min(dt_max, 1.0 / denom);
162 double adaptive_timestepping_ratio) {
164 double grid_factor = 1.0 / (dx * dx) + 1.0 / (dy * dy);
165 return MaxTimestep(adaptive_timestepping_ratio * 2.0 / (D_max * grid_factor),
"diffusivity");
std::shared_ptr< const Config > ConstPtr
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.
double * get_column(int i, int j)
A virtual class collecting methods common to ice and bedrock 3D fields.
std::shared_ptr< const Grid > grid() const
bool icy(int i, int j) const
"Cell type" mask. Adds convenience methods to array::Scalar.
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.
CFLData max_timestep_cfl_2d(const array::Scalar &ice_thickness, const array::CellType &cell_type, const array::Vector &velocity)
Compute the CFL constant associated to first-order upwinding for the sliding contribution to mass con...
void GlobalMax(MPI_Comm comm, double *local, double *result, int count)
CFLData max_timestep_cfl_3d(const array::Scalar &ice_thickness, const array::CellType &cell_type, const array::Array3D &u3, const array::Array3D &v3, const array::Array3D &w3)
Compute the maximum velocities for time-stepping and reporting to user.
MaxTimestep max_timestep_diffusivity(double D_max, double dx, double dy, double adaptive_timestepping_ratio)
void GlobalMin(MPI_Comm comm, double *local, double *result, int count)