From 5a89598788ec57fc088e186d3aa14c093647d272 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 23 Jun 2016 22:15:05 +0200 Subject: [PATCH] Write TRAN? to the INIT file. --- opm/autodiff/SimulatorBase_impl.hpp | 56 ++++++++++++++++++- .../SimulatorFullyImplicitBlackoilOutput.cpp | 5 +- .../SimulatorFullyImplicitBlackoilOutput.hpp | 3 +- 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/opm/autodiff/SimulatorBase_impl.hpp b/opm/autodiff/SimulatorBase_impl.hpp index 77bf55833..4cfd22c79 100644 --- a/opm/autodiff/SimulatorBase_impl.hpp +++ b/opm/autodiff/SimulatorBase_impl.hpp @@ -19,6 +19,7 @@ along with OPM. If not, see . */ +#include #include #include #include @@ -109,7 +110,60 @@ namespace Opm adaptiveTimeStepping.reset( new AdaptiveTimeStepping( param_, terminal_output_ ) ); } - output_writer_.writeInit(); + + /// 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( )); + } std::string restorefilename = param_.getDefault("restorefile", std::string("") ); if( ! restorefilename.empty() ) diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp index e98e94c1b..6e7db7388 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.cpp @@ -247,14 +247,15 @@ namespace Opm void BlackoilOutputWriter:: - writeInit() + writeInit(const std::vector& simProps, const NNC& nnc) { if( eclWriter_ ) { - eclWriter_->writeInit(); + eclWriter_->writeInit(simProps, nnc); } } + namespace detail { struct WriterCall : public ThreadHandle :: ObjectInterface diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp index 895e8728b..dab72e36b 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -215,7 +216,7 @@ namespace Opm const double* permeability ); /** \copydoc Opm::OutputWriter::writeInit */ - void writeInit(); + void writeInit(const std::vector& simProps = {} , const NNC& = NNC()); /** \copydoc Opm::OutputWriter::writeTimeStep */ void writeTimeStep(const SimulatorTimerInterface& timer,