2011-11-30 07:01:38 -06:00
|
|
|
#include <iostream>
|
2011-12-02 12:09:56 -06:00
|
|
|
#include <string>
|
2011-11-30 07:01:38 -06:00
|
|
|
#include <vector>
|
2011-11-30 07:20:09 -06:00
|
|
|
|
2011-12-12 04:28:09 -06:00
|
|
|
#include <opm/core/grid.h>
|
|
|
|
#include <opm/core/utility/cpgpreprocess/preprocess.h>
|
|
|
|
#include <opm/core/utility/cpgpreprocess/cgridinterface.h>
|
2011-11-30 07:01:38 -06:00
|
|
|
|
2011-12-12 04:28:09 -06:00
|
|
|
#include <opm/core/utility/cpgpreprocess/readvector.hpp>
|
2011-11-30 07:01:38 -06:00
|
|
|
|
2012-02-01 07:56:38 -06:00
|
|
|
static struct UnstructuredGrid*
|
2011-12-02 12:09:56 -06:00
|
|
|
read_grid(const std::string& dir)
|
2011-11-30 07:01:38 -06:00
|
|
|
{
|
2011-12-02 12:09:56 -06:00
|
|
|
std::string fn;
|
|
|
|
fn = dir + '/' + "zcorn.txt";
|
|
|
|
|
2011-11-30 07:01:38 -06:00
|
|
|
std::vector<double> zcorn;
|
2011-12-02 12:09:56 -06:00
|
|
|
read_vector_from_file(fn, zcorn);
|
2011-11-30 07:01:38 -06:00
|
|
|
|
2011-12-02 12:09:56 -06:00
|
|
|
fn = dir + '/' + "coord.txt";
|
2011-11-30 07:01:38 -06:00
|
|
|
::std::vector<double> coord;
|
2011-12-02 12:09:56 -06:00
|
|
|
read_vector_from_file(fn, coord);
|
2011-11-30 07:01:38 -06:00
|
|
|
|
2011-12-02 12:09:56 -06:00
|
|
|
fn = dir + '/' + "actnum.txt";
|
|
|
|
std::vector<int> actnum;
|
|
|
|
read_vector_from_file(fn, actnum);
|
|
|
|
|
|
|
|
fn = dir + '/' + "dimens.txt";
|
2011-12-13 03:36:44 -06:00
|
|
|
::std::vector<int> dimens;
|
2011-12-02 12:09:56 -06:00
|
|
|
read_vector_from_file(fn, dimens);
|
2011-11-30 07:01:38 -06:00
|
|
|
|
|
|
|
struct grdecl grdecl;
|
|
|
|
grdecl.zcorn = &zcorn[0];
|
|
|
|
grdecl.coord = &coord[0];
|
|
|
|
grdecl.actnum = &actnum[0];
|
|
|
|
|
|
|
|
grdecl.dims[0] = dimens[0];
|
|
|
|
grdecl.dims[1] = dimens[1];
|
|
|
|
grdecl.dims[2] = dimens[2];
|
|
|
|
|
2012-02-01 07:56:38 -06:00
|
|
|
struct UnstructuredGrid *g= preprocess(&grdecl, 0.0);
|
2011-11-30 07:01:38 -06:00
|
|
|
|
|
|
|
double vol = 0.0;
|
|
|
|
for (int c = 0; c < g->number_of_cells; c++) {
|
|
|
|
vol += g->cell_volumes[c];
|
|
|
|
}
|
|
|
|
std::cout << "Sum volumes = " << vol << '\n';
|
|
|
|
|
|
|
|
for (int c = 0, i = 0; c < g->number_of_cells; c++) {
|
|
|
|
for (; i < g->cell_facepos[c + 1]; i++) {
|
2012-02-01 07:56:38 -06:00
|
|
|
std::cout << "(c,i) = (" << c << "," << g->cell_facetag[i] << ")\n";
|
2011-11-30 07:01:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-01 07:56:38 -06:00
|
|
|
return g;
|
2011-12-02 12:09:56 -06:00
|
|
|
}
|
2011-11-30 07:01:38 -06:00
|
|
|
|
2011-12-02 12:09:56 -06:00
|
|
|
int main()
|
|
|
|
{
|
2012-02-01 07:56:38 -06:00
|
|
|
struct UnstructuredGrid *g;
|
2011-12-02 12:09:56 -06:00
|
|
|
|
2012-02-01 07:56:38 -06:00
|
|
|
g = read_grid(std::string("example"));
|
2011-12-02 12:09:56 -06:00
|
|
|
|
2012-02-01 08:45:13 -06:00
|
|
|
free_grid(g);
|
2011-12-02 12:09:56 -06:00
|
|
|
|
2011-11-30 07:01:38 -06:00
|
|
|
return 0;
|
|
|
|
}
|