49 std::vector<double>
const& delta_ts,
50 Time const& fixed_output_time)
52 if (fixed_output_time < t_initial)
54 return std::numeric_limits<std::size_t>::max();
57 auto timestepper_time = t_initial;
58 for (std::size_t k = 0; k < delta_ts.size(); ++k)
60 if (timestepper_time <= fixed_output_time &&
61 fixed_output_time < timestepper_time + delta_ts[k])
65 timestepper_time += delta_ts[k];
68 return std::numeric_limits<std::size_t>::max();
73 std::vector<double>& delta_ts,
74 std::vector<double>
const& fixed_times_for_output)
76 if (fixed_times_for_output.empty())
81 if (
auto lower_bound = std::lower_bound(
82 begin(fixed_times_for_output), end(fixed_times_for_output),
83 t_initial, [](
auto const time,
NumLib::Time const& initial_time)
85 lower_bound != begin(fixed_times_for_output))
88 "Request for output at times {}, but the simulation's start time "
89 "is {}. Output will be skipped.",
90 fmt::join(begin(fixed_times_for_output), lower_bound,
", "),
94 if (
auto upper_bound =
95 std::upper_bound(begin(fixed_times_for_output),
96 end(fixed_times_for_output), t_end());
97 upper_bound != end(fixed_times_for_output))
100 "Request for output at times {}, but simulation's end time is {}. "
101 "Output will be skipped.",
102 fmt::join(upper_bound, end(fixed_times_for_output),
", "),
106 if (delta_ts.empty())
108 WARN(
"No timesteps specified.");
113 for (
auto const fixed_time_for_output : fixed_times_for_output)
116 t_initial, delta_ts,
Time(fixed_time_for_output));
117 if (interval_number == std::numeric_limits<std::size_t>::max())
119 WARN(
"Did not find interval for fixed output time {}",
120 fixed_time_for_output);
124 auto const lower_bound = std::accumulate(
125 begin(delta_ts), begin(delta_ts) + interval_number, t_initial);
126 auto const upper_bound = lower_bound + delta_ts[interval_number];
136 delta_ts[interval_number] = fixed_time_for_output - lower_bound();
138 delta_ts.insert(delta_ts.begin() + interval_number + 1,
139 upper_bound() - fixed_time_for_output);
144 double t0,
double tn, std::vector<RepeatDtPair>
const& repeat_dt_pairs,
145 std::vector<double>
const& fixed_times_for_output)
153 "FixedTimeStepping: No time steps can be generated for the time "
154 "interval [{}, {}]. The end time must be larger than the start "
161 OGS_FATAL(
"FixedTimeStepping: Couldn't construct object from data");
164 for (
auto const& [repeat, delta_t] : repeat_dt_pairs)
168 t_curr = addTimeIncrement(
dt_vector_, repeat, delta_t, t_curr);
176 auto const repeat =
static_cast<std::size_t
>(
188 "FixedTimeStepping: No time steps were generated for the time "
189 "interval [{}, {}].",
195 "FixedTimeStepping: The last prescribed time step size is {:g}, "
196 "but must be positive.",
201 fixed_times_for_output);
208 if (
Time(t_end) <=
Time(t0) || dt <= 0.0)
211 "FixedTimeStepping: No time steps can be generated for the time "
212 "interval [{}, {}] with the time step size {:g}. The end time must "
213 "be larger than the start time and the time step size must be "
218 auto const new_size =
219 static_cast<std::size_t
>(std::ceil((t_end - t0) / dt));
222 dt_vector_ = std::vector<double>(new_size, dt);
224 catch (std::length_error
const& e)
227 "Resize of the time steps vector failed for the requested new "
228 "size {}. Probably there is not enough memory ({:g} GiB "
230 "Thrown exception: {}",
231 new_size, new_size *
sizeof(
double) / 1024. / 1024. / 1024.,
234 catch (std::bad_alloc
const& e)
237 "Allocation of the time steps vector failed for the requested "
238 "size {}. Probably there is not enough memory ({:g} GiB "
240 "Thrown exception: {}",
242 new_size *
sizeof(
double) / 1024. / 1024. / 1024.,