OGS
CreateIterationNumberBasedTimeStepping.cpp
Go to the documentation of this file.
1
11
12#include <string>
13
14#include "BaseLib/Algorithm.h"
15#include "BaseLib/ConfigTree.h"
17#include "TimeStepAlgorithm.h"
18
19namespace NumLib
20{
21
22IterationNumberBasedTimeSteppingParameters
24{
26 config.checkConfigParameter("type", "IterationNumberBasedTimeStepping");
27
29 auto const t_initial = config.getConfigParameter<double>("t_initial");
31 auto const t_end = config.getConfigParameter<double>("t_end");
32 if (t_end < t_initial)
33 {
35 "iteration number based timestepping: t_end({}) is smaller than "
36 "t_initial({})",
37 t_end,
38 t_initial);
39 }
40
42 auto const initial_dt = config.getConfigParameter<double>("initial_dt");
44 auto const minimum_dt = config.getConfigParameter<double>("minimum_dt");
46 auto const maximum_dt = config.getConfigParameter<double>("maximum_dt");
47
48 auto number_iterations =
50 config.getConfigParameter<std::vector<int>>("number_iterations");
51 auto multiplier =
53 config.getConfigParameter<std::vector<double>>("multiplier");
54
55 return {t_initial,
56 t_end,
57 minimum_dt,
58 maximum_dt,
59 initial_dt,
60 std::move(number_iterations),
61 std::move(multiplier)};
62}
63
66std::unique_ptr<TimeStepAlgorithm> createIterationNumberBasedTimeStepping(
68 std::vector<double> const& fixed_times_for_output)
69{
70 if (parameters.t_end < parameters.t_initial)
71 {
73 "iteration number based timestepping: end time ({}) is smaller "
74 "than initial time ({})",
75 parameters.t_end,
76 parameters.t_initial);
77 }
78
79 return std::make_unique<IterationNumberBasedTimeStepping>(
80 parameters.t_initial, parameters.t_end, parameters.minimum_dt,
81 parameters.maximum_dt, parameters.initial_dt,
82 std::move(parameters.number_iterations),
83 std::move(parameters.multiplier), fixed_times_for_output);
84}
85
86} // namespace NumLib
#define OGS_FATAL(...)
Definition Error.h:26
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
IterationNumberBasedTimeSteppingParameters parseIterationNumberBasedTimeStepping(BaseLib::ConfigTree const &config)
std::unique_ptr< TimeStepAlgorithm > createIterationNumberBasedTimeStepping(IterationNumberBasedTimeSteppingParameters &&parameters, std::vector< double > const &fixed_times_for_output)