From fbe81573329f7f19d26e43d1d5cc9b32cab9b85e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 20 Dec 2010 10:39:20 +0000 Subject: [PATCH] Export the cell-face tags (i.e., cells.faces(:,2)) back to M in a manner consistent with the traditional semantics of the grid_structure. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bård Skaflestad --- processgrid.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/processgrid.c b/processgrid.c index f15ee344..1e43ce94 100644 --- a/processgrid.c +++ b/processgrid.c @@ -184,16 +184,26 @@ void fill_grid(mxArray **out, struct processed_grid *grid) } } - mxArray *cellfaces = mxCreateNumericMatrix(num_half_faces, 1, + mxArray *cellfaces = mxCreateNumericMatrix(num_half_faces, 2, mxINT32_CLASS, mxREAL); { int *iptr = mxGetData(cellfaces); + int c1, c2, cf_tag; for (i=0; inumber_of_faces; ++i) { - int c1 = grid->face_neighbors[2*i]; - int c2 = grid->face_neighbors[2*i+1]; - if(c1 != -1) iptr[counter[c1]++] = i+1; - if(c2 != -1) iptr[counter[c2]++] = i+1; + cf_tag = 2 * grid->face_tag[i] + 1; /* [1, 3, 5] */ + c1 = grid->face_neighbors[2*i+0]; + c2 = grid->face_neighbors[2*i+1]; + if(c1 != -1) { + iptr[counter[c1] + 0*num_half_faces] = i+1; + iptr[counter[c1] + 1*num_half_faces] = cf_tag + 1; /* out */ + counter[c1] += 1; + } + if(c2 != -1) { + iptr[counter[c2] + 0*num_half_faces] = i+1; + iptr[counter[c2] + 1*num_half_faces] = cf_tag + 0; /* in */ + counter[c2] += 1; + } } } mxSetField(cells, 0, "faces", cellfaces);