Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions opm/simulators/flow/equil/InitStateEquilComp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,13 @@ class InitialStateComputer
gasAtDatum ? FluidSystem::gasPhaseIdx : FluidSystem::oilPhaseIdx);

// A gas-oil contact inside a single-zone region requires the composition
// to vary across it, so the flash can label the phases correctly.
if ((reg.zgoc > span[0]) && (reg.zgoc < span[1]) &&
// to vary across it, so the flash can label the phases correctly. Only
// the hydrocarbon above the water-oil contact needs labelling.
const Scalar hydrocarbonBottom = FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)
? std::min(span[1], reg.zwoc) : span[1];
if ((reg.zgoc > span[0]) && (reg.zgoc < hydrocarbonBottom) &&
!compositionVariesBetween(reg, span[0], reg.zgoc) &&
!compositionVariesBetween(reg, reg.zgoc, span[1])) {
!compositionVariesBetween(reg, reg.zgoc, hydrocarbonBottom)) {
OpmLog::warning(fmt::format("Equilibration region {}: the gas-oil contact "
"at {} m lies inside a type-1 region, but the "
"composition does not vary across the contact. "
Expand Down
24 changes: 24 additions & 0 deletions tests/test_compequil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include <opm/simulators/flow/equil/InitStateEquilComp.hpp>

#include <opm/common/OpmLog/CounterLog.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>

#include <opm/material/common/MathToolbox.hpp>

#include <opm/material/constraintsolvers/SaturationPressure.hpp>
Expand Down Expand Up @@ -930,6 +933,27 @@ BOOST_AUTO_TEST_CASE(DatumOnCoincidentContactsKeepsTheGasRoot)
BOOST_CHECK_CLOSE(inferred, stated, 1e-8);
}

BOOST_AUTO_TEST_CASE(CoincidentContactsNeedNoPhaseLabelling)
{
// Below coinciding contacts there is only water, so a composition that does
// not vary across the gas-oil contact needs no warning. With the contact
// above the water the hydrocarbon spans it, and the warning remains.
const auto warnings = [](const std::string& equil) {
const WaterEquilFixture fix(waterDeckString(equil, "COMPVD\n 2000 0 0.5 0.5 0 10.0 /\n"));
const auto counter = std::make_shared<Opm::CounterLog>(Opm::Log::DefaultMessageTypes);
Opm::OpmLog::addBackend("COUNTER", counter);
const auto states = fix.compute(std::vector<int>(20, 0),
std::vector<Scalar>(20, connateSw),
std::vector<Scalar>(20, 1.0)).fluidStates();
Opm::OpmLog::removeBackend("COUNTER");
BOOST_REQUIRE_EQUAL(states.size(), std::size_t{20});
return counter->numMessages(Opm::Log::MessageType::Warning);
};

BOOST_CHECK_EQUAL(warnings("EQUIL\n 2060 10 2050 0 2050 0 /\n"), std::size_t{0});
BOOST_CHECK_EQUAL(warnings("EQUIL\n 2060 10 2050 0 2030 0 /\n"), std::size_t{1});
}

BOOST_AUTO_TEST_CASE(WaterEndpointsAreReadPerCell)
{
// The endpoints come from the scaled saturation functions, so they may
Expand Down
Loading