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) };
31 double flux = face_flux[face];
32 for (
int i = 0; i < 2; ++i) {
35 for (
int d = 0; d < dimension; ++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++) {
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);
int * well_connpos
Definition: wells.h:81
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)
double getCoordinate(T *cc, int i)
Get the i-th corrdinate of a centroid.
Definition: GridHelpers.hpp:337
int number_of_wells
Definition: wells.h:52
Definition: AnisotropicEikonal.hpp:43
int * well_cells
Definition: wells.h:87
double * depth_ref
Definition: wells.h:63
Definition: RockCompressibility.hpp:33
const double gravity
Definition: Units.hpp:120
void estimateCellVelocity(const UnstructuredGrid &grid, const std::vector< double > &face_flux, std::vector< double > &cell_velocity)
Estimates a scalar cell velocity from face fluxes.
T * increment(T *cc, int i, int dim)
Increment an iterator over an array that reresents a dense row-major matrix with dims columns...
Definition: GridHelpers.hpp:318
const double flux
Definition: Units.hpp:150
double poroMult(double pressure) const
Porosity multiplier.
void computePorevolume(const UnstructuredGrid &grid, const double *porosity, std::vector< double > &porevol)
Computes pore volume of all cells in a grid.