From 0450e1bb77d55ebce14b72c06fb301cdc870e9f3 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 3 Jan 2014 15:34:01 +0100 Subject: [PATCH] Extracted everything related to well controls to separate header well_controls.h - to simplify introducing new parser. --- opm/core/pressure/tpfa/cfs_tpfa_residual.c | 1 + opm/core/simulator/WellState.hpp | 1 + opm/core/utility/miscUtilities.cpp | 1 + opm/core/well_controls.h | 103 +++++++++++++++++++++ opm/core/wells.h | 75 +-------------- opm/core/wells/WellsGroup.cpp | 1 + opm/core/wells/wells.c | 1 + 7 files changed, 112 insertions(+), 71 deletions(-) create mode 100644 opm/core/well_controls.h diff --git a/opm/core/pressure/tpfa/cfs_tpfa_residual.c b/opm/core/pressure/tpfa/cfs_tpfa_residual.c index 001f9a3bf..ef1dc5fa3 100644 --- a/opm/core/pressure/tpfa/cfs_tpfa_residual.c +++ b/opm/core/pressure/tpfa/cfs_tpfa_residual.c @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/opm/core/simulator/WellState.hpp b/opm/core/simulator/WellState.hpp index 9849bd680..ff5c705fa 100644 --- a/opm/core/simulator/WellState.hpp +++ b/opm/core/simulator/WellState.hpp @@ -21,6 +21,7 @@ #define OPM_WELLSTATE_HEADER_INCLUDED #include +#include #include namespace Opm diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index 6ed26f1a8..d39632d12 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/opm/core/well_controls.h b/opm/core/well_controls.h new file mode 100644 index 000000000..80d97c7ee --- /dev/null +++ b/opm/core/well_controls.h @@ -0,0 +1,103 @@ +/* + Copyright 2012 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef OPM_WELL_CONTROLS_H_INCLUDED +#define OPM_WELL_CONTROLS_H_INCLUDED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + + + +/** + * Controls for a single well. + * Each control specifies a well rate or bottom-hole pressure. Only + * one control can be active at a time, indicated by current. The + * meaning of each control's target value depends on the control type: + * + * - BHP -> target pressure in Pascal. + * - RESERVOIR_RATE -> target reservoir volume rate in cubic(meter)/second + * - SURFACE_RATE -> target surface volume rate in cubic(meter)/second + * + * The sign convention for RATE targets is as follows: + * + * - (+) Fluid flowing into reservoir, i.e. injecting. + * - (-) Fluid flowing out of reservoir, i.e. producing. + * + * For *_RATE controls, the distribution of phases used for the control + * is also needed. For example, a total rate control should have 1.0 + * for each phase, whereas a control on oil rate should have 1.0 for + * the oil phase and 0.0 for the rest. For BHP controls, this is unused. + * The active control acts as an equality constraint, whereas the + * non-active controls should be interpreted as inequality + * constraints (upper or lower bounds). For instance, a PRODUCER's + * BHP constraint defines a minimum acceptable bottom-hole pressure + * value for the well. + */ +struct WellControls +{ + /** + * Number of controls. + */ + int num; + + int number_of_phases; + + /** + * Array of control types. + */ + enum WellControlType *type; + + /** + * Array of control targets. + */ + double *target; + + /** + * Array of rate control distributions, + * number_of_phases numbers for each control + */ + double *distr; + + /** + * Index of current active control. + */ + int current; + + /** + * Internal management structure. + */ + void *data; +}; + + +bool +well_controls_equal(const struct WellControls *ctrls1, const struct WellControls *ctrls2); + + +#ifdef __cplusplus +} +#endif + +#endif /* OPM_WELL_CONTROLS_H_INCLUDED */ diff --git a/opm/core/wells.h b/opm/core/wells.h index d9971fed1..b9f1bdd94 100644 --- a/opm/core/wells.h +++ b/opm/core/wells.h @@ -21,6 +21,8 @@ #define OPM_WELLS_H_INCLUDED #include +#include +#include /** * \file @@ -42,75 +44,6 @@ enum WellType { PRODUCER /**< Well is a producer */ }; -/** - * Type of well control equation or inequality constraint. - */ -enum WellControlType { - BHP, /**< Well constrained by BHP target */ - RESERVOIR_RATE, /**< Well constrained by reservoir volume flow rate */ - SURFACE_RATE /**< Well constrained by surface volume flow rate */ -}; - -/** - * Controls for a single well. - * Each control specifies a well rate or bottom-hole pressure. Only - * one control can be active at a time, indicated by current. The - * meaning of each control's target value depends on the control type: - * - * - BHP -> target pressure in Pascal. - * - RESERVOIR_RATE -> target reservoir volume rate in cubic(meter)/second - * - SURFACE_RATE -> target surface volume rate in cubic(meter)/second - * - * The sign convention for RATE targets is as follows: - * - * - (+) Fluid flowing into reservoir, i.e. injecting. - * - (-) Fluid flowing out of reservoir, i.e. producing. - * - * For *_RATE controls, the distribution of phases used for the control - * is also needed. For example, a total rate control should have 1.0 - * for each phase, whereas a control on oil rate should have 1.0 for - * the oil phase and 0.0 for the rest. For BHP controls, this is unused. - * The active control acts as an equality constraint, whereas the - * non-active controls should be interpreted as inequality - * constraints (upper or lower bounds). For instance, a PRODUCER's - * BHP constraint defines a minimum acceptable bottom-hole pressure - * value for the well. - */ -struct WellControls -{ - /** - * Number of controls. - */ - int num; - - int number_of_phases; - - /** - * Array of control types. - */ - enum WellControlType *type; - - /** - * Array of control targets. - */ - double *target; - - /** - * Array of rate control distributions, - * number_of_phases numbers for each control - */ - double *distr; - - /** - * Index of current active control. - */ - int current; - - /** - * Internal management structure. - */ - void *data; -}; @@ -285,6 +218,8 @@ add_well(enum WellType type , * \param[in,out] W Existing set of well controls. * \return Non-zero (true) if successful and zero (false) otherwise. */ + + int append_well_controls(enum WellControlType type , double target, @@ -333,8 +268,6 @@ clone_wells(const struct Wells *W); bool wells_equal(const struct Wells *W1, const struct Wells *W2); -bool -well_controls_equal(const struct WellControls *ctrls1, const struct WellControls *ctrls2); #ifdef __cplusplus diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index d65555ed3..d1fb2e802 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -20,6 +20,7 @@ #include "config.h" #include #include +#include #include #include diff --git a/opm/core/wells/wells.c b/opm/core/wells/wells.c index 5c06a0a2b..d4208ad51 100644 --- a/opm/core/wells/wells.c +++ b/opm/core/wells/wells.c @@ -35,6 +35,7 @@ */ #include "config.h" #include +#include #include #include