ExplicitArraysFluidState: always make it appear threephase to the exterior, but also accept twophase arrays

This commit is contained in:
Andreas Lauser 2015-08-21 14:05:06 +02:00
parent 08a77e36d0
commit d57d121c38
2 changed files with 21 additions and 27 deletions

View File

@ -281,7 +281,7 @@ namespace Opm
assert(cells != 0); assert(cells != 0);
const int np = phase_usage_.num_phases; const int np = phase_usage_.num_phases;
ExplicitArraysFluidState fluidState(np); ExplicitArraysFluidState fluidState(phase_usage_);
fluidState.setSaturationArray(s); fluidState.setSaturationArray(s);
if (dkrds) { if (dkrds) {
@ -334,7 +334,7 @@ namespace Opm
assert(cells != 0); assert(cells != 0);
const int np = phase_usage_.num_phases; const int np = phase_usage_.num_phases;
ExplicitArraysFluidState fluidState(np); ExplicitArraysFluidState fluidState(phase_usage_);
fluidState.setSaturationArray(s); fluidState.setSaturationArray(s);
if (dpcds) { if (dpcds) {
@ -474,7 +474,7 @@ namespace Opm
const int max_np = BlackoilPhases::MaxNumPhases; const int max_np = BlackoilPhases::MaxNumPhases;
double s[max_np] = { 0.0 }; double s[max_np] = { 0.0 };
s[wpos] = swat; s[wpos] = swat;
ExplicitArraysFluidState fluidState(phase_usage_.num_phases); ExplicitArraysFluidState fluidState(phase_usage_);
fluidState.setSaturationArray(s); fluidState.setSaturationArray(s);
fluidState.setIndex(0); fluidState.setIndex(0);
double pc[max_np] = { 0.0 }; double pc[max_np] = { 0.0 };

View File

@ -35,9 +35,10 @@ class ExplicitArraysFluidState
{ {
public: public:
typedef double Scalar; typedef double Scalar;
enum { numPhases = BlackoilPhases::MaxNumPhases };
explicit ExplicitArraysFluidState(const unsigned int num_phases) explicit ExplicitArraysFluidState(const PhaseUsage& phaseUsage)
: numPhases_(num_phases) : phaseUsage_(phaseUsage)
{} {}
/*! /*!
@ -47,7 +48,17 @@ public:
* index. * index.
*/ */
void setIndex(unsigned arrayIdx) 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. * \brief Set the array containing the phase saturations.
@ -60,35 +71,18 @@ public:
void setSaturationArray(const double* saturations) void setSaturationArray(const double* saturations)
{ saturations_ = 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. * \brief Returns the saturation of a phase for the current cell index.
*/ */
Scalar saturation(int phaseIdx) const Scalar saturation(int phaseIdx) const
{ return saturations_[numPhases_*arrayIdx_ + phaseIdx]; } { return sats_[phaseIdx]; }
/*! // TODO (?) temperature, pressure, composition, etc
* \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
private: private:
const PhaseUsage phaseUsage_;
const double* saturations_; const double* saturations_;
const double* temperature_; std::array<Scalar, BlackoilPhases::MaxNumPhases> sats_;
unsigned arrayIdx_;
unsigned numPhases_;
}; };
} // namespace Opm } // namespace Opm