Added wellsToSrc() function. Use forward declarations in header.

This commit is contained in:
Atgeirr Flø Rasmussen 2012-03-14 09:51:08 +01:00
parent df3592473a
commit a50bb8ffe9
2 changed files with 34 additions and 3 deletions

View File

@ -18,6 +18,9 @@
*/
#include <opm/core/utility/miscUtilities.hpp>
#include <opm/core/grid.h>
#include <opm/core/newwells.h>
#include <opm/core/fluid/IncompPropertiesInterface.hpp>
#include <opm/core/utility/ErrorMacros.hpp>
#include <algorithm>
#include <functional>
@ -333,6 +336,27 @@ namespace Opm
}
/// Create a src vector equivalent to a wells structure.
/// For this to be valid, the wells must be all rate-controlled and
/// single-perforation.
void wellsToSrc(const Wells& wells, const int num_cells, std::vector<double>& src)
{
src.resize(num_cells);
for (int w = 0; w < wells.number_of_wells; ++w) {
if (wells.ctrls[w]->num != 1) {
THROW("In wellsToSrc(): well has more than one control.");
}
if (wells.ctrls[w]->type[0] != RATE) {
THROW("In wellsToSrc(): well is BHP, not RATE.");
}
if (wells.well_connpos[w+1] - wells.well_connpos[w] != 1) {
THROW("In wellsToSrc(): well has multiple perforations.");
}
const double flow = wells.ctrls[w]->target[0];
const double cell = wells.well_cells[wells.well_connpos[w]];
src[cell] = (wells.type[w] == INJECTOR) ? flow : -flow;
}
}
} // namespace Opm

View File

@ -20,15 +20,16 @@
#ifndef OPM_MISCUTILITIES_HEADER_INCLUDED
#define OPM_MISCUTILITIES_HEADER_INCLUDED
#include <opm/core/grid.h>
#include <opm/core/fluid/IncompPropertiesInterface.hpp>
#include <vector>
struct Wells;
struct UnstructuredGrid;
namespace Opm
{
class IncompPropertiesInterface;
/// @brief Computes pore volume of all cells in a grid.
/// @param[in] grid a grid
/// @param[in] props rock and fluid properties
@ -151,6 +152,12 @@ namespace Opm
void toBothSat(const std::vector<double>& sw,
std::vector<double>& sboth);
/// Create a src vector equivalent to a wells structure.
/// For this to be valid, the wells must be all rate-controlled and
/// single-perforation.
void wellsToSrc(const Wells& wells, const int num_cells, std::vector<double>& src);
} // namespace Opm
#endif // OPM_MISCUTILITIES_HEADER_INCLUDED