diff --git a/ebos/eclbasevanguard.hh b/ebos/eclbasevanguard.hh index d37a0fcb3..ec1ce2dc6 100644 --- a/ebos/eclbasevanguard.hh +++ b/ebos/eclbasevanguard.hh @@ -34,7 +34,6 @@ #include #include -#include #include #include @@ -700,14 +699,6 @@ protected: asImp_().filterConnections_(); asImp_().updateOutputDir_(); asImp_().finalizeInit_(); - - if (enableExperiments) { - if (asImp_().grid().size(0)) //grid not loadbalanced yet for ebos! - { - Opm::RelpermDiagnostics relpermDiagnostics; - relpermDiagnostics.diagnosis(*eclState_, asImp_().grid()); - } - } } void updateCartesianToCompressedMapping_() { diff --git a/ebos/eclproblem.hh b/ebos/eclproblem.hh index 737337ad2..25464fec1 100644 --- a/ebos/eclproblem.hh +++ b/ebos/eclproblem.hh @@ -66,6 +66,8 @@ #include "ecltracermodel.hh" #include "vtkecltracermodule.hh" +#include + #include #include #include @@ -839,6 +841,9 @@ public: maxTimeStepAfterWellEvent_ = EWOMS_GET_PARAM(TypeTag, Scalar, EclMaxTimeStepSizeAfterWellEvent); restartShrinkFactor_ = EWOMS_GET_PARAM(TypeTag, Scalar, EclRestartShrinkFactor); maxFails_ = EWOMS_GET_PARAM(TypeTag, unsigned, MaxTimeStepDivisions); + + Opm::RelpermDiagnostics relpermDiagnostics; + relpermDiagnostics.diagnosis(vanguard.eclState(), vanguard.cartesianIndexMapper()); } /*! diff --git a/opm/core/props/satfunc/RelpermDiagnostics.hpp b/opm/core/props/satfunc/RelpermDiagnostics.hpp index 672bb29d5..0489f807b 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics.hpp @@ -52,9 +52,9 @@ namespace Opm { ///output if they're found. ///\param[in] eclState eclipse state. ///\param[in] grid unstructured grid. - template + template void diagnosis(const EclipseState& eclState, - const GridT& grid); + const CartesianIndexMapper& cartesianIndexMapper); private: enum FluidSystem { @@ -91,9 +91,9 @@ namespace Opm { ///Check endpoints in the saturation tables. void unscaledEndPointsCheck_(const EclipseState& eclState); - template + template void scaledEndPointsCheck_(const EclipseState& eclState, - const GridT& grid); + const CartesianIndexMapper& cartesianIndexMapper); ///For every table, need to deal with case by case. void swofTableCheck_(const Opm::SwofTable& swofTables, diff --git a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp index fc3c36a6b..0e6868185 100644 --- a/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp +++ b/opm/core/props/satfunc/RelpermDiagnostics_impl.hpp @@ -31,28 +31,25 @@ namespace Opm { - template + template void RelpermDiagnostics::diagnosis(const Opm::EclipseState& eclState, - const GridT& grid) + const CartesianIndexMapper& cartesianIndexMapper) { OpmLog::info("\n===============Saturation Functions Diagnostics===============\n"); phaseCheck_(eclState); satFamilyCheck_(eclState); tableCheck_(eclState); unscaledEndPointsCheck_(eclState); - scaledEndPointsCheck_(eclState, grid); + scaledEndPointsCheck_(eclState, cartesianIndexMapper); } - template + template void RelpermDiagnostics::scaledEndPointsCheck_(const EclipseState& eclState, - const GridT& grid) + const CartesianIndexMapper& cartesianIndexMapper) { // All end points are subject to round-off errors, checks should account for it const float tolerance = 1e-6; - const int nc = Opm::UgGridHelpers::numCells(grid); - const auto& global_cell = Opm::UgGridHelpers::globalCell(grid); - const auto dims = Opm::UgGridHelpers::cartDims(grid); - const auto& compressedToCartesianIdx = Opm::compressedToCartesian(nc, global_cell); + const int nc = cartesianIndexMapper.compressedSize(); const bool threepoint = eclState.runspec().endpointScaling().threepoint(); scaledEpsInfo_.resize(nc); EclEpsGridProperties epsGridProperties(eclState, false); @@ -62,10 +59,7 @@ namespace Opm { std::string cellIdx; { std::array ijk; - int cartIdx = compressedToCartesianIdx[c]; - ijk[0] = cartIdx % dims[0]; cartIdx /= dims[0]; - ijk[1] = cartIdx % dims[1]; - ijk[2] = cartIdx / dims[1]; + cartesianIndexMapper.cartesianCoordinate(c, ijk); cellIdx = "(" + std::to_string(ijk[0]) + ", " + std::to_string(ijk[1]) + ", " + std::to_string(ijk[2]) + ")"; diff --git a/opm/simulators/flow/FlowMainEbos.hpp b/opm/simulators/flow/FlowMainEbos.hpp index 631a9fb13..cbabd4daf 100644 --- a/opm/simulators/flow/FlowMainEbos.hpp +++ b/opm/simulators/flow/FlowMainEbos.hpp @@ -407,7 +407,6 @@ namespace Opm setupParallelism(); setupEbosSimulator(); - runDiagnostics(); createSimulator(); // if run, do the actual work, else just initialize @@ -545,35 +544,6 @@ namespace Opm const Schedule& schedule() const { return ebosSimulator_->vanguard().schedule(); } - - // Run diagnostics. - // Writes to: - // OpmLog singleton. - void runDiagnostics() - { - if (!this->output_cout_) { - return; - } - - // Run relperm diagnostics if we have more than one phase. - if (FluidSystem::numActivePhases() > 1) { - RelpermDiagnostics diagnostic; - if (mpi_size_ > 1) { -#if HAVE_MPI - this->grid().switchToGlobalView(); - static_cast(this->eclState()).switchToGlobalProps(); -#endif - } - diagnostic.diagnosis(eclState(), this->grid()); - if (mpi_size_ > 1) { -#if HAVE_MPI - this->grid().switchToDistributedView(); - static_cast(this->eclState()).switchToDistributedProps(); -#endif - } - } - } - // Run the simulator. int runSimulator() { diff --git a/tests/test_relpermdiagnostics.cpp b/tests/test_relpermdiagnostics.cpp index abb4a8297..fd8f5de77 100644 --- a/tests/test_relpermdiagnostics.cpp +++ b/tests/test_relpermdiagnostics.cpp @@ -36,29 +36,54 @@ #include #include -#include -#include -#include +#include +#include #include #include #include +#if HAVE_DUNE_FEM +#include +#else +#include +#endif + BOOST_AUTO_TEST_SUITE () BOOST_AUTO_TEST_CASE(diagnosis) { + // MPI setup. + int argcDummy = 1; + const char *tmp[] = {"test_relpermdiagnostic"}; + char **argvDummy = const_cast(tmp); + +#if HAVE_DUNE_FEM + Dune::Fem::MPIManager::initialize(argcDummy, argvDummy); +#else + Dune::MPIHelper::instance(argcDummy, argvDummy); +#endif + using namespace Opm; Parser parser; Opm::Deck deck = parser.parseFile("../tests/relpermDiagnostics.DATA"); EclipseState eclState(deck); - GridManager gm(eclState.getInputGrid()); - const UnstructuredGrid& grid = *gm.c_grid(); + typedef Dune::CpGrid Grid; + Grid grid = Grid(); + grid.processEclipseFormat(&eclState.getInputGrid(), + /*isPeriodic=*/false, + /*flipNormals=*/false, + /*clipZ=*/false, + eclState.fieldProps().porv(true), + eclState.getInputNNC()); + + typedef Dune::CartesianIndexMapper CartesianIndexMapper; + CartesianIndexMapper cartesianIndexMapper = CartesianIndexMapper(grid); std::shared_ptr counterLog = std::make_shared(Log::DefaultMessageTypes); OpmLog::addBackend( "COUNTERLOG" , counterLog ); RelpermDiagnostics diagnostics; - diagnostics.diagnosis(eclState, grid); + diagnostics.diagnosis(eclState, cartesianIndexMapper); BOOST_CHECK_EQUAL(1, counterLog->numMessages(Log::MessageType::Warning)); } BOOST_AUTO_TEST_SUITE_END()