mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
ExplicitArraysFluidState: always make it appear threephase to the exterior, but also accept twophase arrays
This commit is contained in:
parent
08a77e36d0
commit
d57d121c38
@ -281,7 +281,7 @@ namespace Opm
|
||||
assert(cells != 0);
|
||||
|
||||
const int np = phase_usage_.num_phases;
|
||||
ExplicitArraysFluidState fluidState(np);
|
||||
ExplicitArraysFluidState fluidState(phase_usage_);
|
||||
fluidState.setSaturationArray(s);
|
||||
|
||||
if (dkrds) {
|
||||
@ -334,7 +334,7 @@ namespace Opm
|
||||
assert(cells != 0);
|
||||
|
||||
const int np = phase_usage_.num_phases;
|
||||
ExplicitArraysFluidState fluidState(np);
|
||||
ExplicitArraysFluidState fluidState(phase_usage_);
|
||||
fluidState.setSaturationArray(s);
|
||||
|
||||
if (dpcds) {
|
||||
@ -474,7 +474,7 @@ namespace Opm
|
||||
const int max_np = BlackoilPhases::MaxNumPhases;
|
||||
double s[max_np] = { 0.0 };
|
||||
s[wpos] = swat;
|
||||
ExplicitArraysFluidState fluidState(phase_usage_.num_phases);
|
||||
ExplicitArraysFluidState fluidState(phase_usage_);
|
||||
fluidState.setSaturationArray(s);
|
||||
fluidState.setIndex(0);
|
||||
double pc[max_np] = { 0.0 };
|
||||
|
@ -35,9 +35,10 @@ class ExplicitArraysFluidState
|
||||
{
|
||||
public:
|
||||
typedef double Scalar;
|
||||
enum { numPhases = BlackoilPhases::MaxNumPhases };
|
||||
|
||||
explicit ExplicitArraysFluidState(const unsigned int num_phases)
|
||||
: numPhases_(num_phases)
|
||||
explicit ExplicitArraysFluidState(const PhaseUsage& phaseUsage)
|
||||
: phaseUsage_(phaseUsage)
|
||||
{}
|
||||
|
||||
/*!
|
||||
@ -47,7 +48,17 @@ public:
|
||||
* index.
|
||||
*/
|
||||
void setIndex(unsigned arrayIdx)
|
||||
{ arrayIdx_ = arrayIdx; }
|
||||
{
|
||||
int np = phaseUsage_.num_phases;
|
||||
for (int phaseIdx = 0; phaseIdx < BlackoilPhases::MaxNumPhases; ++phaseIdx) {
|
||||
if (!phaseUsage_.phase_used[phaseIdx]) {
|
||||
sats_[phaseIdx] = 0.0;
|
||||
}
|
||||
else {
|
||||
sats_[phaseIdx] = saturations_[np*arrayIdx + phaseUsage_.phase_pos[phaseIdx]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set the array containing the phase saturations.
|
||||
@ -60,35 +71,18 @@ public:
|
||||
void setSaturationArray(const double* saturations)
|
||||
{ saturations_ = saturations; }
|
||||
|
||||
/*!
|
||||
* \brief Set the array containing the phase temperatures.
|
||||
*
|
||||
* This array is supposed to be of size 'size' and is not allowed to be
|
||||
* deleted while the ExplicitArraysFluidState object is alive.
|
||||
*/
|
||||
void setTemperatureArray(const double* temperature)
|
||||
{ temperature_ = temperature; }
|
||||
|
||||
/*!
|
||||
* \brief Returns the saturation of a phase for the current cell index.
|
||||
*/
|
||||
Scalar saturation(int phaseIdx) const
|
||||
{ return saturations_[numPhases_*arrayIdx_ + phaseIdx]; }
|
||||
{ return sats_[phaseIdx]; }
|
||||
|
||||
/*!
|
||||
* \brief Returns the temperature [K] of a phase for the current cell index.
|
||||
*/
|
||||
Scalar temperature(int /* phaseIdx */) const
|
||||
{ return temperature_[arrayIdx_]; }
|
||||
|
||||
// TODO (?) pressure, composition, etc
|
||||
// TODO (?) temperature, pressure, composition, etc
|
||||
|
||||
private:
|
||||
const PhaseUsage phaseUsage_;
|
||||
const double* saturations_;
|
||||
const double* temperature_;
|
||||
|
||||
unsigned arrayIdx_;
|
||||
unsigned numPhases_;
|
||||
std::array<Scalar, BlackoilPhases::MaxNumPhases> sats_;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
Loading…
Reference in New Issue
Block a user