From 790d6f4b8b085393ae600e3f68618aab4aac59bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 16 Sep 2010 06:37:23 +0000 Subject: [PATCH] Track reverse mapping into WI/depth tables in 'cwells'. Update allocation sizes accordingly. --- well.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/well.c b/well.c index 4229ccaf..95f07de3 100644 --- a/well.c +++ b/well.c @@ -27,8 +27,8 @@ allocate_cell_wells(int nc, well_t *W, int **cwpos, int **cwells) totwconn = W->well_connpos[W->number_of_wells]; - *cwpos = calloc(nc + 1 , sizeof **cwpos ); - *cwells = malloc(totwconn * sizeof **cwells); + *cwpos = calloc(nc + 1 , sizeof **cwpos ); + *cwells = malloc(2 * totwconn * sizeof **cwells); if ((*cwpos == NULL) || (*cwells == NULL)) { deallocate_cell_wells(*cwpos, *cwells); @@ -69,7 +69,10 @@ derive_cell_wells(int nc, well_t *W, int *cwpos, int *cwells) c = W->well_cells; for (w = 0; w < W->number_of_wells; w++) { for (; c != W->well_cells + connpos[w + 1]; c++) { - cwells[ cwpos[*c + 1] ++ ] = w; + cwells[ 2*cwpos[*c + 1] + 0 ] = w; + cwells[ 2*cwpos[*c + 1] + 1 ] = c - W->well_cells; + + cwpos[*c + 1] += 1; } } }