From f6a7a488315823856058c3f3860aa3928c2f9130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 26 Jun 2012 20:54:37 +0200 Subject: [PATCH 1/6] Compute_cell_geometry(): Don't print misleading diagnostic message. We don't know if we should emit a diagnostic concerning non-positive cell volumes until we have accumulated all tetrahedral contributions. While here, amend the diagnostic message to also report the cell in which non-positive volumes are detected. --- geometry.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/geometry.c b/geometry.c index 27e4cfdd..c4c06394 100644 --- a/geometry.c +++ b/geometry.c @@ -131,6 +131,12 @@ compute_cell_geometry(int ndims, double *coords, double ccell[3]; double cface[3] = {0}; const double twothirds = 0.666666666666666666666666666667; + + int ndigits; + + ndigits = ((int) (log(ncells) / log(10.0))) + 1; + + for (c=0; c0)){ - fprintf(stderr, "Internal error in mex_compute_geometry: negative volume\n"); - } /* face centroid of triangle */ for (i=0; i 0.0)) { + fprintf(stderr, + "Internal error in mex_compute_geometry(%*d): " + "negative volume\n", ndigits, c); + } + for (i=0; i Date: Tue, 26 Jun 2012 20:57:00 +0200 Subject: [PATCH 2/6] Remove some long-disabled code that only served to confuse the reader. --- geometry.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/geometry.c b/geometry.c index c4c06394..5af49087 100644 --- a/geometry.c +++ b/geometry.c @@ -198,14 +198,10 @@ compute_cell_geometry(int ndims, double *coords, cross(u,v,w); - - tet_volume = 0; for(i=0; i Date: Tue, 26 Jun 2012 20:59:19 +0200 Subject: [PATCH 3/6] Lower constant tet_volume multiplication below accumulation loop. --- geometry.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/geometry.c b/geometry.c index 5af49087..37e11008 100644 --- a/geometry.c +++ b/geometry.c @@ -200,8 +200,9 @@ compute_cell_geometry(int ndims, double *coords, tet_volume = 0; for(i=0; i Date: Mon, 25 Jun 2012 19:59:10 +0000 Subject: [PATCH 4/6] Use more traditional comparison: "a!=b" rather than "!(a==b)" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.sintef.no/simmatlab/branches/mrst-reorg/mex/libgeometry@9310 ea62cf4e-aff8-4dd6-bb37-af94872dbd4c Signed-off-by: Bård Skaflestad --- geometry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry.c b/geometry.c index 37e11008..21c1dafd 100644 --- a/geometry.c +++ b/geometry.c @@ -212,7 +212,7 @@ compute_cell_geometry(int ndims, double *coords, if(subnormal_sign<0){ tet_volume*=-1.0; } - if(!(neighbors[2*face+0]==c)){ + if (neighbors[2*face + 0] != c) { tet_volume*=-1.0; } From 37d7f4d8e2331fb8fde712d265e7080ce39bf5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 25 Jun 2012 20:00:25 +0000 Subject: [PATCH 5/6] Negate quantity by unary minus rather than multiplication by "-1". MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.sintef.no/simmatlab/branches/mrst-reorg/mex/libgeometry@9311 ea62cf4e-aff8-4dd6-bb37-af94872dbd4c Signed-off-by: Bård Skaflestad --- geometry.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geometry.c b/geometry.c index 21c1dafd..4d47c307 100644 --- a/geometry.c +++ b/geometry.c @@ -210,10 +210,10 @@ compute_cell_geometry(int ndims, double *coords, } if(subnormal_sign<0){ - tet_volume*=-1.0; + tet_volume = - tet_volume; } if (neighbors[2*face + 0] != c) { - tet_volume*=-1.0; + tet_volume = - tet_volume; } volume += tet_volume; From 619ce079385a8d6ef215950d0c11c8cd87654335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 25 Jun 2012 20:01:02 +0000 Subject: [PATCH 6/6] Insert white-space for readability. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.sintef.no/simmatlab/branches/mrst-reorg/mex/libgeometry@9312 ea62cf4e-aff8-4dd6-bb37-af94872dbd4c Signed-off-by: Bård Skaflestad --- geometry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry.c b/geometry.c index 4d47c307..b4dfc211 100644 --- a/geometry.c +++ b/geometry.c @@ -209,7 +209,7 @@ compute_cell_geometry(int ndims, double *coords, subnormal_sign += w[i]*fnormals[3*face+i]; } - if(subnormal_sign<0){ + if (subnormal_sign < 0.0) { tet_volume = - tet_volume; } if (neighbors[2*face + 0] != c) {