diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 6f59b156b..67c7c363b 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -153,7 +153,6 @@ list (APPEND PUBLIC_HEADER_FILES opm/autodiff/AutoDiffHelpers.hpp opm/autodiff/AutoDiffMatrix.hpp opm/autodiff/AutoDiff.hpp - opm/autodiff/BackupRestore.hpp opm/autodiff/BlackoilDetails.hpp opm/autodiff/BlackoilLegacyDetails.hpp opm/autodiff/BlackoilModel.hpp diff --git a/opm/autodiff/BackupRestore.hpp b/opm/autodiff/BackupRestore.hpp deleted file mode 100644 index 14dffb14e..000000000 --- a/opm/autodiff/BackupRestore.hpp +++ /dev/null @@ -1,321 +0,0 @@ -/* - Copyright 2014 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 . -*/ - -#ifndef OPM_BACKUPRESTORE_HEADER_INCLUDED -#define OPM_BACKUPRESTORE_HEADER_INCLUDED - -#include -#include - - -#include -#include - -namespace Opm { - - namespace { - template - void writeValue( std::ostream& stream, const T& value ) - { - stream.write( (const char *) &value, sizeof( T ) ); - } - - template - void readValue( std::istream& stream, T& value ) - { - stream.read( (char *) &value, sizeof( T ) ); - } - - // write any container that provides a size method and a data method - template - void writeContainer( std::ostream& stream, const Vector& vector) - { - typedef typename Vector :: value_type T; - unsigned int size = vector.size() * sizeof( T ); - writeValue( stream, size ); - if( size > 0 ) { - stream.write( (const char *) vector.data(), size ); - } - } - - // write map where the key is a std::string - // and the value is a std::vector or std::array - template - void writeMap( std::ostream& stream, const Map& m) - { - const unsigned int mapEntries = m.size(); - writeValue( stream, mapEntries ); - if( mapEntries > 0 ) - { - const auto& end = m.end(); - for(auto it = m.begin(); it != end; ++it ) - { - // write key (assume that key is a container) - writeContainer( stream, (*it).first ); - // write value (assume that value is a container) - writeContainer( stream, (*it).second ); - } - } - } - - template - void resizeContainer( Container& container, size_t size ) - { - container.resize( size ); - } - - template - void resizeContainer( std::array& /* a */, size_t size ) - { - static_cast(size); - assert( int(size) == int(n) ); - } - - template - void readData(std::istream& stream, Container& container, size_t datasize) - { - stream.read( reinterpret_cast( container.data() ), datasize ); - } - - //We need to be careful with string, because string.data() returns something that - //"A program shall not alter any of the characters in this sequence." - template <> - void readData(std::istream& stream, std::string& string, size_t datasize) - { - std::vector raw_data(datasize); - readData(stream, raw_data, datasize); - string = std::string(raw_data.data(), datasize); - } - - template - void readContainerImpl( std::istream& stream, Container& container, const bool adjustSize ) - { - typedef typename Container :: value_type T; - unsigned int dataSize = 0; - readValue( stream, dataSize ); - if( adjustSize && dataSize > 0 ) { - resizeContainer( container, dataSize/sizeof(T) ); - } - - if( dataSize != container.size() * sizeof( T ) ) - { - OPM_THROW(std::logic_error, - "Size of stored data and simulation data does not match " - << dataSize << " " << (container.size() * sizeof( T )) ); - } - if( dataSize > 0 ) { - readData(stream, container, dataSize); - } - } - - template - void readAndResizeContainer( std::istream& stream, Container& container ) - { - readContainerImpl( stream, container, true ); - } - - template - void readContainer( std::istream& stream, Container& container ) - { - readContainerImpl( stream, container, false ); - } - - template - void readMap( std::istream& stream, Map& m) - { - m.clear(); - unsigned int mapEntries = 0; - readValue( stream, mapEntries ); - for( unsigned int entry = 0; entry mapEntry; - // read key - readAndResizeContainer( stream, mapEntry.first ); - // read values - readContainer( stream, mapEntry.second ); - - // insert entry into map - m.insert( mapEntry ); - } - } - - enum { SimulatorStateId = 0, - WellStateId = 1, - WellStateFullyImplicitBackoilId = 3 }; - - inline int objectId( const SimulationDataContainer& /* state */) { - return SimulatorStateId; - } - - inline int objectId( const WellState& /* state */) { - return WellStateId; - } - - inline int objectId( const WellStateFullyImplicitBlackoil& /* state */) { - return WellStateFullyImplicitBackoilId; - } - - template - void checkObjectId( std::istream& in, const State& state ) - { - // read id and compare with object - int id = -1; - readValue( in, id ); - if( id != objectId( state ) ) { - OPM_THROW(std::logic_error,"backup-restore object type mismatch"); - } - } - } - - // SimulationDataContainer - inline - std::ostream& operator << (std::ostream& out, const SimulationDataContainer& state ) - { - // write id of object to stream - writeValue( out, objectId( state ) ); - - const int numPhases = state.numPhases(); - writeValue( out, numPhases ); - - // write variables - writeContainer( out, state.pressure() ); - writeContainer( out, state.temperature() ); - writeContainer( out, state.facepressure() ); - writeContainer( out, state.faceflux() ); - writeContainer( out, state.saturation() ); - - return out; - } - - inline - std::istream& operator >> (std::istream& in, SimulationDataContainer& state ) - { - // check id of stored object - checkObjectId( in, state ); - - int numPhases = 0; - readValue( in, numPhases ); - - if( numPhases != (int) state.numPhases() ) - OPM_THROW(std::logic_error,"num phases wrong"); - - // read variables - readContainer( in, state.pressure() ); - readContainer( in, state.temperature() ); - readContainer( in, state.facepressure() ); - readContainer( in, state.faceflux() ); - readContainer( in, state.saturation() ); - - return in; - } - - // WellState - inline - std::ostream& operator << (std::ostream& out, const WellState& state ) - { - // write id of object to stream - writeValue( out, objectId( state ) ); - - // backup well state - writeContainer( out, state.bhp() ); - writeContainer( out, state.temperature() ); - writeContainer( out, state.wellRates() ); - writeContainer( out, state.perfRates() ); - writeContainer( out, state.perfPress() ); - - return out; - } - - inline - std::istream& operator >> (std::istream& in, WellState& state ) - { - // check id of stored object - checkObjectId( in, state ); - - // restore well state - readAndResizeContainer( in, state.bhp() ); - readAndResizeContainer( in, state.temperature() ); - readAndResizeContainer( in, state.wellRates() ); - readAndResizeContainer( in, state.perfRates() ); - readAndResizeContainer( in, state.perfPress() ); - - return in; - } - - // WellStateFullyImplicitBlackoil - inline - std::ostream& operator << (std::ostream& out, const WellStateFullyImplicitBlackoil& state ) - { - // write id of object to stream - writeValue( out, objectId( state ) ); - - // backup well state - const WellState& wellState = static_cast< const WellState& > (state); - out << wellState; - - const int numWells = state.numWells(); - writeValue( out, numWells ); - if( numWells > 0 ) - { - const int numPhases = state.numPhases(); - writeValue( out, numPhases ); - - // backup additional variables - writeContainer( out, state.perfPhaseRates() ); - writeContainer( out, state.currentControls() ); - writeMap( out, state.wellMap() ); - } - - return out; - } - - inline - std::istream& operator >> (std::istream& in, WellStateFullyImplicitBlackoil& state ) - { - // check id of stored object - checkObjectId( in, state ); - - // restore well state - WellState& wellState = static_cast< WellState& > (state); - in >> wellState; - - int numWells = 0; - readValue( in, numWells ); - if( numWells != state.numWells() ) - OPM_THROW(std::logic_error,"wrong numWells"); - - if( numWells > 0 ) - { - int numPhases = 0; - readValue( in, numPhases ); - if( numPhases != state.numPhases() ) - OPM_THROW(std::logic_error,"wrong numPhases"); - - // restore additional variables - readAndResizeContainer( in, state.perfPhaseRates() ); - readAndResizeContainer( in, state.currentControls() ); - readMap( in, state.wellMap() ); - } - - return in; - } - -} // namespace Opm - -#endif // OPM_BACKUPRESTORE_HEADER_INCLUDED diff --git a/opm/autodiff/FlowMainEbos.hpp b/opm/autodiff/FlowMainEbos.hpp index d6e6581d8..9bf162223 100755 --- a/opm/autodiff/FlowMainEbos.hpp +++ b/opm/autodiff/FlowMainEbos.hpp @@ -360,7 +360,8 @@ namespace Opm strftime(tmstr, sizeof(tmstr), "%d-%m-%Y at %X", &tstruct); const double mem_size = getTotalSystemMemory() / megabyte; std::ostringstream ss; - ss << "\n\n\n ######## # ###### # #\n"; + ss << "\n\n\n"; + ss << " ######## # ###### # #\n"; ss << " # # # # # # \n"; ss << " ##### # # # # # # \n"; ss << " # # # # # # # # \n"; @@ -693,11 +694,6 @@ namespace Opm } } - if (output_to_files_) { - std::string filename = output_dir_ + "/walltime.txt"; - std::fstream tot_os(filename.c_str(), std::fstream::trunc | std::fstream::out); - successReport.reportParam(tot_os); - } } else { if (output_cout_) { std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush; @@ -730,7 +726,6 @@ namespace Opm *fis_solver_, FluidSystem::enableDissolvedGas(), FluidSystem::enableVaporizedOil(), - eclState(), *output_writer_)); } diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 47c4240c1..770bcfcf5 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -132,19 +132,6 @@ namespace Opm } } - std::string restorefilename = param_.getDefault("restorefile", std::string("") ); - if( ! restorefilename.empty() ) - { - // -1 means that we'll take the last report step that was written - const int desiredRestoreStep = param_.getDefault("restorestep", int(-1) ); - - output_writer_.restore( timer, - state, - prev_well_state, - restorefilename, - desiredRestoreStep ); - } - DynamicListEconLimited dynamic_list_econ_limited; SimulatorReport report; SimulatorReport stepReport; diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index 63d86dd33..505b407b5 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -98,7 +98,6 @@ public: NewtonIterationBlackoilInterface& linsolver, const bool has_disgas, const bool has_vapoil, - const EclipseState& /* eclState */, OutputWriter& output_writer) : ebosSimulator_(ebosSimulator), param_(param), @@ -122,6 +121,7 @@ public: is_parallel_run_ = ( info.communicator().size() > 1 ); } #endif + createLocalFipnum(); } /// Run the simulation. @@ -162,16 +162,8 @@ public: // Create timers and file for writing timing info. Opm::time::StopWatch solver_timer; - Opm::time::StopWatch step_timer; Opm::time::StopWatch total_timer; total_timer.start(); - std::string tstep_filename = output_writer_.outputDirectory() + "/step_timing.txt"; - std::ofstream tstep_os; - - if ( output_writer_.output() && output_writer_.isIORank() ) - { - tstep_os.open(tstep_filename.c_str()); - } // adaptive time stepping const auto& events = schedule().getEvents(); @@ -192,29 +184,9 @@ public: } } - std::string restorefilename = param_.getDefault("restorefile", std::string("") ); - if( ! restorefilename.empty() ) - { - // -1 means that we'll take the last report step that was written - const int desiredRestoreStep = param_.getDefault("restorestep", int(-1) ); - - output_writer_.restore( timer, - state, - prev_well_state, - restorefilename, - desiredRestoreStep ); - initHydroCarbonState(state, phaseUsage_, Opm::UgGridHelpers::numCells(grid()), has_disgas_, has_vapoil_); - initHysteresisParams(state); - // communicate the restart solution to ebos - convertInput(0, state, ebosSimulator_); - ebosSimulator_.model().invalidateIntensiveQuantitiesCache(/*timeIdx=*/0); - } - SimulatorReport report; SimulatorReport stepReport; - createLocalFipnum(); - WellModel well_model(ebosSimulator_, model_param_, terminal_output_); if (output_writer_.isRestart()) { well_model.setRestartWellState(prev_well_state); // Neccessary for perfect restarts @@ -225,7 +197,6 @@ public: // Main simulation loop. while (!timer.done()) { // Report timestep. - step_timer.start(); if ( terminal_output_ ) { std::ostringstream ss; @@ -321,11 +292,6 @@ public: // update timing. report.solver_time += solver_timer.secsSinceStart(); - if ( output_writer_.output() && output_writer_.isIORank() ) - { - stepReport.reportParam(tstep_os); - } - // We don't need the reservoir state anymore. It is just passed around to avoid // code duplication. Pass empty state instead. if (timer.initialStep()) { diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp index 58c79cc16..3dec4af6a 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp @@ -34,7 +34,6 @@ #include #include -#include #include #include @@ -351,107 +350,6 @@ namespace Opm restart_double_si_); } } - - // write backup file - if( backupfile_.is_open() ) - { - int reportStep = timer.reportStepNum(); - int currentTimeStep = timer.currentStepNum(); - if( (reportStep == currentTimeStep || // true for SimulatorTimer - currentTimeStep == 0 || // true for AdaptiveSimulatorTimer at reportStep - timer.done() ) // true for AdaptiveSimulatorTimer at reportStep - && lastBackupReportStep_ != reportStep ) // only backup report step once - { - // store report step - lastBackupReportStep_ = reportStep; - // write resport step number - backupfile_.write( (const char *) &reportStep, sizeof(int) ); - - try { - backupfile_ << state; - - const WellStateFullyImplicitBlackoil& boWellState = static_cast< const WellStateFullyImplicitBlackoil& > (wellState); - backupfile_ << boWellState; - } - catch ( const std::bad_cast& e ) - { - } - - backupfile_ << std::flush; - } - } // end backup - } - - void - BlackoilOutputWriter:: - restore(SimulatorTimerInterface& timer, - BlackoilState& state, - WellStateFullyImplicitBlackoil& wellState, - const std::string& filename, - const int desiredResportStep ) - { - std::ifstream restorefile( filename.c_str() ); - if( restorefile ) - { - std::cout << "============================================================================"<isIORank(); } - void restore(SimulatorTimerInterface& timer, - BlackoilState& state, - WellStateFullyImplicitBlackoil& wellState, - const std::string& filename, - const int desiredReportStep); - - template void initFromRestartFile(const PhaseUsage& phaseUsage, const Grid& grid, @@ -315,9 +308,6 @@ namespace Opm const std::string outputDir_; const bool restart_double_si_; - int lastBackupReportStep_; - - std::ofstream backupfile_; Opm::PhaseUsage phaseUsage_; std::unique_ptr< BlackoilSubWriter > vtkWriter_; std::unique_ptr< BlackoilSubWriter > matlabWriter_; @@ -354,7 +344,6 @@ namespace Opm parallelOutput_( output_ ? new ParallelDebugOutput< Grid >( grid, eclipseState, schedule, phaseUsage.num_phases, phaseUsage ) : 0 ), outputDir_( eclipseState.getIOConfig().getOutputDir() ), restart_double_si_( output_ ? param.getDefault("restart_double_si", false) : false ), - lastBackupReportStep_( -1 ), phaseUsage_( phaseUsage ), eclipseState_(eclipseState), schedule_(schedule), @@ -390,12 +379,6 @@ namespace Opm // Ensure that output dir exists ensureDirectoryExists(outputDir_); - - std::string backupfilename = param.getDefault("backupfile", std::string("") ); - if( ! backupfilename.empty() ) - { - backupfile_.open( backupfilename.c_str() ); - } } // create output thread if enabled and rank is I/O rank