From 644b3c92aa0475fcb8139644d53ac0a53f4c9ac1 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Fri, 30 Oct 2020 16:17:13 +0100
Subject: [PATCH] [test][2p][material] Output largest error of spline
 approximation

---
 .../2p/test_material_2p_spline.cc                   | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/test/material/fluidmatrixinteractions/2p/test_material_2p_spline.cc b/test/material/fluidmatrixinteractions/2p/test_material_2p_spline.cc
index 28f4fd6824..fe123a17ea 100644
--- a/test/material/fluidmatrixinteractions/2p/test_material_2p_spline.cc
+++ b/test/material/fluidmatrixinteractions/2p/test_material_2p_spline.cc
@@ -82,9 +82,9 @@ void runTest(const std::string& name, const Function& f,
         auto pcTest = swTest;
 
         Dune::Timer timer;
-        double res = 0.0;
+        auto resOrig = swTest;
         for (int i = 0; i < testSamples; ++i)
-            res += f(swTest[i], orig);
+            resOrig[i] = f(swTest[i], orig);
         timer.stop();
 
         const auto vgTime = timer.elapsed();
@@ -92,15 +92,20 @@ void runTest(const std::string& name, const Function& f,
 
         timer.reset();
         timer.start();
-        res = 0.0;
+        auto resSpline = swTest;
         for (int i = 0; i < testSamples; ++i)
-            res += f(swTest[i], spline);
+            resSpline[i] = f(swTest[i], spline);
         timer.stop();
 
         const auto vgSplineTime = timer.elapsed();
         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;
+
+        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;
     }
 }
 
-- 
GitLab