24 #include "pism/icemodel/IceModel.hh"
26 #include "pism/stressbalance/StressBalance.hh"
28 #include "pism/util/Grid.hh"
29 #include "pism/util/ConfigInterface.hh"
30 #include "pism/util/Time.hh"
32 #include "pism/util/pism_utilities.hh"
51 std::shared_ptr<const Grid> grid = u3.
grid();
54 CFL_x = grid->dx() / dt,
55 CFL_y = grid->dy() / dt;
59 unsigned int CFL_violation_count = 0;
62 for (
auto p = grid->points(); p; p.next()) {
63 const int i = p.i(), j = p.j();
65 const int ks = grid->kBelowHeight(ice_thickness(i,j));
72 for (
int k = 0;
k <= ks;
k++) {
73 if (fabs(u[
k]) > CFL_x) {
74 CFL_violation_count += 1;
76 if (fabs(v[
k]) > CFL_y) {
77 CFL_violation_count += 1;
86 return (
unsigned int)
GlobalMax(grid->com, CFL_violation_count);
99 if (n_CFL_violations > 0.0) {
100 const double CFLviolpercent = 100.0 * n_CFL_violations / (
m_grid->Mx() *
m_grid->My() *
m_grid->Mz());
102 const double CFLVIOL_REPORT_VERB2_PERCENT = 0.1;
103 if (CFLviolpercent > CFLVIOL_REPORT_VERB2_PERCENT ||
104 m_log->get_threshold() > 2) {
105 auto tempstr =
pism::printf(
" [!CFL#=%d (=%5.2f%% of 3D grid)] ",
106 n_CFL_violations, CFLviolpercent);
117 double meltfrac = 0.0;
118 if (tempAndAge or
m_log->get_threshold() >= 3) {
124 volume, area, meltfrac, max_diffusivity);
166 double volume,
double area,
167 double ,
double max_diffusivity) {
168 const bool do_energy =
m_config->get_flag(
"energy.enabled");
169 const int log10scalevol =
static_cast<int>(
m_config->get_number(
"output.runtime.volume_scale_factor_log10")),
170 log10scalearea =
static_cast<int>(
m_config->get_number(
"output.runtime.area_scale_factor_log10"));
171 const std::string time_units =
m_config->get_string(
"output.runtime.time_unit_name");
172 const bool use_calendar =
m_config->get_flag(
"output.runtime.time_use_calendar");
174 const double scalevol = pow(10.0,
static_cast<double>(log10scalevol)),
175 scalearea = pow(10.0,
static_cast<double>(log10scalearea));
179 if (log10scalevol != 0) {
182 if (log10scalearea != 0) {
186 if (printPrototype) {
188 "P time: ivol iarea max_diffusivity max_sliding_vel\n");
190 "U %s %skm^3 %skm^2 m^2 s^-1 m/%s\n",
193 areascalestr.c_str(),
200 static std::string stdout_flags_count0;
201 static int mass_cont_sub_counter = 0;
202 static double mass_cont_sub_dtsum = 0.0;
203 if (mass_cont_sub_counter == 0) {
207 mass_cont_sub_counter++;
208 mass_cont_sub_dtsum += delta_t;
211 if (tempAndAge or (not do_energy) or (
m_log->get_threshold() > 2)) {
214 const double major_dt =
m_time->convert_time_interval(mass_cont_sub_dtsum, time_units);
215 if (mass_cont_sub_counter <= 1) {
218 tempstr =
pism::printf(
" (dt=%.5f in %d substeps; av dt_sub_mass_cont=%.5f)",
219 major_dt, mass_cont_sub_counter, major_dt / mass_cont_sub_counter);
221 stdout_flags_count0 += tempstr;
224 stdout_flags_count0 +=
"\n";
225 m_log->message(2, stdout_flags_count0);
228 double T =
m_time->current();
236 std::string velocity_units =
"meters / (" + time_units +
")";
238 "m second-1", velocity_units);
241 "S %s: %8.5f %9.5f %12.5f %12.5f\n",
243 volume/(scalevol*1.0e9), area/(scalearea*1.0e6),
244 max_diffusivity, maxvel);
246 mass_cont_sub_counter = 0;
247 mass_cont_sub_dtsum = 0.0;
array::Scalar2 ice_thickness
virtual double compute_temperate_base_fraction(double ice_area)
std::shared_ptr< stressbalance::StressBalance > m_stress_balance
const Config::Ptr m_config
Configuration flags and parameters.
const Time::Ptr m_time
Time manager.
const Logger::Ptr m_log
Logger.
virtual void print_summary(bool tempAndAge)
std::string m_stdout_flags
const units::System::Ptr m_sys
Unit system.
virtual void print_summary_line(bool printPrototype, bool tempAndAge, double delta_t, double volume, double area, double meltfrac, double max_diffusivity)
Print a line to stdout which summarizes the state of the modeled ice sheet at the end of the time ste...
double dt_TempAge
enthalpy/temperature and age time-steps
double m_dt
mass continuity time step, s
const std::shared_ptr< Grid > m_grid
Computational grid.
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
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.
unsigned int count_CFL_violations(const array::Array3D &u3, const array::Array3D &v3, const array::Scalar &ice_thickness, double dt)
Because of the -skip mechanism it is still possible that we can have CFL violations: count them.
double ice_area(const Geometry &geometry, double thickness_threshold)
Computes ice area, in m^2.
void GlobalMax(MPI_Comm comm, double *local, double *result, int count)
std::string printf(const char *format,...)
double ice_volume(const Geometry &geometry, double thickness_threshold)
Computes the ice volume, in m^3.