Merge pull request #819 from blattms/use-defunct-wells-from-loadbalancer-for-wellsmanager

Use names of defunct wells from loadbalancer for wellsmanager
This commit is contained in:
Atgeirr Flø Rasmussen 2016-09-19 13:42:42 +02:00 committed by GitHub
commit 06e41bdaca
14 changed files with 108 additions and 46 deletions

View File

@ -214,6 +214,9 @@ namespace Opm
std::unique_ptr<Simulator> simulator_; std::unique_ptr<Simulator> simulator_;
// create log file // create log file
std::string logFile_; std::string logFile_;
// The names of wells that are artifically defunct in parallel runs.
// Those wells are handled on a another process.
std::unordered_set<std::string> defunct_well_names_;
// ------------ Methods ------------ // ------------ Methods ------------
@ -598,6 +601,7 @@ namespace Opm
// If there are more than one processors involved, we now repartition the grid // If there are more than one processors involved, we now repartition the grid
// and initilialize new properties and states for it. // and initilialize new properties and states for it.
if (must_distribute_) { if (must_distribute_) {
defunct_well_names_ =
distributeGridAndData(grid_init_->grid(), deck_, eclipse_state_, distributeGridAndData(grid_init_->grid(), deck_, eclipse_state_,
*state_, *fluidprops_, *geoprops_, *state_, *fluidprops_, *geoprops_,
material_law_manager_, threshold_pressures_, material_law_manager_, threshold_pressures_,
@ -811,7 +815,8 @@ namespace Opm
Base::deck_->hasKeyword("VAPOIL"), Base::deck_->hasKeyword("VAPOIL"),
Base::eclipse_state_, Base::eclipse_state_,
*Base::output_writer_, *Base::output_writer_,
Base::threshold_pressures_)); Base::threshold_pressures_,
Base::defunct_well_names_));
} }
}; };

View File

@ -19,6 +19,8 @@
#ifndef OPM_PARALLELDEBUGOUTPUT_HEADER_INCLUDED #ifndef OPM_PARALLELDEBUGOUTPUT_HEADER_INCLUDED
#define OPM_PARALLELDEBUGOUTPUT_HEADER_INCLUDED #define OPM_PARALLELDEBUGOUTPUT_HEADER_INCLUDED
#include <unordered_set>
#include <opm/common/data/SimulationDataContainer.hpp> #include <opm/common/data/SimulationDataContainer.hpp>
@ -543,7 +545,14 @@ namespace Opm
Opm::UgGridHelpers::beginFaceCentroids( globalGrid ), Opm::UgGridHelpers::beginFaceCentroids( globalGrid ),
permeability_, permeability_,
dynamic_list_econ_limited, dynamic_list_econ_limited,
false); false
// We need to pass the optionaly arguments
// as we get the following error otherwise
// with c++ (Debian 4.9.2-10) 4.9.2 and -std=c++11
// converting to const std::unordered_set<std::basic_string<char> > from initializer list would use explicit constructor
, std::vector<double>(),
std::unordered_set<std::string>()
);
const Wells* wells = wells_manager.c_wells(); const Wells* wells = wells_manager.c_wells();
globalWellState_.init(wells, *globalReservoirState_, globalWellState_ ); globalWellState_.init(wells, *globalReservoirState_, globalWellState_ );

View File

@ -1,7 +1,7 @@
/* /*
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services. Copyright 2015-2016 Dr. Blatt - HPC-Simulation-Software & Services.
Coypright 2015 NTNU Coypright 2015 NTNU
Copyright 2015 Statoil AS Copyright 2015-2016 Statoil AS
Copyright 2015 IRIS AS Copyright 2015 IRIS AS
This file is part of the Open Porous Media project (OPM). This file is part of the Open Porous Media project (OPM).
@ -22,6 +22,9 @@
#ifndef OPM_REDISTRIBUTEDATAHANDLES_HEADER #ifndef OPM_REDISTRIBUTEDATAHANDLES_HEADER
#define OPM_REDISTRIBUTEDATAHANDLES_HEADER #define OPM_REDISTRIBUTEDATAHANDLES_HEADER
#include <unordered_set>
#include <string>
#include <opm/core/simulator/BlackoilState.hpp> #include <opm/core/simulator/BlackoilState.hpp>
#include <opm/autodiff/BlackoilPropsAdFromDeck.hpp> #include <opm/autodiff/BlackoilPropsAdFromDeck.hpp>
@ -33,7 +36,8 @@ namespace Opm
{ {
template <class Grid> template <class Grid>
inline void distributeGridAndData( Grid& , inline std::unordered_set<std::string>
distributeGridAndData( Grid& ,
Opm::DeckConstPtr , Opm::DeckConstPtr ,
EclipseStateConstPtr , EclipseStateConstPtr ,
BlackoilState& , BlackoilState& ,
@ -44,6 +48,7 @@ inline void distributeGridAndData( Grid& ,
boost::any& , boost::any& ,
const bool ) const bool )
{ {
return std::unordered_set<std::string>();
} }
#if HAVE_OPM_GRID && HAVE_MPI #if HAVE_OPM_GRID && HAVE_MPI
@ -413,7 +418,8 @@ private:
}; };
inline inline
void distributeGridAndData( Dune::CpGrid& grid, std::unordered_set<std::string>
distributeGridAndData( Dune::CpGrid& grid,
Opm::DeckConstPtr deck, Opm::DeckConstPtr deck,
EclipseStateConstPtr eclipseState, EclipseStateConstPtr eclipseState,
BlackoilState& state, BlackoilState& state,
@ -428,7 +434,9 @@ void distributeGridAndData( Dune::CpGrid& grid,
global_grid.switchToGlobalView(); global_grid.switchToGlobalView();
// distribute the grid and switch to the distributed view // distribute the grid and switch to the distributed view
grid.loadBalance(eclipseState, geology.transmissibility().data()); using std::get;
auto my_defunct_wells = get<1>(grid.loadBalance(eclipseState,
geology.transmissibility().data()));
grid.switchToDistributedView(); grid.switchToDistributedView();
std::vector<int> compressedToCartesianIdx; std::vector<int> compressedToCartesianIdx;
Opm::createGlobalCellArray(grid, compressedToCartesianIdx); Opm::createGlobalCellArray(grid, compressedToCartesianIdx);
@ -493,6 +501,8 @@ void distributeGridAndData( Dune::CpGrid& grid,
material_law_manager = distributed_material_law_manager; material_law_manager = distributed_material_law_manager;
threshold_pressures = distributed_pressures; threshold_pressures = distributed_pressures;
extractParallelGridInformationToISTL(grid, parallelInformation); extractParallelGridInformationToISTL(grid, parallelInformation);
return my_defunct_wells;
} }
#endif #endif

View File

@ -130,7 +130,8 @@ namespace Opm
const bool vapoil, const bool vapoil,
std::shared_ptr<EclipseState> eclipse_state, std::shared_ptr<EclipseState> eclipse_state,
OutputWriter& output_writer, OutputWriter& output_writer,
const std::vector<double>& threshold_pressures_by_face); const std::vector<double>& threshold_pressures_by_face,
const std::unordered_set<std::string>& defunct_well_names);
/// Run the simulation. /// Run the simulation.
/// This will run succesive timesteps until timer.done() is true. It will /// This will run succesive timesteps until timer.done() is true. It will
@ -214,6 +215,10 @@ namespace Opm
std::vector<double> threshold_pressures_by_face_; std::vector<double> threshold_pressures_by_face_;
// Whether this a parallel simulation or not // Whether this a parallel simulation or not
bool is_parallel_run_; bool is_parallel_run_;
// The names of wells that should be defunct
// (e.g. in a parallel run when they are handeled by
// a different process)
std::unordered_set<std::string> defunct_well_names_;
}; };
} // namespace Opm } // namespace Opm

View File

@ -43,7 +43,8 @@ namespace Opm
const bool has_vapoil, const bool has_vapoil,
std::shared_ptr<EclipseState> eclipse_state, std::shared_ptr<EclipseState> eclipse_state,
OutputWriter& output_writer, OutputWriter& output_writer,
const std::vector<double>& threshold_pressures_by_face) const std::vector<double>& threshold_pressures_by_face,
const std::unordered_set<std::string>& defunct_well_names)
: param_(param), : param_(param),
model_param_(param), model_param_(param),
solver_param_(param), solver_param_(param),
@ -60,7 +61,8 @@ namespace Opm
output_writer_(output_writer), output_writer_(output_writer),
rateConverter_(props_, std::vector<int>(AutoDiffGrid::numCells(grid_), 0)), rateConverter_(props_, std::vector<int>(AutoDiffGrid::numCells(grid_), 0)),
threshold_pressures_by_face_(threshold_pressures_by_face), threshold_pressures_by_face_(threshold_pressures_by_face),
is_parallel_run_( false ) is_parallel_run_( false ),
defunct_well_names_(defunct_well_names)
{ {
// Misc init. // Misc init.
const int num_cells = AutoDiffGrid::numCells(grid); const int num_cells = AutoDiffGrid::numCells(grid);
@ -167,7 +169,8 @@ namespace Opm
props_.permeability(), props_.permeability(),
dynamic_list_econ_limited, dynamic_list_econ_limited,
is_parallel_run_, is_parallel_run_,
well_potentials); well_potentials,
defunct_well_names_);
const Wells* wells = wells_manager.c_wells(); const Wells* wells = wells_manager.c_wells();
WellState well_state; WellState well_state;
well_state.init(wells, state, prev_well_state); well_state.init(wells, state, prev_well_state);

View File

@ -61,9 +61,10 @@ public:
const bool vapoil, const bool vapoil,
std::shared_ptr<EclipseState> eclipse_state, std::shared_ptr<EclipseState> eclipse_state,
BlackoilOutputWriter& output_writer, BlackoilOutputWriter& output_writer,
const std::vector<double>& threshold_pressures_by_face) const std::vector<double>& threshold_pressures_by_face,
const std::unordered_set<std::string>& defunct_well_names)
: Base(param, grid, geo, props, rock_comp_props, linsolver, gravity, disgas, vapoil, : Base(param, grid, geo, props, rock_comp_props, linsolver, gravity, disgas, vapoil,
eclipse_state, output_writer, threshold_pressures_by_face) eclipse_state, output_writer, threshold_pressures_by_face, defunct_well_names)
{} {}
}; };

View File

@ -73,9 +73,10 @@ public:
const bool vapoil, const bool vapoil,
std::shared_ptr<EclipseState> eclipse_state, std::shared_ptr<EclipseState> eclipse_state,
BlackoilOutputWriter& output_writer, BlackoilOutputWriter& output_writer,
const std::vector<double>& threshold_pressures_by_face) const std::vector<double>& threshold_pressures_by_face,
const std::unordered_set<std::string>& defunct_well_names)
: Base(param, grid, geo, props, rock_comp_props, linsolver, gravity, disgas, vapoil, : Base(param, grid, geo, props, rock_comp_props, linsolver, gravity, disgas, vapoil,
eclipse_state, output_writer, threshold_pressures_by_face) eclipse_state, output_writer, threshold_pressures_by_face, defunct_well_names)
{} {}

View File

@ -108,7 +108,13 @@ namespace Opm
Opm::UgGridHelpers::beginFaceCentroids(grid_), Opm::UgGridHelpers::beginFaceCentroids(grid_),
props_.permeability(), props_.permeability(),
dynamic_list_econ_limited, dynamic_list_econ_limited,
is_parallel_run_); is_parallel_run_,
// We need to pass the optionaly arguments
// as we get the following error otherwise
// with c++ (Debian 4.9.2-10) 4.9.2 and -std=c++11
// converting to const std::unordered_set<std::basic_string<char> > from initializer list would use explicit constructor
std::vector<double>(), // null well_potentials
Base::defunct_well_names_);
const Wells* wells = wells_manager.c_wells(); const Wells* wells = wells_manager.c_wells();
WellState well_state; WellState well_state;
// well_state.init(wells, state, prev_well_state); // well_state.init(wells, state, prev_well_state);

View File

@ -397,7 +397,14 @@ namespace Opm
Opm::UgGridHelpers::cell2Faces(grid), Opm::UgGridHelpers::cell2Faces(grid),
Opm::UgGridHelpers::beginFaceCentroids(grid), Opm::UgGridHelpers::beginFaceCentroids(grid),
permeability, permeability,
dummy_list_econ_limited); dummy_list_econ_limited
// We need to pass the optionaly arguments
// as we get the following error otherwise
// with c++ (Debian 4.9.2-10) 4.9.2 and -std=c++11
// converting to const std::unordered_set<std::basic_string<char> > from initializer list would use explicit constructo
, false,
std::vector<double>(),
std::unordered_set<std::string>());
const Wells* wells = wellsmanager.c_wells(); const Wells* wells = wellsmanager.c_wells();
wellstate.resize(wells, simulatorstate); //Resize for restart step wellstate.resize(wells, simulatorstate); //Resize for restart step

View File

@ -50,7 +50,9 @@ namespace Opm
has_vapoil, has_vapoil,
eclipse_state, eclipse_state,
output_writer, output_writer,
threshold_pressures_by_face) threshold_pressures_by_face,
// names of deactivated wells in parallel run
std::unordered_set<std::string>())
, has_solvent_(has_solvent) , has_solvent_(has_solvent)
, deck_(deck) , deck_(deck)
, solvent_props_(solvent_props) , solvent_props_(solvent_props)

View File

@ -65,7 +65,9 @@ public:
BlackoilOutputWriter& output_writer, BlackoilOutputWriter& output_writer,
const std::vector<double>& threshold_pressures_by_face) const std::vector<double>& threshold_pressures_by_face)
: Base(param, grid, geo, props, rock_comp_props, linsolver, gravity, disgas, vapoil, : Base(param, grid, geo, props, rock_comp_props, linsolver, gravity, disgas, vapoil,
eclipse_state, output_writer, threshold_pressures_by_face) eclipse_state, output_writer, threshold_pressures_by_face,
// names of deactivated wells in parallel run
std::unordered_set<std::string>())
{} {}
}; };

View File

@ -51,7 +51,9 @@ namespace Opm
has_vapoil, has_vapoil,
eclipse_state, eclipse_state,
output_writer, output_writer,
threshold_pressures_by_face) threshold_pressures_by_face,
// names of deactivated wells in parallel run
std::unordered_set<std::string>())
, polymer_props_(polymer_props) , polymer_props_(polymer_props)
, has_polymer_(has_polymer) , has_polymer_(has_polymer)
, has_plyshlog_(has_plyshlog) , has_plyshlog_(has_plyshlog)

View File

@ -48,7 +48,9 @@ SimulatorFullyImplicitCompressiblePolymer(const parameter::ParameterGroup& param
/*vapoil=*/false, /*vapoil=*/false,
eclipse_state, eclipse_state,
output_writer, output_writer,
/*threshold_pressures_by_face=*/std::vector<double>()) /*threshold_pressures_by_face=*/std::vector<double>(),
// names of deactivated wells in parallel run
std::unordered_set<std::string>())
, deck_(deck) , deck_(deck)
, polymer_props_(polymer_props) , polymer_props_(polymer_props)

View File

@ -28,6 +28,7 @@
#define BOOST_TEST_MODULE MultisegmentWellsTest #define BOOST_TEST_MODULE MultisegmentWellsTest
#include <vector> #include <vector>
#include <unordered_set>
#include <memory> #include <memory>
#include <array> #include <array>
@ -106,7 +107,13 @@ struct SetupMSW {
Opm::UgGridHelpers::beginFaceCentroids(grid), Opm::UgGridHelpers::beginFaceCentroids(grid),
fluidprops->permeability(), fluidprops->permeability(),
dummy_dynamic_list, dummy_dynamic_list,
false); false
// We need to pass the optionaly arguments
// as we get the following error otherwise
// with c++ (Debian 4.9.2-10) 4.9.2 and -std=c++11
// converting to const std::unordered_set<std::basic_string<char> > from initializer list would use explicit constructor
, std::vector<double>(), // null well_potentials
std::unordered_set<std::string>());
const Wells* wells = wells_manager.c_wells(); const Wells* wells = wells_manager.c_wells();
const auto wells_ecl = ecl_state->getSchedule()->getWells(current_timestep); const auto wells_ecl = ecl_state->getSchedule()->getWells(current_timestep);