1#include <opm/core/grid/GridHelpers.hpp>
15 template<
class CC,
class FC,
class FC1,
class CV>
18 FC begin_face_centroids,
20 CC begin_cell_centroids,
21 CV begin_cell_volumes,
23 const std::vector<double>& face_flux,
24 std::vector<double>& cell_velocity)
26 cell_velocity.clear();
27 cell_velocity.resize(number_of_cells*dimension, 0.0);
28 for (
int face = 0; face < number_of_faces; ++face) {
29 int c[2] = { face_cells(face, 0), face_cells(face, 1) };
30 FC fc = UgGridHelpers::increment(begin_face_centroids, face, dimension);
31 double flux = face_flux[face];
32 for (
int i = 0; i < 2; ++i) {
34 CC cc = UgGridHelpers::increment(begin_cell_centroids, c[i], dimension);
35 for (
int d = 0; d < dimension; ++d) {
36 double v_contrib = UgGridHelpers::getCoordinate(fc, d) - UgGridHelpers::getCoordinate(cc, d);
37 v_contrib *= flux/begin_cell_volumes[c[i]];
38 cell_velocity[c[i]*dimension + d] += (i == 0) ? v_contrib : -v_contrib;
48 const double* porosity,
49 std::vector<double>& porevol)
51 porevol.resize(number_of_cells);
52 std::transform(porosity, porosity + number_of_cells,
55 std::multiplies<double>());
67 const double* porosity,
69 const std::vector<double>& pressure,
70 std::vector<double>& porevol)
72 porevol.resize(number_of_cells);
73 for (
int i = 0; i < number_of_cells; ++i) {
74 porevol[i] = porosity[i]*begin_cell_volumes[i]*rock_comp.
poroMult(pressure[i]);
79 void computeWDP(
const Wells& wells,
int number_of_cells, T begin_cell_centroids,
const std::vector<double>& saturations,
80 const double* densities,
const double gravity,
const bool per_grid_cell,
81 std::vector<double>& wdp)
84 const size_t np = per_grid_cell ?
85 saturations.size()/number_of_cells
88 for (
int i = 0; i < nw; i++) {
94 double cell_depth = UgGridHelpers
95 ::getCoordinate(UgGridHelpers::increment(begin_cell_centroids, cell, 3), 2);
97 double saturation_sum = 0.0;
98 for (
size_t p = 0; p < np; p++) {
100 saturation_sum += saturations[j * np + p];
102 saturation_sum += saturations[np * cell + p];
105 if (saturation_sum == 0) {
106 saturation_sum = 1.0;
108 double density = 0.0;
109 for (
size_t p = 0; p < np; p++) {
110 if (!per_grid_cell) {
111 density += saturations[j * np + p] * densities[p] / saturation_sum;
114 density += saturations[np * cell + p] * densities[p] / saturation_sum;
119 wdp.push_back(density * (cell_depth - depth_ref) * gravity);
Definition: RockCompressibility.hpp:33
double poroMult(double pressure) const
Porosity multiplier.
Definition: AnisotropicEikonal.hpp:44
void computeWDP(const Wells &wells, const UnstructuredGrid &grid, const std::vector< double > &saturations, const double *densities, const double gravity, const bool per_grid_cell, std::vector< double > &wdp)
void estimateCellVelocity(const UnstructuredGrid &grid, const std::vector< double > &face_flux, std::vector< double > &cell_velocity)
Estimates a scalar cell velocity from face fluxes.
void computePorevolume(const UnstructuredGrid &grid, const double *porosity, std::vector< double > &porevol)
Computes pore volume of all cells in a grid.
double * depth_ref
Definition: wells.h:63
int * well_connpos
Definition: wells.h:81
int number_of_wells
Definition: wells.h:52
int * well_cells
Definition: wells.h:87