initHydroCarbonState.hpp
Go to the documentation of this file.
1#ifndef INITHYDROCARBONSTATE_HPP
2#define INITHYDROCARBONSTATE_HPP
3
5
6namespace Opm
7{
8
9inline void initHydroCarbonState(BlackoilState& state, const PhaseUsage& pu, const int num_cells, const bool has_disgas, const bool has_vapoil) {
11 // hydrocarbonstate is only used when gas and oil is present
12 assert(pu.phase_used[Oil]);
13 std::vector<HydroCarbonState>& hydroCarbonState = state.hydroCarbonState();
14 hydroCarbonState.resize(num_cells);
15 if (!pu.phase_used[Gas]) {
16 // hydroCarbonState should only be used when oil and gas is present. Return OilOnly to avoid potential trouble.
17 std::fill(hydroCarbonState.begin(), hydroCarbonState.end(), HydroCarbonState::OilOnly);
18 return;
19 }
20 const int np = pu.num_phases;
21 std::fill(hydroCarbonState.begin(), hydroCarbonState.end(), HydroCarbonState::GasAndOil);
22
23 // set hydrocarbon state
24 const double epsilon = std::sqrt(std::numeric_limits<double>::epsilon());
25 const std::vector<double>& saturation = state.saturation();
26 for (int c = 0; c < num_cells; ++c) {
27 if (pu.phase_used[Water]) {
28 if ( saturation[c*np + pu.phase_pos[ Water ]] > (1.0 - epsilon)) {
29 continue; // cases (almost) filled with water is treated as GasAndOil case;
30 }
31 }
32 if ( saturation[c*np + pu.phase_pos[ Gas ]] == 0.0 && has_disgas) {
33 hydroCarbonState[c] = HydroCarbonState::OilOnly;
34 continue;
35 }
36 if ( saturation[c*np + pu.phase_pos[ Oil ]] == 0.0 && has_vapoil) {
37 hydroCarbonState[c] = HydroCarbonState::GasOnly;
38 }
39 }
40}
41
42
43} // namespace Opm
44#endif // INITHYDROCARBONSTATE_HPP
@ Liquid
Definition: BlackoilPhases.hpp:40
@ Aqua
Definition: BlackoilPhases.hpp:40
@ Vapour
Definition: BlackoilPhases.hpp:40
Simulator state for a blackoil simulator.
Definition: BlackoilState.hpp:41
std::vector< HydroCarbonState > & hydroCarbonState()
Definition: BlackoilState.hpp:73
Definition: AnisotropicEikonal.hpp:44
@ OilOnly
Definition: BlackoilState.hpp:36
@ GasOnly
Definition: BlackoilState.hpp:34
@ GasAndOil
Definition: BlackoilState.hpp:35
void initHydroCarbonState(BlackoilState &state, const PhaseUsage &pu, const int num_cells, const bool has_disgas, const bool has_vapoil)
Definition: initHydroCarbonState.hpp:9
Definition: BlackoilPhases.hpp:44
int phase_pos[MaxNumPhases+NumCryptoPhases]
Definition: BlackoilPhases.hpp:47
int phase_used[MaxNumPhases+NumCryptoPhases]
Definition: BlackoilPhases.hpp:46
int num_phases
Definition: BlackoilPhases.hpp:45