mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-27 11:06:25 -06:00
Create PhaseUsage constructor
This commit is contained in:
parent
624d8b1343
commit
bcdc974585
@ -32,6 +32,7 @@ list (APPEND MAIN_SOURCE_FILES
|
|||||||
ebos/eclgenericvanguard.cc
|
ebos/eclgenericvanguard.cc
|
||||||
ebos/eclgenericwriter.cc
|
ebos/eclgenericwriter.cc
|
||||||
ebos/ecltransmissibility.cc
|
ebos/ecltransmissibility.cc
|
||||||
|
opm/core/props/BlackoilPhases.cpp
|
||||||
opm/core/props/phaseUsageFromDeck.cpp
|
opm/core/props/phaseUsageFromDeck.cpp
|
||||||
opm/core/props/satfunc/RelpermDiagnostics.cpp
|
opm/core/props/satfunc/RelpermDiagnostics.cpp
|
||||||
opm/simulators/timestepping/SimulatorReport.cpp
|
opm/simulators/timestepping/SimulatorReport.cpp
|
||||||
|
53
opm/core/props/BlackoilPhases.cpp
Normal file
53
opm/core/props/BlackoilPhases.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 Equinor ASA
|
||||||
|
|
||||||
|
This file is part of the Open Porous Media project (OPM).
|
||||||
|
|
||||||
|
OPM is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OPM is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <opm/core/props/BlackoilPhases.hpp>
|
||||||
|
|
||||||
|
Opm::PhaseUsage::PhaseUsage(std::vector<BlackoilPhases::PhaseIndex> phases)
|
||||||
|
{
|
||||||
|
std::sort(phases.begin(), phases.end());
|
||||||
|
this->phase_used.fill(0);
|
||||||
|
this->phase_pos.fill(-1);
|
||||||
|
|
||||||
|
std::size_t current_pos = 0;
|
||||||
|
for (const auto& phase : phases) {
|
||||||
|
this->phase_used[phase] = 1;
|
||||||
|
this->phase_pos[phase] = current_pos;
|
||||||
|
|
||||||
|
current_pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->num_phases = 0;
|
||||||
|
if (this->phase_used[BlackoilPhases::Aqua])
|
||||||
|
this->num_phases++;
|
||||||
|
if (this->phase_used[BlackoilPhases::Liquid])
|
||||||
|
this->num_phases++;
|
||||||
|
if (this->phase_used[BlackoilPhases::Vapour])
|
||||||
|
this->num_phases++;
|
||||||
|
|
||||||
|
this->has_solvent = this->phase_used[BlackoilPhases::Solvent];
|
||||||
|
this->has_polymer = this->phase_used[BlackoilPhases::Polymer];
|
||||||
|
this->has_energy = this->phase_used[BlackoilPhases::Energy];
|
||||||
|
this->has_polymermw = this->phase_used[BlackoilPhases::PolymerMW];
|
||||||
|
this->has_foam = this->phase_used[BlackoilPhases::Foam];
|
||||||
|
this->has_brine = this->phase_used[BlackoilPhases::Brine];
|
||||||
|
this->has_zFraction = this->phase_used[BlackoilPhases::ZFraction];
|
||||||
|
}
|
@ -21,6 +21,7 @@
|
|||||||
#define OPM_BLACKOILPHASES_HEADER_INCLUDED
|
#define OPM_BLACKOILPHASES_HEADER_INCLUDED
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
@ -43,6 +44,10 @@ namespace Opm
|
|||||||
|
|
||||||
struct PhaseUsage : public BlackoilPhases
|
struct PhaseUsage : public BlackoilPhases
|
||||||
{
|
{
|
||||||
|
PhaseUsage() = default;
|
||||||
|
explicit PhaseUsage(std::vector<BlackoilPhases::PhaseIndex> phases);
|
||||||
|
|
||||||
|
|
||||||
std::array<int, MaxNumPhases + NumCryptoPhases> phase_used;
|
std::array<int, MaxNumPhases + NumCryptoPhases> phase_used;
|
||||||
std::array<int, MaxNumPhases + NumCryptoPhases> phase_pos;
|
std::array<int, MaxNumPhases + NumCryptoPhases> phase_pos;
|
||||||
|
|
||||||
|
@ -594,6 +594,27 @@ BOOST_AUTO_TEST_CASE(TestSingleWellState) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(TestPU) {
|
||||||
|
Opm::PhaseUsage pu({Opm::BlackoilPhases::Polymer, Opm::BlackoilPhases::Solvent, Opm::BlackoilPhases::Aqua, Opm::BlackoilPhases::ZFraction});
|
||||||
|
|
||||||
|
BOOST_CHECK(pu.phase_used[Opm::BlackoilPhases::Aqua]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Aqua], 0);
|
||||||
|
BOOST_CHECK(pu.phase_used[Opm::BlackoilPhases::Solvent]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Solvent], 1);
|
||||||
|
BOOST_CHECK(pu.phase_used[Opm::BlackoilPhases::Polymer]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Polymer], 2);
|
||||||
|
BOOST_CHECK(pu.phase_used[Opm::BlackoilPhases::ZFraction]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::ZFraction], 3);
|
||||||
|
|
||||||
|
BOOST_CHECK(!pu.phase_used[Opm::BlackoilPhases::Liquid]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Liquid], -1);
|
||||||
|
BOOST_CHECK(!pu.phase_used[Opm::BlackoilPhases::Energy]); BOOST_CHECK_EQUAL(pu.phase_pos[Opm::BlackoilPhases::Energy], -1);
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL(pu.num_phases, 1); // Only Aqua counts as a phase.
|
||||||
|
BOOST_CHECK(pu.has_polymer);
|
||||||
|
BOOST_CHECK(pu.has_solvent);
|
||||||
|
BOOST_CHECK(pu.has_zFraction);
|
||||||
|
|
||||||
|
BOOST_CHECK(!pu.has_energy);
|
||||||
|
BOOST_CHECK(!pu.has_polymermw);
|
||||||
|
BOOST_CHECK(!pu.has_foam);
|
||||||
|
BOOST_CHECK(!pu.has_brine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
Loading…
Reference in New Issue
Block a user