UnstructuredGrid.h File Reference
#include <stddef.h>
#include <stdbool.h>
Include dependency graph for UnstructuredGrid.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)
 
void attach_zcorn_copy (struct UnstructuredGrid *G, const double *zcorn)
 
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

◆ 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.

Referenced by Dune::PolyhedralGrid< dim, dimworld, coord_t >::allocateGrid().

◆ attach_zcorn_copy()

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.

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

Referenced by Dune::PolyhedralGrid< dim, dimworld, coord_t >::UnstructuredGridDeleter::operator()().

◆ 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.

The grids are declared equal if all of the following conditions hold:

  1. They have the same physical dimensions, the same number of cells, the same number of faces, and the same number of nodes.
  2. All cell, face, and node topology arrays are exactly equal.
  3. All node coordinate, centroid, face normal, face area and cell volume arrays differ by a relative distance of at most
    1.0e-5
    in each element.
Parameters
[in]grid1First grid.
[in]grid2Second grid.
Returns
True (integer one) if the grids are equal and false (integer zero) otherwise.

◆ 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.