mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-11 09:55:34 -06:00
Fix another parallel bug.
A WellSwitchingLogger was created in a local context (meaning not all processes might be there), but since its destructor does communication it must be called in a global context (guaranteeing that all processes create it).
This commit is contained in:
parent
09405ce6f5
commit
7e91381cd8
@ -318,6 +318,7 @@ namespace Opm {
|
||||
// no wells needing testing, otherwise we will have locking.
|
||||
std::vector< Scalar > B_avg(numComponents(), Scalar() );
|
||||
computeAverageFormationFactor(B_avg);
|
||||
wellhelpers::WellSwitchingLogger logger;
|
||||
|
||||
const auto& wellsForTesting = wellTestState_.updateWell(wtest_config, simulationTime);
|
||||
for (const auto& testWell : wellsForTesting) {
|
||||
@ -336,7 +337,7 @@ namespace Opm {
|
||||
const WellTestConfig::Reason testing_reason = testWell.second;
|
||||
|
||||
well->wellTesting(ebosSimulator_, B_avg, simulationTime, timeStepIdx, terminal_output_,
|
||||
testing_reason, well_state_, wellTestState_);
|
||||
testing_reason, well_state_, wellTestState_, logger);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ namespace Opm
|
||||
virtual void wellTestingPhysical(Simulator& simulator, const std::vector<double>& B_avg,
|
||||
const double simulation_time, const int report_step,
|
||||
const bool terminal_output,
|
||||
WellState& well_state, WellTestState& welltest_state) override;
|
||||
WellState& well_state, WellTestState& welltest_state, wellhelpers::WellSwitchingLogger& logger) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1897,7 +1897,7 @@ namespace Opm
|
||||
MultisegmentWell<TypeTag>::
|
||||
wellTestingPhysical(Simulator& simulator, const std::vector<double>& B_avg,
|
||||
const double simulation_time, const int report_step, const bool terminal_output,
|
||||
WellState& well_state, WellTestState& welltest_state)
|
||||
WellState& well_state, WellTestState& welltest_state, wellhelpers::WellSwitchingLogger& logger)
|
||||
{
|
||||
const std::string msg = "Support of well testing for physical limits for multisegment wells is not "
|
||||
"implemented yet, wellTestingPhysical() for " + name() + " will do nothing";
|
||||
|
@ -406,7 +406,7 @@ namespace Opm
|
||||
|
||||
virtual void wellTestingPhysical(Simulator& simulator, const std::vector<double>& B_avg,
|
||||
const double simulation_time, const int report_step, const bool terminal_output,
|
||||
WellState& well_state, WellTestState& welltest_state);
|
||||
WellState& well_state, WellTestState& welltest_state, wellhelpers::WellSwitchingLogger& logger) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -2724,7 +2724,7 @@ namespace Opm
|
||||
StandardWell<TypeTag>::
|
||||
wellTestingPhysical(Simulator& ebos_simulator, const std::vector<double>& B_avg,
|
||||
const double simulation_time, const int report_step, const bool terminal_output,
|
||||
WellState& well_state, WellTestState& welltest_state)
|
||||
WellState& well_state, WellTestState& welltest_state, wellhelpers::WellSwitchingLogger& logger)
|
||||
{
|
||||
OpmLog::debug(" well " + name() + " is being tested for physical limits");
|
||||
|
||||
@ -2759,7 +2759,7 @@ namespace Opm
|
||||
updatePrimaryVariables(well_state_copy);
|
||||
initPrimaryVariablesEvaluation();
|
||||
|
||||
const bool converged = this->solveWellEqUntilConverged(ebos_simulator, B_avg, well_state_copy);
|
||||
const bool converged = this->solveWellEqUntilConverged(ebos_simulator, B_avg, well_state_copy, logger);
|
||||
|
||||
if (!converged) {
|
||||
const std::string msg = " well " + name() + " did not get converged during well testing for physical reason";
|
||||
|
@ -219,7 +219,8 @@ namespace Opm
|
||||
void wellTesting(Simulator& simulator, const std::vector<double>& B_avg,
|
||||
const double simulation_time, const int report_step, const bool terminal_output,
|
||||
const WellTestConfig::Reason testing_reason,
|
||||
/* const */ WellState& well_state, WellTestState& welltest_state);
|
||||
/* const */ WellState& well_state, WellTestState& welltest_state,
|
||||
wellhelpers::WellSwitchingLogger& logger);
|
||||
|
||||
void updatePerforatedCell(std::vector<bool>& is_cell_perforated);
|
||||
|
||||
@ -362,11 +363,11 @@ namespace Opm
|
||||
|
||||
void wellTestingEconomic(Simulator& simulator, const std::vector<double>& B_avg,
|
||||
const double simulation_time, const int report_step, const bool terminal_output,
|
||||
const WellState& well_state, WellTestState& welltest_state);
|
||||
const WellState& well_state, WellTestState& welltest_state, wellhelpers::WellSwitchingLogger& logger);
|
||||
|
||||
virtual void wellTestingPhysical(Simulator& simulator, const std::vector<double>& B_avg,
|
||||
const double simulation_time, const int report_step, const bool terminal_output,
|
||||
WellState& well_state, WellTestState& welltest_state) = 0;
|
||||
WellState& well_state, WellTestState& welltest_state, wellhelpers::WellSwitchingLogger& logger) = 0;
|
||||
|
||||
void updateWellTestStateEconomic(const WellState& well_state,
|
||||
const double simulation_time,
|
||||
@ -379,11 +380,13 @@ namespace Opm
|
||||
WellTestState& well_test_state) const;
|
||||
|
||||
void solveWellForTesting(Simulator& ebosSimulator, WellState& well_state,
|
||||
const std::vector<double>& B_avg, bool terminal_output);
|
||||
const std::vector<double>& B_avg, bool terminal_output,
|
||||
wellhelpers::WellSwitchingLogger& logger);
|
||||
|
||||
bool solveWellEqUntilConverged(Simulator& ebosSimulator,
|
||||
const std::vector<double>& B_avg,
|
||||
WellState& well_state);
|
||||
const std::vector<double>& B_avg,
|
||||
WellState& well_state,
|
||||
wellhelpers::WellSwitchingLogger& logger);
|
||||
|
||||
void scaleProductivityIndex(const int perfIdx, double& productivity_index) const;
|
||||
|
||||
|
@ -925,16 +925,17 @@ namespace Opm
|
||||
const double simulation_time, const int report_step, const bool terminal_output,
|
||||
const WellTestConfig::Reason testing_reason,
|
||||
/* const */ WellState& well_state,
|
||||
WellTestState& well_test_state)
|
||||
WellTestState& well_test_state,
|
||||
wellhelpers::WellSwitchingLogger& logger)
|
||||
{
|
||||
if (testing_reason == WellTestConfig::Reason::PHYSICAL) {
|
||||
wellTestingPhysical(simulator, B_avg, simulation_time, report_step,
|
||||
terminal_output, well_state, well_test_state);
|
||||
terminal_output, well_state, well_test_state, logger);
|
||||
}
|
||||
|
||||
if (testing_reason == WellTestConfig::Reason::ECONOMIC) {
|
||||
wellTestingEconomic(simulator, B_avg, simulation_time, report_step,
|
||||
terminal_output, well_state, well_test_state);
|
||||
terminal_output, well_state, well_test_state, logger);
|
||||
}
|
||||
}
|
||||
|
||||
@ -947,7 +948,7 @@ namespace Opm
|
||||
WellInterface<TypeTag>::
|
||||
wellTestingEconomic(Simulator& simulator, const std::vector<double>& B_avg,
|
||||
const double simulation_time, const int report_step, const bool terminal_output,
|
||||
const WellState& well_state, WellTestState& welltest_state)
|
||||
const WellState& well_state, WellTestState& welltest_state, wellhelpers::WellSwitchingLogger& logger)
|
||||
{
|
||||
OpmLog::debug(" well " + name() + " is being tested for economic limits");
|
||||
|
||||
@ -965,7 +966,7 @@ namespace Opm
|
||||
// untill the number of closed completions do not increase anymore.
|
||||
while (testWell) {
|
||||
const size_t original_number_closed_completions = welltest_state_temp.sizeCompletions();
|
||||
solveWellForTesting(simulator, well_state_copy, B_avg, terminal_output);
|
||||
solveWellForTesting(simulator, well_state_copy, B_avg, terminal_output, logger);
|
||||
updateWellTestState(well_state_copy, simulation_time, /*writeMessageToOPMLog=*/ false, welltest_state_temp);
|
||||
closeCompletions(welltest_state_temp);
|
||||
|
||||
@ -1152,7 +1153,8 @@ namespace Opm
|
||||
WellInterface<TypeTag>::
|
||||
solveWellEqUntilConverged(Simulator& ebosSimulator,
|
||||
const std::vector<double>& B_avg,
|
||||
WellState& well_state)
|
||||
WellState& well_state,
|
||||
wellhelpers::WellSwitchingLogger& logger)
|
||||
{
|
||||
const int max_iter = param_.max_welleq_iter_;
|
||||
int it = 0;
|
||||
@ -1171,7 +1173,6 @@ namespace Opm
|
||||
++it;
|
||||
solveEqAndUpdateWellState(well_state);
|
||||
|
||||
wellhelpers::WellSwitchingLogger logger;
|
||||
updateWellControl(ebosSimulator, well_state, logger);
|
||||
initPrimaryVariablesEvaluation();
|
||||
} while (it < max_iter);
|
||||
@ -1222,13 +1223,12 @@ namespace Opm
|
||||
void
|
||||
WellInterface<TypeTag>::
|
||||
solveWellForTesting(Simulator& ebosSimulator, WellState& well_state,
|
||||
const std::vector<double>& B_avg, bool terminal_output)
|
||||
const std::vector<double>& B_avg, bool terminal_output,
|
||||
wellhelpers::WellSwitchingLogger& logger)
|
||||
{
|
||||
// keep a copy of the original well state
|
||||
const WellState well_state0 = well_state;
|
||||
|
||||
const bool converged = solveWellEqUntilConverged(ebosSimulator, B_avg, well_state);
|
||||
|
||||
const bool converged = solveWellEqUntilConverged(ebosSimulator, B_avg, well_state, logger);
|
||||
if (converged) {
|
||||
if ( terminal_output ) {
|
||||
OpmLog::debug("WellTest: Well equation for well " + name() + " solution gets converged");
|
||||
|
Loading…
Reference in New Issue
Block a user