From 0b22ea48e85c33eba4b8e58c19f2d499b9e3d176 Mon Sep 17 00:00:00 2001
From: becker <beatrix.becker@iws.uni-stuttgart.de>
Date: Tue, 17 Sep 2019 14:20:37 +0200
Subject: [PATCH] [test compositionalflash] Dune throw if mismatch

---
 .../test_compositionalflash.cc                | 31 +++++++++++--------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/test/material/compositionalflash/test_compositionalflash.cc b/test/material/compositionalflash/test_compositionalflash.cc
index a44caec5da..bdf540a306 100644
--- a/test/material/compositionalflash/test_compositionalflash.cc
+++ b/test/material/compositionalflash/test_compositionalflash.cc
@@ -57,30 +57,35 @@ void checkSame(const FluidState1 &fsRef, const FluidState2 &fsFlash)
         using std::abs;
         error = 1 - fsRef.pressure(phaseIdx)/fsFlash.pressure(phaseIdx);
         if (abs(error) > 1e-6) {
-            std::cout << "pressure error phase " << phaseIdx << ": "
-                      << fsFlash.pressure(phaseIdx)  << " flash vs "
-                      << fsRef.pressure(phaseIdx) << " reference"
-                      << " error=" << error << "\n";
+            DUNE_THROW(Dune::Exception, "Mismatch to reference. Pressure of phase "
+                      << phaseIdx << " calculated by flash is: "
+                      << fsFlash.pressure(phaseIdx)  << " vs "
+                      << fsRef.pressure(phaseIdx) << " calculated as reference."
+                      << " Error = " << error << "\n");
         }
 
         // check the saturations
         error = fsRef.saturation(phaseIdx) - fsFlash.saturation(phaseIdx);
         if (abs(error) > 1e-6)
-            std::cout << "saturation error phase " << phaseIdx << ": "
-                      << fsFlash.saturation(phaseIdx) << " flash vs "
-                      << fsRef.saturation(phaseIdx) << " reference"
-                      << " error=" << error << "\n";
+            DUNE_THROW(Dune::Exception, "Mismatch to reference. Saturation of phase "
+            << phaseIdx << " calculated by flash is: "
+            << fsFlash.saturation(phaseIdx)  << " vs "
+            << fsRef.saturation(phaseIdx) << " calculated as reference."
+            << " Error = " << error << "\n");
 
         // check the compositions for existing phases
-        if(fsRef.saturation(phaseIdx) > 0.0)
+        if(fsRef.saturation(phaseIdx) > 0.0) {
             for (int compIdx = 0; compIdx < numComponents; ++ compIdx) {
                 error = fsRef.moleFraction(phaseIdx, compIdx) - fsFlash.moleFraction(phaseIdx, compIdx);
                 if (abs(error) > 1e-6)
-                    std::cout << "composition error phase " << phaseIdx << ", component " << compIdx << ": "
-                    << fsFlash.moleFraction(phaseIdx, compIdx) << " flash vs "
-                    << fsRef.moleFraction(phaseIdx, compIdx) << " reference"
-                    << " error=" << error << "\n";
+                    DUNE_THROW(Dune::Exception, "Mismatch to reference. Mole fraction of component "
+                    << compIdx << " in phase "
+                    << phaseIdx << " calculated by flash is: "
+                    << fsFlash.moleFraction(phaseIdx, compIdx) << " vs "
+                    << fsRef.moleFraction(phaseIdx, compIdx) << " calculated as reference."
+                    << " Error = " << error << "\n");
             }
+        }
     }
 }
 
-- 
GitLab