Merge pull request #581 from joakim-hove/GridManager-EclipseGrid-constructor

Grid manager eclipse grid constructor
This commit is contained in:
Bård Skaflestad 2014-04-24 16:52:55 +02:00
commit a97db3f157
11 changed files with 475 additions and 22 deletions

View File

@ -152,6 +152,7 @@ list (APPEND TEST_SOURCE_FILES
tests/test_propertysystem.cpp
tests/test_dgbasis.cpp
tests/test_cartgrid.cpp
tests/test_ug.cpp
tests/test_cubic.cpp
tests/test_event.cpp
tests/test_nonuniformtablelinear.cpp
@ -201,6 +202,7 @@ list (APPEND TEST_DATA_FILES
tests/wells_manager_data_wellSTOP.data
tests/wells_group.data
tests/TESTTIMER.DATA
tests/CORNERPOINT_ACTNUM.DATA
)
# originally generated with the command:

View File

@ -21,6 +21,7 @@
#define OPM_GRID_HEADER_INCLUDED
#include <stddef.h>
#include <stdbool.h>
/**
* \file
@ -299,6 +300,11 @@ allocate_grid(size_t ndims ,
struct UnstructuredGrid *
read_grid(const char *fname);
bool
grid_equal(const struct UnstructuredGrid * grid1 , const struct UnstructuredGrid * grid2);
#ifdef __cplusplus
}
#endif

View File

@ -18,6 +18,7 @@
*/
#include "config.h"
#include <opm/core/grid/GridManager.hpp>
#include <opm/core/io/eclipse/EclipseGridParser.hpp>
#include <opm/core/grid.h>
@ -55,6 +56,34 @@ namespace Opm
}
}
GridManager::GridManager(Opm::EclipseGridConstPtr eclipseGrid) {
struct grdecl g;
std::vector<int> actnum;
std::vector<double> coord;
std::vector<double> zcorn;
std::vector<double> mapaxes;
g.dims[0] = eclipseGrid->getNX();
g.dims[1] = eclipseGrid->getNY();
g.dims[2] = eclipseGrid->getNZ();
eclipseGrid->exportMAPAXES( mapaxes );
eclipseGrid->exportCOORD( coord );
eclipseGrid->exportZCORN( zcorn );
eclipseGrid->exportACTNUM( actnum );
g.coord = coord.data();
g.zcorn = zcorn.data();
g.actnum = actnum.data();
g.mapaxes = mapaxes.data();
ug_ = create_grid_cornerpoint(&g , 0.0);
if (!ug_) {
OPM_THROW(std::runtime_error, "Failed to construct grid.");
}
}
/// Construct a 3d corner-point grid from a deck.
GridManager::GridManager(Opm::DeckConstPtr newParserDeck)
{
@ -76,7 +105,7 @@ namespace Opm
initFromDeckTensorgrid(newParserDeck);
} else {
OPM_THROW(std::runtime_error, "Could not initialize grid from deck. "
"Need either ZCORN + COORD or DXV + DYV + DZV keywords.");
"Need either ZCORN + COORD or DXV + DYV + DZV keywords.");
}
}

View File

@ -21,6 +21,7 @@
#define OPM_GRIDMANAGER_HEADER_INCLUDED
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <string>
@ -49,6 +50,9 @@ namespace Opm
/// Construct a 3d corner-point grid or tensor grid from a deck.
explicit GridManager(Opm::DeckConstPtr newParserDeck);
/// Construct a grid from an EclipseState::EclipseGrid instance
explicit GridManager(Opm::EclipseGridConstPtr eclipseGrid);
/// Construct a 2d cartesian grid with cells of unit size.
GridManager(int nx, int ny);

View File

@ -540,3 +540,92 @@ read_grid(const char *fname)
return G;
}
/**
Ahhh - the joys of comparing floating point numbers ....
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
*/
static int memcmp_double(const double * p1 , const double *p2 , size_t num_elements) {
if (memcmp(p1 , p2 , num_elements * sizeof * p1) == 0)
return 0;
else {
const double epsilon = 1e-5;
for (size_t index = 0; index < num_elements; index++) {
double diff = abs(p1[index] - p2[index]);
if (diff != 0) {
double sum = abs(p1[index]) + abs(p2[index]);
if (diff > sum * epsilon)
return 1;
}
}
return 0;
}
}
bool
grid_equal(const struct UnstructuredGrid * grid1 , const struct UnstructuredGrid * grid2) {
if ((grid1->dimensions == grid2->dimensions) &&
(grid1->number_of_cells == grid2->number_of_cells) &&
(grid1->number_of_faces == grid2->number_of_faces) &&
(grid1->number_of_nodes == grid2->number_of_nodes)) {
// Exact integer comparisons
{
if (memcmp(grid1->face_nodepos , grid2->face_nodepos , (grid1->number_of_faces + 1) * sizeof * grid1->face_nodepos) != 0)
return false;
if (memcmp(grid1->face_nodes , grid2->face_nodes , grid1->face_nodepos[grid1->number_of_faces] * sizeof * grid1->face_nodes) != 0)
return false;
if (memcmp(grid1->face_cells , grid2->face_cells , 2 * grid1->number_of_faces * sizeof * grid1->face_cells) != 0)
return false;
if (memcmp(grid1->cell_faces , grid2->cell_faces , grid1->cell_facepos[grid1->number_of_cells] * sizeof * grid1->cell_faces) != 0)
return false;
if (memcmp(grid1->cell_facepos , grid2->cell_facepos , (grid1->number_of_cells + 1) * sizeof * grid1->cell_facepos) != 0)
return false;
if (grid1->global_cell && grid2->global_cell) {
if (memcmp(grid1->global_cell , grid2->global_cell , grid1->number_of_cells * sizeof * grid1->global_cell) != 0)
return false;
} else if (grid1->global_cell != grid2->global_cell)
return false;
if (grid1->cell_facetag && grid2->cell_facetag) {
if (memcmp(grid1->cell_facetag , grid2->cell_facetag , grid1->cell_facepos[grid1->number_of_cells] * sizeof * grid1->cell_facetag) != 0)
return false;
} else if (grid1->cell_facetag != grid2->cell_facetag)
return false;
}
// Floating point comparisons.
{
if (memcmp_double( grid1->node_coordinates , grid2->node_coordinates , grid1->dimensions * grid1->number_of_nodes) != 0)
return false;
if (memcmp_double( grid1->face_centroids , grid2->face_centroids , grid1->dimensions * grid1->number_of_faces) != 0)
return false;
if (memcmp_double( grid1->face_areas , grid2->face_areas , grid1->number_of_faces) != 0)
return false;
if (memcmp_double( grid1->face_normals , grid2->face_normals , grid1->dimensions * grid1->number_of_faces) != 0)
return false;
if (memcmp_double( grid1->cell_centroids , grid2->cell_centroids , grid1->dimensions * grid1->number_of_cells) != 0)
return false;
if (memcmp_double( grid1->cell_volumes , grid2->cell_volumes , grid1->number_of_cells) != 0)
return false;
}
return true;
} else
return false;
}

View File

@ -503,9 +503,9 @@ private:
/**
* Representation of an Eclipse grid.
*/
struct EclipseGrid : public EclipseHandle <ecl_grid_type> {
struct EclipseWriterGrid : public EclipseHandle <ecl_grid_type> {
/// Create a grid based on the keywords available in input file
static EclipseGrid make (Opm::DeckConstPtr newParserDeck,
static EclipseWriterGrid make (Opm::DeckConstPtr newParserDeck,
int number_of_cells,
const int* cart_dims,
const int* global_cell)
@ -520,7 +520,7 @@ struct EclipseGrid : public EclipseHandle <ecl_grid_type> {
const auto& dyv = newParserDeck->getKeyword("DYV")->getSIDoubleData();
const auto& dzv = newParserDeck->getKeyword("DZV")->getSIDoubleData();
return EclipseGrid (dxv, dyv, dzv);
return EclipseWriterGrid (dxv, dyv, dzv);
}
else if (newParserDeck->hasKeyword("ZCORN")) {
struct grdecl g;
@ -542,7 +542,7 @@ struct EclipseGrid : public EclipseHandle <ecl_grid_type> {
mapaxes_kw = std::move (EclipseKeyword<float> (MAPAXES_KW, mapaxesData));
}
return EclipseGrid (cart_dims, zcorn_kw, coord_kw, actnum_kw, mapaxes_kw);
return EclipseWriterGrid (cart_dims, zcorn_kw, coord_kw, actnum_kw, mapaxes_kw);
}
else {
OPM_THROW(std::runtime_error,
@ -565,14 +565,14 @@ struct EclipseGrid : public EclipseHandle <ecl_grid_type> {
// GCC 4.4 doesn't generate these constructors for us; provide the
// default implementation explicitly here instead
EclipseGrid (EclipseGrid&& rhs)
EclipseWriterGrid (EclipseWriterGrid&& rhs)
: EclipseHandle <ecl_grid_type> (std::move (rhs)) { }
EclipseGrid& operator= (EclipseGrid&& rhs) {
EclipseWriterGrid& operator= (EclipseWriterGrid&& rhs) {
EclipseHandle <ecl_grid_type>::operator= (std::move(rhs));
return *this;
}
EclipseGrid (const EclipseGrid&) = delete;
EclipseGrid& operator= (const EclipseGrid&) = delete;
EclipseWriterGrid (const EclipseWriterGrid&) = delete;
EclipseWriterGrid& operator= (const EclipseWriterGrid&) = delete;
private:
// each of these cases could have been their respective subclass,
@ -580,7 +580,7 @@ private:
// once we have the handle
// setup smart pointer for Cartesian grid
EclipseGrid (const std::vector<double>& dxv,
EclipseWriterGrid (const std::vector<double>& dxv,
const std::vector<double>& dyv,
const std::vector<double>& dzv)
: EclipseHandle <ecl_grid_type> (
@ -594,7 +594,7 @@ private:
ecl_grid_free) { }
// setup smart pointer for cornerpoint grid
EclipseGrid (const int dims[],
EclipseWriterGrid (const int dims[],
const EclipseKeyword<float>& zcorn,
const EclipseKeyword<float>& coord,
const EclipseKeyword<int>& actnum,
@ -644,7 +644,7 @@ struct EclipseInit : public EclipseHandle <fortio_type> {
auto dataField = getAllSiDoubles_(newParserDeck->getKeyword(PORO_KW));
restrictToActiveCells_(dataField, number_of_cells, global_cell);
EclipseGrid eclGrid = EclipseGrid::make (newParserDeck, number_of_cells,
EclipseWriterGrid eclGrid = EclipseWriterGrid::make (newParserDeck, number_of_cells,
cart_dims, global_cell);
EclipseKeyword<float> poro (PORO_KW, dataField);
@ -1054,8 +1054,8 @@ void EclipseWriter::writeInit(const SimulatorTimer &timer)
return;
}
/* Grid files */
EclipseGrid eclGrid = EclipseGrid::make (newParserDeck_, number_of_cells_,
cart_dims_, global_cell_);
EclipseWriterGrid eclGrid = EclipseWriterGrid::make (newParserDeck_, number_of_cells_,
cart_dims_, global_cell_);
eclGrid.write (outputDir_, baseName_, /*stepIdx=*/0);
EclipseInit fortio = EclipseInit::make (outputDir_, baseName_, /*stepIdx=*/0);

View File

@ -0,0 +1,206 @@
RUNSPEC
DIMENS
10 10 5 /
GRID
COORD
0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00
0.00000000E+00 0.20000000E+02 0.10000000E+02 0.00000000E+00
0.00000000E+00 0.10000000E+02 0.00000000E+00 0.20000000E+02
0.20000000E+02 0.00000000E+00 0.00000000E+00 0.20000000E+02
0.00000000E+00 0.20000000E+02 0.30000000E+02 0.00000000E+00
0.00000000E+00 0.30000000E+02 0.00000000E+00 0.20000000E+02
0.40000000E+02 0.00000000E+00 0.00000000E+00 0.40000000E+02
0.00000000E+00 0.20000000E+02 0.50000000E+02 0.00000000E+00
0.00000000E+00 0.50000000E+02 0.00000000E+00 0.20000000E+02
0.60000000E+02 0.00000000E+00 0.00000000E+00 0.60000000E+02
0.00000000E+00 0.20000000E+02 0.70000000E+02 0.00000000E+00
0.00000000E+00 0.70000000E+02 0.00000000E+00 0.20000000E+02
0.80000000E+02 0.00000000E+00 0.00000000E+00 0.80000000E+02
0.00000000E+00 0.20000000E+02 0.90000000E+02 0.00000000E+00
0.00000000E+00 0.90000000E+02 0.00000000E+00 0.20000000E+02
0.10000000E+03 0.00000000E+00 0.00000000E+00 0.10000000E+03
0.00000000E+00 0.20000000E+02 0.00000000E+00 0.12000000E+02
0.00000000E+00 0.00000000E+00 0.12000000E+02 0.20000000E+02
0.10000000E+02 0.12000000E+02 0.00000000E+00 0.10000000E+02
0.12000000E+02 0.20000000E+02 0.20000000E+02 0.12000000E+02
0.00000000E+00 0.20000000E+02 0.12000000E+02 0.20000000E+02
0.30000000E+02 0.12000000E+02 0.00000000E+00 0.30000000E+02
0.12000000E+02 0.20000000E+02 0.40000000E+02 0.12000000E+02
0.00000000E+00 0.40000000E+02 0.12000000E+02 0.20000000E+02
0.50000000E+02 0.12000000E+02 0.00000000E+00 0.50000000E+02
0.12000000E+02 0.20000000E+02 0.60000000E+02 0.12000000E+02
0.00000000E+00 0.60000000E+02 0.12000000E+02 0.20000000E+02
0.70000000E+02 0.12000000E+02 0.00000000E+00 0.70000000E+02
0.12000000E+02 0.20000000E+02 0.80000000E+02 0.12000000E+02
0.00000000E+00 0.80000000E+02 0.12000000E+02 0.20000000E+02
0.90000000E+02 0.12000000E+02 0.00000000E+00 0.90000000E+02
0.12000000E+02 0.20000000E+02 0.10000000E+03 0.12000000E+02
0.00000000E+00 0.10000000E+03 0.12000000E+02 0.20000000E+02
0.00000000E+00 0.24000000E+02 0.00000000E+00 0.00000000E+00
0.24000000E+02 0.20000000E+02 0.10000000E+02 0.24000000E+02
0.00000000E+00 0.10000000E+02 0.24000000E+02 0.20000000E+02
0.20000000E+02 0.24000000E+02 0.00000000E+00 0.20000000E+02
0.24000000E+02 0.20000000E+02 0.30000000E+02 0.24000000E+02
0.00000000E+00 0.30000000E+02 0.24000000E+02 0.20000000E+02
0.40000000E+02 0.24000000E+02 0.00000000E+00 0.40000000E+02
0.24000000E+02 0.20000000E+02 0.50000000E+02 0.24000000E+02
0.00000000E+00 0.50000000E+02 0.24000000E+02 0.20000000E+02
0.60000000E+02 0.24000000E+02 0.00000000E+00 0.60000000E+02
0.24000000E+02 0.20000000E+02 0.70000000E+02 0.24000000E+02
0.00000000E+00 0.70000000E+02 0.24000000E+02 0.20000000E+02
0.80000000E+02 0.24000000E+02 0.00000000E+00 0.80000000E+02
0.24000000E+02 0.20000000E+02 0.90000000E+02 0.24000000E+02
0.00000000E+00 0.90000000E+02 0.24000000E+02 0.20000000E+02
0.10000000E+03 0.24000000E+02 0.00000000E+00 0.10000000E+03
0.24000000E+02 0.20000000E+02 0.00000000E+00 0.36000000E+02
0.00000000E+00 0.00000000E+00 0.36000000E+02 0.20000000E+02
0.10000000E+02 0.36000000E+02 0.00000000E+00 0.10000000E+02
0.36000000E+02 0.20000000E+02 0.20000000E+02 0.36000000E+02
0.00000000E+00 0.20000000E+02 0.36000000E+02 0.20000000E+02
0.30000000E+02 0.36000000E+02 0.00000000E+00 0.30000000E+02
0.36000000E+02 0.20000000E+02 0.40000000E+02 0.36000000E+02
0.00000000E+00 0.40000000E+02 0.36000000E+02 0.20000000E+02
0.50000000E+02 0.36000000E+02 0.00000000E+00 0.50000000E+02
0.36000000E+02 0.20000000E+02 0.60000000E+02 0.36000000E+02
0.00000000E+00 0.60000000E+02 0.36000000E+02 0.20000000E+02
0.70000000E+02 0.36000000E+02 0.00000000E+00 0.70000000E+02
0.36000000E+02 0.20000000E+02 0.80000000E+02 0.36000000E+02
0.00000000E+00 0.80000000E+02 0.36000000E+02 0.20000000E+02
0.90000000E+02 0.36000000E+02 0.00000000E+00 0.90000000E+02
0.36000000E+02 0.20000000E+02 0.10000000E+03 0.36000000E+02
0.00000000E+00 0.10000000E+03 0.36000000E+02 0.20000000E+02
0.00000000E+00 0.48000000E+02 0.00000000E+00 0.00000000E+00
0.48000000E+02 0.20000000E+02 0.10000000E+02 0.48000000E+02
0.00000000E+00 0.10000000E+02 0.48000000E+02 0.20000000E+02
0.20000000E+02 0.48000000E+02 0.00000000E+00 0.20000000E+02
0.48000000E+02 0.20000000E+02 0.30000000E+02 0.48000000E+02
0.00000000E+00 0.30000000E+02 0.48000000E+02 0.20000000E+02
0.40000000E+02 0.48000000E+02 0.00000000E+00 0.40000000E+02
0.48000000E+02 0.20000000E+02 0.50000000E+02 0.48000000E+02
0.00000000E+00 0.50000000E+02 0.48000000E+02 0.20000000E+02
0.60000000E+02 0.48000000E+02 0.00000000E+00 0.60000000E+02
0.48000000E+02 0.20000000E+02 0.70000000E+02 0.48000000E+02
0.00000000E+00 0.70000000E+02 0.48000000E+02 0.20000000E+02
0.80000000E+02 0.48000000E+02 0.00000000E+00 0.80000000E+02
0.48000000E+02 0.20000000E+02 0.90000000E+02 0.48000000E+02
0.00000000E+00 0.90000000E+02 0.48000000E+02 0.20000000E+02
0.10000000E+03 0.48000000E+02 0.00000000E+00 0.10000000E+03
0.48000000E+02 0.20000000E+02 0.00000000E+00 0.60000000E+02
0.00000000E+00 0.00000000E+00 0.60000000E+02 0.20000000E+02
0.10000000E+02 0.60000000E+02 0.00000000E+00 0.10000000E+02
0.60000000E+02 0.20000000E+02 0.20000000E+02 0.60000000E+02
0.00000000E+00 0.20000000E+02 0.60000000E+02 0.20000000E+02
0.30000000E+02 0.60000000E+02 0.00000000E+00 0.30000000E+02
0.60000000E+02 0.20000000E+02 0.40000000E+02 0.60000000E+02
0.00000000E+00 0.40000000E+02 0.60000000E+02 0.20000000E+02
0.50000000E+02 0.60000000E+02 0.00000000E+00 0.50000000E+02
0.60000000E+02 0.20000000E+02 0.60000000E+02 0.60000000E+02
0.00000000E+00 0.60000000E+02 0.60000000E+02 0.20000000E+02
0.70000000E+02 0.60000000E+02 0.00000000E+00 0.70000000E+02
0.60000000E+02 0.20000000E+02 0.80000000E+02 0.60000000E+02
0.00000000E+00 0.80000000E+02 0.60000000E+02 0.20000000E+02
0.90000000E+02 0.60000000E+02 0.00000000E+00 0.90000000E+02
0.60000000E+02 0.20000000E+02 0.10000000E+03 0.60000000E+02
0.00000000E+00 0.10000000E+03 0.60000000E+02 0.20000000E+02
0.00000000E+00 0.72000000E+02 0.00000000E+00 0.00000000E+00
0.72000000E+02 0.20000000E+02 0.10000000E+02 0.72000000E+02
0.00000000E+00 0.10000000E+02 0.72000000E+02 0.20000000E+02
0.20000000E+02 0.72000000E+02 0.00000000E+00 0.20000000E+02
0.72000000E+02 0.20000000E+02 0.30000000E+02 0.72000000E+02
0.00000000E+00 0.30000000E+02 0.72000000E+02 0.20000000E+02
0.40000000E+02 0.72000000E+02 0.00000000E+00 0.40000000E+02
0.72000000E+02 0.20000000E+02 0.50000000E+02 0.72000000E+02
0.00000000E+00 0.50000000E+02 0.72000000E+02 0.20000000E+02
0.60000000E+02 0.72000000E+02 0.00000000E+00 0.60000000E+02
0.72000000E+02 0.20000000E+02 0.70000000E+02 0.72000000E+02
0.00000000E+00 0.70000000E+02 0.72000000E+02 0.20000000E+02
0.80000000E+02 0.72000000E+02 0.00000000E+00 0.80000000E+02
0.72000000E+02 0.20000000E+02 0.90000000E+02 0.72000000E+02
0.00000000E+00 0.90000000E+02 0.72000000E+02 0.20000000E+02
0.10000000E+03 0.72000000E+02 0.00000000E+00 0.10000000E+03
0.72000000E+02 0.20000000E+02 0.00000000E+00 0.84000000E+02
0.00000000E+00 0.00000000E+00 0.84000000E+02 0.20000000E+02
0.10000000E+02 0.84000000E+02 0.00000000E+00 0.10000000E+02
0.84000000E+02 0.20000000E+02 0.20000000E+02 0.84000000E+02
0.00000000E+00 0.20000000E+02 0.84000000E+02 0.20000000E+02
0.30000000E+02 0.84000000E+02 0.00000000E+00 0.30000000E+02
0.84000000E+02 0.20000000E+02 0.40000000E+02 0.84000000E+02
0.00000000E+00 0.40000000E+02 0.84000000E+02 0.20000000E+02
0.50000000E+02 0.84000000E+02 0.00000000E+00 0.50000000E+02
0.84000000E+02 0.20000000E+02 0.60000000E+02 0.84000000E+02
0.00000000E+00 0.60000000E+02 0.84000000E+02 0.20000000E+02
0.70000000E+02 0.84000000E+02 0.00000000E+00 0.70000000E+02
0.84000000E+02 0.20000000E+02 0.80000000E+02 0.84000000E+02
0.00000000E+00 0.80000000E+02 0.84000000E+02 0.20000000E+02
0.90000000E+02 0.84000000E+02 0.00000000E+00 0.90000000E+02
0.84000000E+02 0.20000000E+02 0.10000000E+03 0.84000000E+02
0.00000000E+00 0.10000000E+03 0.84000000E+02 0.20000000E+02
0.00000000E+00 0.96000000E+02 0.00000000E+00 0.00000000E+00
0.96000000E+02 0.20000000E+02 0.10000000E+02 0.96000000E+02
0.00000000E+00 0.10000000E+02 0.96000000E+02 0.20000000E+02
0.20000000E+02 0.96000000E+02 0.00000000E+00 0.20000000E+02
0.96000000E+02 0.20000000E+02 0.30000000E+02 0.96000000E+02
0.00000000E+00 0.30000000E+02 0.96000000E+02 0.20000000E+02
0.40000000E+02 0.96000000E+02 0.00000000E+00 0.40000000E+02
0.96000000E+02 0.20000000E+02 0.50000000E+02 0.96000000E+02
0.00000000E+00 0.50000000E+02 0.96000000E+02 0.20000000E+02
0.60000000E+02 0.96000000E+02 0.00000000E+00 0.60000000E+02
0.96000000E+02 0.20000000E+02 0.70000000E+02 0.96000000E+02
0.00000000E+00 0.70000000E+02 0.96000000E+02 0.20000000E+02
0.80000000E+02 0.96000000E+02 0.00000000E+00 0.80000000E+02
0.96000000E+02 0.20000000E+02 0.90000000E+02 0.96000000E+02
0.00000000E+00 0.90000000E+02 0.96000000E+02 0.20000000E+02
0.10000000E+03 0.96000000E+02 0.00000000E+00 0.10000000E+03
0.96000000E+02 0.20000000E+02 0.00000000E+00 0.10800000E+03
0.00000000E+00 0.00000000E+00 0.10800000E+03 0.20000000E+02
0.10000000E+02 0.10800000E+03 0.00000000E+00 0.10000000E+02
0.10800000E+03 0.20000000E+02 0.20000000E+02 0.10800000E+03
0.00000000E+00 0.20000000E+02 0.10800000E+03 0.20000000E+02
0.30000000E+02 0.10800000E+03 0.00000000E+00 0.30000000E+02
0.10800000E+03 0.20000000E+02 0.40000000E+02 0.10800000E+03
0.00000000E+00 0.40000000E+02 0.10800000E+03 0.20000000E+02
0.50000000E+02 0.10800000E+03 0.00000000E+00 0.50000000E+02
0.10800000E+03 0.20000000E+02 0.60000000E+02 0.10800000E+03
0.00000000E+00 0.60000000E+02 0.10800000E+03 0.20000000E+02
0.70000000E+02 0.10800000E+03 0.00000000E+00 0.70000000E+02
0.10800000E+03 0.20000000E+02 0.80000000E+02 0.10800000E+03
0.00000000E+00 0.80000000E+02 0.10800000E+03 0.20000000E+02
0.90000000E+02 0.10800000E+03 0.00000000E+00 0.90000000E+02
0.10800000E+03 0.20000000E+02 0.10000000E+03 0.10800000E+03
0.00000000E+00 0.10000000E+03 0.10800000E+03 0.20000000E+02
0.00000000E+00 0.12000000E+03 0.00000000E+00 0.00000000E+00
0.12000000E+03 0.20000000E+02 0.10000000E+02 0.12000000E+03
0.00000000E+00 0.10000000E+02 0.12000000E+03 0.20000000E+02
0.20000000E+02 0.12000000E+03 0.00000000E+00 0.20000000E+02
0.12000000E+03 0.20000000E+02 0.30000000E+02 0.12000000E+03
0.00000000E+00 0.30000000E+02 0.12000000E+03 0.20000000E+02
0.40000000E+02 0.12000000E+03 0.00000000E+00 0.40000000E+02
0.12000000E+03 0.20000000E+02 0.50000000E+02 0.12000000E+03
0.00000000E+00 0.50000000E+02 0.12000000E+03 0.20000000E+02
0.60000000E+02 0.12000000E+03 0.00000000E+00 0.60000000E+02
0.12000000E+03 0.20000000E+02 0.70000000E+02 0.12000000E+03
0.00000000E+00 0.70000000E+02 0.12000000E+03 0.20000000E+02
0.80000000E+02 0.12000000E+03 0.00000000E+00 0.80000000E+02
0.12000000E+03 0.20000000E+02 0.90000000E+02 0.12000000E+03
0.00000000E+00 0.90000000E+02 0.12000000E+03 0.20000000E+02
0.10000000E+03 0.12000000E+03 0.00000000E+00 0.10000000E+03
0.12000000E+03 0.20000000E+02
/
ZCORN
400*0.00
400*0.40E+01
400*0.80E+01
400*1.20E+02
400*1.60E+02
400*2.00E+02
/
ACTNUM
200*0 100*1 200*0 /
EDIT

112
tests/test_ug.cpp Normal file
View File

@ -0,0 +1,112 @@
/* Copyright 2014 Statoil ASA
* This file is licensed under GPL3, see http://www.opm-project.org/
*/
#include <config.h>
/* --- Boost.Test boilerplate --- */
#if HAVE_DYNAMIC_BOOST_TEST
#define BOOST_TEST_DYN_LINK
#endif
#define NVERBOSE // Suppress own messages when throw()ing
#define BOOST_TEST_MODULE TEST_UG
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
/* --- our own headers --- */
#include <algorithm>
#include <vector>
#include <opm/core/grid.h>
#include <opm/core/grid/cornerpoint_grid.h> /* compute_geometry */
#include <opm/core/grid/GridManager.hpp> /* compute_geometry */
#include <opm/core/grid/cpgpreprocess/preprocess.h>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
using namespace std;
BOOST_AUTO_TEST_CASE(Equal) {
const std::string filename1 = "CORNERPOINT_ACTNUM.DATA";
const char *deck2Data =
"RUNSPEC\n"
"\n"
"DIMENS\n"
" 10 10 10 /\n"
"GRID\n"
"DXV\n"
"10*0.25 /\n"
"DYV\n"
"10*0.25 /\n"
"DZV\n"
"10*0.25 /\n"
"TOPS\n"
"100*0.25 /\n"
"EDIT\n"
"\n";
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck1 = parser->parseFile( filename1 );
Opm::DeckConstPtr deck2 = parser->parseString( deck2Data );
BOOST_CHECK( deck1->hasKeyword("ZCORN") );
BOOST_CHECK( deck1->hasKeyword("COORD") );
Opm::GridManager grid1(deck1);
Opm::GridManager grid2(deck2);
const UnstructuredGrid* cgrid1 = grid1.c_grid();
const UnstructuredGrid* cgrid2 = grid2.c_grid();
BOOST_CHECK( grid_equal( cgrid1 , cgrid1 ));
BOOST_CHECK( grid_equal( cgrid2 , cgrid2 ));
BOOST_CHECK( !grid_equal( cgrid1 , cgrid2 ));
}
BOOST_AUTO_TEST_CASE(EqualEclipseGrid) {
const std::string filename = "CORNERPOINT_ACTNUM.DATA";
Opm::ParserPtr parser(new Opm::Parser() );
Opm::DeckConstPtr deck = parser->parseFile( filename );
std::shared_ptr<Opm::RUNSPECSection> runspecSection(new Opm::RUNSPECSection(deck) );
std::shared_ptr<Opm::GRIDSection> gridSection(new Opm::GRIDSection(deck) );
std::shared_ptr<const Opm::EclipseGrid> grid(new Opm::EclipseGrid( runspecSection , gridSection ));
Opm::GridManager gridM(grid);
const UnstructuredGrid* cgrid1 = gridM.c_grid();
struct UnstructuredGrid * cgrid2;
{
struct grdecl g;
Opm::DeckKeywordConstPtr dimens = deck->getKeyword("DIMENS");
Opm::DeckKeywordConstPtr coord = deck->getKeyword("COORD");
Opm::DeckKeywordConstPtr zcorn = deck->getKeyword("ZCORN");
Opm::DeckKeywordConstPtr actnum = deck->getKeyword("ACTNUM");
g.dims[0] = dimens->getRecord(0)->getItem("NX")->getInt(0);
g.dims[1] = dimens->getRecord(0)->getItem("NY")->getInt(0);
g.dims[2] = dimens->getRecord(0)->getItem("NZ")->getInt(0);
g.coord = coord->getSIDoubleData().data();
g.zcorn = zcorn->getSIDoubleData().data();
g.actnum = actnum->getIntData().data();
g.mapaxes = NULL;
cgrid2 = create_grid_cornerpoint(&g , 0.0);
if (!cgrid2)
throw std::runtime_error("Failed to construct grid.");
}
BOOST_CHECK( grid_equal( cgrid1 , cgrid2 ));
destroy_grid( cgrid2 );
}

View File

@ -1,3 +1,5 @@
RUNSPEC
OIL
GAS
WATER
@ -16,9 +18,8 @@ DYV
DZV
10.0 20.0 30.0 10.0 5.0 /
DEPTHZ
121*2000
/
TOPS
100*10 /
SCHEDULE

View File

@ -1,3 +1,5 @@
RUNSPEC
OIL
GAS
WATER
@ -16,8 +18,8 @@ DYV
DZV
10.0 20.0 30.0 10.0 5.0 /
DEPTHZ
121*2000 /
TOPS
100*10 /
SCHEDULE

View File

@ -1,7 +1,10 @@
RUNSPEC
OIL
GAS
WATER
DIMENS
10 10 5 /
@ -16,9 +19,8 @@ DYV
DZV
10.0 20.0 30.0 10.0 5.0 /
DEPTHZ
121*2000
/
TOPS
100*10 /
SCHEDULE