grid.h File Reference
#include <stddef.h>
#include <stdbool.h>
Include dependency graph for grid.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  UnstructuredGrid
 

Functions

void destroy_grid (struct UnstructuredGrid *g)
 
struct UnstructuredGridcreate_grid_empty (void)
 
struct UnstructuredGridallocate_grid (size_t ndims, size_t ncells, size_t nfaces, size_t nfacenodes, size_t ncellfaces, size_t nnodes)
 
struct UnstructuredGridread_grid (const char *fname)
 
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

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.
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.
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().

bool grid_equal ( const struct UnstructuredGrid grid1,
const struct UnstructuredGrid grid2 
)
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.