mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-27 09:40:59 -06:00
add an energy "phase"
This is quite a hack: Even though energy is not a "phase" and it is also not considered in MaxNumPhases and pu.num_phases because this would break a lot of assumptions in old code, it is nevertheless assigned an "canonical index" that can be translated "active index" via PhaseUsage::phase_pos[]. This awkwardness is needed because much of the legacy OPM code conflates the concepts of "fluid phase" and "conserved quantity" and fixing that issue would basically mean an almost complete rewrite of much of the legacy code. That said, the same statement applies to polymer and solvent, but these are currently handled as even more second-class citizens because they are not even given a canonical index and also cannot be translated into an active one.
This commit is contained in:
parent
075d518bea
commit
4571a8f841
@ -29,17 +29,18 @@ namespace Opm
|
||||
public:
|
||||
static const int MaxNumPhases = 3;
|
||||
// enum ComponentIndex { Water = 0, Oil = 1, Gas = 2 };
|
||||
enum PhaseIndex { Aqua = 0, Liquid = 1, Vapour = 2 };
|
||||
enum PhaseIndex { Aqua = 0, Liquid = 1, Vapour = 2, Energy = 3 };
|
||||
|
||||
};
|
||||
|
||||
struct PhaseUsage : public BlackoilPhases
|
||||
{
|
||||
int num_phases;
|
||||
int phase_used[MaxNumPhases];
|
||||
int phase_pos[MaxNumPhases];
|
||||
int phase_used[MaxNumPhases + 1];
|
||||
int phase_pos[MaxNumPhases + 1];
|
||||
bool has_solvent;
|
||||
bool has_polymer;
|
||||
bool has_energy;
|
||||
};
|
||||
|
||||
/// Check or assign presence of a formed, free phase. Limited to
|
||||
|
@ -50,9 +50,16 @@ namespace Opm
|
||||
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];
|
||||
int numActivePhases = 0;
|
||||
for (int phaseIdx = 0; phaseIdx < BlackoilPhases::MaxNumPhases; ++phaseIdx) {
|
||||
if (!pu.phase_used[numActivePhases]) {
|
||||
pu.phase_pos[phaseIdx] = -1;
|
||||
}
|
||||
else {
|
||||
pu.phase_pos[phaseIdx] = numActivePhases;
|
||||
++ numActivePhases;
|
||||
pu.num_phases = numActivePhases;
|
||||
}
|
||||
}
|
||||
|
||||
// Only 2 or 3 phase systems handled.
|
||||
@ -78,6 +85,17 @@ namespace Opm
|
||||
pu.has_polymer = true;
|
||||
}
|
||||
|
||||
// Add energy info
|
||||
pu.has_energy = phase.active(Phase::ENERGY);
|
||||
if (pu.has_energy) {
|
||||
// this is quite a hack: even though energy is not considered as in
|
||||
// MaxNumPhases and pu.num_phases because this would break a lot of
|
||||
// assumptions in old code, it is nevertheless an index to be translated
|
||||
// to. polymer and solvent are even larger hacks because not even this can be
|
||||
// done for them.
|
||||
pu.phase_pos[BlackoilPhases::Energy] = numActivePhases;
|
||||
++ numActivePhases;
|
||||
}
|
||||
return pu;
|
||||
}
|
||||
|
||||
@ -136,6 +154,9 @@ namespace Opm
|
||||
pu.has_polymer = true;
|
||||
}
|
||||
|
||||
// Add energy info
|
||||
pu.has_energy = phase.active(Phase::ENERGY);
|
||||
|
||||
return pu;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user