From e262d0da68208e123b9fe7f1439cfbcbb44409e6 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 24 Jun 2016 16:17:32 +0200 Subject: [PATCH] Renamed writeInit -> writeInitAndEgrid( ) --- opm/autodiff/FlowMain.hpp | 2 +- opm/autodiff/GeoProps.hpp | 66 +++++++++++++++++++ opm/autodiff/SimulatorBase_impl.hpp | 53 +-------------- ...FullyImplicitBlackoilMultiSegment_impl.hpp | 2 +- .../SimulatorFullyImplicitBlackoilOutput.cpp | 2 +- .../SimulatorFullyImplicitBlackoilOutput.hpp | 2 +- 6 files changed, 71 insertions(+), 56 deletions(-) diff --git a/opm/autodiff/FlowMain.hpp b/opm/autodiff/FlowMain.hpp index 3b9fcf5f6..810f275a1 100644 --- a/opm/autodiff/FlowMain.hpp +++ b/opm/autodiff/FlowMain.hpp @@ -746,7 +746,7 @@ namespace Opm fullReport.reportParam(tot_os); } } else { - output_writer_->writeInit(); + output_writer_->writeInit(geoprops_->simProps(grid_init_->grid()) , geoprops_->nonCartesianConnections( )); if (output_cout_) { std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush; } diff --git a/opm/autodiff/GeoProps.hpp b/opm/autodiff/GeoProps.hpp index 68b078f46..884b731fd 100644 --- a/opm/autodiff/GeoProps.hpp +++ b/opm/autodiff/GeoProps.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -218,6 +219,71 @@ namespace Opm const NNC& nnc() const { return nnc_;} const NNC& nonCartesianConnections() const { return noncartesian_;} + + /// Most properties are loaded by the parser, and managed by + /// the EclipseState class in the opm-parser. However - some + /// properties must be calculated by the simulator, the + /// purpose of this method is to calculate these properties in + /// a form suitable for output. Currently the transmissibility + /// is the only property calculated this way: + /// + /// The grid properties TRANX, TRANY and TRANZ are initialized + /// in a form suitable for writing to the INIT file. These + /// properties should be interpreted with a + /// 'the-grid-is-nearly-cartesian' mindset: + /// + /// TRANX[i,j,k] = T on face between cells (i,j,k) and (i+1,j ,k ) + /// TRANY[i,j,k] = T on face between cells (i,j,k) and (i ,j+1,k ) + /// TRANZ[i,j,k] = T on face between cells (i,j,k) and (i ,j ,k+1) + /// + /// If the grid structure has no resemblance to a cartesian + /// grid the whole TRAN keyword is quite meaningless. + + template + const std::vector simProps( const Grid& grid ) const { + using namespace UgGridHelpers; + const int* dims = cartDims( grid ); + const int globalSize = dims[0] * dims[1] * dims[2]; + const auto& trans = this->transmissibility( ); + + data::CellData tranx = {"TRANX" , UnitSystem::measure::transmissibility, std::vector( globalSize )}; + data::CellData trany = {"TRANY" , UnitSystem::measure::transmissibility, std::vector( globalSize )}; + data::CellData tranz = {"TRANZ" , UnitSystem::measure::transmissibility, std::vector( globalSize )}; + + size_t num_faces = numFaces(grid); + auto fc = faceCells(grid); + for (size_t i = 0; i < num_faces; ++i) { + auto c1 = std::min( fc(i,0) , fc(i,1)); + auto c2 = std::max( fc(i,0) , fc(i,1)); + + if (c1 == -1 || c2 == -1) + continue; + + c1 = globalCell(grid) ? globalCell(grid)[c1] : c1; + c2 = globalCell(grid) ? globalCell(grid)[c2] : c2; + + if ((c2 - c1) == 1) { + tranx.data[c1] = trans[i]; + } + + if ((c2 - c1) == dims[0]) { + trany.data[c1] = trans[i]; + } + + if ((c2 - c1) == dims[0]*dims[1]) { + tranz.data[c1] = trans[i]; + } + } + + std::vector tran; + tran.push_back( std::move( tranx )); + tran.push_back( std::move( trany )); + tran.push_back( std::move( tranz )); + + return tran; + } + + private: template void multiplyHalfIntersections_(const Grid &grid, diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 4cfd22c79..ac92c1557 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -111,59 +111,8 @@ namespace Opm } - /// This code block is used to initialize grid properties TRANX, TRANY - /// and TRANZ which will be written to the INIT file. These properties - /// should be interpreted with a 'the-grid-is-nearly-cartesian' - /// mindset: - /// - /// TRANX[i,j,k] = T on face between cells (i,j,k) and (i+1,j ,k ) - /// TRANY[i,j,k] = T on face between cells (i,j,k) and (i ,j+1,k ) - /// TRANZ[i,j,k] = T on face between cells (i,j,k) and (i ,j ,k+1) - /// - /// If the grid structure has no resemblance to a cartesian grid the - /// whole TRAN keyword is quite meaningless. - { - using namespace UgGridHelpers; - const int* dims = cartDims( grid_ ); - const int globalSize = dims[0] * dims[1] * dims[2]; - const auto& trans = geo_.transmissibility( ); - - data::CellData tranx = {"TRANX" , UnitSystem::measure::transmissibility, std::vector( globalSize )}; - data::CellData trany = {"TRANY" , UnitSystem::measure::transmissibility, std::vector( globalSize )}; - data::CellData tranz = {"TRANZ" , UnitSystem::measure::transmissibility, std::vector( globalSize )}; - - size_t num_faces = numFaces(grid_); - auto fc = faceCells(grid_); - for (size_t i = 0; i < num_faces; ++i) { - auto c1 = std::min( fc(i,0) , fc(i,1)); - auto c2 = std::max( fc(i,0) , fc(i,1)); - - if (c1 == -1 || c2 == -1) - continue; - - c1 = globalCell(grid_) ? globalCell(grid_)[c1] : c1; - c2 = globalCell(grid_) ? globalCell(grid_)[c2] : c2; - - if ((c2 - c1) == 1) { - tranx.data[c1] = trans[i]; - } - - if ((c2 - c1) == dims[0]) { - trany.data[c1] = trans[i]; - } - - if ((c2 - c1) == dims[0]*dims[1]) { - tranz.data[c1] = trans[i]; - } - } - - std::vector tran; - tran.push_back( std::move( tranx )); - tran.push_back( std::move( trany )); - tran.push_back( std::move( tranz )); - output_writer_.writeInit( tran , geo_.nonCartesianConnections( )); - } + output_writer_.writeInit( geo_.simProps(grid_) , geo_.nonCartesianConnections( ) ); std::string restorefilename = param_.getDefault("restorefile", std::string("") ); if( ! restorefilename.empty() ) diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp index 5e20fff11..ec9821b48 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilMultiSegment_impl.hpp @@ -73,7 +73,7 @@ namespace Opm } // init output writer - output_writer_.writeInit(); + output_writer_.writeInit( geo_.simProps(grid_) , geo_.nonCartesianConnections( ) ); std::string restorefilename = param_.getDefault("restorefile", std::string("") ); if( ! restorefilename.empty() ) diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp index 6e7db7388..fc0581fb9 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp @@ -250,7 +250,7 @@ namespace Opm writeInit(const std::vector& simProps, const NNC& nnc) { if( eclWriter_ ) { - eclWriter_->writeInit(simProps, nnc); + eclWriter_->writeInitAndEgrid(simProps, nnc); } } diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp index dab72e36b..c5bd51499 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp @@ -216,7 +216,7 @@ namespace Opm const double* permeability ); /** \copydoc Opm::OutputWriter::writeInit */ - void writeInit(const std::vector& simProps = {} , const NNC& = NNC()); + void writeInit(const std::vector& simProps, const NNC& nnc); /** \copydoc Opm::OutputWriter::writeTimeStep */ void writeTimeStep(const SimulatorTimerInterface& timer,