From 939085155e12498f484990debab9991af49cda25 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 1 Apr 2016 10:49:27 +0800 Subject: [PATCH 1/3] refactor relperm diagnostics using OpmLog functions. --- examples/diagnose_relperm.cpp | 6 +- opm/core/props/satfunc/RelpermDiagnostics.cpp | 136 ++++++++---------- opm/core/props/satfunc/RelpermDiagnostics.hpp | 10 -- .../props/satfunc/RelpermDiagnostics_impl.hpp | 22 +-- tests/test_relpermdiagnostics.cpp | 6 +- 5 files changed, 82 insertions(+), 98 deletions(-) diff --git a/examples/diagnose_relperm.cpp b/examples/diagnose_relperm.cpp index 1c7775e929..862fb96d73 100644 --- a/examples/diagnose_relperm.cpp +++ b/examples/diagnose_relperm.cpp @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include @@ -88,9 +90,11 @@ 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(); - RelpermDiagnostics diagnostic(logFile); + RelpermDiagnostics diagnostic; diagnostic.diagnosis(eclState, deck, grid); timer.stop(); double tt = timer.secsSinceStart(); diff --git a/opm/core/props/satfunc/RelpermDiagnostics.cpp b/opm/core/props/satfunc/RelpermDiagnostics.cpp index a8bc423f0b..8bd4579f1b 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.cpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.cpp @@ -24,11 +24,6 @@ namespace Opm{ - RelpermDiagnostics::RelpermDiagnostics(std::string& logFile) - { - streamLog_ = std::make_shared(logFile, Opm::Log::DefaultMessageTypes); - } - RelpermDiagnostics::Counter::Counter() :error(0) @@ -43,15 +38,6 @@ namespace Opm{ - std::shared_ptr - RelpermDiagnostics::getOpmLog() const - { - return streamLog_; - } - - - - std::vector RelpermDiagnostics::getMessages() const { @@ -71,31 +57,31 @@ namespace Opm{ if (hasWater && hasGas && !hasOil && !hasSolvent) { const std::string msg = "System: Water-Gas system."; std::cout << msg << std::endl; - streamLog_->addMessage(Log::MessageType::Info, msg); + OpmLog::info(msg); fluidSystem_ = FluidSystem::WaterGas; } if (hasWater && hasOil && !hasGas && !hasSolvent) { const std::string msg = "System: Oil-Water system."; std::cout << msg << std::endl; - streamLog_->addMessage(Log::MessageType::Info, msg); + OpmLog::info(msg); fluidSystem_ = FluidSystem::OilWater; } if (hasOil && hasGas && !hasWater && !hasSolvent) { const std::string msg = "System: Oil-Gas system."; std::cout << msg << std::endl; - streamLog_->addMessage(Log::MessageType::Info, msg); + OpmLog::info(msg); fluidSystem_ = FluidSystem::OilGas; } if (hasOil && hasWater && hasGas && !hasSolvent) { const std::string msg = "System: Black-oil system."; std::cout << msg << std::endl; - streamLog_->addMessage(Log::MessageType::Info, msg); + OpmLog::info(msg); fluidSystem_ = FluidSystem::BlackOil; } if (hasSolvent) { const std::string msg = "System: Solvent model."; std::cout << msg << std::endl; - streamLog_->addMessage(Log::MessageType::Info, msg); + OpmLog::info(msg); fluidSystem_ = FluidSystem::Solvent; } } @@ -123,7 +109,7 @@ 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."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -132,7 +118,7 @@ namespace Opm{ family 1 or family 2 keywords \n \ Use either SGOF and SWOF or SGFN, SWFN and SOF3."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -140,13 +126,13 @@ namespace Opm{ satFamily_ = SaturationFunctionFamily::FamilyI; const std::string msg = "Relative permeability input format: Saturation Family I."; std::cout << msg << std::endl; - streamLog_->addMessage(Log::MessageType::Info, msg); + 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; - streamLog_->addMessage(Log::MessageType::Info, msg); + OpmLog::info(msg); } } @@ -159,7 +145,7 @@ 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; - streamLog_->addMessage(Log::MessageType::Info, msg); + OpmLog::info(msg); const auto& tableManager = eclState->getTableManager(); const TableContainer& swofTables = tableManager->getSwofTables(); const TableContainer& slgofTables= tableManager->getSlgofTables(); @@ -233,7 +219,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } //TODO check endpoint sw.back() == 1. - Sor. @@ -241,13 +227,13 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -255,7 +241,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } ///TODO check if run with gas. @@ -276,13 +262,13 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } //TODO check endpoint sw.back() == 1. - Sor. @@ -290,13 +276,13 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -304,7 +290,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } //TODO check if run with water. @@ -322,33 +308,33 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -367,7 +353,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -375,14 +361,14 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -401,7 +387,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -409,13 +395,13 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -436,7 +422,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -444,13 +430,13 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -458,21 +444,21 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -492,7 +478,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -500,13 +486,13 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -526,7 +512,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -534,13 +520,13 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -549,13 +535,13 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -572,7 +558,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -580,7 +566,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -599,7 +585,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -607,7 +593,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -626,7 +612,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -634,7 +620,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -642,7 +628,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -663,7 +649,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -671,7 +657,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -692,7 +678,7 @@ 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]."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -700,7 +686,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } @@ -708,7 +694,7 @@ namespace Opm{ 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); - streamLog_->addMessage(Log::MessageType::Error, msg); + OpmLog::error(msg); counter_.error += 1; } } @@ -738,13 +724,13 @@ 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."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Warning, msg); + 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); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.warning += 1; } @@ -778,7 +764,7 @@ 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)."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.warning += 1; } } @@ -787,13 +773,13 @@ 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."; messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Warning, msg); + 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); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.warning += 1; } } diff --git a/opm/core/props/satfunc/RelpermDiagnostics.hpp b/opm/core/props/satfunc/RelpermDiagnostics.hpp index 741b013064..191998582e 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.hpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -52,10 +51,6 @@ namespace Opm { class RelpermDiagnostics { public: - - ///Constructor for OpmLog. - explicit RelpermDiagnostics(std::string& logFile); - ///This function is used to diagnosis relperm in ///eclipse data file. Errors and warings will be ///output if they're found. @@ -67,8 +62,6 @@ namespace Opm { DeckConstPtr deck, const GridT& grid); - ///return streamLog - std::shared_ptr getOpmLog() const; std::vector getMessages() const; private: @@ -107,9 +100,6 @@ namespace Opm { ///Store scaled information. std::vector scaled_messages_; - ///Use OpmLog - std::shared_ptr streamLog_; - ///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 57b323e207..4787b0e0e1 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -67,7 +67,7 @@ namespace Opm { 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"; - streamLog_->addMessage(Log::MessageType::Info, summary_msg); + OpmLog::info(summary_msg); std::cout << summary_msg << std::endl; } @@ -101,7 +101,7 @@ 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"; scaled_messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.warning += 1; } @@ -109,7 +109,7 @@ namespace Opm { 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); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.warning += 1; } @@ -118,14 +118,14 @@ 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"; scaled_messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(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"; scaled_messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.error += 1; } } @@ -134,21 +134,21 @@ namespace Opm { 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); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(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"; scaled_messages_.push_back(msg); - streamLog_->addMessage(Opm::Log::MessageType::Warning, msg); + OpmLog::warning(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"; scaled_messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.warning += 1; } } @@ -157,7 +157,7 @@ namespace Opm { 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); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.warning += 1; } } @@ -166,14 +166,14 @@ namespace Opm { 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); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(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"; scaled_messages_.push_back(msg); - streamLog_->addMessage(Log::MessageType::Warning, msg); + OpmLog::warning(msg); counter_.warning += 1; } } diff --git a/tests/test_relpermdiagnostics.cpp b/tests/test_relpermdiagnostics.cpp index 379a6c14ab..65862ae3d3 100644 --- a/tests/test_relpermdiagnostics.cpp +++ b/tests/test_relpermdiagnostics.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -60,7 +62,9 @@ BOOST_AUTO_TEST_CASE(diagnosis) GridManager gm(deck); const UnstructuredGrid& grid = *gm.c_grid(); std::string logFile = "LOGFILE.txt"; - RelpermDiagnostics diagnostics(logFile); + std::shared_ptr prtLog = std::make_shared(logFile, Log::DefaultMessageTypes); + OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog ); + RelpermDiagnostics diagnostics; diagnostics.diagnosis(eclState, deck, grid); auto msg = diagnostics.getMessages(); BOOST_CHECK(!msg.empty()); From c2bcc9cea8803d3ec917235a9c6cf60bf747230f Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Sat, 2 Apr 2016 11:45:18 +0800 Subject: [PATCH 2/3] do not write error summary twice. --- opm/core/props/satfunc/RelpermDiagnostics_impl.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 4787b0e0e1..1ee53b92e7 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -67,7 +67,6 @@ namespace Opm { 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"; - OpmLog::info(summary_msg); std::cout << summary_msg << std::endl; } From c5925c4dd981f8bed44dfb2f086db3c109f0ae73 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Sat, 2 Apr 2016 11:53:36 +0800 Subject: [PATCH 3/3] mistake: count warning as error. --- opm/core/props/satfunc/RelpermDiagnostics_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index 1ee53b92e7..5c6220fe21 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -125,7 +125,7 @@ namespace Opm { 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_.error += 1; + counter_.warning += 1; } } ///Following rules come from NEXUS.