Merge pull request #3611 from joakim-hove/broadcast-wtest-state

Broadcast wtest state
This commit is contained in:
Bård Skaflestad 2021-10-19 12:01:17 +02:00 committed by GitHub
commit 89adc1919b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 5 deletions

View File

@ -46,7 +46,7 @@ void eclStateBroadcast(Parallel::Communication comm, EclipseState& eclState, Sch
SummaryConfig& summaryConfig,
UDQState& udqState,
Action::State& actionState,
WellTestState& /* wtestState */)
WellTestState& wtestState)
{
Opm::EclMpiSerializer ser(comm);
ser.broadcast(eclState);
@ -54,7 +54,7 @@ void eclStateBroadcast(Parallel::Communication comm, EclipseState& eclState, Sch
ser.broadcast(summaryConfig);
ser.broadcast(udqState);
ser.broadcast(actionState);
//ser.broadcast(wtestState);
ser.broadcast(wtestState);
}
void eclScheduleBroadcast(Parallel::Communication comm, Schedule& schedule)

View File

@ -180,6 +180,7 @@ namespace {
std::shared_ptr<Opm::Schedule>& schedule,
std::unique_ptr<Opm::UDQState>& udqState,
std::unique_ptr<Opm::Action::State>& actionState,
std::unique_ptr<Opm::WellTestState>& wtestState,
Opm::ErrorGuard& errorGuard)
{
if (schedule == nullptr) {
@ -192,6 +193,7 @@ namespace {
((*schedule)[0].udq().params().undefinedValue());
actionState = std::make_unique<Opm::Action::State>();
wtestState = std::make_unique<Opm::WellTestState>();
}
std::shared_ptr<Opm::Deck>
@ -276,7 +278,7 @@ namespace {
else {
createNonRestartDynamicObjects(*deck, *eclipseState,
*parseContext, std::move(python),
schedule, udqState, actionState,
schedule, udqState, actionState, wtestState,
errorGuard);
}
@ -302,6 +304,7 @@ namespace {
std::shared_ptr<Opm::Schedule>& schedule,
std::unique_ptr<Opm::UDQState>& udqState,
std::unique_ptr<Opm::Action::State>& actionState,
std::unique_ptr<Opm::WellTestState>& wtestState,
std::shared_ptr<Opm::SummaryConfig>& summaryConfig)
{
if (eclipseState == nullptr) {
@ -320,6 +323,10 @@ namespace {
actionState = std::make_unique<Opm::Action::State>();
}
if (wtestState == nullptr) {
wtestState = std::make_unique<Opm::WellTestState>();
}
if (summaryConfig == nullptr) {
summaryConfig = std::make_shared<Opm::SummaryConfig>();
}
@ -464,7 +471,7 @@ void Opm::readDeck(Opm::Parallel::Communication comm,
#if HAVE_MPI
else {
defineStateObjectsOnNonIORank(comm, std::move(python), eclipseState,
schedule, udqState, actionState,
schedule, udqState, actionState, wtestState,
summaryConfig);
}

View File

@ -279,7 +279,7 @@ initFromRestartFile(const RestartValue& restartValues,
}
this->active_wgstate_.well_test_state = std::move(wtestState);
this->active_wgstate_.wtest_state(std::move(wtestState));
this->commitWGState();
initial_step_ = false;
}

View File

@ -28,4 +28,10 @@ WGState::WGState(const PhaseUsage& pu) :
well_test_state{}
{}
void WGState::wtest_state(WellTestState wtest_state)
{
wtest_state.filter_wells( this->well_state.wells() );
this->well_test_state = std::move(wtest_state);
}
}

View File

@ -34,6 +34,7 @@ struct PhaseUsage;
struct WGState {
WGState(const PhaseUsage& pu);
void wtest_state(WellTestState wtest_state);
WellState well_state;
GroupState group_state;

View File

@ -157,6 +157,15 @@ public:
throw std::logic_error("No such well");
}
std::vector<std::string> wells() const {
std::vector<std::string> wlist;
for (const auto& [wname, _] : this->index_map) {
(void)_;
wlist.push_back(wname);
}
return wlist;
}
private:
void update_if(std::size_t index, const std::string& name, const WellContainer<T>& other) {

View File

@ -73,6 +73,10 @@ public:
return this->wells_.size();
}
std::vector<std::string> wells() const {
return this->wells_.wells();
}
int numWells() const
{

View File

@ -17,8 +17,10 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <algorithm>
#include <config.h>
#include <functional>
#include <vector>
#define BOOST_TEST_MODULE WellStateFIBOTest
@ -440,6 +442,9 @@ BOOST_AUTO_TEST_CASE(TESTWellContainer) {
BOOST_CHECK_EQUAL(wc.well_name(1), "W2");
BOOST_CHECK_THROW(wc.well_name(10), std::exception);
const auto& wells = wc.wells();
std::vector<std::string> expected = {"W1", "W2"};
BOOST_CHECK( std::is_permutation( wells.begin(), wells.end(), expected.begin(), expected.end()) );
Opm::WellContainer<int> wc2;
wc2.copy_welldata(wc);