Skip to content
Snippets Groups Projects
Commit 50d61d9e authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Dmitri Naumov
Browse files

[T] adapted to std::function

parent b4c4a06b
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ bool f(const double,
bool df(const double /*t*/,
MathLib::MappedConstVector<1> const y,
MathLib::MappedVector<1> /*ydot*/,
MathLib::MappedConstVector<1> /*ydot*/,
MathLib::MappedMatrix<1, 1> jac)
{
if (y[0] <= 0.0) return false;
......@@ -103,10 +103,17 @@ TEST(MathLibCVodeTest, ExponentialExtraData)
auto tree = boost::property_tree::ptree{};
BaseLib::ConfigTree config(tree, "", BaseLib::ConfigTree::onerror,
BaseLib::ConfigTree::onwarning);
auto ode_solver = MathLib::createOdeSolver<1, ExtraData>(config);
auto ode_solver = MathLib::createOdeSolver<1>(config);
ExtraData data;
ode_solver->setFunction(f_extra, nullptr, data);
auto f_lambda = [&](double t,
MathLib::MappedConstVector<1> const y,
MathLib::MappedVector<1> ydot)
{
return f_extra(t, y, ydot, data);
};
ode_solver->setFunction(f_lambda, nullptr);
ode_solver->setTolerance(1e-8, 1e-6);
ode_solver->setIC(t0, {y0});
......@@ -133,7 +140,7 @@ TEST(MathLibCVodeTest, ExponentialExtraData)
// std::printf("time: %g\n", time_reached);
}
ode_solver->setFunction(f_extra, nullptr, data);
ode_solver->setFunction(f_lambda, nullptr);
ode_solver->preSolve();
for (unsigned i = 11; i <= 15; ++i)
{
......
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