From b66ee7505871930a5e479eecc53564c8428f5134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Wed, 11 Apr 2012 11:32:52 +0200 Subject: [PATCH] Moved free_grid() to grid.h and (new file) grid.c. --- Makefile.am | 1 + opm/core/grid.c | 46 ++++++++++++++++++++++++++++++++ opm/core/grid.h | 4 +++ opm/core/grid/cornerpoint_grid.c | 24 ----------------- opm/core/grid/cornerpoint_grid.h | 1 - 5 files changed, 51 insertions(+), 25 deletions(-) create mode 100644 opm/core/grid.c diff --git a/Makefile.am b/Makefile.am index cffd85a9..beb12e01 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,6 +50,7 @@ opm/core/fluid/RockCompressibility.cpp \ opm/core/fluid/RockFromDeck.cpp \ opm/core/fluid/SaturationPropsBasic.cpp \ opm/core/fluid/SaturationPropsFromDeck.cpp \ +opm/core/grid.c \ opm/core/grid/cart_grid.c \ opm/core/grid/cornerpoint_grid.c \ opm/core/grid/cpgpreprocess/geometry.c \ diff --git a/opm/core/grid.c b/opm/core/grid.c new file mode 100644 index 00000000..c66f401a --- /dev/null +++ b/opm/core/grid.c @@ -0,0 +1,46 @@ +/* + Copyright 2012 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include +#include + +void free_grid(struct UnstructuredGrid *g) +{ + if (g!=NULL) + { + free(g->face_nodes); + free(g->face_nodepos); + free(g->face_cells); + free(g->cell_facepos); + free(g->cell_faces); + + free(g->node_coordinates); + free(g->face_centroids); + free(g->face_areas); + free(g->face_normals); + free(g->cell_centroids); + free(g->cell_volumes); + + free(g->global_cell); + free(g->cell_facetag); + } + + free(g); +} + diff --git a/opm/core/grid.h b/opm/core/grid.h index 6bc445ce..3fa5aa83 100644 --- a/opm/core/grid.h +++ b/opm/core/grid.h @@ -56,6 +56,10 @@ struct UnstructuredGrid { int *cell_facetag; }; + +void free_grid(struct UnstructuredGrid *g); + + #ifdef __cplusplus } #endif diff --git a/opm/core/grid/cornerpoint_grid.c b/opm/core/grid/cornerpoint_grid.c index 45459000..7a4c4114 100644 --- a/opm/core/grid/cornerpoint_grid.c +++ b/opm/core/grid/cornerpoint_grid.c @@ -103,30 +103,6 @@ fill_cell_topology(struct processed_grid *pg, return g->cell_facepos != NULL; } -void free_grid(struct UnstructuredGrid *g) -{ - if (g!=NULL) - { - free(g->face_nodes); - free(g->face_nodepos); - free(g->face_cells); - free(g->cell_facepos); - free(g->cell_faces); - - free(g->node_coordinates); - free(g->face_centroids); - free(g->face_areas); - free(g->face_normals); - free(g->cell_centroids); - free(g->cell_volumes); - - free(g->global_cell); - free(g->cell_facetag); - } - - free(g); -} - static int allocate_geometry(struct UnstructuredGrid *g) { diff --git a/opm/core/grid/cornerpoint_grid.h b/opm/core/grid/cornerpoint_grid.h index be8d5f4d..0583c139 100644 --- a/opm/core/grid/cornerpoint_grid.h +++ b/opm/core/grid/cornerpoint_grid.h @@ -46,7 +46,6 @@ extern "C" { void compute_geometry (struct UnstructuredGrid *g); - void free_grid(struct UnstructuredGrid *g); #ifdef __cplusplus } #endif