97 for (
const auto& reg : rmap_.activeRegions()) {
98 auto& ra = attr_.attributes(reg);
100 ra.temperature = 0.0;
104 ra.saltConcentration = 0.0;
110 std::unordered_map<RegionId, Attributes> attributes_pv;
113 std::unordered_map<RegionId, Attributes> attributes_hpv;
115 for (
const auto& reg : rmap_.activeRegions()) {
116 attributes_pv.insert({reg, Attributes()});
117 attributes_hpv.insert({reg, Attributes()});
120 ElementContext elemCtx( simulator );
121 const auto& gridView = simulator.
gridView();
122 const auto& comm = gridView.comm();
124 OPM_BEGIN_PARALLEL_TRY_CATCH();
125 for (
const auto& elem : elements(gridView, Dune::Partitions::interior)) {
126 elemCtx.updatePrimaryStencil(elem);
127 elemCtx.updatePrimaryIntensiveQuantities(0);
128 const unsigned cellIdx = elemCtx.globalSpaceIndex(0, 0);
129 const auto& intQuants = elemCtx.intensiveQuantities(0, 0);
130 const auto& fs = intQuants.fluidState();
132 const Scalar pv_cell =
133 simulator.
model().dofTotalVolume(simulator.
vanguard().gridEquilIdxToGridIdx(cellIdx))
134 * intQuants.porosity().value();
137 Scalar hydrocarbon = 1.0;
138 if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
139 hydrocarbon -= fs.saturation(FluidSystem::waterPhaseIdx).value();
142 const int reg = rmap_.region(cellIdx);
146 const Scalar hydrocarbonPV = pv_cell*hydrocarbon;
147 if (hydrocarbonPV > 0.) {
148 auto& attr = attributes_hpv[reg];
149 attr.pv += hydrocarbonPV;
150 if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
151 attr.rs += fs.Rs().value() * hydrocarbonPV;
152 attr.rv += fs.Rv().value() * hydrocarbonPV;
154 if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
155 attr.pressure += fs.pressure(FluidSystem::oilPhaseIdx).value() * hydrocarbonPV;
156 attr.temperature += fs.temperature(FluidSystem::oilPhaseIdx).value() * hydrocarbonPV;
158 assert(FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx));
159 attr.pressure += fs.pressure(FluidSystem::gasPhaseIdx).value() * hydrocarbonPV;
160 attr.temperature += fs.temperature(FluidSystem::gasPhaseIdx).value() * hydrocarbonPV;
162 attr.saltConcentration += fs.saltConcentration().value() * hydrocarbonPV;
163 if (FluidSystem::enableDissolvedGasInWater()) {
164 attr.rsw += fs.Rsw().value() * hydrocarbonPV;
166 if (FluidSystem::enableVaporizedWater()) {
167 attr.rvw += fs.Rvw().value() * hydrocarbonPV;
172 auto& attr = attributes_pv[reg];
174 if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
175 attr.rs += fs.Rs().value() * pv_cell;
176 attr.rv += fs.Rv().value() * pv_cell;
178 if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
179 attr.pressure += fs.pressure(FluidSystem::oilPhaseIdx).value() * pv_cell;
180 attr.temperature += fs.temperature(FluidSystem::oilPhaseIdx).value() * pv_cell;
181 }
else if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
182 attr.pressure += fs.pressure(FluidSystem::gasPhaseIdx).value() * pv_cell;
183 attr.temperature += fs.temperature(FluidSystem::gasPhaseIdx).value() * pv_cell;
185 assert(FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx));
186 attr.pressure += fs.pressure(FluidSystem::waterPhaseIdx).value() * pv_cell;
187 attr.temperature += fs.temperature(FluidSystem::waterPhaseIdx).value() * pv_cell;
189 attr.saltConcentration += fs.saltConcentration().value() * pv_cell;
190 if (FluidSystem::enableDissolvedGasInWater()) {
191 attr.rsw += fs.Rsw().value() * pv_cell;
193 if (FluidSystem::enableVaporizedWater()) {
194 attr.rvw += fs.Rvw().value() * pv_cell;
199 OPM_END_PARALLEL_TRY_CATCH(
"SurfaceToReservoirVoidage::defineState() failed: ", simulator.
vanguard().grid().comm());
201 this->sumRates(attributes_hpv,