Merge pull request #446 from atgeirr/use-opm-cellvolumes
Use OPM cell volume calculations.
This commit is contained in:
@@ -181,9 +181,9 @@ namespace Opm {
|
||||
Value<double> m_pinch;
|
||||
PinchMode::ModeEnum m_pinchoutMode;
|
||||
PinchMode::ModeEnum m_multzMode;
|
||||
mutable std::vector<double> volume_cache;
|
||||
mutable std::vector< int > activeMap;
|
||||
bool m_circle = false;
|
||||
|
||||
/*
|
||||
The internal class grid_ptr is a a std::unique_ptr with
|
||||
special copy semantics. The purpose of implementing this is
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <functional>
|
||||
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
#include <opm/common/utility/numeric/calculateCellVol.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Section.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
@@ -57,11 +58,13 @@ namespace Opm {
|
||||
const std::vector<double>& zcorn ,
|
||||
const int * actnum,
|
||||
const double * mapaxes)
|
||||
: m_minpvValue(0),
|
||||
: GridDims(dims),
|
||||
m_minpvValue(0),
|
||||
m_minpvMode(MinpvMode::ModeEnum::Inactive),
|
||||
m_pinch("PINCH"),
|
||||
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
|
||||
m_multzMode(PinchMode::ModeEnum::TOP)
|
||||
m_multzMode(PinchMode::ModeEnum::TOP),
|
||||
volume_cache(dims[0] * dims[1] * dims[2], -1.0)
|
||||
{
|
||||
initCornerPointGrid( dims, coord , zcorn , actnum , mapaxes );
|
||||
}
|
||||
@@ -89,6 +92,8 @@ namespace Opm {
|
||||
m_nx = ecl_grid_get_nx( c_ptr() );
|
||||
m_ny = ecl_grid_get_ny( c_ptr() );
|
||||
m_nz = ecl_grid_get_nz( c_ptr() );
|
||||
|
||||
volume_cache.resize(m_nx * m_ny * m_nz, -1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +105,7 @@ namespace Opm {
|
||||
m_pinch("PINCH"),
|
||||
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
|
||||
m_multzMode(PinchMode::ModeEnum::TOP),
|
||||
volume_cache(nx * ny * nz, -1.0),
|
||||
m_grid( ecl_grid_alloc_rectangular(nx, ny, nz, dx, dy, dz, NULL) )
|
||||
{
|
||||
}
|
||||
@@ -110,7 +116,8 @@ namespace Opm {
|
||||
m_minpvMode( src.m_minpvMode ),
|
||||
m_pinch( src.m_pinch ),
|
||||
m_pinchoutMode( src.m_pinchoutMode ),
|
||||
m_multzMode( src.m_multzMode )
|
||||
m_multzMode( src.m_multzMode ),
|
||||
volume_cache(src.volume_cache.size(), -1.0)
|
||||
{
|
||||
const int * actnum_data = (actnum.empty()) ? nullptr : actnum.data();
|
||||
m_grid.reset( ecl_grid_alloc_processed_copy( src.c_ptr(), zcorn , actnum_data ));
|
||||
@@ -163,7 +170,8 @@ namespace Opm {
|
||||
m_minpvMode(MinpvMode::ModeEnum::Inactive),
|
||||
m_pinch("PINCH"),
|
||||
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
|
||||
m_multzMode(PinchMode::ModeEnum::TOP)
|
||||
m_multzMode(PinchMode::ModeEnum::TOP),
|
||||
volume_cache(m_nx * m_ny * m_nz, -1.0)
|
||||
{
|
||||
|
||||
const std::array<int, 3> dims = getNXYZ();
|
||||
@@ -728,13 +736,23 @@ namespace Opm {
|
||||
|
||||
double EclipseGrid::getCellVolume(size_t globalIndex) const {
|
||||
assertGlobalIndex( globalIndex );
|
||||
return ecl_grid_get_cell_volume1( c_ptr() , static_cast<int>(globalIndex));
|
||||
if (volume_cache[globalIndex] < 0.0) {
|
||||
// Calculate cell volume and put it in the cache.
|
||||
std::vector<double> x(8,0);
|
||||
std::vector<double> y(8,0);
|
||||
std::vector<double> z(8,0);
|
||||
for (int i=0; i < 8; i++) {
|
||||
ecl_grid_get_cell_corner_xyz1(c_ptr(), static_cast<int>(globalIndex), i, &x[i], &y[i], &z[i]);
|
||||
}
|
||||
volume_cache[globalIndex] = calculateCellVol(x,y,z);
|
||||
}
|
||||
return volume_cache[globalIndex];
|
||||
}
|
||||
|
||||
|
||||
double EclipseGrid::getCellVolume(size_t i , size_t j , size_t k) const {
|
||||
assertIJK(i,j,k);
|
||||
return ecl_grid_get_cell_volume3( c_ptr() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k));
|
||||
return getCellVolume(getGlobalIndex(i, j, k));
|
||||
}
|
||||
|
||||
double EclipseGrid::getCellThicknes(size_t i , size_t j , size_t k) const {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <opm/test_util/EclFilesComparator.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/common/utility/numeric/calculateCellVol.hpp>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -405,6 +406,20 @@ void RegressionTest::deviationsForCell(double val1, double val2, const std::stri
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
double getCellVolume(const ecl_grid_type* ecl_grid, const int globalIndex) {
|
||||
std::vector<double> x(8, 0.0);
|
||||
std::vector<double> y(8, 0.0);
|
||||
std::vector<double> z(8, 0.0);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ecl_grid_get_cell_corner_xyz1(ecl_grid, globalIndex, i, &x.data()[i], &y.data()[i], &z.data()[i]);
|
||||
}
|
||||
return calculateCellVol(x,y,z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RegressionTest::gridCompare(const bool volumecheck) const {
|
||||
double absTolerance = getAbsTolerance();
|
||||
double relTolerance = getRelTolerance();
|
||||
@@ -442,8 +457,8 @@ void RegressionTest::gridCompare(const bool volumecheck) const {
|
||||
<< (active1 ? "active" : "inactive") << " in first grid, but "
|
||||
<< (active2 ? "active" : "inactive") << " in second grid.");
|
||||
}
|
||||
const double cellVolume1 = ecl_grid_get_cell_volume1(ecl_grid1, cell);
|
||||
const double cellVolume2 = ecl_grid_get_cell_volume1(ecl_grid2, cell);
|
||||
const double cellVolume1 = getCellVolume(ecl_grid1, cell);
|
||||
const double cellVolume2 = getCellVolume(ecl_grid2, cell);
|
||||
Deviation dev = calculateDeviations(cellVolume1, cellVolume2);
|
||||
if (dev.abs > absTolerance && dev.rel > relTolerance) {
|
||||
int i, j, k;
|
||||
@@ -580,8 +595,8 @@ void IntegrationTest::setCellVolumes() {
|
||||
<< "\nThe number of active cells differ.");
|
||||
}
|
||||
for (unsigned int cell = 0; cell < globalGridCount1; ++cell) {
|
||||
const double cellVolume1 = ecl_grid_get_cell_volume1(ecl_grid1, cell);
|
||||
const double cellVolume2 = ecl_grid_get_cell_volume1(ecl_grid2, cell);
|
||||
const double cellVolume1 = getCellVolume(ecl_grid1, cell);
|
||||
const double cellVolume2 = getCellVolume(ecl_grid2, cell);
|
||||
Deviation dev = calculateDeviations(cellVolume1, cellVolume2);
|
||||
if (dev.abs > absTolerance && dev.rel > relTolerance) {
|
||||
int i, j, k;
|
||||
|
||||
Reference in New Issue
Block a user