23 class TimeStepAlgorithm;
37 std::vector<double> timesteps;
38 double t_curr = t_initial;
44 if (range.begin() == range.end())
46 OGS_FATAL(
"no timesteps have been given");
48 for (
auto const pair : range)
51 auto const repeat = pair.getConfigParameter<std::size_t>(
"repeat");
53 delta_t = pair.getConfigParameter<
double>(
"delta_t");
61 OGS_FATAL(
"timestep <delta_t> is <= 0.0.");
66 auto const new_size = timesteps.size() + repeat;
69 timesteps.resize(new_size, delta_t);
71 catch (std::length_error
const& e)
74 "Resize of the time steps vector failed for the requested "
75 "new size {:d}. Probably there is not enough memory ({:g} "
77 "Thrown exception: {:s}",
79 new_size *
sizeof(
double) / 1024. / 1024. / 1024.,
82 catch (std::bad_alloc
const& e)
85 "Resize of the time steps vector failed for the requested "
86 "new size {:d}. Probably there is not enough memory ({:g} "
88 "Thrown exception: {:s}",
89 new_size, new_size *
sizeof(
double) / 1024. / 1024. / 1024.,
93 t_curr += repeat * delta_t;
101 static_cast<std::size_t
>(std::ceil((t_end - t_curr) / delta_t));
102 auto const new_size = timesteps.size() + repeat;
105 timesteps.resize(new_size, delta_t);
107 catch (std::length_error
const& e)
110 "Resize of the time steps vector failed for the requested new "
111 "size {:d}. Probably there is not enough memory ({:g} GiB "
113 "Thrown exception: {:s}",
115 new_size *
sizeof(
double) / 1024. / 1024. / 1024.,
118 catch (std::bad_alloc
const& e)
121 "Resize of the time steps vector failed for the requested new "
122 "size {:d}. Probably there is not enough memory ({:g} GiB "
124 "Thrown exception: {:s}",
125 new_size, new_size *
sizeof(
double) / 1024. / 1024. / 1024.,
130 return std::make_unique<FixedTimeStepping>(t_initial, t_end, timesteps);
void checkConfigParameter(std::string const ¶m, T const &value) const
T getConfigParameter(std::string const ¶m) const
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
ConfigTree getConfigSubtree(std::string const &root) const
std::unique_ptr< TimeStepAlgorithm > createFixedTimeStepping(BaseLib::ConfigTree const &config)