Skip to content

Commit

Permalink
Merge pull request #411 from joakim-hove/use-tskille-volume
Browse files Browse the repository at this point in the history
Use volume calculation provided by tskille
  • Loading branch information
joakim-hove authored May 29, 2018
2 parents e4063ce + a57f7d0 commit 3a9e9eb
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 146 deletions.
5 changes: 0 additions & 5 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,6 @@ add_test(NAME ecl_grid_cell_contains_wellpath1
${_eclpath}/CellContains/model/SMS-0.EGRID
${_eclpath}/CellContains/R_PB-4H.jira)

add_executable(ecl_grid_cell_volume ecl/tests/ecl_grid_cell_volume.c)
target_link_libraries(ecl_grid_cell_volume ecl)
add_test(NAME ecl_grid_cell_volume1 COMMAND ecl_grid_cell_volume)
add_test(NAME ecl_grid_cell_volume2 COMMAND ecl_grid_cell_volume ${_eclpath}/Gurbat/ECLIPSE.EGRID)
add_test(NAME ecl_grid_cell_volume3 COMMAND ecl_grid_cell_volume ${_eclpath}/Heidrun/Summary/FF12_2013B3_CLEAN_RS.EGRID)

add_executable(ecl_region2region ecl/tests/ecl_region2region_test.c)
target_link_libraries(ecl_region2region ecl)
Expand Down
84 changes: 1 addition & 83 deletions lib/ecl/ecl_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ static double C(double *r,int f1,int f2,int f3){
}


static double ecl_cell_get_volume_tskille( ecl_cell_type * cell ) {
static double ecl_cell_get_volume( ecl_cell_type * cell ) {
double volume = 0;
int pb,pg,qa,qg,ra,rb;
double X[8];
Expand Down Expand Up @@ -1269,79 +1269,6 @@ static bool tetrahedron_contains(tetrahedron_type tet, const point_type p) {
return (fabs(tetra_volume - decomposition_volume) < epsilon);
}

/*
* This function used to account for a significant amount of execution time
* when used in opm-parser and has been optimised significantly. This means
* inlining several operations, e.g. vector operations, and other tricks.
*/
static double ecl_cell_get_signed_volume( ecl_cell_type * cell) {
if (GET_CELL_FLAG(cell , CELL_FLAG_VOLUME))
return cell->volume;

ecl_cell_assert_center( cell );
{
/*
* We make an activation record local copy of the cell's corners for less
* jumping in memory and better cache performance.
*/
point_type center = cell->center;
point_type corners[ 8 ];
memcpy( corners, cell->corner_list, sizeof( point_type ) * 8 );

tetrahedron_type tet;
tet.p0 = center;
double volume = 0;
/*
using both tetrahedron decompositions - gives good agreement
with porv from eclipse init files.
*/

/*
* The order of these loops is intentional and guided by profiling. It's much
* faster to access method, then the number, rather than the other way
* around. If you are to change this, please measure performance impact.
*/
for( int method = 0; method < 2; ++method ) {
for( int itet = 0; itet < 12; ++itet ) {
const int point0 = tetrahedron_permutations[ method ][ itet ][ 0 ];
const int point1 = tetrahedron_permutations[ method ][ itet ][ 1 ];
const int point2 = tetrahedron_permutations[ method ][ itet ][ 2 ];

tet.p1 = corners[ point0 ];
tet.p2 = corners[ point1 ];
tet.p3 = corners[ point2 ];
volume += tetrahedron_volume6( tet ) / 6;
}
}

/* The volume of a tetrahedron is
* |a·(b x c)|
* V = -----------
* 6
* Since sum( |a·(b x c)| ) / 6 is equal to
* sum( |a·(b x c)| / 6 ) we can do the (rather expensive) division only once
* and still get the correct result. We multiply by 0.5 because we've now
* considered two decompositions of the tetrahedron, and want their average.
*
*
* Note added: these volume calculations are used to calculate pore
* volumes in OPM, it turns out that opm is very sensitive to these
* volumes. Extracting the divison by 6.0 was actually enough to
* induce a regression test failure in flow, this has therefore been
* reverted.
*/

cell->volume = volume * 0.5;
SET_CELL_FLAG( cell , CELL_FLAG_VOLUME );
}
return cell->volume;
}


static double ecl_cell_get_volume( ecl_cell_type * cell ) {
return fabs( ecl_cell_get_signed_volume(cell));
}




Expand Down Expand Up @@ -5389,15 +5316,6 @@ double ecl_grid_get_cell_volume1A( const ecl_grid_type * ecl_grid, int active_in



double ecl_grid_get_cell_volume1_tskille( const ecl_grid_type * ecl_grid, int global_index ) {
ecl_cell_type * cell = ecl_grid_get_cell( ecl_grid , global_index );
return ecl_cell_get_volume_tskille( cell );
}





double ecl_grid_get_cell_volume3( const ecl_grid_type * ecl_grid, int i , int j , int k) {
int global_index = ecl_grid_get_global_index3( ecl_grid , i , j , k);
return ecl_grid_get_cell_volume1( ecl_grid , global_index );
Expand Down
57 changes: 0 additions & 57 deletions lib/ecl/tests/ecl_grid_cell_volume.c

This file was deleted.

1 change: 0 additions & 1 deletion lib/include/ert/ecl/ecl_grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ extern "C" {
bool ecl_grid_cell_contains_xyz1( const ecl_grid_type * ecl_grid , int global_index , double x , double y , double z);
bool ecl_grid_cell_contains_xyz3( const ecl_grid_type * ecl_grid , int i , int j , int k, double x , double y , double z );
double ecl_grid_get_cell_volume1( const ecl_grid_type * ecl_grid, int global_index );
double ecl_grid_get_cell_volume1_tskille( const ecl_grid_type * ecl_grid, int global_index );
double ecl_grid_get_cell_volume3( const ecl_grid_type * ecl_grid, int i , int j , int k);
double ecl_grid_get_cell_volume1A( const ecl_grid_type * ecl_grid, int active_index );
bool ecl_grid_cell_contains1(const ecl_grid_type * grid , int global_index , double x , double y , double z);
Expand Down

0 comments on commit 3a9e9eb

Please sign in to comment.