fixing warnings in other folder under opm-simulators

This commit is contained in:
Kai Bao
2019-06-26 09:50:56 +02:00
parent 53b15527c2
commit 9a2fcdbfd5
14 changed files with 50 additions and 61 deletions

View File

@@ -659,7 +659,6 @@ public:
if (enableTuning_) { if (enableTuning_) {
// if support for the TUNING keyword is enabled, we get the initial time // if support for the TUNING keyword is enabled, we get the initial time
// steping parameters from it instead of from command line parameters // steping parameters from it instead of from command line parameters
const auto& schedule = simulator.vanguard().schedule();
const auto& tuning = schedule.getTuning(); const auto& tuning = schedule.getTuning();
initialTimeStepSize_ = tuning.getTSINIT(0); initialTimeStepSize_ = tuning.getTSINIT(0);
maxTimeStepAfterWellEvent_ = tuning.getTMAXWC(0); maxTimeStepAfterWellEvent_ = tuning.getTMAXWC(0);
@@ -745,7 +744,7 @@ public:
void deserialize(Restarter& res) void deserialize(Restarter& res)
{ {
// reload the current episode/report step from the deck // reload the current episode/report step from the deck
beginEpisode(/*isOnRestart=*/true); beginEpisode();
// deserialize the wells // deserialize the wells
wellModel_.deserialize(res); wellModel_.deserialize(res);
@@ -773,7 +772,7 @@ public:
/*! /*!
* \brief Called by the simulator before an episode begins. * \brief Called by the simulator before an episode begins.
*/ */
void beginEpisode(bool isOnRestart = false) void beginEpisode()
{ {
// Proceed to the next report step // Proceed to the next report step
auto& simulator = this->simulator(); auto& simulator = this->simulator();
@@ -1514,7 +1513,7 @@ public:
// convert the source term from the total mass rate of the // convert the source term from the total mass rate of the
// cell to the one per unit of volume as used by the model. // cell to the one per unit of volume as used by the model.
unsigned globalDofIdx = context.globalSpaceIndex(spaceIdx, timeIdx); const unsigned globalDofIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
for (unsigned eqIdx = 0; eqIdx < numEq; ++ eqIdx) { for (unsigned eqIdx = 0; eqIdx < numEq; ++ eqIdx) {
rate[eqIdx] /= this->model().dofTotalVolume(globalDofIdx); rate[eqIdx] /= this->model().dofTotalVolume(globalDofIdx);
@@ -1528,7 +1527,6 @@ public:
// if requested, compensate systematic mass loss for cells which were "well // if requested, compensate systematic mass loss for cells which were "well
// behaved" in the last time step // behaved" in the last time step
if (enableDriftCompensation_) { if (enableDriftCompensation_) {
unsigned globalDofIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
const auto& intQuants = context.intensiveQuantities(spaceIdx, timeIdx); const auto& intQuants = context.intensiveQuantities(spaceIdx, timeIdx);
const auto& simulator = this->simulator(); const auto& simulator = this->simulator();
const auto& model = this->model(); const auto& model = this->model();
@@ -2651,10 +2649,10 @@ private:
////// //////
// set temperature // set temperature
////// //////
Scalar temperature = tempiData[cartesianDofIdx]; Scalar temperatureLoc = tempiData[cartesianDofIdx];
if (!std::isfinite(temperature) || temperature <= 0) if (!std::isfinite(temperatureLoc) || temperatureLoc <= 0)
temperature = FluidSystem::surfaceTemperature; temperatureLoc = FluidSystem::surfaceTemperature;
dofFluidState.setTemperature(temperature); dofFluidState.setTemperature(temperatureLoc);
////// //////
// set saturations // set saturations

View File

@@ -80,7 +80,7 @@ namespace Opm
OPM_THROW(std::runtime_error, "Trying to add well " << wellChild.name() << " Step: " << boost::lexical_cast<std::string>(timeStep) << " to group named " << wellChild.groupName() << ", but this group does not exist in the WellCollection."); OPM_THROW(std::runtime_error, "Trying to add well " << wellChild.name() << " Step: " << boost::lexical_cast<std::string>(timeStep) << " to group named " << wellChild.groupName() << ", but this group does not exist in the WellCollection.");
} }
std::shared_ptr<WellsGroupInterface> child = createWellWellsGroup(wellChild, summaryState, timeStep, phaseUsage); std::shared_ptr<WellsGroupInterface> child = createWellWellsGroup(wellChild, summaryState, phaseUsage);
WellsGroup* parent_as_group = static_cast<WellsGroup*> (parent); WellsGroup* parent_as_group = static_cast<WellsGroup*> (parent);
if (!parent_as_group) { if (!parent_as_group) {

View File

@@ -1588,7 +1588,7 @@ namespace Opm
'CMODE_UNDEFINED' - we do not carry that over the specification 'CMODE_UNDEFINED' - we do not carry that over the specification
objects here. objects here.
*/ */
std::shared_ptr<WellsGroupInterface> createWellWellsGroup(const Well2& well, const SummaryState& summaryState, size_t timeStep, const PhaseUsage& phase_usage ) std::shared_ptr<WellsGroupInterface> createWellWellsGroup(const Well2& well, const SummaryState& summaryState, const PhaseUsage& phase_usage )
{ {
InjectionSpecification injection_specification; InjectionSpecification injection_specification;
ProductionSpecification production_specification; ProductionSpecification production_specification;

View File

@@ -543,7 +543,6 @@ namespace Opm
/// \param[in] the phase usage /// \param[in] the phase usage
std::shared_ptr<WellsGroupInterface> createWellWellsGroup(const Well2& well, std::shared_ptr<WellsGroupInterface> createWellWellsGroup(const Well2& well,
const SummaryState& summaryState, const SummaryState& summaryState,
size_t timeStep,
const PhaseUsage& phase_usage ); const PhaseUsage& phase_usage );
/// Creates the WellsGroupInterface for the given Group /// Creates the WellsGroupInterface for the given Group

View File

@@ -294,7 +294,6 @@ namespace Opm
void WellsManager::setupWellControls(const std::vector<Well2>& wells, void WellsManager::setupWellControls(const std::vector<Well2>& wells,
const SummaryState& summaryState, const SummaryState& summaryState,
size_t timeStep,
std::vector<std::string>& well_names, std::vector<std::string>& well_names,
const PhaseUsage& phaseUsage, const PhaseUsage& phaseUsage,
const std::vector<int>& wells_on_proc) { const std::vector<int>& wells_on_proc) {
@@ -599,7 +598,7 @@ namespace Opm
} }
// only handle the guide rates from the keyword WGRUPCON // only handle the guide rates from the keyword WGRUPCON
void WellsManager::setupGuideRates(const std::vector<Well2>& wells, const size_t timeStep, std::vector<WellData>& well_data, std::map<std::string, int>& well_names_to_index) void WellsManager::setupGuideRates(const std::vector<Well2>& wells, std::vector<WellData>& well_data, std::map<std::string, int>& well_names_to_index)
{ {
for (auto wellIter = wells.begin(); wellIter != wells.end(); ++wellIter ) { for (auto wellIter = wells.begin(); wellIter != wells.end(); ++wellIter ) {
const auto& well = *wellIter; const auto& well = *wellIter;

View File

@@ -170,7 +170,7 @@ namespace Opm
WellsManager(const WellsManager& other); WellsManager(const WellsManager& other);
WellsManager& operator=(const WellsManager& other); WellsManager& operator=(const WellsManager& other);
static void setupCompressedToCartesian(const int* global_cell, int number_of_cells, std::map<int,int>& cartesian_to_compressed ); static void setupCompressedToCartesian(const int* global_cell, int number_of_cells, std::map<int,int>& cartesian_to_compressed );
void setupWellControls(const std::vector<Well2>& wells, const SummaryState& summaryState, size_t timeStep, void setupWellControls(const std::vector<Well2>& wells, const SummaryState& summaryState,
std::vector<std::string>& well_names, const PhaseUsage& phaseUsage, std::vector<std::string>& well_names, const PhaseUsage& phaseUsage,
const std::vector<int>& wells_on_proc); const std::vector<int>& wells_on_proc);
@@ -191,7 +191,7 @@ namespace Opm
std::vector<int>& wells_on_proc, std::vector<int>& wells_on_proc,
const std::unordered_set<std::string>& deactivated_wells); const std::unordered_set<std::string>& deactivated_wells);
void setupGuideRates(const std::vector<Well2>& wells, const size_t timeStep, std::vector<WellData>& well_data, std::map<std::string, int>& well_names_to_index); void setupGuideRates(const std::vector<Well2>& wells, std::vector<WellData>& well_data, std::map<std::string, int>& well_names_to_index);
// Data // Data
Wells* w_; Wells* w_;

View File

@@ -226,16 +226,16 @@ void WellsManager::createWellsFromSpecs(const std::vector<Well2>& wells, size_t
destroy_wells( w ); destroy_wells( w );
// Add wells. // Add wells.
for (int w = 0; w < num_wells; ++w) { for (int iw = 0; iw < num_wells; ++iw) {
const int w_num_perf = wellperf_data[w].size(); const int w_num_perf = wellperf_data[iw].size();
std::vector<int> perf_cells (w_num_perf); std::vector<int> perf_cells (w_num_perf);
std::vector<double> perf_prodind(w_num_perf); std::vector<double> perf_prodind(w_num_perf);
std::vector<int> perf_satnumid(w_num_perf); std::vector<int> perf_satnumid(w_num_perf);
for (int perf = 0; perf < w_num_perf; ++perf) { for (int perf = 0; perf < w_num_perf; ++perf) {
perf_cells [perf] = wellperf_data[w][perf].cell; perf_cells [perf] = wellperf_data[iw][perf].cell;
perf_prodind[perf] = wellperf_data[w][perf].well_index; perf_prodind[perf] = wellperf_data[iw][perf].well_index;
perf_satnumid[perf] = wellperf_data[w][perf].satnumid; perf_satnumid[perf] = wellperf_data[iw][perf].satnumid;
} }
const double* comp_frac = NULL; const double* comp_frac = NULL;
@@ -243,21 +243,21 @@ void WellsManager::createWellsFromSpecs(const std::vector<Well2>& wells, size_t
// We initialize all wells with a null component fraction, // We initialize all wells with a null component fraction,
// and must (for injection wells) overwrite it later. // and must (for injection wells) overwrite it later.
const int ok = const int ok =
add_well(well_data[w].type, add_well(well_data[iw].type,
well_data[w].reference_bhp_depth, well_data[iw].reference_bhp_depth,
w_num_perf, w_num_perf,
comp_frac, comp_frac,
perf_cells.data(), perf_cells.data(),
perf_prodind.data(), perf_prodind.data(),
perf_satnumid.data(), perf_satnumid.data(),
well_names[w].c_str(), well_names[iw].c_str(),
well_data[w].allowCrossFlow, well_data[iw].allowCrossFlow,
w_); w_);
if (!ok) { if (!ok) {
OPM_THROW(std::runtime_error, OPM_THROW(std::runtime_error,
"Failed adding well " "Failed adding well "
<< well_names[w] << well_names[iw]
<< " to Wells data structure."); << " to Wells data structure.");
} }
} }
@@ -368,7 +368,7 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
pu, cartesian_to_compressed, interleavedPerm.data(), ntg, pu, cartesian_to_compressed, interleavedPerm.data(), ntg,
wells_on_proc, deactivated_wells); wells_on_proc, deactivated_wells);
setupWellControls(wells, summaryState, timeStep, well_names, pu, wells_on_proc); setupWellControls(wells, summaryState, well_names, pu, wells_on_proc);
{ {
const auto& fieldGroup = schedule.getGroup( "FIELD" ); const auto& fieldGroup = schedule.getGroup( "FIELD" );
@@ -401,7 +401,7 @@ WellsManager::init(const Opm::EclipseState& eclipseState,
if (well_collection_.groupControlActive()) { if (well_collection_.groupControlActive()) {
// here does not consider the well potentials related guide rate setting // here does not consider the well potentials related guide rate setting
setupGuideRates(wells, timeStep, well_data, well_names_to_index); setupGuideRates(wells, well_data, well_names_to_index);
} }
// Debug output. // Debug output.

View File

@@ -437,8 +437,8 @@ namespace Opm {
resultDenom += pressureNew*pressureNew; resultDenom += pressureNew*pressureNew;
for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++ phaseIdx) { for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++ phaseIdx) {
Scalar tmp = saturationsNew[phaseIdx] - saturationsOld[phaseIdx]; const Scalar tmpSat = saturationsNew[phaseIdx] - saturationsOld[phaseIdx];
resultDelta += tmp*tmp; resultDelta += tmpSat * tmpSat;
resultDenom += saturationsNew[phaseIdx]*saturationsNew[phaseIdx]; resultDenom += saturationsNew[phaseIdx]*saturationsNew[phaseIdx];
} }
} }
@@ -882,9 +882,9 @@ namespace Opm {
const BlackoilWellModel<TypeTag>& const BlackoilWellModel<TypeTag>&
wellModel() const { return well_model_; } wellModel() const { return well_model_; }
void beginReportStep(bool isRestart) void beginReportStep()
{ {
ebosSimulator_.problem().beginEpisode(isRestart); ebosSimulator_.problem().beginEpisode();
} }
void endReportStep() void endReportStep()

View File

@@ -204,10 +204,6 @@ public:
wellModel_().initFromRestartFile(*restartValues); wellModel_().initFromRestartFile(*restartValues);
} }
// beginReportStep(...) wants to know when we are at the
// beginning of a restart
bool firstRestartStep = isRestart();
// Main simulation loop. // Main simulation loop.
while (!timer.done()) { while (!timer.done()) {
// Report timestep. // Report timestep.
@@ -252,9 +248,7 @@ public:
ebosSimulator_.startNextEpisode(ebosSimulator_.startTime() + schedule().getTimeMap().getTimePassedUntil(timer.currentStepNum()), ebosSimulator_.startNextEpisode(ebosSimulator_.startTime() + schedule().getTimeMap().getTimePassedUntil(timer.currentStepNum()),
timer.currentStepLength()); timer.currentStepLength());
ebosSimulator_.setEpisodeIndex(timer.currentStepNum()); ebosSimulator_.setEpisodeIndex(timer.currentStepNum());
solver->model().beginReportStep(firstRestartStep); solver->model().beginReportStep();
firstRestartStep = false;
// If sub stepping is enabled allow the solver to sub cycle // If sub stepping is enabled allow the solver to sub cycle
// in case the report steps are too large for the solver to converge // in case the report steps are too large for the solver to converge

View File

@@ -335,7 +335,6 @@ protected:
} }
else else
{ {
const WellModel& wellModel = simulator_.problem().wellModel();
typedef WellModelMatrixAdapter< Matrix, Vector, Vector, WellModel, false > Operator; typedef WellModelMatrixAdapter< Matrix, Vector, Vector, WellModel, false > Operator;
Operator opA(*matrix_, *matrix_, wellModel); Operator opA(*matrix_, *matrix_, wellModel);
solve( opA, x, *rhs_ ); solve( opA, x, *rhs_ );

View File

@@ -520,8 +520,8 @@ namespace Opm {
failing_wells.insert(wf.wellName()); failing_wells.insert(wf.wellName());
} }
if (sr_size >= num_steps) { if (sr_size >= num_steps) {
for (int step = 1; step < num_steps; ++step) { for (int s = 1; s < num_steps; ++s) {
const auto& srep = sr[sr_size - 1 - step]; const auto& srep = sr[sr_size - 1 - s];
// Report must be from same report step and substep, otherwise we have // Report must be from same report step and substep, otherwise we have
// not chopped/retried enough times on this step. // not chopped/retried enough times on this step.
if (srep.report_step != rep_step || srep.current_step != sub_step) { if (srep.report_step != rep_step || srep.current_step != sub_step) {

View File

@@ -174,7 +174,7 @@ namespace Opm {
int well_was_shut = 0; int well_was_shut = 0;
for (const auto& well : well_container_) { for (const auto& well : well_container_) {
if (well->name() == wellname) { if (well->name() == wellname) {
if (well->underPredictionMode() { if (well->underPredictionMode()) {
wellTestState_.closeWell(wellname, WellTestConfig::Reason::PHYSICAL, simulation_time); wellTestState_.closeWell(wellname, WellTestConfig::Reason::PHYSICAL, simulation_time);
well_was_shut = 1; well_was_shut = 1;
} }

View File

@@ -67,24 +67,24 @@ BOOST_AUTO_TEST_CASE(deferredlogger)
std::ostringstream log_stream; std::ostringstream log_stream;
initLogger(log_stream); initLogger(log_stream);
auto deferredlogger = Opm::DeferredLogger(); auto deferred_logger = Opm::DeferredLogger();
deferredlogger.info("info 1"); deferred_logger.info("info 1");
deferredlogger.warning("warning 1"); deferred_logger.warning("warning 1");
deferredlogger.error("error 1"); deferred_logger.error("error 1");
deferredlogger.error("error 2"); deferred_logger.error("error 2");
deferredlogger.problem("problem 1"); deferred_logger.problem("problem 1");
deferredlogger.bug("bug 1"); deferred_logger.bug("bug 1");
deferredlogger.debug("debug 1"); deferred_logger.debug("debug 1");
deferredlogger.note("note 1"); deferred_logger.note("note 1");
deferredlogger.note("tagme", "note 2"); deferred_logger.note("tagme", "note 2");
deferredlogger.note("tagme", "note 3"); deferred_logger.note("tagme", "note 3");
deferredlogger.note("tagme", "note 3"); deferred_logger.note("tagme", "note 3");
deferredlogger.note("tagme", "note 3"); deferred_logger.note("tagme", "note 3");
deferredlogger.note("tagme", "note 3"); deferred_logger.note("tagme", "note 3");
deferredlogger.note("tagme", "note 3"); deferred_logger.note("tagme", "note 3");
deferredlogger.note("tagme", "note 3"); deferred_logger.note("tagme", "note 3");
deferredlogger.logMessages(); deferred_logger.logMessages();
auto counter = OpmLog::getBackend<CounterLog>("COUNTER"); auto counter = OpmLog::getBackend<CounterLog>("COUNTER");
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Warning) ); BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Warning) );

View File

@@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(ConstructGroupFromWell) {
for (size_t i=0; i<wells.size(); i++) { for (size_t i=0; i<wells.size(); i++) {
const auto& well = wells[i]; const auto& well = wells[i];
std::shared_ptr<WellsGroupInterface> wellsGroup = createWellWellsGroup(well, summaryState, 2, pu); std::shared_ptr<WellsGroupInterface> wellsGroup = createWellWellsGroup(well, summaryState, pu);
BOOST_CHECK_EQUAL(well.name(), wellsGroup->name()); BOOST_CHECK_EQUAL(well.name(), wellsGroup->name());
if (well.isInjector()) { if (well.isInjector()) {
const auto controls = well.injectionControls(summaryState); const auto controls = well.injectionControls(summaryState);