From aeb8807d890b2de37098da9f9b380e91fd01d108 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Tue, 24 Nov 2015 10:01:43 +0100 Subject: [PATCH 1/3] Use cell centroid from EclipseGrid The cell center in EclipseGrid is computed based on averaging the corners of the cells as in Eclipse and not computing the centroid of the cell as in the unstructured grid in opm. --- opm/autodiff/GeoProps.hpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/opm/autodiff/GeoProps.hpp b/opm/autodiff/GeoProps.hpp index 3e1722f2f..c10088a3a 100644 --- a/opm/autodiff/GeoProps.hpp +++ b/opm/autodiff/GeoProps.hpp @@ -125,7 +125,7 @@ namespace Opm tpfa_htrans_compute(ug, props.permeability(), htrans.data()); } else { - tpfa_loc_trans_compute_(grid,props.permeability(),htrans); + tpfa_loc_trans_compute_(grid,eclgrid, props.permeability(),htrans); } std::vector mult; @@ -191,6 +191,7 @@ namespace Opm template void tpfa_loc_trans_compute_(const Grid &grid, + Opm::EclipseGridConstPtr eclGrid, const double* perm, Vector &hTrans); @@ -338,6 +339,7 @@ namespace Opm template inline void DerivedGeology::tpfa_loc_trans_compute_(const GridType& grid, + Opm::EclipseGridConstPtr eclGrid, const double* perm, Vector& hTrans){ @@ -358,6 +360,7 @@ 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; @@ -388,11 +391,26 @@ namespace Opm const double* scaledFaceNormal = faceNormal; #endif + int cartesianCellIdx = AutoDiffGrid::globalCell(grid)[cellIdx]; + auto cellCentroid = eclGrid->getCellCenter(cartesianCellIdx); + for (int indx = 0; indx < dim; ++indx) { - const double Ci = Opm::UgGridHelpers::faceCentroid(grid, faceIdx)[indx] - - Opm::UgGridHelpers::cellCentroidCoordinate(grid, cellIdx, indx); + + double Ci = Opm::UgGridHelpers::faceCentroid(grid, faceIdx)[indx]; + switch (indx) { + case 0: + Ci -= std::get<0>(cellCentroid); + break; + case 1: + Ci -= std::get<1>(cellCentroid); + break; + case 2: + Ci -= std::get<2>(cellCentroid); + break; + + } dist += Ci*Ci; - cn += sgn * Ci * scaledFaceNormal[ indx ]; //Opm::UgGridHelpers::faceNormal(grid, faceIdx)[indx]; + cn += sgn * Ci * scaledFaceNormal[ indx ]; } if (cn < 0){ From 2a13275943ce887472ba21dd50dd5db08e654ba4 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Tue, 24 Nov 2015 10:06:05 +0100 Subject: [PATCH 2/3] Use cell depth calculated directly from the corners of the cell --- opm/autodiff/GeoProps.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/autodiff/GeoProps.hpp b/opm/autodiff/GeoProps.hpp index c10088a3a..d030d149c 100644 --- a/opm/autodiff/GeoProps.hpp +++ b/opm/autodiff/GeoProps.hpp @@ -143,7 +143,7 @@ namespace Opm // Compute z coordinates for (int c = 0; c Date: Wed, 25 Nov 2015 15:15:22 +0100 Subject: [PATCH 3/3] Adapt to changes in EclipseGrids getCellCenter() in EclipseGrid no longer returns tuble but array This simplifies its usage. Variable name is changed from cellCentroid to cellCenter to emphasize a difference between the value in the unstructured grid and in EclispeGrid --- opm/autodiff/GeoProps.hpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/opm/autodiff/GeoProps.hpp b/opm/autodiff/GeoProps.hpp index d030d149c..fa1d29af4 100644 --- a/opm/autodiff/GeoProps.hpp +++ b/opm/autodiff/GeoProps.hpp @@ -392,23 +392,11 @@ namespace Opm #endif int cartesianCellIdx = AutoDiffGrid::globalCell(grid)[cellIdx]; - auto cellCentroid = eclGrid->getCellCenter(cartesianCellIdx); + auto cellCenter = eclGrid->getCellCenter(cartesianCellIdx); for (int indx = 0; indx < dim; ++indx) { - double Ci = Opm::UgGridHelpers::faceCentroid(grid, faceIdx)[indx]; - switch (indx) { - case 0: - Ci -= std::get<0>(cellCentroid); - break; - case 1: - Ci -= std::get<1>(cellCentroid); - break; - case 2: - Ci -= std::get<2>(cellCentroid); - break; - - } + const double Ci = Opm::UgGridHelpers::faceCentroid(grid, faceIdx)[indx] - cellCenter[indx]; dist += Ci*Ci; cn += sgn * Ci * scaledFaceNormal[ indx ]; }