diff --git a/examples/diagnose_relperm.cpp b/examples/diagnose_relperm.cpp index 6de6a9489..20d6828dd 100644 --- a/examples/diagnose_relperm.cpp +++ b/examples/diagnose_relperm.cpp @@ -92,13 +92,13 @@ try std::string logFile = baseName + ".SATFUNCLOG"; std::shared_ptr prtLog = std::make_shared(logFile, Log::DefaultMessageTypes); OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog ); - Opm::time::StopWatch timer; - timer.start(); + prtLog->setMessageFormatter(std::make_shared(true, false)); + std::shared_ptr streamLog = std::make_shared(std::cout, Log::DefaultMessageTypes); + OpmLog::addBackend( "STREAMLOG" , streamLog ); + streamLog->setMessageLimiter(std::make_shared(10)); + streamLog->setMessageFormatter(std::make_shared(true, true)); RelpermDiagnostics diagnostic; diagnostic.diagnosis(eclState, deck, grid); - timer.stop(); - double tt = timer.secsSinceStart(); - std::cout << "relperm diagnostics: " << tt << " seconds." << std::endl; } catch (const std::exception &e) { std::cerr << "Program threw an exception: " << e.what() << "\n"; diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index 5cf71b59a..40713f245 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -24,29 +24,6 @@ namespace Opm{ - - RelpermDiagnostics::Counter::Counter() - :error(0) - ,warning(0) - ,problem(0) - ,bug(0) - { - } - - - - - - - std::vector - RelpermDiagnostics::getMessages() const - { - return messages_; - } - - - - void RelpermDiagnostics::phaseCheck_(DeckConstPtr deck) { bool hasWater = deck->hasKeyword("WATER"); @@ -56,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; } @@ -107,31 +79,25 @@ namespace Opm{ bool family2 = ((!swfnTables.empty() && !sgfnTables.empty()) || !sgwfnTables.empty()) && (!sof3Tables.empty() || !sof2Tables.empty()); 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."; - messages_.push_back(msg); + const std::string msg = "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) { - const std::string msg = "-- Error, Saturations function must be specified using either \n \ + const std::string msg = "Saturations function must be specified using either \n \ family 1 or family 2 keywords \n \ Use either SGOF and SWOF or SGFN, SWFN and SOF3."; - messages_.push_back(msg); 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); } } @@ -144,7 +110,6 @@ namespace Opm{ { const int numSatRegions = deck->getKeyword("TABDIMS").getRecord(0).getItem("NTSFUN").get< int >(0); const std::string msg = "Number of saturation regions: " + std::to_string(numSatRegions) + "\n"; - std::cout << msg << std::endl; OpmLog::info(msg); const auto& tableManager = eclState->getTableManager(); const TableContainer& swofTables = tableManager.getSwofTables(); @@ -217,32 +182,24 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. 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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "In SWOF table SATNUM = "+ regionIdx + ", krow should be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } ///TODO check if run with gas. } @@ -260,38 +217,28 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. 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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "In SGOF table SATNUM = " + regionIdx + ", krog should be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } //TODO check if run with water. } @@ -306,36 +253,26 @@ namespace Opm{ //Check sl column. //TODO first value means sl = swco + sor 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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "In SLGOF table SATNUM = " + regionIdx + ", krog shoule be in range [0, 1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -351,25 +288,19 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "In SWFN table SATNUM = " + regionIdx + ", first value of krw should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -385,24 +316,18 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sg column. 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]."; - messages_.push_back(msg); + 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]."; - messages_.push_back(msg); + 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."; - messages_.push_back(msg); + const std::string msg = "Error: In SGFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -420,46 +345,34 @@ namespace Opm{ //Check so column. //TODO: The max so = 1 - Swco 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "In SOF3 table SATNUM = " + regionIdx + ", max value of krog and krow should be the same."; OpmLog::error(msg); - counter_.error += 1; } } @@ -476,24 +389,18 @@ namespace Opm{ //Check so column. //TODO: The max so = 1 - Swco 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "In SOF2 table SATNUM = " + regionIdx + ", first value of krow should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -510,39 +417,29 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sg column. 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "In SGWFN table SATNUM = " + regionIdx + ", first value of krg should be 0."; OpmLog::error(msg); - counter_.error += 1; } //Check krgw column. //TODO check saturation sw = 1. - sg 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]."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "In SGWFN table SATNUM = " + regionIdx + ", last value of krgw should be 0."; OpmLog::error(msg); - counter_.error += 1; } } @@ -556,18 +453,14 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "In SGCWMIS table SATNUM = " + regionIdx + ", critical gas saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -583,18 +476,14 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check sw column. 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "In SORWMIS table SATNUM = " + regionIdx + ", critical oil saturation should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -610,26 +499,20 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "In SSFN table SATNUM = " + regionIdx + ", solvent relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -647,18 +530,14 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "In MISC table SATNUM = " + regionIdx + ", miscibility should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -676,26 +555,20 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx); //Check phase fraction column. 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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "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]."; - messages_.push_back(msg); + const std::string msg = "In MSFN table SATNUM = " + regionIdx + ", oil relative permeability multiplier should be in range [0,1]."; OpmLog::error(msg); - counter_.error += 1; } } @@ -722,16 +595,12 @@ namespace Opm{ const std::string regionIdx = std::to_string(satnumIdx + 1); ///Consistency check. if (unscaledEpsInfo_[satnumIdx].Sgu > (1. - unscaledEpsInfo_[satnumIdx].Swl)) { - const std::string msg = "-- Warning: In saturation table SATNUM = " + regionIdx + ", Sgmax should not exceed 1-Swco."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "In saturation table SATNUM = " + regionIdx + ", Sgco should not exceed 1-Swmax."; OpmLog::warning(msg); - counter_.warning += 1; } //Krow(Sou) == Krog(Sou) for three-phase @@ -762,25 +631,19 @@ namespace Opm{ krog_value = table.evaluate("KROG" , Sou); } if (krow_value != krog_value) { - const std::string msg = "-- Warning: In saturation table SATNUM = " + regionIdx + ", Krow(Somax) should be equal to Krog(Somax)."; - messages_.push_back(msg); + const std::string msg = "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. //Mobile fluid requirements 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."; - messages_.push_back(msg); + const std::string msg = "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."; - messages_.push_back(msg); + const std::string msg = "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 191998582..cb5cf138f 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.hpp @@ -62,8 +62,6 @@ namespace Opm { DeckConstPtr deck, const GridT& grid); - std::vector getMessages() const; - private: enum FluidSystem { OilWater, @@ -83,22 +81,9 @@ namespace Opm { SaturationFunctionFamily satFamily_; - struct Counter { - Counter(); - int error; - int warning; - int problem; - int bug; - }; - - Counter counter_; - std::vector > unscaledEpsInfo_; std::vector > scaledEpsInfo_; - std::vector messages_; - ///Store scaled information. - std::vector scaled_messages_; ///Check the phase that used. void phaseCheck_(DeckConstPtr deck); diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 869e8cbb5..4e0d01669 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -33,41 +33,12 @@ namespace Opm { Opm::DeckConstPtr deck, const GridT& grid) { - std::cout << "\n\n***************Saturation Functions Diagnostics***************\n\n"; + OpmLog::info("***************Saturation Functions Diagnostics***************"); phaseCheck_(deck); satFamilyCheck_(eclState); tableCheck_(eclState, deck); unscaledEndPointsCheck_(deck, eclState); scaledEndPointsCheck_(deck, eclState, grid); - if (!messages_.empty()) { - std::sort(messages_.begin(), messages_.end()); - auto it = std::unique(messages_.begin(), messages_.end()); - messages_.erase(it, messages_.end()); - std::cout << std::endl; - for (const auto& x : messages_) { - std::cout << x << std::endl; - } - } - int limits = 0; - if (!scaled_messages_.empty()) { - std::cout << std::endl; - for (const auto& x : scaled_messages_) { - if (limits < 10) { - std::cout << x << std::endl; - limits++; - } else { - std::cout << "\nMore inconsistencies exist. Check saturation function input and LOGFILE!" << std::endl; - break; - } - } - } - - const std::string summary_msg = "\n\nError summary:" + - std::string("\nWarnings " + std::to_string(counter_.warning)) + - std::string("\nProblems " + std::to_string(counter_.problem)) + - std::string("\nErrors " + std::to_string(counter_.error)) + - std::string("\nBugs " + std::to_string(counter_.bug))+ "\n"; - std::cout << summary_msg << std::endl; } template @@ -83,7 +54,8 @@ namespace Opm { EclEpsGridProperties epsGridProperties; epsGridProperties.initFromDeck(deck, eclState, /*imbibition=*/false); const auto& satnum = eclState->get3DProperties().getIntGridProperty("SATNUM"); - + + const std::string tag = "Scaled endpoints"; for (int c = 0; c < nc; ++c) { const int cartIdx = compressedToCartesianIdx[c]; const std::string satnumIdx = std::to_string(satnum.iget(cartIdx)); @@ -98,82 +70,62 @@ namespace Opm { // SGU <= 1.0 - SWL 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"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGU exceed 1.0 - SWL"; + OpmLog::warning(tag, msg); } // 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"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL exceed 1.0 - SWU"; + OpmLog::warning(tag, msg); } if (deck->hasKeyword("SCALECRS") && fluidSystem_ == FluidSystem::BlackOil) { // Mobilility check. 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"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR + SWCR exceed 1.0"; + OpmLog::warning(tag, msg); } 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"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR + SGCR + SWL exceed 1.0"; + OpmLog::warning(tag, msg); } } ///Following rules come from NEXUS. if (fluidSystem_ != FluidSystem::WaterGas) { if (scaledEpsInfo_[c].Swl > scaledEpsInfo_[c].Swcr) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWL > SWCR"; + OpmLog::warning(tag, msg); } if (scaledEpsInfo_[c].Swcr > scaledEpsInfo_[c].Sowcr) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SWCR > SOWCR"; + OpmLog::warning(tag, msg); } if (scaledEpsInfo_[c].Sowcr > scaledEpsInfo_[c].Swu) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOWCR > SWU"; + OpmLog::warning(tag, msg); } } if (fluidSystem_ != FluidSystem::OilWater) { if (scaledEpsInfo_[c].Sgl > scaledEpsInfo_[c].Sgcr) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGL > SGCR"; + OpmLog::warning(tag, msg); } } if (fluidSystem_ != FluidSystem::BlackOil) { if (scaledEpsInfo_[c].Sgcr > scaledEpsInfo_[c].Sogcr) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGCR > SOGCR"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SGCR > SOGCR"; + OpmLog::warning(tag, msg); } if (scaledEpsInfo_[c].Sogcr > scaledEpsInfo_[c].Sgu) { - const std::string msg = "-- Warning: For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; - scaled_messages_.push_back(msg); - OpmLog::warning(msg); - counter_.warning += 1; + const std::string msg = "For scaled endpoints input, cell" + cellIdx + " SATNUM = " + satnumIdx + ", SOGCR > SGU"; + OpmLog::warning(tag, msg); } } } diff --git a/tests/test_relpermdiagnostics.cpp b/tests/test_relpermdiagnostics.cpp index ae9c285e3..553606e42 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()