Added functionality to "fix" ZCORN problems.
This commit is contained in:
@@ -698,11 +698,17 @@ namespace Opm {
|
||||
ecl_grid_init_coord_data_double( c_ptr() , coord.data() );
|
||||
}
|
||||
|
||||
void EclipseGrid::exportZCORN( std::vector<double>& zcorn) const {
|
||||
size_t EclipseGrid::exportZCORN( std::vector<double>& zcorn) const {
|
||||
ZcornMapper mapper( getNX(), getNY(), getNZ());
|
||||
|
||||
zcorn.resize( ecl_grid_get_zcorn_size( c_ptr() ));
|
||||
ecl_grid_init_zcorn_data_double( c_ptr() , zcorn.data() );
|
||||
|
||||
return mapper.fixupZCORN( zcorn );
|
||||
}
|
||||
|
||||
|
||||
|
||||
const std::vector<int>& EclipseGrid::getActiveMap() const {
|
||||
if( !this->activeMap.empty() ) return this->activeMap;
|
||||
|
||||
@@ -766,6 +772,32 @@ namespace Opm {
|
||||
|
||||
return index(i,j,k,c);
|
||||
}
|
||||
|
||||
size_t ZcornMapper::fixupZCORN( std::vector<double>& zcorn, int sign, size_t i, size_t j, size_t k , size_t c) {
|
||||
size_t index1 = this->index(i,j,k,c);
|
||||
size_t index2 = this->index(i,j,k,c+4);
|
||||
|
||||
if ((zcorn[index2] - zcorn[index1]) * sign < 0 ) {
|
||||
zcorn[index2] = zcorn[index1];
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
size_t ZcornMapper::fixupZCORN( std::vector<double>& zcorn) {
|
||||
int sign = zcorn[ this->index(0,0,0,0) ] <= zcorn[this->index(0,0, this->dims[2] - 1,4)] ? 1 : -1;
|
||||
size_t cells_adjusted = 0;
|
||||
|
||||
for (size_t k=0; k < this->dims[2]; k++)
|
||||
for (size_t j=0; j < this->dims[1]; j++)
|
||||
for (size_t i=0; i < this->dims[0]; i++)
|
||||
for (size_t c=0; c < 4; c++)
|
||||
cells_adjusted += this->fixupZCORN( zcorn , sign, i , j , k , c );
|
||||
|
||||
return cells_adjusted;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -154,10 +154,15 @@ namespace Opm {
|
||||
double getCellDepth(size_t globalIndex) const;
|
||||
ZcornMapper zcornMapper() const;
|
||||
|
||||
/*
|
||||
The exportZCORN method will adjust the z coordinates to ensure that cells do not
|
||||
overlap. The return value is the number of points which have been adjusted.
|
||||
*/
|
||||
size_t exportZCORN( std::vector<double>& zcorn) const;
|
||||
|
||||
|
||||
void exportMAPAXES( std::vector<double>& mapaxes) const;
|
||||
void exportCOORD( std::vector<double>& coord) const;
|
||||
void exportZCORN( std::vector<double>& zcorn) const;
|
||||
void exportACTNUM( std::vector<int>& actnum) const;
|
||||
void resetACTNUM( const int * actnum);
|
||||
bool equal(const EclipseGrid& other) const;
|
||||
@@ -220,6 +225,23 @@ namespace Opm {
|
||||
size_t index(size_t i, size_t j, size_t k, int c) const;
|
||||
size_t index(size_t g, int c) const;
|
||||
|
||||
/*
|
||||
The fixupZCORN method will take a zcorn vector as input and
|
||||
run through it. If the following situation is detected:
|
||||
|
||||
/| /|
|
||||
/ | / |
|
||||
/ | / |
|
||||
/ | / |
|
||||
/ | ==> / |
|
||||
/ | / |
|
||||
---/------x /---------x
|
||||
| /
|
||||
|/
|
||||
|
||||
*/
|
||||
size_t fixupZCORN( std::vector<double>& zcorn);
|
||||
size_t fixupZCORN( std::vector<double>& zcorn, int sign, size_t, size_t , size_t k , size_t c);
|
||||
private:
|
||||
std::array<size_t,3> dims;
|
||||
std::array<size_t,3> stride;
|
||||
|
||||
@@ -1057,6 +1057,17 @@ BOOST_AUTO_TEST_CASE(ZcornMapper) {
|
||||
BOOST_CHECK_EQUAL( zmp.index(g , c) , zmp.index( i,j,k,c));
|
||||
BOOST_CHECK_EQUAL( zmp.index(i,j,k,c) , ecl_grid_zcorn_index( ert_grid, i , j , k, c));
|
||||
}
|
||||
|
||||
std::vector<double> zcorn;
|
||||
auto points_adjusted = grid.exportZCORN( zcorn );
|
||||
BOOST_CHECK_EQUAL( points_adjusted , 0 );
|
||||
|
||||
/* Manually destroy it */
|
||||
zcorn[ zmp.index(0,0,0,4) ] = zcorn[ zmp.index(0,0,0,0) ] - 1;
|
||||
|
||||
points_adjusted = zmp.fixupZCORN( zcorn );
|
||||
BOOST_CHECK_EQUAL( points_adjusted , 1 );
|
||||
BOOST_CHECK_EQUAL( zcorn[ zmp.index(0,0,0,4) ] , zcorn[ zmp.index(0,0,0,0) ] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user