Introducing NNC output

* Compute NNC by face2cell information from a grid
* Pass NNC information to EclipseWriter
* Made NNC respect ECLIPSE input data
* nncStructure() is now exportNncStructure()
This commit is contained in:
Pål Grønås Drange 2016-05-03 10:12:29 +02:00
parent 1f4b9e56f8
commit 973914931d
5 changed files with 59 additions and 9 deletions

View File

@ -252,9 +252,57 @@ namespace Opm
#endif #endif
} }
/// checks cartesian adjacency of global indices g1 and g2
bool cartesianAdjacent(const Grid& grid, int g1, int g2) {
// we need cartDims from UgGridHelpers
using namespace UgGridHelpers;
int diff = std::abs(g1 - g2);
const int * dimens = cartDims(grid);
if (diff == 1)
return true;
if (diff == dimens[0])
return true;
if (diff == dimens[0] * dimens[1])
return true;
return false;
}
/// Write the NNC structure of the given grid to NNC.
///
/// Write cell adjacencies beyond Cartesian neighborhoods to NNC.
///
/// The trans vector is indexed by face number as it is in grid.
void exportNncStructure(NNC& nnc, const Grid& grid, const std::vector<double>& trans) {
// we use numFaces, numCells, cell2Faces, globalCell from UgGridHelpers
using namespace UgGridHelpers;
size_t num_faces = numFaces(grid);
if (trans.size() > 0 && trans.size() != num_faces) {
throw std::logic_error(
"non-empty trans vector with wrong dimension.");
}
auto fc = faceCells(grid);
for (size_t i = 0; i < num_faces; ++i) {
auto c1 = fc(i, 0);
auto c2 = fc(i, 1);
if (c1 == -1 || c2 == -1)
continue; // face on grid boundary
// translate from active cell idx (ac1,ac2) to global cell idx
c1 = globalCell(grid) ? globalCell(grid)[c1] : c1;
c2 = globalCell(grid) ? globalCell(grid)[c2] : c2;
if (!cartesianAdjacent(grid, c1, c2)) {
// suppose c1,c2 is specified in ECLIPSE input
// we here overwrite its trans by grid's
nnc.addNNC(c1, c2, trans[i]);
}
}
}
// Print startup message if on output rank. // Print startup message if on output rank.
void printStartupMessage() void printStartupMessage()
@ -676,7 +724,8 @@ namespace Opm
const auto initConfig = eclipse_state_->getInitConfig(); const auto initConfig = eclipse_state_->getInitConfig();
simtimer.init(timeMap, (size_t)initConfig->getRestartStep()); simtimer.init(timeMap, (size_t)initConfig->getRestartStep());
Opm::NNC nnc = eclipse_state_->getNNC(); // copy, otherwise we write to ecl_state
exportNncStructure(nnc, grid_init_->grid(), trans_);
if (!schedule->initOnly()) { if (!schedule->initOnly()) {
if (output_cout_) { if (output_cout_) {
@ -704,10 +753,11 @@ namespace Opm
fullReport.reportParam(tot_os); fullReport.reportParam(tot_os);
} }
} else { } else {
output_writer_->writeInit( simtimer ); output_writer_->writeInit( simtimer, geoprops_->nnc() );
if (output_cout_) { if (output_cout_) {
std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush; std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush;
} }
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -110,7 +110,7 @@ namespace Opm
} }
// init output writer // init output writer
output_writer_.writeInit( timer ); output_writer_.writeInit( timer, geo_.nnc() );
std::string restorefilename = param_.getDefault("restorefile", std::string("") ); std::string restorefilename = param_.getDefault("restorefile", std::string("") );
if( ! restorefilename.empty() ) if( ! restorefilename.empty() )

View File

@ -74,7 +74,7 @@ namespace Opm
} }
// init output writer // init output writer
output_writer_.writeInit( timer ); output_writer_.writeInit( timer, geo_.nnc());
std::string restorefilename = param_.getDefault("restorefile", std::string("") ); std::string restorefilename = param_.getDefault("restorefile", std::string("") );
if( ! restorefilename.empty() ) if( ! restorefilename.empty() )

View File

@ -246,10 +246,10 @@ namespace Opm
void void
BlackoilOutputWriter:: BlackoilOutputWriter::
writeInit(const SimulatorTimerInterface& timer) writeInit(const SimulatorTimerInterface& timer, const NNC& nnc)
{ {
if( eclWriter_ ) { if( eclWriter_ ) {
eclWriter_->writeInit(timer); eclWriter_->writeInit(timer, nnc);
} }
} }

View File

@ -153,7 +153,7 @@ namespace Opm
{} {}
/** \copydoc Opm::OutputWriter::writeInit */ /** \copydoc Opm::OutputWriter::writeInit */
void writeInit(const SimulatorTimerInterface& /* timer */) void writeInit(const SimulatorTimerInterface& /* timer */, const NNC& nnc)
{} {}
/** \copydoc Opm::OutputWriter::writeTimeStep */ /** \copydoc Opm::OutputWriter::writeTimeStep */
@ -183,7 +183,7 @@ namespace Opm
{} {}
/** \copydoc Opm::OutputWriter::writeInit */ /** \copydoc Opm::OutputWriter::writeInit */
void writeInit(const SimulatorTimerInterface& /* timer */) void writeInit(const SimulatorTimerInterface& /* timer */, const NNC& nnc)
{} {}
/** \copydoc Opm::OutputWriter::writeTimeStep */ /** \copydoc Opm::OutputWriter::writeTimeStep */
@ -214,7 +214,7 @@ namespace Opm
const double* permeability ); const double* permeability );
/** \copydoc Opm::OutputWriter::writeInit */ /** \copydoc Opm::OutputWriter::writeInit */
void writeInit(const SimulatorTimerInterface &timer); void writeInit(const SimulatorTimerInterface &timer, const NNC& nnc);
/** \copydoc Opm::OutputWriter::writeTimeStep */ /** \copydoc Opm::OutputWriter::writeTimeStep */
void writeTimeStep(const SimulatorTimerInterface& timer, void writeTimeStep(const SimulatorTimerInterface& timer,