Loading...
Searching...
No Matches
UnstructuredGrid.h
Go to the documentation of this file.
/*
Copyright 2010, 2011, 2012 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_GRID_HEADER_INCLUDED
#define OPM_GRID_HEADER_INCLUDED
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
---- synopsis of grid.h ----
struct UnstructuredGrid
{
int dimensions;
int number_of_cells;
int number_of_faces;
int number_of_nodes;
int *face_nodes;
int *face_nodepos;
int *face_cells;
int *cell_faces;
int *cell_facepos;
double *node_coordinates;
double *face_centroids;
double *face_areas;
double *face_normals;
double *cell_centroids;
double *cell_volumes;
int *global_cell;
int cartdims[3];
int *cell_facetag;
};
void destroy_grid(struct UnstructuredGrid *g);
struct UnstructuredGrid *
create_grid_empty(void);
struct UnstructuredGrid *
allocate_grid(size_t ndims ,
size_t ncells ,
size_t nfaces ,
size_t nfacenodes,
size_t ncellfaces,
size_t nnodes );
struct UnstructuredGrid *
read_grid(const char *fname);
---- end of synopsis of grid.h ----
*/
typedef unsigned grid_size_t;
struct UnstructuredGrid
{
int dimensions;
int number_of_cells;
int number_of_faces;
int number_of_nodes;
int *face_nodes;
grid_size_t *face_nodepos;
int *face_cells;
int *cell_faces;
grid_size_t *cell_facepos;
double *node_coordinates;
double *face_centroids;
double *face_areas;
double *face_normals;
double *cell_centroids;
double *cell_volumes;
int *global_cell;
int cartdims[3];
int *cell_facetag;
/*
This vector is retained to be able to construct an
EclipseGrid representation of the Grid. If the grid
processor actually modifies the elements of the zcorn
vector from the input the modified version is stored here;
otherwise we just use the default.
*/
double * zcorn;
};
void destroy_grid(struct UnstructuredGrid *g);
struct UnstructuredGrid *
create_grid_empty(void);
struct UnstructuredGrid *
allocate_grid(size_t ndims ,
size_t ncells ,
size_t nfaces ,
size_t nfacenodes,
size_t ncellfaces,
size_t nnodes );
void
attach_zcorn_copy(struct UnstructuredGrid* G ,
const double * zcorn);
struct UnstructuredGrid *
read_grid(const char *fname);
bool
grid_equal(const struct UnstructuredGrid *grid1,
const struct UnstructuredGrid *grid2);
#ifdef __cplusplus
}
#endif
#endif /* OPM_GRID_HEADER_INCLUDED */
attach_zcorn_copy
void attach_zcorn_copy(struct UnstructuredGrid *G, const double *zcorn)
Allocate and initialise an UnstructuredGrid where pointers are set to location with correct size.
Definition UnstructuredGrid.c:73
create_grid_empty
struct UnstructuredGrid * create_grid_empty(void)
Allocate and initialise an empty UnstructuredGrid.
Definition UnstructuredGrid.c:58
destroy_grid
void destroy_grid(struct UnstructuredGrid *g)
Destroy and deallocate an UnstructuredGrid and all its data.
Definition UnstructuredGrid.c:30
read_grid
struct UnstructuredGrid * read_grid(const char *fname)
Import a grid from a character representation stored in file.
Definition UnstructuredGrid.c:524
grid_equal
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.
UnstructuredGrid
Data structure for an unstructured grid, unstructured meaning that any cell may have an arbitrary num...
Definition UnstructuredGrid.h:101
UnstructuredGrid::face_nodes
int * face_nodes
Contains for each face, the indices of its adjacent nodes.
Definition UnstructuredGrid.h:123
UnstructuredGrid::face_nodepos
grid_size_t * face_nodepos
For a face f, face_nodepos[f] contains the starting index for f's nodes in the face_nodes array.
Definition UnstructuredGrid.h:129
UnstructuredGrid::number_of_cells
int number_of_cells
The number of cells in the grid.
Definition UnstructuredGrid.h:111
UnstructuredGrid::face_areas
double * face_areas
Exact or approximate face areas.
Definition UnstructuredGrid.h:175
UnstructuredGrid::cell_faces
int * cell_faces
Contains for each cell, the indices of its adjacent faces.
Definition UnstructuredGrid.h:148
UnstructuredGrid::number_of_faces
int number_of_faces
The number of faces in the grid.
Definition UnstructuredGrid.h:113
UnstructuredGrid::cell_centroids
double * cell_centroids
Exact or approximate cell centroids, stored consecutively for each cell.
Definition UnstructuredGrid.h:194
UnstructuredGrid::cell_facetag
int * cell_facetag
If non-null, this array contains a number for cell-face adjacency indicating the face's position with...
Definition UnstructuredGrid.h:246
UnstructuredGrid::cell_volumes
double * cell_volumes
Exact or approximate cell volumes.
Definition UnstructuredGrid.h:199
UnstructuredGrid::face_cells
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
UnstructuredGrid::cell_facepos
grid_size_t * cell_facepos
For a cell c, cell_facepos[c] contains the starting index for c's faces in the cell_faces array.
Definition UnstructuredGrid.h:154
UnstructuredGrid::face_centroids
double * face_centroids
Exact or approximate face centroids, stored consecutively for each face.
Definition UnstructuredGrid.h:170
UnstructuredGrid::number_of_nodes
int number_of_nodes
The number of nodes in the grid.
Definition UnstructuredGrid.h:115
UnstructuredGrid::dimensions
int dimensions
The topological and geometrical dimensionality of the grid.
Definition UnstructuredGrid.h:108
UnstructuredGrid::cartdims
int cartdims[3]
Contains the size of the logical cartesian structure (if any) of the grid.
Definition UnstructuredGrid.h:229
UnstructuredGrid::global_cell
int * global_cell
If non-null, this array contains the logical cartesian indices (in a lexicographic ordering) of each ...
Definition UnstructuredGrid.h:216
UnstructuredGrid::face_normals
double * face_normals
Exact or approximate face normals, stored consecutively for each face.
Definition UnstructuredGrid.h:186
UnstructuredGrid::node_coordinates
double * node_coordinates
Node coordinates, stored consecutively for each node.
Definition UnstructuredGrid.h:162