[cig-commits] r6832 - cs/cigma/trunk/tests

luis at geodynamics.org luis at geodynamics.org
Wed May 9 17:39:42 PDT 2007


Author: luis
Date: 2007-05-09 17:39:41 -0700 (Wed, 09 May 2007)
New Revision: 6832

Added:
   cs/cigma/trunk/tests/test_volume.c
Log:
Volume calculation, and testing for containment


Added: cs/cigma/trunk/tests/test_volume.c
===================================================================
--- cs/cigma/trunk/tests/test_volume.c	2007-05-10 00:38:31 UTC (rev 6831)
+++ cs/cigma/trunk/tests/test_volume.c	2007-05-10 00:39:41 UTC (rev 6832)
@@ -0,0 +1,63 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cigma/tet4.h>
+
+int main(int argc, char *argv[])
+{
+    double verts[4*3] = {
+        -1.0, -1.0, -1.0,
+        +1.0, -1.0, -1.0,
+        -1.0, +1.0, -1.0,
+        -1.0, -1.0, +1.0
+    };
+
+    #define NPTS 5
+    double points[NPTS*3] = {
+        -1.0, -1.0, -1.0,
+        -0.79894646954959103, -0.79894646954959103, -0.79894646954959103,
+        -1.0, -1.0, -1.01,
+         1.0, 1.0, 1.0,
+         0.0,  0.0,  0.0
+    };
+
+    int expected[NPTS] = {
+        0, 0, -1, -1, -1
+    };
+
+    double vols[4];
+
+    int v;
+    int i;
+    int ierr;
+
+    printf("vol = %g\n\n", tet4_volume(&verts[3*0], &verts[3*1], &verts[3*2], &verts[3*3]));
+
+    for (i = 0; i < NPTS; i++)
+    {
+        ierr = tet4_test2(verts, &points[3*i], vols);
+        printf("x = (%g, %g, %g)\n", points[3*i+0], points[3*i+1], points[3*i+2]);
+
+        for (v = 0; v < 4; v++)
+        {
+            printf("v[%d] = %g\n", v, vols[v]);
+        }
+        
+        if (ierr < 0)
+        {
+            printf("failed");
+            if (expected[i] < 0)
+                printf(" (as expected)");
+        }
+        else
+        {
+            printf("passed!");
+            if (expected[i] == 0)
+                printf(" (as expected)");
+        }
+        
+        printf("\n\n");
+    }
+
+
+    return EXIT_SUCCESS;
+}



More information about the cig-commits mailing list