Store the nncs in geoprops

This commit is contained in:
Tor Harald Sandve 2015-12-08 10:20:25 +01:00
parent cb3ed9aa4f
commit 99ddc46318
3 changed files with 37 additions and 29 deletions

View File

@ -23,7 +23,11 @@
#include <opm/autodiff/AutoDiffBlock.hpp>
#include <opm/autodiff/GridHelpers.hpp>
#include <opm/autodiff/GeoProps.hpp>
#include <opm/core/grid.h>
#include <opm/core/grid/PinchProcessor.hpp>
#include <opm/core/props/rock/RockFromDeck.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
@ -69,7 +73,7 @@ struct HelperOps
/// Constructs all helper vectors and matrices.
template<class Grid>
HelperOps(const Grid& grid, Opm::EclipseStateConstPtr eclState = EclipseStateConstPtr () )
HelperOps(const Grid& grid, const NNC& nnc = NNC())
{
using namespace AutoDiffGrid;
const int nc = numCells(grid);
@ -78,39 +82,33 @@ struct HelperOps
TwoColInt nbi;
extractInternalFaces(grid, internal_faces, nbi);
int num_internal = internal_faces.size();
// num_connections may also include non-neighboring connections
int num_connections = num_internal;
int numNNC = 0;
const int num_internal = internal_faces.size();
// handle non-neighboring connections
std::shared_ptr<const NNC> nnc = eclState ? eclState->getNNC()
: std::shared_ptr<const Opm::NNC>();
const bool has_nnc = nnc && nnc->hasNNC();
const bool has_nnc = nnc.hasNNC();
size_t numNNC = nnc.numNNC();
// num_connections may also include non-neighboring connections
const int num_connections = num_internal + numNNC;
if (has_nnc) {
numNNC = nnc->numNNC();
num_connections += numNNC;
//std::cout << "Added " << numNNC << " NNC" <<std::endl;
nbi.resize(num_internal, 2);
const int *cartDims = AutoDiffGrid::cartDims(grid);
const int numCartesianCells = cartDims[0] * cartDims[1] * cartDims[2];
// the nnc's acts on global indicies and must be mapped to cell indicies
size_t cartesianSize = eclState->getEclipseGrid()->getCartesianSize();
std::vector<int> global2localIdx(cartesianSize,0);
std::vector<int> global2localIdx(numCartesianCells,0);
for (int i = 0; i< nc; ++i) {
global2localIdx[ globalCell( grid )[i] ] = i;
}
const std::vector<size_t>& NNC1 = nnc->nnc1();
const std::vector<size_t>& NNC2 = nnc->nnc2();
const std::vector<size_t>& NNC1 = nnc.nnc1();
const std::vector<size_t>& NNC2 = nnc.nnc2();
nnc_cells.resize(numNNC,2);
nnc_trans.resize(numNNC);
for (int i = 0; i < numNNC; ++i) {
nnc_cells(i,0) = global2localIdx[NNC1[i]];
nnc_cells(i,1) = global2localIdx[NNC2[i]];
// store the nnc transmissibilities for later usage.
nnc_trans(i) = nnc.trans()[i];
}
// store the nnc transmissibilities for later usage.
nnc_trans = Eigen::Map<const V>(nnc->trans().data(), numNNC);
} else {
nnc_trans.resize(0);
nnc_cells.resize(0, 2); // Required to have two columns.
}
@ -166,7 +164,6 @@ struct HelperOps
fulldiv = fullngrad.transpose();
}
};
// -------------------- upwinding helper class --------------------

View File

@ -163,7 +163,7 @@ namespace detail {
, active_(detail::activePhases(fluid.phaseUsage()))
, canph_ (detail::active2Canonical(fluid.phaseUsage()))
, cells_ (detail::buildAllCells(Opm::AutoDiffGrid::numCells(grid)))
, ops_ (grid, eclState)
, ops_ (grid, geo.nnc())
, wops_ (wells_)
, has_disgas_(has_disgas)
, has_vapoil_(has_vapoil)

View File

@ -28,6 +28,7 @@
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <Eigen/Eigen>
@ -101,10 +102,9 @@ namespace Opm
ntg = eclState->getDoubleGridProperty("NTG")->getData();
}
// get grid from parser.
// Get original grid cell volume.
// Get grid from parser.
EclipseGridConstPtr eclgrid = eclState->getEclipseGrid();
// Pore volume.
// New keywords MINPVF will add some PV due to OPM cpgrid process algorithm.
// But the default behavior is to get the comparable pore volume with ECLIPSE.
@ -142,6 +142,12 @@ namespace Opm
std::vector<double> mult;
multiplyHalfIntersections_(grid, eclState, ntg, htrans, mult);
// Handle NNCs
std::shared_ptr<const NNC> nnc_deck = eclState ? eclState->getNNC()
: std::shared_ptr<const Opm::NNC>();
NNC nnc (*nnc_deck);
nnc_ = nnc;
// combine the half-face transmissibilites into the final face
// transmissibilites.
tpfa_trans_compute(ug, htrans.data(), trans_.data());
@ -191,6 +197,7 @@ namespace Opm
const double* gravity() const { return gravity_;}
Vector& poreVolume() { return pvol_ ;}
Vector& transmissibility() { return trans_ ;}
const NNC& nnc() const { return nnc_;}
private:
template <class Grid>
@ -218,6 +225,13 @@ namespace Opm
double gravity_[3]; // Size 3 even if grid is 2-dim.
bool use_local_perm_;
/// Non-neighboring connections
NNC nnc_;
};
template <class GridType>
@ -369,7 +383,6 @@ namespace Opm
for(auto cellFaceIter = cellFacesRange.begin(), cellFaceEnd = cellFacesRange.end();
cellFaceIter != cellFaceEnd; ++cellFaceIter, ++cellFaceIdx)
{
// The index of the face in the compressed grid
const int faceIdx = *cellFaceIter;
@ -402,9 +415,7 @@ namespace Opm
int cartesianCellIdx = AutoDiffGrid::globalCell(grid)[cellIdx];
auto cellCenter = eclGrid->getCellCenter(cartesianCellIdx);
for (int indx = 0; indx < dim; ++indx) {
const double Ci = Opm::UgGridHelpers::faceCentroid(grid, faceIdx)[indx] - cellCenter[indx];
dist += Ci*Ci;
cn += sgn * Ci * scaledFaceNormal[ indx ];