98 for (
const auto& reg : rmap_.activeRegions()) {
99 auto& ra = attr_.attributes(reg);
101 ra.temperature = 0.0;
105 ra.saltConcentration = 0.0;
111 std::unordered_map<RegionId, Attributes> attributes_pv;
114 std::unordered_map<RegionId, Attributes> attributes_hpv;
116 for (
const auto& reg : rmap_.activeRegions()) {
117 attributes_pv.insert({reg, Attributes()});
118 attributes_hpv.insert({reg, Attributes()});
121 ElementContext elemCtx( simulator );
122 const auto& gridView = simulator.gridView();
123 const auto& comm = gridView.comm();
125 OPM_BEGIN_PARALLEL_TRY_CATCH();
126 for (
const auto& elem : elements(gridView, Dune::Partitions::interior)) {
127 elemCtx.updatePrimaryStencil(elem);
128 elemCtx.updatePrimaryIntensiveQuantities(0);
129 const unsigned cellIdx = elemCtx.globalSpaceIndex(0, 0);
130 const auto& intQuants = elemCtx.intensiveQuantities(0, 0);
131 const auto& fs = intQuants.fluidState();
133 const double pv_cell =
134 simulator.model().dofTotalVolume(cellIdx)
135 * intQuants.porosity().value();
138 double hydrocarbon = 1.0;
139 const auto& pu = phaseUsage_;
141 hydrocarbon -= fs.saturation(FluidSystem::waterPhaseIdx).value();
144 const int reg = rmap_.region(cellIdx);
148 const double hydrocarbonPV = pv_cell*hydrocarbon;
149 if (hydrocarbonPV > 0.) {
150 auto& attr = attributes_hpv[reg];
151 attr.pv += hydrocarbonPV;
153 attr.rs += fs.Rs().value() * hydrocarbonPV;
154 attr.rv += fs.Rv().value() * hydrocarbonPV;
157 attr.pressure += fs.pressure(FluidSystem::oilPhaseIdx).value() * hydrocarbonPV;
158 attr.temperature += fs.temperature(FluidSystem::oilPhaseIdx).value() * hydrocarbonPV;
161 attr.pressure += fs.pressure(FluidSystem::gasPhaseIdx).value() * hydrocarbonPV;
162 attr.temperature += fs.temperature(FluidSystem::gasPhaseIdx).value() * hydrocarbonPV;
164 attr.saltConcentration += fs.saltConcentration().value() * hydrocarbonPV;
165 if (FluidSystem::enableDissolvedGasInWater()) {
166 attr.rsw += fs.Rsw().value() * hydrocarbonPV;
168 if (FluidSystem::enableVaporizedWater()) {
169 attr.rvw += fs.Rvw().value() * hydrocarbonPV;
174 auto& attr = attributes_pv[reg];
177 attr.rs += fs.Rs().value() * pv_cell;
178 attr.rv += fs.Rv().value() * pv_cell;
181 attr.pressure += fs.pressure(FluidSystem::oilPhaseIdx).value() * pv_cell;
182 attr.temperature += fs.temperature(FluidSystem::oilPhaseIdx).value() * pv_cell;
184 attr.pressure += fs.pressure(FluidSystem::gasPhaseIdx).value() * pv_cell;
185 attr.temperature += fs.temperature(FluidSystem::gasPhaseIdx).value() * pv_cell;
188 attr.pressure += fs.pressure(FluidSystem::waterPhaseIdx).value() * pv_cell;
189 attr.temperature += fs.temperature(FluidSystem::waterPhaseIdx).value() * pv_cell;
191 attr.saltConcentration += fs.saltConcentration().value() * pv_cell;
192 if (FluidSystem::enableDissolvedGasInWater()) {
193 attr.rsw += fs.Rsw().value() * pv_cell;
195 if (FluidSystem::enableVaporizedWater()) {
196 attr.rvw += fs.Rvw().value() * pv_cell;
201 OPM_END_PARALLEL_TRY_CATCH(
"SurfaceToReservoirVoidage::defineState() failed: ", simulator.vanguard().grid().comm());
203 this->sumRates(attributes_hpv,