Add default grid constructor. Creates an empty grid.

This is mostly for use in *other* grid constructors, as it enables
putting a grid into a defined state before allocating and/or filling
the specific fields of the UnstructuredGrid.

While here, add a Doxygen \file command lest function documentation
not be output to the documentation set.
This commit is contained in:
Bård Skaflestad 2012-04-11 18:48:29 +02:00
parent c65dff9f2d
commit 394c463f1e
2 changed files with 31 additions and 0 deletions

View File

@ -44,3 +44,17 @@ void destroy_grid(struct UnstructuredGrid *g)
free(g);
}
struct UnstructuredGrid *
create_grid_empty(void)
{
struct UnstructuredGrid *G, g = { 0 };
G = malloc(1 * sizeof *G);
if (G != NULL) {
*G = g;
}
return G;
}

View File

@ -20,6 +20,12 @@
#ifndef OPM_GRID_HEADER_INCLUDED
#define OPM_GRID_HEADER_INCLUDED
/**
* \file
*
* Main OPM-Core grid data structure along with destructor and default
* constructor.
*/
#ifdef __cplusplus
extern "C" {
@ -221,6 +227,17 @@ struct UnstructuredGrid
*/
void destroy_grid(struct UnstructuredGrid *g);
/**
Allocate and initialise an empty UnstructuredGrid.
This is the moral equivalent of a C++ default constructor.
\return Fully formed UnstructuredGrid with all fields zero or
<code>NULL</code> as appropriate. <code>NULL</code> in case of
allocation failure.
*/
struct UnstructuredGrid *
create_grid_empty(void);
#ifdef __cplusplus
}