Skip to content
Snippets Groups Projects
Commit 644b3c92 authored by Timo Koch's avatar Timo Koch Committed by Kilian Weishaupt
Browse files

[test][2p][material] Output largest error of spline approximation

parent 6ae12b10
No related branches found
No related tags found
1 merge request!1607Feature/new materiallaw 2p
...@@ -82,9 +82,9 @@ void runTest(const std::string& name, const Function& f, ...@@ -82,9 +82,9 @@ void runTest(const std::string& name, const Function& f,
auto pcTest = swTest; auto pcTest = swTest;
Dune::Timer timer; Dune::Timer timer;
double res = 0.0; auto resOrig = swTest;
for (int i = 0; i < testSamples; ++i) for (int i = 0; i < testSamples; ++i)
res += f(swTest[i], orig); resOrig[i] = f(swTest[i], orig);
timer.stop(); timer.stop();
const auto vgTime = timer.elapsed(); const auto vgTime = timer.elapsed();
...@@ -92,15 +92,20 @@ void runTest(const std::string& name, const Function& f, ...@@ -92,15 +92,20 @@ void runTest(const std::string& name, const Function& f,
timer.reset(); timer.reset();
timer.start(); timer.start();
res = 0.0; auto resSpline = swTest;
for (int i = 0; i < testSamples; ++i) for (int i = 0; i < testSamples; ++i)
res += f(swTest[i], spline); resSpline[i] = f(swTest[i], spline);
timer.stop(); timer.stop();
const auto vgSplineTime = timer.elapsed(); const auto vgSplineTime = timer.elapsed();
std::cout << "Spline law computed " << testSamples << " samples in " << vgSplineTime << " seconds." << std::endl; std::cout << "Spline law computed " << testSamples << " samples in " << vgSplineTime << " seconds." << std::endl;
std::cout << "Speed-up factor ca. " << (vgTime/vgSplineTime) << "x (only in spline region)" << std::endl; std::cout << "Speed-up factor ca. " << (vgTime/vgSplineTime) << "x (only in spline region)" << std::endl;
auto error = resOrig;
for (int i = 0; i < error.size(); ++i)
error[i] = std::abs(error[i]-resSpline[i]);
std::cout << "Maximum error: " << *std::max_element(error.begin(), error.end()) << std::endl;
} }
} }
......
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