2012-03-06 06:59:51 -06:00
|
|
|
/*
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPM_WELLSMANAGER_HEADER_INCLUDED
|
|
|
|
#define OPM_WELLSMANAGER_HEADER_INCLUDED
|
2012-05-02 02:27:34 -05:00
|
|
|
|
|
|
|
|
2014-01-08 09:10:55 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
2014-01-07 09:10:45 -06:00
|
|
|
|
2012-06-05 08:42:49 -05:00
|
|
|
#include <opm/core/wells/WellCollection.hpp>
|
|
|
|
#include <opm/core/wells/WellsGroup.hpp>
|
2014-02-14 06:43:25 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Schedule/GroupTree.hpp>
|
2012-05-02 02:27:34 -05:00
|
|
|
|
2012-03-06 06:59:51 -06:00
|
|
|
struct Wells;
|
|
|
|
struct UnstructuredGrid;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
|
|
|
class EclipseGridParser;
|
2014-02-03 01:58:54 -06:00
|
|
|
struct WellData
|
|
|
|
{
|
|
|
|
WellType type;
|
|
|
|
// WellControlType control;
|
|
|
|
// double target;
|
|
|
|
double reference_bhp_depth;
|
|
|
|
// Opm::InjectionSpecification::InjectorType injected_phase;
|
|
|
|
int welspecsline;
|
|
|
|
};
|
|
|
|
|
2012-03-06 06:59:51 -06:00
|
|
|
|
2014-02-03 01:58:54 -06:00
|
|
|
struct PerfData
|
|
|
|
{
|
|
|
|
int cell;
|
|
|
|
double well_index;
|
|
|
|
};
|
2012-03-07 02:15:34 -06:00
|
|
|
/// This class manages a Wells struct in the sense that it
|
2012-03-06 06:59:51 -06:00
|
|
|
/// encapsulates creation and destruction of the wells
|
|
|
|
/// data structure.
|
|
|
|
/// The resulting Wells is available through the c_wells() method.
|
|
|
|
class WellsManager
|
|
|
|
{
|
|
|
|
public:
|
2014-02-03 01:58:54 -06:00
|
|
|
/// Default constructor -- no wells.
|
|
|
|
WellsManager();
|
|
|
|
|
|
|
|
/// Construct from existing wells object.
|
|
|
|
/// WellsManager is not properly initialised in the sense that the logic to
|
|
|
|
/// manage control switching does not exist.
|
|
|
|
///
|
|
|
|
/// @param[in] W Existing wells object.
|
2014-03-27 09:27:11 -05:00
|
|
|
explicit WellsManager(struct Wells* W, bool checkCellExistence=true);
|
2014-02-03 01:58:54 -06:00
|
|
|
|
|
|
|
/// Construct from input deck and grid.
|
|
|
|
/// The permeability argument may be zero if the input contain
|
|
|
|
/// well productivity indices, otherwise it must be given in
|
|
|
|
/// order to approximate these by the Peaceman formula.
|
2014-02-25 10:52:51 -06:00
|
|
|
template<class CC, class F2C, class FC>
|
2014-02-03 01:58:54 -06:00
|
|
|
WellsManager(const Opm::EclipseStateConstPtr eclipseState,
|
|
|
|
const size_t timeStep,
|
2014-02-25 10:52:51 -06:00
|
|
|
int num_cells,
|
|
|
|
const int* global_cell,
|
|
|
|
const int* cart_dims,
|
|
|
|
int dimensions,
|
|
|
|
CC begin_cell_centroids,
|
|
|
|
const F2C& f2c,
|
|
|
|
FC begin_face_centroids,
|
2014-02-03 01:58:54 -06:00
|
|
|
const double* permeability);
|
2014-02-25 10:52:51 -06:00
|
|
|
|
2014-02-03 01:58:54 -06:00
|
|
|
WellsManager(const Opm::EclipseStateConstPtr eclipseState,
|
|
|
|
const size_t timeStep,
|
|
|
|
const UnstructuredGrid& grid,
|
2014-03-27 09:27:11 -05:00
|
|
|
const double* permeability);
|
2014-02-03 01:58:54 -06:00
|
|
|
/// Destructor.
|
|
|
|
~WellsManager();
|
2012-05-09 09:09:13 -05:00
|
|
|
|
|
|
|
/// Does the "deck" define any wells?
|
|
|
|
bool empty() const;
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2014-02-03 01:58:54 -06:00
|
|
|
/// Access the managed Wells.
|
|
|
|
/// The method is named similarly to c_str() in std::string,
|
|
|
|
/// to make it clear that we are returning a C-compatible struct.
|
|
|
|
const Wells* c_wells() const;
|
2012-04-25 05:50:43 -05:00
|
|
|
|
|
|
|
/// Access the well group hierarchy.
|
2012-04-12 07:25:39 -05:00
|
|
|
const WellCollection& wellCollection() const;
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-25 09:40:31 -05:00
|
|
|
/// Checks if each condition is met, applies well controls where needed
|
|
|
|
/// (that is, it either changes the active control of violating wells, or shuts
|
|
|
|
/// down wells). Only one change is applied per invocation. Typical use will be
|
|
|
|
/// \code
|
|
|
|
/// solve_pressure();
|
2012-05-02 06:02:59 -05:00
|
|
|
/// while(!wells.conditionsMet(...)) {
|
2012-04-25 09:40:31 -05:00
|
|
|
/// solve_pressure();
|
|
|
|
/// }
|
|
|
|
/// \endcode
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] well_bhp A vector containing the bhp for each well. Is assumed
|
2012-04-25 09:40:31 -05:00
|
|
|
/// to be ordered the same way as the related Wells-struct.
|
2012-05-02 06:02:59 -05:00
|
|
|
/// \param[in] well_reservoirrates_phase
|
|
|
|
/// A vector containing reservoir rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
/// \param[in] well_surfacerates_phase
|
|
|
|
/// A vector containing surface rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
2012-04-25 09:40:31 -05:00
|
|
|
/// \return true if no violations were found, false otherwise (false also implies a change).
|
2012-05-02 06:02:59 -05:00
|
|
|
bool conditionsMet(const std::vector<double>& well_bhp,
|
|
|
|
const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-09 06:03:37 -05:00
|
|
|
/// Applies explicit reinjection controls. This must be called at each timestep to be correct.
|
|
|
|
/// \param[in] well_reservoirrates_phase
|
|
|
|
/// A vector containing reservoir rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
/// \param[in] well_surfacerates_phase
|
|
|
|
/// A vector containing surface rates by phase for each well.
|
|
|
|
/// Is assumed to be ordered the same way as the related Wells-struct,
|
|
|
|
/// with all phase rates of a single well adjacent in the array.
|
|
|
|
void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
|
|
|
|
const std::vector<double>& well_surfacerates_phase);
|
2012-03-06 06:59:51 -06:00
|
|
|
|
2012-04-25 05:50:43 -05:00
|
|
|
|
2014-02-03 01:58:54 -06:00
|
|
|
private:
|
2014-03-27 09:27:11 -05:00
|
|
|
template<class CC, class C2F, class FC>
|
|
|
|
void init(const Opm::EclipseStateConstPtr eclipseState,
|
|
|
|
const size_t timeStep,
|
2014-02-25 10:52:51 -06:00
|
|
|
int num_cells,
|
|
|
|
const int* global_cell,
|
|
|
|
const int* cart_dims,
|
|
|
|
int dimensions,
|
|
|
|
CC begin_cell_centroids,
|
2014-03-27 09:27:11 -05:00
|
|
|
const C2F& cell_to_faces,
|
2014-02-25 10:52:51 -06:00
|
|
|
FC begin_face_centroids,
|
|
|
|
const double* permeability);
|
2014-02-03 01:58:54 -06:00
|
|
|
// Disable copying and assignment.
|
|
|
|
WellsManager(const WellsManager& other);
|
|
|
|
WellsManager& operator=(const WellsManager& other);
|
2014-02-17 06:23:01 -06:00
|
|
|
static void setupCompressedToCartesian(const int* global_cell, int number_of_cells, std::map<int,int>& cartesian_to_compressed );
|
2014-02-03 02:07:58 -06:00
|
|
|
void setupWellControls(std::vector<WellConstPtr>& wells, size_t timeStep,
|
|
|
|
std::vector<std::string>& well_names, const PhaseUsage& phaseUsage);
|
2014-02-25 10:52:51 -06:00
|
|
|
template<class C2F, class CC, class FC>
|
2014-02-03 02:22:28 -06:00
|
|
|
void createWellsFromSpecs( std::vector<WellConstPtr>& wells, size_t timeStep,
|
2014-03-27 09:27:11 -05:00
|
|
|
const C2F& cell_to_faces,
|
2014-02-25 10:52:51 -06:00
|
|
|
const int* cart_dims,
|
|
|
|
FC begin_face_centroids,
|
|
|
|
CC begin_cell_centroids,
|
|
|
|
int dimensions,
|
2014-02-03 01:58:54 -06:00
|
|
|
std::vector<std::string>& well_names,
|
|
|
|
std::vector<WellData>& well_data,
|
|
|
|
std::map<std::string, int> & well_names_to_index,
|
|
|
|
const PhaseUsage& phaseUsage,
|
|
|
|
const std::map<int,int> cartesian_to_compressed,
|
|
|
|
const double* permeability);
|
|
|
|
|
2014-02-14 06:43:25 -06:00
|
|
|
void addChildGroups(GroupTreeNodeConstPtr parentNode, ScheduleConstPtr schedule, size_t timeStep, const PhaseUsage& phaseUsage);
|
2014-02-24 08:24:33 -06:00
|
|
|
void setupGuideRates(std::vector<WellConstPtr>& wells, const size_t timeStep, std::vector<WellData>& well_data, std::map<std::string, int>& well_names_to_index);
|
2014-02-03 01:58:54 -06:00
|
|
|
|
|
|
|
|
|
|
|
// Data
|
|
|
|
Wells* w_;
|
|
|
|
WellCollection well_collection_;
|
2012-03-06 06:59:51 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Opm
|
|
|
|
|
2014-02-25 10:52:51 -06:00
|
|
|
#include "WellsManager_impl.hpp"
|
2012-03-06 06:59:51 -06:00
|
|
|
#endif // OPM_WELLSMANAGER_HEADER_INCLUDED
|