diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index 65e0191ca..f65ba0722 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,28 @@ namespace Opm } + /// @brief Computes pore volume of all cells in a grid, with rock compressibility effects. + /// @param[in] grid a grid + /// @param[in] props rock and fluid properties + /// @param[in] rock_comp rock compressibility properties + /// @param[in] pressure pressure by cell + /// @param[out] porevol the pore volume by cell. + void computePorevolume(const UnstructuredGrid& grid, + const IncompPropertiesInterface& props, + const RockCompressibility& rock_comp, + const std::vector& pressure, + std::vector& porevol) + { + int num_cells = grid.number_of_cells; + ASSERT(num_cells == props.numCells()); + porevol.resize(num_cells); + const double* poro = props.porosity(); + for (int i = 0; i < num_cells; ++i) { + porevol[i] = poro[i]*grid.cell_volumes[i]*rock_comp.poroMult(pressure[i]); + } + } + + /// @brief Computes total saturated volumes over all grid cells. /// @param[in] pv the pore volume by cell. /// @param[in] s saturation values (for all P phases) diff --git a/opm/core/utility/miscUtilities.hpp b/opm/core/utility/miscUtilities.hpp index a5eafd214..98d8cb3a2 100644 --- a/opm/core/utility/miscUtilities.hpp +++ b/opm/core/utility/miscUtilities.hpp @@ -30,6 +30,7 @@ namespace Opm { class IncompPropertiesInterface; + class RockCompressibility; /// @brief Computes pore volume of all cells in a grid. /// @param[in] grid a grid @@ -40,6 +41,19 @@ namespace Opm std::vector& porevol); + /// @brief Computes pore volume of all cells in a grid, with rock compressibility effects. + /// @param[in] grid a grid + /// @param[in] props rock and fluid properties + /// @param[in] rock_comp rock compressibility properties + /// @param[in] pressure pressure by cell + /// @param[out] porevol the pore volume by cell. + void computePorevolume(const UnstructuredGrid& grid, + const IncompPropertiesInterface& props, + const RockCompressibility& rock_comp, + const std::vector& pressure, + std::vector& porevol); + + /// @brief Computes total saturated volumes over all grid cells. /// @param[in] pv the pore volume by cell. /// @param[in] s saturation values (for all P phases)