Skip to content
Snippets Groups Projects
Commit eaeba6ad authored by Tom Fischer's avatar Tom Fischer
Browse files

[T|TestFixedTimeStepping] Check special setting

The setting was provided by a user and didn't work properly. With the
previous commits it works now.
parent 0955c7c3
No related branches found
No related tags found
No related merge requests found
......@@ -142,3 +142,56 @@ TEST_F(NumLibFixedTimeStepping, next)
ac::check<std::vector<double>>(
test, 1000, time_points, gtest_reporter, double_classifier);
}
TEST_F(NumLibFixedTimeStepping, next_StaticTest)
{
std::vector<double> expected_time_points{};
for (int i = 0; i < 101; ++i)
{
expected_time_points.push_back(i * 1e-2);
}
std::vector<double> fixed_output_times{};
for (int i = 0; i < 10; ++i)
{
fixed_output_times.push_back(i * 1e-1);
}
double const t_initial = expected_time_points.front();
expected_time_points.erase(expected_time_points.begin());
double const t_end = expected_time_points.back();
auto dts = transformTimesToDts(expected_time_points);
dts.front() -= t_initial;
auto const repeat_dt_pair = transformToRepeatDtPair(dts);
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);
for (auto const& expected_time_point : expected_time_points)
{
auto [is_next, step_size] =
fixed_time_stepping.next(0.0 /* solution_error */,
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 && std::abs((ts_current.current() + step_size) -
expected_time_point) >
NumLib::TimeStep::minimalTimeStepSize);
// if next is true then the step size should be larger than zero
ASSERT_FALSE(is_next && step_size == 0.0);
ts_current += step_size;
}
ASSERT_EQ(ts_current.timeStepNumber(), dts.size());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment