remove BlackoilOutputEbos

after the actual output writing code has been moved to core ebos, this
was just a unnecessary glue layer for API compatibility.
This commit is contained in:
Andreas Lauser 2018-06-06 10:59:41 +02:00
parent dfbc24b35f
commit 37b6a540af
8 changed files with 44 additions and 183 deletions

View File

@ -322,7 +322,6 @@ list (APPEND PUBLIC_HEADER_FILES
opm/autodiff/WellDensitySegmented.hpp
opm/autodiff/WellStateFullyImplicitBlackoil.hpp
opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp
opm/autodiff/BlackoilOutputEbos.hpp
opm/autodiff/ThreadHandle.hpp
opm/autodiff/VFPProperties.hpp
opm/autodiff/VFPHelpers.hpp

View File

@ -1054,6 +1054,9 @@ namespace Opm {
const Simulator& ebosSimulator() const
{ return ebosSimulator_; }
Simulator& ebosSimulator()
{ return ebosSimulator_; }
/// return the statistics if the nonlinearIteration() method failed
const SimulatorReport& failureReport() const
{ return failureReport_; }
@ -1130,4 +1133,4 @@ namespace Opm {
};
} // namespace Opm
#endif // OPM_BLACKOILMODELBASE_IMPL_HEADER_INCLUDED
#endif // OPM_BLACKOILMODELBASE_IMPL_HEADER_INCLUDED

View File

@ -1,144 +0,0 @@
/*
Copyright (c) 2017 IRIS AS
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_BLACKOILOUTPUTEBOS_HEADER_INCLUDED
#define OPM_BLACKOILOUTPUTEBOS_HEADER_INCLUDED
#include <ebos/eclproblem.hh>
#include <ewoms/common/start.hh>
#include <opm/grid/UnstructuredGrid.h>
#include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
#include <opm/core/utility/DataMap.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/core/utility/miscUtilities.hpp>
#include <opm/common/utility/parameters/ParameterGroup.hpp>
#include <opm/core/wells/DynamicListEconLimited.hpp>
#include <opm/core/simulator/SimulatorReport.hpp>
#include <opm/core/wells/WellsManager.hpp>
#include <opm/output/data/Cells.hpp>
#include <opm/output/data/Solution.hpp>
#include <opm/autodiff/Compat.hpp>
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <string>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <thread>
#include <map>
#include <boost/filesystem.hpp>
#ifdef HAVE_OPM_GRID
#include <opm/grid/CpGrid.hpp>
#endif
namespace Opm
{
/// Extra data to read/write for OPM restarting
struct ExtraData
{
double suggested_step = -1.0;
};
/** \brief Wrapper ECL output. */
template<class TypeTag>
class BlackoilOutputEbos
{
public:
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
// constructor creating different sub writers
BlackoilOutputEbos(Simulator& ebosSimulator,
const ParameterGroup& param)
: output_( [ &param ] () -> bool {
// If output parameter is true or all, then we do output
const std::string outputString = param.getDefault("output", std::string("all"));
return ( outputString == "all" || outputString == "true" );
}()
),
ebosSimulator_(ebosSimulator),
phaseUsage_(phaseUsageFromDeck(eclState()))
{}
/*!
* \brief Write a blackoil reservoir state to disk for later inspection with
* visualization tools like ResInsight. This function will extract the
* requested output cell properties specified by the RPTRST keyword
* and write these to file.
*/
template<class Model>
void writeTimeStep(const SimulatorTimerInterface& timer,
const Model& physicalModel,
const bool isSubstep = false,
const double nextStepSize = -1.0,
const SimulatorReport& simulatorReport = SimulatorReport())
{
if( output_ )
{
// Add TCPU if simulatorReport is not defaulted.
const double totalSolverTime = simulatorReport.solver_time;
const Opm::WellStateFullyImplicitBlackoil& localWellState = physicalModel.wellModel().wellState();
// The writeOutput expects a local data::solution vector and a local data::well vector.
auto localWellData = localWellState.report(phaseUsage_, Opm::UgGridHelpers::globalCell(grid()) );
ebosSimulator_.problem().writeOutput(localWellData, timer.simulationTimeElapsed(), isSubstep, totalSolverTime, nextStepSize);
}
}
const Grid& grid()
{ return ebosSimulator_.vanguard().grid(); }
const Schedule& schedule() const
{ return ebosSimulator_.vanguard().schedule(); }
const EclipseState& eclState() const
{ return ebosSimulator_.vanguard().eclState(); }
bool isRestart() const {
const auto& initconfig = eclState().getInitConfig();
return initconfig.restartRequested();
}
protected:
const bool output_;
Simulator& ebosSimulator_;
Opm::PhaseUsage phaseUsage_;
};
}
#endif

View File

@ -49,6 +49,7 @@
#include <opm/autodiff/WellInterface.hpp>
#include <opm/autodiff/StandardWell.hpp>
#include <opm/autodiff/MultisegmentWell.hpp>
#include <opm/autodiff/Compat.hpp>
#include<opm/autodiff/SimFIBODetails.hpp>
#include<dune/common/fmatrix.hh>
#include<dune/istl/bcrsmatrix.hh>

View File

@ -85,7 +85,6 @@ namespace Opm
typedef Opm::SimulatorFullyImplicitBlackoilEbos<TypeTag> Simulator;
typedef typename Simulator::ReservoirState ReservoirState;
typedef typename Simulator::OutputWriter OutputWriter;
/// This is the main function of Flow.
/// It runs a complete simulation, with the given grid and
@ -107,7 +106,6 @@ namespace Opm
setupLogging();
printPRTHeader();
runDiagnostics();
setupOutputWriter();
setupLinearSolver();
createSimulator();
@ -480,20 +478,6 @@ namespace Opm
diagnostic.diagnosis(eclState(), deck(), this->grid());
}
// Setup output writer.
// Writes to:
// output_writer_
void setupOutputWriter()
{
// create output writer after grid is distributed, otherwise the parallel output
// won't work correctly since we need to create a mapping from the distributed to
// the global view
output_writer_.reset(new OutputWriter(*ebosSimulator_,
param_));
}
// Run the simulator.
// Returns EXIT_SUCCESS if it does not throw.
int runSimulator()
@ -569,8 +553,7 @@ namespace Opm
param_,
*fis_solver_,
FluidSystem::enableDissolvedGas(),
FluidSystem::enableVaporizedOil(),
*output_writer_));
FluidSystem::enableVaporizedOil()));
}
private:
@ -619,7 +602,6 @@ namespace Opm
bool must_distribute_ = false;
ParameterGroup param_;
bool output_to_files_ = false;
std::unique_ptr<OutputWriter> output_writer_;
boost::any parallel_information_;
std::unique_ptr<NewtonIterationBlackoilInterface> fis_solver_;
std::unique_ptr<Simulator> simulator_;

View File

@ -23,6 +23,8 @@
#include <opm/core/simulator/SimulatorReport.hpp>
#include <opm/common/utility/parameters/ParameterGroup.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/Exceptions.hpp>
#include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>

View File

@ -22,7 +22,6 @@
#ifndef OPM_SIMULATORFULLYIMPLICITBLACKOILEBOS_HEADER_INCLUDED
#define OPM_SIMULATORFULLYIMPLICITBLACKOILEBOS_HEADER_INCLUDED
#include <opm/autodiff/BlackoilOutputEbos.hpp>
#include <opm/autodiff/IterationReport.hpp>
#include <opm/autodiff/NonlinearSolverEbos.hpp>
#include <opm/autodiff/BlackoilModelEbos.hpp>
@ -61,7 +60,6 @@ public:
typedef WellStateFullyImplicitBlackoil WellState;
typedef BlackoilState ReservoirState;
typedef BlackoilOutputEbos<TypeTag> OutputWriter;
typedef BlackoilModelEbos<TypeTag> Model;
typedef BlackoilModelParameters ModelParameters;
typedef NonlinearSolverEbos<Model> Solver;
@ -96,8 +94,7 @@ public:
const ParameterGroup& param,
NewtonIterationBlackoilInterface& linsolver,
const bool hasDisgas,
const bool hasVapoil,
OutputWriter& outputWriter)
const bool hasVapoil)
: ebosSimulator_(ebosSimulator)
, param_(param)
, modelParam_(param)
@ -107,7 +104,6 @@ public:
, hasDisgas_(hasDisgas)
, hasVapoil_(hasVapoil)
, terminalOutput_(param.getDefault("output_terminal", true))
, outputWriter_(outputWriter)
{
#if HAVE_MPI
if (solver_.parallelInformation().type() == typeid(ParallelISTLInformation)) {
@ -131,7 +127,7 @@ public:
// handle restarts
std::unique_ptr<RestartValue> restartValues;
if (outputWriter_.isRestart()) {
if (isRestart()) {
std::vector<RestartKey> extraKeys = {
{"OPMEXTRA" , Opm::UnitSystem::measure::identity, false}
};
@ -158,7 +154,7 @@ public:
}
double suggestedStepSize = -1.0;
if (outputWriter_.isRestart()) {
if (isRestart()) {
// This is a restart, determine the time step size from the restart data
if (restartValues->hasExtra("OPMEXTRA")) {
std::vector<double> opmextra = restartValues->getExtra("OPMEXTRA");
@ -180,7 +176,7 @@ public:
SimulatorReport stepReport;
WellModel wellModel(ebosSimulator_, modelParam_, terminalOutput_);
if (outputWriter_.isRestart()) {
if (isRestart()) {
wellModel.initFromRestartFile(*restartValues);
}
@ -217,7 +213,12 @@ public:
// No per cell data is written for initial step, but will be
// for subsequent steps, when we have started simulating
outputWriter_.writeTimeStep(timer, solver->model());
auto localWellData = wellModel.wellState().report(phaseUsage_, Opm::UgGridHelpers::globalCell(grid()));
ebosSimulator_.problem().writeOutput(localWellData,
timer.simulationTimeElapsed(),
/*isSubstep=*/false,
totalTimer.secsSinceStart(),
/*nextStepSize=*/-1.0);
report.output_write_time += perfTimer.stop();
}
@ -252,7 +253,7 @@ public:
events.hasEvent(ScheduleEvents::PRODUCTION_UPDATE, timer.currentStepNum()) ||
events.hasEvent(ScheduleEvents::INJECTION_UPDATE, timer.currentStepNum()) ||
events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE, timer.currentStepNum());
stepReport = adaptiveTimeStepping->step(timer, *solver, event, outputWriter_, nullptr);
stepReport = adaptiveTimeStepping->step(timer, *solver, event, nullptr);
report += stepReport;
failureReport_ += adaptiveTimeStepping->failureReport();
}
@ -294,7 +295,12 @@ public:
perfTimer.start();
const double nextstep = adaptiveTimeStepping ? adaptiveTimeStepping->suggestedNextStep() : -1.0;
outputWriter_.writeTimeStep(timer, solver->model(), false, nextstep, report);
auto localWellData = wellModel.wellState().report(phaseUsage_, Opm::UgGridHelpers::globalCell(grid()));
ebosSimulator_.problem().writeOutput(localWellData,
timer.simulationTimeElapsed(),
/*isSubstep=*/false,
totalTimer.secsSinceStart(),
nextstep);
report.output_write_time += perfTimer.stop();
if (terminalOutput_) {
@ -357,6 +363,11 @@ protected:
const Schedule& schedule() const
{ return ebosSimulator_.vanguard().schedule(); }
bool isRestart() const
{
const auto& initconfig = eclState().getInitConfig();
return initconfig.restartRequested();
}
// Data.
Simulator& ebosSimulator_;
@ -376,8 +387,6 @@ protected:
const bool hasDisgas_;
const bool hasVapoil_;
bool terminalOutput_;
// outputWriter
OutputWriter& outputWriter_;
};
} // namespace Opm

View File

@ -97,11 +97,10 @@ namespace Opm {
/** \brief step method that acts like the solver::step method
in a sub cycle of time steps
*/
template <class Solver, class Output>
template <class Solver>
SimulatorReport step(const SimulatorTimer& simulatorTimer,
Solver& solver,
const bool isEvent,
Output& outputWriter,
const std::vector<int>* fipnum = nullptr)
{
SimulatorReport report;
@ -121,6 +120,10 @@ namespace Opm {
suggestedNextTimestep_ = timestepAfterEvent_;
}
auto& ebosSimulator = solver.model().ebosSimulator();
auto& ebosProblem = ebosSimulator.problem();
auto phaseUsage = Opm::phaseUsageFromDeck(ebosSimulator.vanguard().eclState());
// create adaptive step timer with previously used sub step size
AdaptiveSimulatorTimer substepTimer(simulatorTimer, suggestedNextTimestep_, maxTimeStep_);
@ -231,9 +234,15 @@ namespace Opm {
}
Opm::time::StopWatch perfTimer;
perfTimer.start();
bool substep = true;
const auto& physicalModel = solver.model();
outputWriter.writeTimeStep(substepTimer, physicalModel, substep, -1.0, substepReport);
// The writeOutput expects a local data::solution vector and a local data::well vector.
auto localWellData = solver.model().wellModel().wellState().report(phaseUsage, Opm::UgGridHelpers::globalCell(ebosSimulator.vanguard().grid()));
ebosProblem.writeOutput(localWellData,
substepTimer.simulationTimeElapsed(),
/*isSubstep=*/true,
substepReport.total_time,
/*nextStepSize=*/-1.0);
report.output_write_time += perfTimer.secsSinceStart();
}