Loading...
Searching...
No Matches
UnstructuredGrid.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...

## Typedefs

typedef unsigned | grid_size_t

## Functions

void | destroy_grid (struct UnstructuredGrid *g)
| Destroy and deallocate an UnstructuredGrid and all its data.
struct UnstructuredGrid * | create_grid_empty (void)
| Allocate and initialise an empty UnstructuredGrid.
void | attach_zcorn_copy (struct UnstructuredGrid *G, const double *zcorn)
| Allocate and initialise an UnstructuredGrid where pointers are set to location with correct size.
struct UnstructuredGrid * | read_grid (const char *fname)
| Import a grid from a character representation stored in file.
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.

## Detailed Description

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

## Function Documentation

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

Parameters

  [in] | ndims | Number of physical dimensions.
  [in] | ncells | Number of cells.
  [in] | nfaces | Number of faces.
  [in] | nfacenodes | Size of mapping from faces to nodes.
  [in] | ncellfaces | Size of mapping from cells to faces. (i.e., the number of `half-faces')
  [in] | nnodes | Number 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 * allocate_grid(size_t ndims , size_t ncells , size_t nfaces , size_t nfacenodes, size_t ncellfaces, size_t nnodes );

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

## 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] | grid1 | First grid.
  [in] | grid2 | Second 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] | fname | File name.

Returns
  Fully formed UnstructuredGrid with all fields allocated and filled. Returns `NULL` in case of allocation failure.