Moved active phase determination into own function.
This commit is contained in:
parent
1c4a621ea5
commit
88379706a3
@ -86,6 +86,7 @@ opm/core/fluid/BlackoilPropertiesInterface.hpp \
|
||||
opm/core/fluid/BlackoilPropertiesFromDeck.hpp \
|
||||
opm/core/fluid/RockFromDeck.hpp \
|
||||
opm/core/fluid/SimpleFluid2p.hpp \
|
||||
opm/core/fluid/blackoil/phaseUsageFromDeck.hpp \
|
||||
opm/core/fluid/blackoil/BlackoilDefs.hpp \
|
||||
opm/core/fluid/blackoil/BlackoilPhases.hpp \
|
||||
opm/core/fluid/blackoil/BlackoilPVT.hpp \
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <opm/core/fluid/blackoil/SinglePvtLiveOil.hpp>
|
||||
#include <opm/core/fluid/blackoil/SinglePvtLiveGas.hpp>
|
||||
#include <opm/core/fluid/blackoil/SinglePvtConstCompr.hpp>
|
||||
#include <opm/core/fluid/blackoil/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
#include <opm/core/utility/ErrorMacros.hpp>
|
||||
@ -33,39 +34,18 @@
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
BlackoilPvtProperties::BlackoilPvtProperties()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BlackoilPvtProperties::init(const Dune::EclipseGridParser& deck)
|
||||
{
|
||||
typedef std::vector<std::vector<std::vector<double> > > table_t;
|
||||
// If we need multiple regions, this class and the SinglePvt* classes must change.
|
||||
region_number_ = 0;
|
||||
|
||||
// Discover phase usage.
|
||||
std::fill(phase_used_, phase_used_ + MaxNumPhases, 0);
|
||||
if (deck.hasField("WATER")) {
|
||||
phase_used_[Aqua] = 1;
|
||||
}
|
||||
if (deck.hasField("OIL")) {
|
||||
phase_used_[Liquid] = 1;
|
||||
}
|
||||
if (deck.hasField("GAS")) {
|
||||
phase_used_[Vapour] = 1;
|
||||
}
|
||||
num_phases_ = 0;
|
||||
for (int i = 0; i < MaxNumPhases; ++i) {
|
||||
phase_pos_[i] = num_phases_;
|
||||
num_phases_ += phase_used_[i];
|
||||
}
|
||||
|
||||
// Only 2 or 3 phase systems handled.
|
||||
if (num_phases_ < 2 || num_phases_ > 3) {
|
||||
THROW("Cannot handle cases with " << num_phases_ << " phases.");
|
||||
}
|
||||
|
||||
// We need oil systems, since we do not support the keywords needed for
|
||||
// water-gas systems.
|
||||
if (!phase_used_[Liquid]) {
|
||||
THROW("Cannot handle cases with no OIL, i.e. water-gas systems.");
|
||||
}
|
||||
phase_usage_ = phaseUsageFromDeck(deck);
|
||||
|
||||
// Surface densities. Accounting for different orders in eclipse and our code.
|
||||
if (deck.hasField("DENSITY")) {
|
||||
@ -79,42 +59,42 @@ namespace Opm
|
||||
}
|
||||
|
||||
// Set the properties.
|
||||
props_.resize(num_phases_);
|
||||
props_.resize(phase_usage_.num_phases);
|
||||
// Water PVT
|
||||
if (phase_used_[Aqua]) {
|
||||
if (phase_usage_.phase_used[Aqua]) {
|
||||
if (deck.hasField("PVTW")) {
|
||||
props_[phase_pos_[Aqua]].reset(new SinglePvtConstCompr(deck.getPVTW().pvtw_));
|
||||
props_[phase_usage_.phase_pos[Aqua]].reset(new SinglePvtConstCompr(deck.getPVTW().pvtw_));
|
||||
} else {
|
||||
// Eclipse 100 default.
|
||||
props_[phase_pos_[Aqua]].reset(new SinglePvtConstCompr(0.5*Dune::prefix::centi*Dune::unit::Poise));
|
||||
props_[phase_usage_.phase_pos[Aqua]].reset(new SinglePvtConstCompr(0.5*Dune::prefix::centi*Dune::unit::Poise));
|
||||
}
|
||||
}
|
||||
// Oil PVT
|
||||
if (phase_used_[Liquid]) {
|
||||
if (phase_usage_.phase_used[Liquid]) {
|
||||
if (deck.hasField("PVDO")) {
|
||||
props_[phase_pos_[Liquid]].reset(new SinglePvtDead(deck.getPVDO().pvdo_));
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDead(deck.getPVDO().pvdo_));
|
||||
} else if (deck.hasField("PVTO")) {
|
||||
props_[phase_pos_[Liquid]].reset(new SinglePvtLiveOil(deck.getPVTO().pvto_));
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(deck.getPVTO().pvto_));
|
||||
} else if (deck.hasField("PVCDO")) {
|
||||
props_[phase_pos_[Liquid]].reset(new SinglePvtConstCompr(deck.getPVCDO().pvcdo_));
|
||||
props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtConstCompr(deck.getPVCDO().pvcdo_));
|
||||
} else {
|
||||
THROW("Input is missing PVDO or PVTO\n");
|
||||
}
|
||||
}
|
||||
// Gas PVT
|
||||
if (phase_used_[Vapour]) {
|
||||
if (phase_usage_.phase_used[Vapour]) {
|
||||
if (deck.hasField("PVDG")) {
|
||||
props_[phase_pos_[Vapour]].reset(new SinglePvtDead(deck.getPVDG().pvdg_));
|
||||
props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDead(deck.getPVDG().pvdg_));
|
||||
} else if (deck.hasField("PVTG")) {
|
||||
props_[phase_pos_[Vapour]].reset(new SinglePvtLiveGas(deck.getPVTG().pvtg_));
|
||||
props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtLiveGas(deck.getPVTG().pvtg_));
|
||||
} else {
|
||||
THROW("Input is missing PVDG or PVTG\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Must inform pvt property objects of phase structure.
|
||||
for (int i = 0; i < num_phases_; ++i) {
|
||||
props_[i]->setPhaseConfiguration(num_phases_, phase_pos_);
|
||||
for (int i = 0; i < phase_usage_.num_phases; ++i) {
|
||||
props_[i]->setPhaseConfiguration(phase_usage_.num_phases, phase_usage_.phase_pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,11 +110,11 @@ namespace Opm
|
||||
double* output_mu) const
|
||||
{
|
||||
data1_.resize(n);
|
||||
for (int phase = 0; phase < num_phases_; ++phase) {
|
||||
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
|
||||
props_[phase]->mu(n, p, z, &data1_[0]);
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_mu[num_phases_*i + phase] = data1_[i];
|
||||
output_mu[phase_usage_.num_phases*i + phase] = data1_[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,11 +125,11 @@ namespace Opm
|
||||
double* output_B) const
|
||||
{
|
||||
data1_.resize(n);
|
||||
for (int phase = 0; phase < num_phases_; ++phase) {
|
||||
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
|
||||
props_[phase]->B(n, p, z, &data1_[0]);
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_B[num_phases_*i + phase] = data1_[i];
|
||||
output_B[phase_usage_.num_phases*i + phase] = data1_[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -162,12 +142,12 @@ namespace Opm
|
||||
{
|
||||
data1_.resize(n);
|
||||
data2_.resize(n);
|
||||
for (int phase = 0; phase < num_phases_; ++phase) {
|
||||
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
|
||||
props_[phase]->dBdp(n, p, z, &data1_[0], &data2_[0]);
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_B[num_phases_*i + phase] = data1_[i];
|
||||
output_dBdp[num_phases_*i + phase] = data2_[i];
|
||||
output_B[phase_usage_.num_phases*i + phase] = data1_[i];
|
||||
output_dBdp[phase_usage_.num_phases*i + phase] = data2_[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -179,11 +159,11 @@ namespace Opm
|
||||
double* output_R) const
|
||||
{
|
||||
data1_.resize(n);
|
||||
for (int phase = 0; phase < num_phases_; ++phase) {
|
||||
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
|
||||
props_[phase]->R(n, p, z, &data1_[0]);
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_R[num_phases_*i + phase] = data1_[i];
|
||||
output_R[phase_usage_.num_phases*i + phase] = data1_[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -196,12 +176,12 @@ namespace Opm
|
||||
{
|
||||
data1_.resize(n);
|
||||
data2_.resize(n);
|
||||
for (int phase = 0; phase < num_phases_; ++phase) {
|
||||
for (int phase = 0; phase < phase_usage_.num_phases; ++phase) {
|
||||
props_[phase]->dRdp(n, p, z, &data1_[0], &data2_[0]);
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < n; ++i) {
|
||||
output_R[num_phases_*i + phase] = data1_[i];
|
||||
output_dRdp[num_phases_*i + phase] = data2_[i];
|
||||
output_R[phase_usage_.num_phases*i + phase] = data1_[i];
|
||||
output_dRdp[phase_usage_.num_phases*i + phase] = data2_[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,10 @@ namespace Opm
|
||||
class BlackoilPvtProperties : public BlackoilPhases
|
||||
{
|
||||
public:
|
||||
/// Default constructor.
|
||||
BlackoilPvtProperties();
|
||||
|
||||
/// Initialize from deck.
|
||||
void init(const Dune::EclipseGridParser& deck);
|
||||
|
||||
/// Number of active phases.
|
||||
@ -99,9 +103,7 @@ namespace Opm
|
||||
BlackoilPvtProperties(const BlackoilPvtProperties&);
|
||||
BlackoilPvtProperties& operator=(const BlackoilPvtProperties&);
|
||||
|
||||
int num_phases_;
|
||||
int phase_used_[MaxNumPhases];
|
||||
int phase_pos_[MaxNumPhases];
|
||||
PhaseUsage phase_usage_;
|
||||
|
||||
int region_number_;
|
||||
|
||||
|
71
opm/core/fluid/blackoil/phaseUsageFromDeck.hpp
Normal file
71
opm/core/fluid/blackoil/phaseUsageFromDeck.hpp
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|
||||
#define OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|
||||
|
||||
|
||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||
#include <opm/core/fluid/blackoil/BlackoilPhases.hpp>
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
|
||||
/// Looks at presence of WATER, OIL and GAS keywords in deck
|
||||
/// to determine active phases.
|
||||
PhaseUsage phaseUsageFromDeck(const Dune::EclipseGridParser& deck)
|
||||
{
|
||||
PhaseUsage pu;
|
||||
std::fill(pu.phase_used, pu.phase_used + BlackoilPhases::MaxNumPhases, 0);
|
||||
|
||||
// Discover phase usage.
|
||||
if (deck.hasField("WATER")) {
|
||||
pu.phase_used[BlackoilPhases::Aqua] = 1;
|
||||
}
|
||||
if (deck.hasField("OIL")) {
|
||||
pu.phase_used[BlackoilPhases::Liquid] = 1;
|
||||
}
|
||||
if (deck.hasField("GAS")) {
|
||||
pu.phase_used[BlackoilPhases::Vapour] = 1;
|
||||
}
|
||||
pu.num_phases = 0;
|
||||
for (int i = 0; i < BlackoilPhases::MaxNumPhases; ++i) {
|
||||
pu.phase_pos[i] = pu.num_phases;
|
||||
pu.num_phases += pu.phase_used[i];
|
||||
}
|
||||
|
||||
// Only 2 or 3 phase systems handled.
|
||||
if (pu.num_phases < 2 || pu.num_phases > 3) {
|
||||
THROW("Cannot handle cases with " << pu.num_phases << " phases.");
|
||||
}
|
||||
|
||||
// We need oil systems, since we do not support the keywords needed for
|
||||
// water-gas systems.
|
||||
if (!pu.phase_used[BlackoilPhases::Liquid]) {
|
||||
THROW("Cannot handle cases with no OIL, i.e. water-gas systems.");
|
||||
}
|
||||
|
||||
return pu;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // OPM_PHASEUSAGEFROMDECK_HEADER_INCLUDED
|
Loading…
Reference in New Issue
Block a user