Merge pull request #1403 from lars-petter-hauge/empty_wells_init

Allow Wells struct initialization without wells
This commit is contained in:
Atgeirr Flø Rasmussen 2018-02-14 10:31:52 +01:00 committed by GitHub
commit 8e9b13584d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -315,7 +315,7 @@ namespace Opm
/// Default constructor.
WellsManager::WellsManager()
: w_(0), is_parallel_run_(false)
: w_(create_wells(0,0,0)), is_parallel_run_(false)
{
}
@ -330,7 +330,7 @@ namespace Opm
const Opm::Schedule& schedule,
const size_t timeStep,
const UnstructuredGrid& grid)
: w_(0), is_parallel_run_(false)
: w_(create_wells(0,0,0)), is_parallel_run_(false)
{
// TODO: not sure about the usage of this WellsManager constructor
// TODO: not sure whether this is the correct thing to do here.

View File

@ -260,13 +260,15 @@ void WellsManager::createWellsFromSpecs(std::vector<const Well*>& wells, size_t
for (int w = 0; w < num_wells; ++w) {
num_perfs += wellperf_data[w].size();
}
// Create the well data structures.
w_ = create_wells(phaseUsage.num_phases, num_wells, num_perfs);
if (!w_) {
struct Wells* w = create_wells(phaseUsage.num_phases, num_wells, num_perfs);
if (!w) {
OPM_THROW(std::runtime_error, "Failed creating Wells struct.");
}
std::swap( w, w_ );
destroy_wells( w );
// Add wells.
for (int w = 0; w < num_wells; ++w) {
@ -320,7 +322,7 @@ WellsManager(const Opm::EclipseState& eclipseState,
const DynamicListEconLimited& list_econ_limited,
bool is_parallel_run,
const std::unordered_set<std::string>& deactivated_wells)
: w_(0), is_parallel_run_(is_parallel_run)
: w_(create_wells(0,0,0)), is_parallel_run_(is_parallel_run)
{
init(eclipseState, schedule, timeStep, number_of_cells, global_cell,
cart_dims, dimensions,