From 5a945b0656e290c002fb762f07df33d0c3ba7a83 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Tue, 27 Aug 2024 18:51:39 +0200 Subject: [PATCH] [NL] Make Time constructor explicit, TimeStepAlgorithm::{begin,end} return Time --- .../Algorithms/FixedTimeStepping.cpp | 20 ++++--- .../Algorithms/FixedTimeStepping.h | 4 +- .../Algorithms/TimeStepAlgorithm.cpp | 2 +- .../Algorithms/TimeStepAlgorithm.h | 4 +- NumLib/TimeStepping/Time.h | 3 +- ProcessLib/CreateTimeLoop.cpp | 4 +- ProcessLib/ProcessData.h | 2 +- Tests/NumLib/TestFixedTimeStepping.cpp | 48 ++++++---------- Tests/NumLib/TestTimeSteppingFixed.cpp | 55 ++++++++++--------- .../TestTimeSteppingIterationNumber.cpp | 48 +++++++--------- Tests/NumLib/TimeSteppingTestingTools.h | 8 +-- Tests/ProcessLib/TestProcessLibOutput.cpp | 13 +++-- 12 files changed, 99 insertions(+), 112 deletions(-) diff --git a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp index cd4ce7d795a..b1d9e7a931f 100644 --- a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp +++ b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.cpp @@ -51,9 +51,9 @@ NumLib::Time addTimeIncrement(std::vector<double>& delta_ts, namespace NumLib { -std::size_t findDeltatInterval(NumLib::Time const t_initial, +std::size_t findDeltatInterval(Time const& t_initial, std::vector<double> const& delta_ts, - double const fixed_output_time) + Time const& fixed_output_time) { if (fixed_output_time < t_initial) { @@ -84,9 +84,11 @@ void incorporateFixedTimesForOutput( return; } - if (auto lower_bound = - std::lower_bound(begin(fixed_times_for_output), - end(fixed_times_for_output), t_initial); + if (auto lower_bound = std::lower_bound( + begin(fixed_times_for_output), end(fixed_times_for_output), + t_initial, + [](auto const time, NumLib::Time const& initial_time) + { return NumLib::Time(time) < initial_time; }); lower_bound != begin(fixed_times_for_output)) { WARN( @@ -117,8 +119,8 @@ void incorporateFixedTimesForOutput( // incorporate fixed output times into dts vector for (auto const fixed_time_for_output : fixed_times_for_output) { - auto const interval_number = - findDeltatInterval(t_initial, delta_ts, fixed_time_for_output); + auto const interval_number = findDeltatInterval( + t_initial, delta_ts, Time(fixed_time_for_output)); if (interval_number == std::numeric_limits<std::size_t>::max()) { WARN("Did not find interval for fixed output time {}", @@ -221,9 +223,9 @@ std::tuple<bool, double> FixedTimeStepping::next( } double dt = _dt_vector[ts_current.timeStepNumber()]; - if (ts_current.current()() + dt > end()) + if (ts_current.current() + dt > end()) { // upper bound by t_end - dt = end() - ts_current.current()(); + dt = end()() - ts_current.current()(); } return std::make_tuple(true, dt); diff --git a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.h b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.h index f340248f928..369bfbc97f1 100644 --- a/NumLib/TimeStepping/Algorithms/FixedTimeStepping.h +++ b/NumLib/TimeStepping/Algorithms/FixedTimeStepping.h @@ -64,7 +64,7 @@ private: std::vector<double> _dt_vector; }; -std::size_t findDeltatInterval(NumLib::Time const t_initial, +std::size_t findDeltatInterval(Time const& t_initial, std::vector<double> const& delta_ts, - double const fixed_output_time); + Time const& fixed_output_time); } // namespace NumLib diff --git a/NumLib/TimeStepping/Algorithms/TimeStepAlgorithm.cpp b/NumLib/TimeStepping/Algorithms/TimeStepAlgorithm.cpp index 36e86846c38..2c4edc6af24 100644 --- a/NumLib/TimeStepping/Algorithms/TimeStepAlgorithm.cpp +++ b/NumLib/TimeStepping/Algorithms/TimeStepAlgorithm.cpp @@ -28,7 +28,7 @@ double possiblyClampDtToNextFixedTime( return dt; } - if ((t < *specific_time) && t + dt > *specific_time) + if ((t < Time(*specific_time)) && t + dt > Time(*specific_time)) { double const t_to_specific_time = *specific_time - t(); return t_to_specific_time; diff --git a/NumLib/TimeStepping/Algorithms/TimeStepAlgorithm.h b/NumLib/TimeStepping/Algorithms/TimeStepAlgorithm.h index 736652b53b6..f986aad4904 100644 --- a/NumLib/TimeStepping/Algorithms/TimeStepAlgorithm.h +++ b/NumLib/TimeStepping/Algorithms/TimeStepAlgorithm.h @@ -37,9 +37,9 @@ public: virtual ~TimeStepAlgorithm() = default; /// return the beginning of time steps - double begin() const { return _t_initial(); } + Time begin() const { return _t_initial; } /// return the end of time steps - double end() const { return _t_end(); } + Time end() const { return _t_end; } /// reset the current step size from the previous time virtual void resetCurrentTimeStep(const double /*dt*/, TimeStep& /*ts_previous*/, diff --git a/NumLib/TimeStepping/Time.h b/NumLib/TimeStepping/Time.h index 97805cc26a5..eb4e3ead45b 100644 --- a/NumLib/TimeStepping/Time.h +++ b/NumLib/TimeStepping/Time.h @@ -22,8 +22,7 @@ namespace NumLib struct Time { - // TODO explicit - constexpr Time(double const time) : value_{time} {} + constexpr explicit Time(double const time) : value_{time} {} constexpr double operator()() const { return value_(); } diff --git a/ProcessLib/CreateTimeLoop.cpp b/ProcessLib/CreateTimeLoop.cpp index 49b5bc64e85..67612ee673c 100644 --- a/ProcessLib/CreateTimeLoop.cpp +++ b/ProcessLib/CreateTimeLoop.cpp @@ -117,10 +117,10 @@ std::unique_ptr<TimeLoop> createTimeLoop( return (a->timestep_algorithm->end() < b->timestep_algorithm->end()); }); - const double start_time = + auto const start_time = per_process_data[minmax_iter.first - per_process_data.begin()] ->timestep_algorithm->begin(); - const double end_time = + auto const end_time = per_process_data[minmax_iter.second - per_process_data.begin()] ->timestep_algorithm->end(); diff --git a/ProcessLib/ProcessData.h b/ProcessLib/ProcessData.h index dd7577a42de..62e2076f996 100644 --- a/ProcessLib/ProcessData.h +++ b/ProcessLib/ProcessData.h @@ -31,7 +31,7 @@ struct ProcessData std::unique_ptr<NumLib::TimeDiscretization>&& time_disc_, int const process_id_, std::string&& process_name_, Process& process_) : timestep_algorithm(std::move(timestep_algorithm_)), - timestep_previous(timestep_algorithm->begin()), + timestep_previous(NumLib::Time(timestep_algorithm->begin())), timestep_current(timestep_previous), nonlinear_solver_tag(nonlinear_solver_tag_), nonlinear_solver(nonlinear_solver_), diff --git a/Tests/NumLib/TestFixedTimeStepping.cpp b/Tests/NumLib/TestFixedTimeStepping.cpp index cb5d24f868e..fc9f825b560 100644 --- a/Tests/NumLib/TestFixedTimeStepping.cpp +++ b/Tests/NumLib/TestFixedTimeStepping.cpp @@ -14,6 +14,7 @@ #include <numeric> #include "NumLib/TimeStepping/Algorithms/FixedTimeStepping.h" +#include "NumLib/TimeStepping/Time.h" namespace ac = autocheck; @@ -98,8 +99,9 @@ TEST_F(NumLibFixedTimeStepping, next) NumLib::FixedTimeStepping fixed_time_stepping{ t_initial, t_end, repeat_dt_pair, {}}; - NumLib::TimeStep ts_dummy(0, 0, 0); - NumLib::TimeStep ts_current(0, t_initial, 0); + NumLib::TimeStep ts_dummy(NumLib::Time(0), NumLib::Time(0), 0); + NumLib::TimeStep ts_current( + NumLib::Time(0), NumLib::Time(t_initial), 0); for (auto const& expected_time_point : expected_time_points) { auto [is_next, step_size] = @@ -107,23 +109,16 @@ TEST_F(NumLibFixedTimeStepping, next) 0 /* number_of_iterations */, ts_dummy, ts_current); - // this only happens if the last time step was processed or the - // current time is already at the end time up to machine precision - if (!is_next && step_size != 0.0) + // check if the current time plus the computed step size is not + // equivalent (comparison with eps included) to the expected time + // point + if (ts_current.current() + step_size != + NumLib::Time(expected_time_point)) { return false; } - // if the current time plus the computed step size minus the - // expected time is larger than the minimal time step size then the - // step size should be larger - // if next is true then the step - if (is_next && - (ts_current.current() + step_size) != expected_time_point) - { - return false; - } - // if next is true then the step size should be larger than zero - if (is_next && step_size == 0.0) + // check if the step size is zero + if (step_size == 0.0) { return false; } @@ -167,8 +162,8 @@ TEST_F(NumLibFixedTimeStepping, next_StaticTest) NumLib::FixedTimeStepping fixed_time_stepping{ t_initial, t_end, repeat_dt_pair, fixed_output_times}; - NumLib::TimeStep ts_dummy(0, 0, 0); - NumLib::TimeStep ts_current(0, t_initial, 0); + NumLib::TimeStep ts_dummy(NumLib::Time(0), NumLib::Time(0), 0); + NumLib::TimeStep ts_current(NumLib::Time(0), NumLib::Time(t_initial), 0); for (auto const& expected_time_point : expected_time_points) { auto [is_next, step_size] = @@ -176,19 +171,10 @@ TEST_F(NumLibFixedTimeStepping, next_StaticTest) 0 /* number_of_iterations */, ts_dummy, ts_current); - // this only happens if the last time step was processed or the - // current time is already at the end time up to machine precision - ASSERT_FALSE(!is_next && step_size != 0.0); - - // if the current time plus the computed step size minus the - // expected time is larger than the minimal time step size then the - // step size should be larger - // if next is true then the step - ASSERT_FALSE(is_next && - (ts_current.current() + step_size) != expected_time_point); - - // if next is true then the step size should be larger than zero - ASSERT_FALSE(is_next && step_size == 0.0); + ASSERT_TRUE(step_size != 0.0); + ASSERT_TRUE(ts_current.current() + step_size == + NumLib::Time(expected_time_point)); + ts_current += step_size; } ASSERT_EQ(ts_current.timeStepNumber(), dts.size()); diff --git a/Tests/NumLib/TestTimeSteppingFixed.cpp b/Tests/NumLib/TestTimeSteppingFixed.cpp index 5a2ec24c58d..c9b8652c1bc 100644 --- a/Tests/NumLib/TestTimeSteppingFixed.cpp +++ b/Tests/NumLib/TestTimeSteppingFixed.cpp @@ -44,8 +44,8 @@ protected: std::size_t find(double const t) { - double const t_initial = 0.0; - return NumLib::findDeltatInterval(t_initial, dts, t); + NumLib::Time const t_initial{0.0}; + return NumLib::findDeltatInterval(t_initial, dts, NumLib::Time(t)); } }; @@ -125,42 +125,41 @@ TEST_F(NumLibTimeSteppingFixed_TimeSteps, DtVectorGreaterThanSum) TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput_2) { - double t_initial = 1e-10; + NumLib::Time t_initial{1e-10}; std::vector<double> dts{}; dts.insert(dts.end(), 10, 1e-1); std::vector<double> fixed_times_for_output{{0.5, 1}}; - auto const expected_time = std::accumulate(dts.begin(), dts.end(), 0.0); + auto const expected_time = + std::accumulate(dts.begin(), dts.end(), NumLib::Time(0.0)); NumLib::incorporateFixedTimesForOutput(t_initial, expected_time, dts, fixed_times_for_output); // incorporation of time steps doesn't influence the entire simulation time - EXPECT_NEAR(expected_time, std::accumulate(dts.begin(), dts.end(), 0.0), - std::numeric_limits<double>::epsilon()); + ASSERT_EQ(expected_time, + std::accumulate(dts.begin(), dts.end(), NumLib::Time(0.0))); ASSERT_EQ(1e-1, dts[0]); ASSERT_EQ(1e-1, dts[1]); ASSERT_EQ(1e-1, dts[2]); ASSERT_EQ(1e-1, dts[3]); // time point 0.4 + 1e-10 - EXPECT_NEAR(1e-1 - t_initial, dts[4], + EXPECT_NEAR(1e-1 - t_initial(), dts[4], std::numeric_limits<double>::epsilon()); // time point 0.5 EXPECT_EQ(5e-1 + 1e-10 - 0.5, dts[5]); // time point 0.5 + 1e-10 EXPECT_EQ(1e-1, dts[6]); // time point 0.6 + 1e-10 EXPECT_EQ(1e-1, dts[7]); // time point 0.7 + 1e-10 EXPECT_EQ(1e-1, dts[8]); // time point 0.8 + 1e-10 EXPECT_EQ(1e-1, dts[9]); // time point 0.9 + 1e-10 - EXPECT_NEAR(1.0 - (9e-1 + t_initial), dts[10], + EXPECT_NEAR(1.0 - (t_initial + 9e-1)(), dts[10], std::numeric_limits<double>::epsilon()); // time point 1.0 - EXPECT_NEAR( - t_initial, dts[11], - std::numeric_limits<double>::epsilon()); // time point 1.0 + 1e-10 + ASSERT_EQ(t_initial, NumLib::Time(dts[11])); // time point 1.0 + 1e-10 } // unit test related to ThermoRichardsMechanics/LiakopoulosHM/liakopoulos.prj TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput_3) { - double t_initial = 0.0; + NumLib::Time t_initial{0.0}; std::vector<double> dts{}; // <pair> <repeat>10</repeat> <delta_t>1</delta_t> </pair> @@ -180,13 +179,15 @@ TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput_3) 1200.0, 2400.0, 4800.0, 6000.0, 7200.0}}; - auto const expected_time = std::accumulate(dts.begin(), dts.end(), 0.0); + auto const expected_time = + std::accumulate(dts.begin(), dts.end(), NumLib::Time(0.0)); NumLib::incorporateFixedTimesForOutput(t_initial, expected_time, dts, fixed_times_for_output); // incorporation of time steps doesn't influence the entire simulation time - ASSERT_EQ(expected_time, std::accumulate(dts.begin(), dts.end(), 0.0)); + ASSERT_EQ(expected_time, + std::accumulate(dts.begin(), dts.end(), NumLib::Time(0.0))); ASSERT_EQ(0.06, dts[0]); ASSERT_EQ(1 - 0.06, dts[1]); @@ -224,8 +225,8 @@ TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput_3) // ogs-ThermoMechanics_CreepBGRa_Verification_m2_3Dload_m2_3Dload TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput_4) { - double t_initial = 0.0; - std::vector<double> dts{t_initial}; + NumLib::Time t_initial{0.0}; + std::vector<double> dts{t_initial()}; // <pair> <repeat>1</repeat> <delta_t>1e-10</delta_t> </pair> dts.insert(dts.end(), 1, 1e-10); @@ -251,16 +252,18 @@ TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput_4) TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput) { - double t_initial = 1.0; + NumLib::Time t_initial{1.0}; std::vector<double> dts{{10, 10, 10}}; std::vector<double> fixed_times_for_output{{9, 12, 28}}; - auto const expected_time = std::accumulate(dts.begin(), dts.end(), 0.0); + auto const expected_time = + std::accumulate(dts.begin(), dts.end(), NumLib::Time(0.0)); - NumLib::incorporateFixedTimesForOutput(t_initial, expected_time, dts, - fixed_times_for_output); + NumLib::incorporateFixedTimesForOutput( + NumLib::Time(t_initial), expected_time, dts, fixed_times_for_output); - ASSERT_EQ(expected_time, std::accumulate(dts.begin(), dts.end(), 0.0)); + ASSERT_EQ(expected_time, + std::accumulate(dts.begin(), dts.end(), NumLib::Time(0.0))); ASSERT_EQ(8.0, dts[0]); ASSERT_EQ(2.0, dts[1]); ASSERT_EQ(1.0, dts[2]); @@ -272,18 +275,16 @@ TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput) TEST(NumLibTimeSteppingFixed_FixedOutputTimes, incorporateFixedTimesForOutput_Matching) { - double t_initial = 1.0; + NumLib::Time t_initial{1.0}; std::vector<double> timesteps{{10, 10, 10}}; std::vector<double> fixed_times_for_output{{9, 11, 31}}; auto const expected_time = - std::accumulate(timesteps.begin(), timesteps.end(), 0.0); + std::accumulate(timesteps.begin(), timesteps.end(), NumLib::Time(0.0)); NumLib::incorporateFixedTimesForOutput(t_initial, expected_time, timesteps, fixed_times_for_output); - ASSERT_EQ(expected_time, - std::accumulate(timesteps.begin(), timesteps.end(), 0.0)); ASSERT_EQ(8.0, timesteps[0]); ASSERT_EQ(2.0, timesteps[1]); ASSERT_EQ(10.0, timesteps[2]); @@ -293,7 +294,7 @@ TEST(NumLibTimeSteppingFixed_FixedOutputTimes, TEST(NumLibTimeSteppingFixed_FixedOutputTimes, OutputTimeBeforeSimulationStartTime) { - double t_initial = 10.0; + NumLib::Time t_initial{10.0}; std::vector<double> timesteps{{10, 10, 10}}; std::vector<double> fixed_times_for_output{{9, 12, 28}}; @@ -313,7 +314,7 @@ TEST(NumLibTimeSteppingFixed_FixedOutputTimes, TEST(NumLibTimeSteppingFixed_FixedOutputTimes, OutputTimeAfterSimulationEndTime) { - double t_initial = 1.0; + NumLib::Time const t_initial{1.0}; std::vector<double> timesteps{{10, 10, 10}}; std::vector<double> fixed_times_for_output{{9, 12, 28, 33}}; diff --git a/Tests/NumLib/TestTimeSteppingIterationNumber.cpp b/Tests/NumLib/TestTimeSteppingIterationNumber.cpp index c2b979b82e0..206cbf2d25d 100644 --- a/Tests/NumLib/TestTimeSteppingIterationNumber.cpp +++ b/Tests/NumLib/TestTimeSteppingIterationNumber.cpp @@ -30,14 +30,14 @@ TEST(NumLib, TimeSteppingIterationNumberBased1) std::move(multiplier_vector), {}); const double solution_error = 0.; - const double end_time = alg.end(); + auto const end_time = alg.end(); NumLib::TimeStep previous_timestep(alg.begin()); NumLib::TimeStep current_timestep(alg.begin()); auto [step_accepted, timestepper_dt] = alg.next(solution_error, 1, previous_timestep, current_timestep); ASSERT_TRUE(step_accepted); - timestepper_dt = (current_timestep.current()() + timestepper_dt > end_time) - ? end_time - current_timestep.current()() + timestepper_dt = (current_timestep.current() + timestepper_dt > end_time) + ? end_time() - current_timestep.current()() : timestepper_dt; NumLib::updateTimeSteps(timestepper_dt, previous_timestep, current_timestep); @@ -52,10 +52,9 @@ TEST(NumLib, TimeSteppingIterationNumberBased1) auto [step_accepted1, timestepper_dt1] = alg.next(solution_error, 1, previous_timestep, current_timestep); ASSERT_TRUE(step_accepted1); - timestepper_dt1 = - (current_timestep.current()() + timestepper_dt1 > end_time) - ? end_time - current_timestep.current()() - : timestepper_dt1; + timestepper_dt1 = (current_timestep.current() + timestepper_dt1 > end_time) + ? end_time() - current_timestep.current()() + : timestepper_dt1; NumLib::updateTimeSteps(timestepper_dt1, previous_timestep, current_timestep); alg.resetCurrentTimeStep(timestepper_dt1, previous_timestep, @@ -64,10 +63,9 @@ TEST(NumLib, TimeSteppingIterationNumberBased1) auto [step_accepted2, timestepper_dt2] = alg.next(solution_error, 3, previous_timestep, current_timestep); ASSERT_TRUE(step_accepted2); - timestepper_dt2 = - (current_timestep.current()() + timestepper_dt2 > end_time) - ? end_time - current_timestep.current()() - : timestepper_dt2; + timestepper_dt2 = (current_timestep.current() + timestepper_dt2 > end_time) + ? end_time() - current_timestep.current()() + : timestepper_dt2; NumLib::updateTimeSteps(timestepper_dt2, previous_timestep, current_timestep); alg.resetCurrentTimeStep(timestepper_dt2, previous_timestep, @@ -81,10 +79,9 @@ TEST(NumLib, TimeSteppingIterationNumberBased1) auto [step_accepted3, timestepper_dt3] = alg.next(solution_error, 5, previous_timestep, current_timestep); ASSERT_TRUE(step_accepted3); - timestepper_dt3 = - (current_timestep.current()() + timestepper_dt3 > end_time) - ? end_time - current_timestep.current()() - : timestepper_dt3; + timestepper_dt3 = (current_timestep.current() + timestepper_dt3 > end_time) + ? end_time() - current_timestep.current()() + : timestepper_dt3; NumLib::updateTimeSteps(timestepper_dt3, previous_timestep, current_timestep); alg.resetCurrentTimeStep(timestepper_dt3, previous_timestep, @@ -98,10 +95,9 @@ TEST(NumLib, TimeSteppingIterationNumberBased1) auto [step_accepted4, timestepper_dt4] = alg.next(solution_error, 7, previous_timestep, current_timestep); ASSERT_TRUE(step_accepted4); - timestepper_dt4 = - (current_timestep.current()() + timestepper_dt4 > end_time) - ? end_time - current_timestep.current()() - : timestepper_dt4; + timestepper_dt4 = (current_timestep.current() + timestepper_dt4 > end_time) + ? end_time() - current_timestep.current()() + : timestepper_dt4; NumLib::updateTimeSteps(timestepper_dt4, previous_timestep, current_timestep); alg.resetCurrentTimeStep(timestepper_dt4, previous_timestep, @@ -115,10 +111,9 @@ TEST(NumLib, TimeSteppingIterationNumberBased1) auto [step_accepted5, timestepper_dt5] = alg.next(solution_error, 8, previous_timestep, current_timestep); ASSERT_TRUE(step_accepted5); - timestepper_dt5 = - (current_timestep.current()() + timestepper_dt5 > end_time) - ? end_time - current_timestep.current()() - : timestepper_dt5; + timestepper_dt5 = (current_timestep.current() + timestepper_dt5 > end_time) + ? end_time() - current_timestep.current()() + : timestepper_dt5; NumLib::updateTimeSteps(timestepper_dt5, previous_timestep, current_timestep); alg.resetCurrentTimeStep(timestepper_dt5, previous_timestep, @@ -134,10 +129,9 @@ TEST(NumLib, TimeSteppingIterationNumberBased1) ASSERT_TRUE(step_accepted6); NumLib::updateTimeSteps(timestepper_dt6, previous_timestep, current_timestep); - timestepper_dt6 = - (current_timestep.current()() + timestepper_dt6 > end_time) - ? end_time - current_timestep.current()() - : timestepper_dt6; + timestepper_dt6 = (current_timestep.current() + timestepper_dt6 > end_time) + ? end_time() - current_timestep.current()() + : timestepper_dt6; alg.resetCurrentTimeStep(timestepper_dt6, previous_timestep, current_timestep); ASSERT_EQ(7u, current_timestep.timeStepNumber()); diff --git a/Tests/NumLib/TimeSteppingTestingTools.h b/Tests/NumLib/TimeSteppingTestingTools.h index ad110c12543..10279f3306f 100644 --- a/Tests/NumLib/TimeSteppingTestingTools.h +++ b/Tests/NumLib/TimeSteppingTestingTools.h @@ -36,9 +36,9 @@ std::vector<double> timeStepping(T_TIME_STEPPING& algorithm, T* obj = nullptr) { std::vector<double> vec_t; - vec_t.push_back(algorithm.begin()); + vec_t.push_back(algorithm.begin()()); - const double end_time = algorithm.end(); + auto const end_time = algorithm.end(); NumLib::TimeStep current_timestep(algorithm.begin()); NumLib::TimeStep previous_timestep(algorithm.begin()); @@ -64,8 +64,8 @@ std::vector<double> timeStepping(T_TIME_STEPPING& algorithm, } timestepper_dt = - (current_timestep.current()() + timestepper_dt > end_time) - ? end_time - current_timestep.current()() + (current_timestep.current() + timestepper_dt > end_time) + ? end_time() - current_timestep.current()() : timestepper_dt; NumLib::updateTimeSteps(timestepper_dt, previous_timestep, diff --git a/Tests/ProcessLib/TestProcessLibOutput.cpp b/Tests/ProcessLib/TestProcessLibOutput.cpp index feb746313ff..be9eaefb67b 100644 --- a/Tests/ProcessLib/TestProcessLibOutput.cpp +++ b/Tests/ProcessLib/TestProcessLibOutput.cpp @@ -12,6 +12,7 @@ #include <autocheck/autocheck.hpp> +#include "NumLib/TimeStepping/Time.h" #include "ProcessLib/Output/OutputDataSpecification.h" namespace ac = autocheck; @@ -71,7 +72,8 @@ TEST_F(ProcessLibOutputDataSpecification, for (auto const fixed_output_time : output_data_specification.fixed_output_times) { - if (!output_data_specification.isOutputStep(1, fixed_output_time)) + if (!output_data_specification.isOutputStep( + 1, NumLib::Time(fixed_output_time))) { return false; } @@ -97,7 +99,8 @@ TEST_F(ProcessLibOutputDataSpecification, fixed_output_time_points.end(), random_time) == fixed_output_time_points.end()) { - if (output_data_specification.isOutputStep(1, random_time)) + if (output_data_specification.isOutputStep( + 1, NumLib::Time(random_time))) { return false; } @@ -224,7 +227,8 @@ TEST_F(ProcessLibOutputDataSpecification, for (auto const fixed_output_time : output_data_specification.fixed_output_times) { - if (!output_data_specification.isOutputStep(1, fixed_output_time)) + if (!output_data_specification.isOutputStep( + 1, NumLib::Time(fixed_output_time))) { return false; } @@ -236,7 +240,8 @@ TEST_F(ProcessLibOutputDataSpecification, for (int i = 0; i < repeats_each_steps_pair.repeat; ++i) { step += repeats_each_steps_pair.each_steps; - if (!output_data_specification.isOutputStep(step, {})) + if (!output_data_specification.isOutputStep(step, + NumLib::Time{0.0})) { return false; } -- GitLab