grid.h File Reference

Main OPM-Core grid data structure along with helper functions for construction, destruction and reading a grid representation from disk. More...

#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  UnstructuredGrid
 Data structure for an unstructured grid, unstructured meaning that any cell may have an arbitrary number of adjacent cells. More...
 

Functions

void destroy_grid (struct UnstructuredGrid *g)
 Destroy and deallocate an UnstructuredGrid and all its data. More...
 
struct UnstructuredGridcreate_grid_empty (void)
 Allocate and initialise an empty UnstructuredGrid. More...
 
struct UnstructuredGridallocate_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. More...
 
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 second argument.
 
struct UnstructuredGridread_grid (const char *fname)
 Import a grid from a character representation stored in file. More...
 
bool grid_equal (const struct UnstructuredGrid *grid1, const struct UnstructuredGrid *grid2)
 

Detailed Description

Main OPM-Core grid data structure along with helper functions for construction, destruction and reading a grid representation from disk.

Function Documentation

◆ allocate_grid()

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.

Parameters
[in]ndimsNumber of physical dimensions.
[in]ncellsNumber of cells.
[in]nfacesNumber of faces.
[in]nfacenodesSize of mapping from faces to nodes.
[in]ncellfacesSize of mapping from cells to faces. (i.e., the number of ‘half-faces’)
[in]nnodesNumber of Nodes.
Returns
Fully formed UnstructuredGrid with all fields except global_cell allocated, but not filled with meaningful values. NULL in case of allocation failure.

◆ create_grid_empty()

struct UnstructuredGrid* create_grid_empty ( void  )

Allocate and initialise an empty UnstructuredGrid.

This is the moral equivalent of a C++ default constructor.

Returns
Fully formed UnstructuredGrid with all fields zero or NULL as appropriate. NULL in case of allocation failure.

◆ destroy_grid()

void destroy_grid ( struct UnstructuredGrid g)

Destroy and deallocate an UnstructuredGrid and all its data.

This function assumes that all arrays of the UnstructuredGrid (if non-null) have been individually allocated by malloc(). They will be deallocated with free().

◆ read_grid()

struct UnstructuredGrid* read_grid ( const char *  fname)

Import a grid from a character representation stored in file.

Parameters
[in]fnameFile name.
Returns
Fully formed UnstructuredGrid with all fields allocated and filled. Returns NULL in case of allocation failure.