std::pair<double, double> poreSatVolumes(const GridInterface& grid, const ReservoirProperties& rp, const std::vector<double>& sat) { typedef typename GridInterface::CellIterator CellIter; double pore_vol = 0.0; double sat_vol = 0.0; for (CellIter c = grid.cellbegin(); c != grid.cellend(); ++c) { double cell_pore_vol = c->volume()*rp.porosity(c->index()); pore_vol += cell_pore_vol; sat_vol += cell_pore_vol*sat[c->index()]; } // Dividing by pore volume gives average saturations. return std::make_pair(pore_vol, sat_vol); }
inline void setupRegionBasedConditions(const Opm::parameter::ParameterGroup& param, const GridInterface& g, BCs& bcs) { // Extract region and pressure value for Dirichlet bcs. typedef typename GridInterface::Vector Vector; Vector low; low[0] = param.getDefault("dir_block_low_x", 0.0); low[1] = param.getDefault("dir_block_low_y", 0.0); low[2] = param.getDefault("dir_block_low_z", 0.0); Vector high; high[0] = param.getDefault("dir_block_high_x", 1.0); high[1] = param.getDefault("dir_block_high_y", 1.0); high[2] = param.getDefault("dir_block_high_z", 1.0); double dir_block_pressure = param.get<double>("dir_block_pressure"); // Set flow conditions for that region. // For this to work correctly, unique boundary ids should be used, // otherwise conditions may spread outside the given region, to all // faces with the same bid as faces inside the region. typedef typename GridInterface::CellIterator CI; typedef typename CI::FaceIterator FI; int max_bid = 0; std::vector<int> dir_bids; for (CI c = g.cellbegin(); c != g.cellend(); ++c) { for (FI f = c->facebegin(); f != c->faceend(); ++f) { int bid = f->boundaryId(); max_bid = std::max(bid, max_bid); if (bid != 0 && isInside(low, high, f->centroid())) { dir_bids.push_back(bid); } } } bcs.resize(max_bid + 1); for (std::vector<int>::const_iterator it = dir_bids.begin(); it != dir_bids.end(); ++it) { bcs.flowCond(*it) = FlowBC(FlowBC::Dirichlet, dir_block_pressure); } // Transport BCs are defaulted. }