diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index eddbbd85..d0396ad5 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -24,19 +24,6 @@ namespace Opm{ - - RelpermDiagnostics::Counter::Counter() - :error(0) - ,warning(0) - ,problem(0) - ,bug(0) - { - } - - - - - void RelpermDiagnostics::phaseCheck_(DeckConstPtr deck) { bool hasWater = deck->hasKeyword("WATER"); @@ -46,31 +33,26 @@ namespace Opm{ if (hasWater && hasGas && !hasOil && !hasSolvent) { const std::string msg = "System: Water-Gas system."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::WaterGas; } if (hasWater && hasOil && !hasGas && !hasSolvent) { const std::string msg = "System: Oil-Water system."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::OilWater; } if (hasOil && hasGas && !hasWater && !hasSolvent) { const std::string msg = "System: Oil-Gas system."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::OilGas; } if (hasOil && hasWater && hasGas && !hasSolvent) { const std::string msg = "System: Black-oil system."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::BlackOil; } if (hasSolvent) { const std::string msg = "System: Solvent model."; - std::cout << msg << std::endl; OpmLog::info(msg); fluidSystem_ = FluidSystem::Solvent; } @@ -99,7 +81,6 @@ namespace Opm{ if (family1 && family2) { const std::string msg = "Error: Saturation families should not be mixed.\n Use either SGOF and SWOF or SGFN, SWFN and SOF3."; OpmLog::error(msg); - counter_.error += 1; } if (!family1 && !family2) { @@ -107,19 +88,16 @@ namespace Opm{ family 1 or family 2 keywords \n \ Use either SGOF and SWOF or SGFN, SWFN and SOF3."; OpmLog::error(msg); - counter_.error += 1; } if (family1 && !family2) { satFamily_ = SaturationFunctionFamily::FamilyI; const std::string msg = "Relative permeability input format: Saturation Family I."; - std::cout << msg << std::endl; OpmLog::info(msg); } if (!family1 && family2) { satFamily_ = SaturationFunctionFamily::FamilyII; const std::string msg = "Relative permeability input format: Saturation Family II."; - std::cout << msg << std::endl; OpmLog::info(msg); } } @@ -207,26 +185,22 @@ namespace Opm{ if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //TODO check endpoint sw.back() == 1. - Sor. //Check krw column. if (krw.front() != 0.0) { const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", first value of krw should be 0."; OpmLog::error(msg); - counter_.error += 1; } if (krw.front() < 0.0 || krw.back() > 1.0) { const std::string msg = "Error: In SWOF table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } ///Check krow column. if (krow.front() > 1.0 || krow.back() < 0.0) { const std::string msg = "Error: In SWOF table SATNUM = "+ regionIdx + ", krow should be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } ///TODO check if run with gas. } @@ -246,31 +220,26 @@ namespace Opm{ if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (sg.front() != 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of sg should be 0."; OpmLog::error(msg); - counter_.error += 1; } //TODO check endpoint sw.back() == 1. - Sor. //Check krw column. if (krg.front() != 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); - counter_.error += 1; } if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krow column. if (krog.front() > 1.0 || krog.back() < 0.0) { const std::string msg = "Error: In SGOF table SATNUM = " + regionIdx + ", krog should be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } //TODO check if run with water. } @@ -287,29 +256,24 @@ namespace Opm{ if (sl.front() < 0.0 || sl.back() > 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (sl.back() != 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of sl should be 1."; OpmLog::error(msg); - counter_.error += 1; } if (krg.front() > 1.0 || krg.back() < 0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krg shoule be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } if (krg.back() != 0.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", last value of krg hould be 0."; OpmLog::error(msg); - counter_.error += 1; } if (krog.front() < 0.0 || krog.back() > 1.0) { const std::string msg = "Error: In SLGOF table SATNUM = " + regionIdx + ", krog shoule be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -327,20 +291,17 @@ namespace Opm{ if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krw column. if (krw.front() < 0.0 || krw.back() > 1.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", krw should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krw.front() != 0.0) { const std::string msg = "Error: In SWFN table SATNUM = " + regionIdx + ", first value of krw should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -358,19 +319,16 @@ namespace Opm{ if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krg.front() != 0.0) { const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -390,38 +348,32 @@ namespace Opm{ if (so.front() < 0.0 || so.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krow column. if (krow.front() < 0.0 || krow.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krow.front() != 0.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krow should be 0."; OpmLog::error(msg); - counter_.error += 1; } //Check krog column. if (krog.front() < 0.0 || krog.back() > 1.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", krog should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krog.front() != 0.0) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", first value of krog should be 0."; OpmLog::error(msg); - counter_.error += 1; } if (krog.back() != krow.back()) { const std::string msg = "Error: In SOF3 table SATNUM = " + regionIdx + ", max value of krog and krow should be the same."; OpmLog::error(msg); - counter_.error += 1; } } @@ -440,19 +392,16 @@ namespace Opm{ if (so.front() < 0.0 || so.back() > 1.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krow column. if (kro.front() < 0.0 || kro.back() > 1.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", krow should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (kro.front() != 0.0) { const std::string msg = "Error: In SOF2 table SATNUM = " + regionIdx + ", first value of krow should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -471,19 +420,16 @@ namespace Opm{ if (sg.front() < 0.0 || sg.back() > 1.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check krg column. if (krg.front() < 0.0 || krg.back() > 1.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krg should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krg.front() != 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); - counter_.error += 1; } //Check krgw column. @@ -491,12 +437,10 @@ namespace Opm{ if (krgw.front() > 1.0 || krgw.back() < 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", krgw should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } if (krgw.back() != 0.0) { const std::string msg = "Error: In SGWFN table SATNUM = " + regionIdx + ", last value of krgw should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -512,14 +456,12 @@ namespace Opm{ if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check critical gas column. if (sgc.front() < 0.0 || sgc.back() > 1.0) { const std::string msg = "Error: In SGCWMIS table SATNUM = " + regionIdx + ", critical gas saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -537,14 +479,12 @@ namespace Opm{ if (sw.front() < 0.0 || sw.back() > 1.0) { const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check critical oil column. if (sor.front() < 0.0 || sor.back() > 1.0) { const std::string msg = "Error: In SORWMIS table SATNUM = " + regionIdx + ", critical oil saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -562,21 +502,18 @@ namespace Opm{ if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check gas relperm multiplier column. if (krgm.front() < 0.0 || krgm.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", gas relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check solvent relperm multiplier column. if (krsm.front() < 0.0 || krsm.back() > 1.0) { const std::string msg = "Error: In SSFN table SATNUM = " + regionIdx + ", solvent relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -596,14 +533,12 @@ namespace Opm{ if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", phase fraction should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check miscibility column. if (misc.front() < 0.0 || misc.back() > 1.0) { const std::string msg = "Error: In MISC table SATNUM = " + regionIdx + ", miscibility should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -623,21 +558,18 @@ namespace Opm{ if (frac.front() < 0.0 || frac.back() > 1.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", total gas fraction should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check gas_solvent relperm multiplier column. if (krgsm.front() < 0.0 || krgsm.back() > 1.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", gas+solvent relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } //Check oil relperm multiplier column. if (krom.front() > 1.0 || krom.back() < 0.0) { const std::string msg = "Error: In MSFN table SATNUM = " + regionIdx + ", oil relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -666,12 +598,10 @@ namespace Opm{ if (unscaledEpsInfo_[satnumIdx].Sgu > (1. - unscaledEpsInfo_[satnumIdx].Swl)) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgmax should not exceed 1-Swco."; OpmLog::warning(msg); - counter_.warning += 1; } if (unscaledEpsInfo_[satnumIdx].Sgl > (1. - unscaledEpsInfo_[satnumIdx].Swu)) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sgco should not exceed 1-Swmax."; OpmLog::warning(msg); - counter_.warning += 1; } //Krow(Sou) == Krog(Sou) for three-phase @@ -704,7 +634,6 @@ namespace Opm{ if (krow_value != krog_value) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Krow(Somax) should be equal to Krog(Somax)."; OpmLog::warning(msg); - counter_.warning += 1; } } //Krw(Sw=0)=Krg(Sg=0)=Krow(So=0)=Krog(So=0)=0. @@ -712,12 +641,10 @@ namespace Opm{ if (((unscaledEpsInfo_[satnumIdx].Sowcr + unscaledEpsInfo_[satnumIdx].Swcr)-1) >= 0) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sowcr + Swcr should be less than 1."; OpmLog::warning(msg); - counter_.warning += 1; } if (((unscaledEpsInfo_[satnumIdx].Sogcr + unscaledEpsInfo_[satnumIdx].Sgcr + unscaledEpsInfo_[satnumIdx].Swl) - 1 ) > 0) { const std::string msg = "Warning: In saturation table SATNUM = " + regionIdx + ", Sogcr + Sgcr + Swco should be less than 1."; OpmLog::warning(msg); - counter_.warning += 1; } } } diff --git a/opm/core/props/satfunc/RelpermDiagnostics.hpp b/opm/core/props/satfunc/RelpermDiagnostics.hpp index af4df2bb..cb5cf138 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.hpp @@ -81,16 +81,6 @@ namespace Opm { SaturationFunctionFamily satFamily_; - struct Counter { - Counter(); - int error; - int warning; - int problem; - int bug; - }; - - Counter counter_; - std::vector > unscaledEpsInfo_; std::vector > scaledEpsInfo_; diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 84783d87..65cb846d 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -72,14 +72,12 @@ namespace Opm { if (scaledEpsInfo_[c].Sgu > (1.0 - scaledEpsInfo_[c].Swl)) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; OpmLog::warning(tag, msg); - counter_.warning += 1; } // SGL <= 1.0 - SWU if (scaledEpsInfo_[c].Sgl > (1.0 - scaledEpsInfo_[c].Swu)) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if (deck->hasKeyword("SCALECRS") && fluidSystem_ == FluidSystem::BlackOil) { @@ -87,13 +85,11 @@ namespace Opm { if ((scaledEpsInfo_[c].Sowcr + scaledEpsInfo_[c].Swcr) >= 1.0) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if ((scaledEpsInfo_[c].Sogcr + scaledEpsInfo_[c].Sgcr + scaledEpsInfo_[c].Swl) >= 1.0) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; OpmLog::warning(tag, msg); - counter_.warning += 1; } } ///Following rules come from NEXUS. @@ -101,19 +97,16 @@ namespace Opm { if (scaledEpsInfo_[c].Swl > scaledEpsInfo_[c].Swcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if (scaledEpsInfo_[c].Swcr > scaledEpsInfo_[c].Sowcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if (scaledEpsInfo_[c].Sowcr > scaledEpsInfo_[c].Swu) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; OpmLog::warning(tag, msg); - counter_.warning += 1; } } @@ -121,7 +114,6 @@ namespace Opm { if (scaledEpsInfo_[c].Sgl > scaledEpsInfo_[c].Sgcr) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; OpmLog::warning(tag, msg); - counter_.warning += 1; } } @@ -129,13 +121,11 @@ namespace Opm { if (scaledEpsInfo_[c].Sgcr > scaledEpsInfo_[c].Sogcr) { const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGCR > SOGCR"; OpmLog::warning(tag, msg); - counter_.warning += 1; } if (scaledEpsInfo_[c].Sogcr > scaledEpsInfo_[c].Sgu) { const std::string msg = "Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; OpmLog::warning(tag, msg); - counter_.warning += 1; } } } diff --git a/tests/test_relpermdiagnostics.cpp b/tests/test_relpermdiagnostics.cpp index ae9c285e..553606e4 100644 --- a/tests/test_relpermdiagnostics.cpp +++ b/tests/test_relpermdiagnostics.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -58,16 +58,12 @@ BOOST_AUTO_TEST_CASE(diagnosis) }); Opm::DeckConstPtr deck(parser->parseFile("../tests/relpermDiagnostics.DATA", parseContext)); eclState.reset(new EclipseState(deck, parseContext)); - GridManager gm(eclState->getInputGrid()); const UnstructuredGrid& grid = *gm.c_grid(); - std::string logFile = "LOGFILE.txt"; - std::shared_ptr prtLog = std::make_shared(logFile, Log::DefaultMessageTypes); - OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog ); + std::shared_ptr counterLog = std::make_shared(Log::DefaultMessageTypes); + OpmLog::addBackend( "COUNTERLOG" , counterLog ); RelpermDiagnostics diagnostics; diagnostics.diagnosis(eclState, deck, grid); - auto msg = diagnostics.getMessages(); - BOOST_CHECK(!msg.empty()); - BOOST_CHECK_EQUAL(msg.size(), 1); + BOOST_CHECK_EQUAL(1, counterLog->numMessages(Log::MessageType::Warning)); } BOOST_AUTO_TEST_SUITE_END()