opm-grid
UnstructuredGrid.h
Go to the documentation of this file.
1 /*
2  Copyright 2010, 2011, 2012 SINTEF ICT, Applied Mathematics.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_GRID_HEADER_INCLUDED
21 #define OPM_GRID_HEADER_INCLUDED
22 
23 #include <stddef.h>
24 #include <stdbool.h>
25 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38 ---- synopsis of grid.h ----
39 
40 struct UnstructuredGrid
41 {
42  int dimensions;
43  int number_of_cells;
44  int number_of_faces;
45  int number_of_nodes;
46  int *face_nodes;
47  int *face_nodepos;
48  int *face_cells;
49  int *cell_faces;
50  int *cell_facepos;
51  double *node_coordinates;
52  double *face_centroids;
53  double *face_areas;
54  double *face_normals;
55  double *cell_centroids;
56  double *cell_volumes;
57  int *global_cell;
58  int cartdims[3];
59  int *cell_facetag;
60 };
61 
62 void destroy_grid(struct UnstructuredGrid *g);
63 
64 struct UnstructuredGrid *
65 create_grid_empty(void);
66 
67 struct UnstructuredGrid *
68 allocate_grid(size_t ndims ,
69  size_t ncells ,
70  size_t nfaces ,
71  size_t nfacenodes,
72  size_t ncellfaces,
73  size_t nnodes );
74 
75 struct UnstructuredGrid *
76 read_grid(const char *fname);
77 
78  ---- end of synopsis of grid.h ----
79 */
80 
81 typedef unsigned grid_size_t;
82 
101 {
109 
116 
129  grid_size_t *face_nodepos;
141 
154  grid_size_t *cell_facepos;
155 
163 
170  double *face_centroids;
175  double *face_areas;
186  double *face_normals;
187 
194  double *cell_centroids;
199  double *cell_volumes;
200 
201 
217 
229  int cartdims[3];
247 
248 
249  /*
250  This vector is retained to be able to construct an
251  EclipseGrid representation of the Grid. If the grid
252  processor actually modifies the elements of the zcorn
253  vector from the input the modified version is stored here;
254  otherwise we just use the default.
255  */
256  double * zcorn;
257 };
258 
266 void destroy_grid(struct UnstructuredGrid *g);
267 
277 struct UnstructuredGrid *
278 create_grid_empty(void);
279 
296 struct UnstructuredGrid *
297 allocate_grid(size_t ndims ,
298  size_t ncells ,
299  size_t nfaces ,
300  size_t nfacenodes,
301  size_t ncellfaces,
302  size_t nnodes );
303 
304 
309 void
311  const double * zcorn);
312 
313 
321 struct UnstructuredGrid *
322 read_grid(const char *fname);
323 
324 
346 bool
347 grid_equal(const struct UnstructuredGrid *grid1,
348  const struct UnstructuredGrid *grid2);
349 
350 #ifdef __cplusplus
351 }
352 #endif
353 
354 #endif /* OPM_GRID_HEADER_INCLUDED */
int * cell_facetag
If non-null, this array contains a number for cell-face adjacency indicating the face&#39;s position with...
Definition: UnstructuredGrid.h:246
int * global_cell
If non-null, this array contains the logical cartesian indices (in a lexicographic ordering) of each ...
Definition: UnstructuredGrid.h:216
double * cell_volumes
Exact or approximate cell volumes.
Definition: UnstructuredGrid.h:199
double * node_coordinates
Node coordinates, stored consecutively for each node.
Definition: UnstructuredGrid.h:162
double * face_centroids
Exact or approximate face centroids, stored consecutively for each face.
Definition: UnstructuredGrid.h:170
bool grid_equal(const struct UnstructuredGrid *grid1, const struct UnstructuredGrid *grid2)
Determine whether or not two grid structures represent the same underlying geometry and topology...
struct UnstructuredGrid * read_grid(const char *fname)
Import a grid from a character representation stored in file.
Definition: UnstructuredGrid.c:524
int number_of_cells
The number of cells in the grid.
Definition: UnstructuredGrid.h:111
void destroy_grid(struct UnstructuredGrid *g)
Destroy and deallocate an UnstructuredGrid and all its data.
Definition: UnstructuredGrid.c:30
void attach_zcorn_copy(struct UnstructuredGrid *G, const double *zcorn)
Will allocate storage internally in the grid object to hold a copy of the zcorn data supplied in the ...
Definition: UnstructuredGrid.c:73
double * cell_centroids
Exact or approximate cell centroids, stored consecutively for each cell.
Definition: UnstructuredGrid.h:194
double * face_normals
Exact or approximate face normals, stored consecutively for each face.
Definition: UnstructuredGrid.h:186
int number_of_faces
The number of faces in the grid.
Definition: UnstructuredGrid.h:113
grid_size_t * cell_facepos
For a cell c, cell_facepos[c] contains the starting index for c&#39;s faces in the cell_faces array...
Definition: UnstructuredGrid.h:154
int dimensions
The topological and geometrical dimensionality of the grid.
Definition: UnstructuredGrid.h:108
int * face_cells
For a face f, face_cells[2*f] and face_cells[2*f + 1] contain the cell indices of the cells adjacent ...
Definition: UnstructuredGrid.h:140
int * cell_faces
Contains for each cell, the indices of its adjacent faces.
Definition: UnstructuredGrid.h:148
double * face_areas
Exact or approximate face areas.
Definition: UnstructuredGrid.h:175
struct UnstructuredGrid * allocate_grid(size_t ndims, size_t ncells, size_t nfaces, size_t nfacenodes, size_t ncellfaces, size_t nnodes)
Allocate and initialise an UnstructuredGrid where pointers are set to location with correct size...
Definition: UnstructuredGrid.c:85
int * face_nodes
Contains for each face, the indices of its adjacent nodes.
Definition: UnstructuredGrid.h:123
Data structure for an unstructured grid, unstructured meaning that any cell may have an arbitrary num...
Definition: UnstructuredGrid.h:100
struct UnstructuredGrid * create_grid_empty(void)
Allocate and initialise an empty UnstructuredGrid.
Definition: UnstructuredGrid.c:58
int number_of_nodes
The number of nodes in the grid.
Definition: UnstructuredGrid.h:115
grid_size_t * face_nodepos
For a face f, face_nodepos[f] contains the starting index for f&#39;s nodes in the face_nodes array...
Definition: UnstructuredGrid.h:129
int cartdims[3]
Contains the size of the logical cartesian structure (if any) of the grid.
Definition: UnstructuredGrid.h:229