TEST(NumLib, TimeSteppingIterationNumberBased2) { std::vector<std::size_t> iter_times_vector = {0, 3, 5, 7}; std::vector<double> multiplier_vector = {2.0, 1.0, 0.5, 0.25}; NumLib::IterationNumberBasedAdaptiveTimeStepping alg(1, 31, 1, 10, 1, iter_times_vector, multiplier_vector); std::vector<std::size_t> nr_iterations = {2, 2, 2, 4, 6, 8, 4, 4, 2, 2}; const std::vector<double> expected_vec_t = {1, 2, 4, 8, 16, 24, 26, 28, 30, 31}; struct IterationNumberUpdate { IterationNumberUpdate(const std::vector<std::size_t> &vec, std::size_t& counter) : _nr_iterations(vec), i(counter) {} std::vector<std::size_t> _nr_iterations; std::size_t& i; void operator()(NumLib::IterationNumberBasedAdaptiveTimeStepping &obj) { std::size_t n = (i<_nr_iterations.size()) ? _nr_iterations[i++] : 0; //INFO("-> NR-iterations=%d", n); obj.setNIterations(n); } }; std::size_t counter = 0; IterationNumberUpdate update(nr_iterations, counter); std::vector<double> vec_t = timeStepping(alg, &update); //std::cout << vec_t; ASSERT_EQ(expected_vec_t.size(), vec_t.size()); ASSERT_EQ(1u, alg.getNRepeatedSteps()); ASSERT_ARRAY_NEAR(expected_vec_t, vec_t, expected_vec_t.size(), std::numeric_limits<double>::epsilon()); }
void MyWindow::displayTimer(int _val) { timeStepping(); glutPostRedisplay(); glutTimerFunc(mDisplayTimeout, refreshTimer, _val); }