[cig-commits] r9083 - in cs/benchmark/cigma/trunk/src: . tests

luis at geodynamics.org luis at geodynamics.org
Wed Jan 16 17:25:10 PST 2008


Author: luis
Date: 2008-01-16 17:25:10 -0800 (Wed, 16 Jan 2008)
New Revision: 9083

Modified:
   cs/benchmark/cigma/trunk/src/Quad.cpp
   cs/benchmark/cigma/trunk/src/Quad.h
   cs/benchmark/cigma/trunk/src/Tri.cpp
   cs/benchmark/cigma/trunk/src/Tri.h
   cs/benchmark/cigma/trunk/src/tests/TestQuad.cpp
   cs/benchmark/cigma/trunk/src/tests/TestTri.cpp
Log:
Cell dimension must be declared properly or jacobian function won't work

Modified: cs/benchmark/cigma/trunk/src/Quad.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/Quad.cpp	2008-01-17 01:25:09 UTC (rev 9082)
+++ cs/benchmark/cigma/trunk/src/Quad.cpp	2008-01-17 01:25:10 UTC (rev 9083)
@@ -3,7 +3,7 @@
 
 // ---------------------------------------------------------------------------
 
-static void quad_shape(double u, double v, double w, double s[4])
+static void quad_shape(double u, double v, double s[4])
 {
     s[0] = 0.25 * (1.0 - u) * (1.0 - v);
     s[1] = 0.25 * (1.0 + u) * (1.0 - v);
@@ -11,25 +11,21 @@
     s[3] = 0.25 * (1.0 - u) * (1.0 + v);
 }
 
-static void quad_grad_shape(double u, double v, double w, double s[4*3])
+static void quad_grad_shape(double u, double v, double s[4*2])
 {
-    #define S(i,j) s[3*(i) + (j)]
+    #define S(i,j) s[2*(i) + (j)]
 
     S(0,0) = -0.25 * (1.0 - v);
     S(0,1) = -0.25 * (1.0 - u);
-    S(0,2) =  0.0;
 
     S(1,0) = +0.25 * (1.0 - v);
     S(1,1) = -0.25 * (1.0 + u);
-    S(1,2) =  0.0;
 
     S(2,0) = +0.25 * (1.0 + v);
     S(2,1) = +0.25 * (1.0 + u);
-    S(2,2) =  0.0;
 
     S(3,0) = -0.25 * (1.0 + v);
     S(3,1) = +0.25 * (1.0 - u);
-    S(3,2) =  0.0;
 
     #undef S
 }
@@ -39,12 +35,12 @@
 cigma::Quad::Quad()
 {
     const int quad_nno = 4;
-    const int quad_celldim = 3; //XXX
+    const int quad_celldim = 2;
     double verts[quad_nno * quad_celldim] = {
-        -1.0, -1.0, 0.0,
-        +1.0, -1.0, 0.0,
-        +1.0, +1.0, 0.0,
-        -1.0, +1.0, 0.0
+        -1.0, -1.0,
+        +1.0, -1.0,
+        +1.0, +1.0,
+        -1.0, +1.0
     };
     set_reference_vertices(verts, quad_nno);
 }
@@ -58,7 +54,7 @@
 
 /*
  *
- * @param points points is an [num x nsd] array (in)
+ * @param points points is an [num x celldim] array (in)
  * @param values values is an [num x ndofs] array (out)
  */
 void cigma::Quad::shape(int num, double *points, double *values)
@@ -66,16 +62,15 @@
     const int nno = n_nodes();
     for (int i = 0; i < num; i++)
     {
-        double u = points[3*i + 0];
-        double v = points[3*i + 1];
-        double w = points[3*i + 2];
-        quad_shape(u, v, w, &values[nno*i]);
+        double u = points[2*i + 0];
+        double v = points[2*i + 1];
+        quad_shape(u, v, &values[nno*i]);
     }
 }
 
 /*
  *
- * @param points points is an [num x nsd] array (in)
+ * @param points points is an [num x celldim] array (in)
  * @param values values is an [num x ndofs x celldim] array (out)
  */
 void cigma::Quad::grad_shape(int num, double *points, double *values)
@@ -85,10 +80,9 @@
     const int stride = nno * celldim;
     for (int i = 0; i < num; i++)
     {
-        double u = points[3*i + 0];
-        double v = points[3*i + 1];
-        double w = points[3*i + 2];
-        quad_grad_shape(u, v, w, &values[stride*i]);
+        double u = points[2*i + 0];
+        double v = points[2*i + 1];
+        quad_grad_shape(u, v, &values[stride*i]);
     }
 }
 

Modified: cs/benchmark/cigma/trunk/src/Quad.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Quad.h	2008-01-17 01:25:09 UTC (rev 9082)
+++ cs/benchmark/cigma/trunk/src/Quad.h	2008-01-17 01:25:10 UTC (rev 9083)
@@ -16,7 +16,7 @@
 
 public:
     int n_nodes() { return 4; }
-    int n_celldim() { return 3; } // XXX: change to 2
+    int n_celldim() { return 2; }
     int n_dim() { return 3; }
 
 public:

Modified: cs/benchmark/cigma/trunk/src/Tri.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/Tri.cpp	2008-01-17 01:25:09 UTC (rev 9082)
+++ cs/benchmark/cigma/trunk/src/Tri.cpp	2008-01-17 01:25:10 UTC (rev 9083)
@@ -3,28 +3,25 @@
 
 // ---------------------------------------------------------------------------
 
-static void tri_shape(double u, double v, double w, double s[3])
+static void tri_shape(double u, double v, double s[3])
 {
     s[0] = 1.0 - u - v ;
     s[1] =       u     ;
     s[2] =           v ;
 }
 
-static void tri_grad_shape(double u, double v, double w, double s[3*3])
+static void tri_grad_shape(double u, double v, double s[3*2])
 {
-    #define S(i,j) s[3*(i) + (j)]
+    #define S(i,j) s[2*(i) + (j)]
 
     S(0,0) = -1.0;
     S(0,1) = -1.0;
-    S(0,2) =  0.0;
 
     S(1,0) = +1.0;
     S(1,1) =  0.0;
-    S(1,2) =  0.0;
 
     S(2,0) =  0.0;
     S(2,1) = +1.0;
-    S(2,2) =  0.0;
 
     #undef S
 }
@@ -35,11 +32,11 @@
 cigma::Tri::Tri()
 {
     const int tri_nno = 3;
-    const int tri_celldim = 3; // XXX
+    const int tri_celldim = 2; // XXX
     double verts[tri_nno * tri_celldim] = {
-        0.0, 0.0, 0.0,
-        1.0, 0.0, 0.0,
-        0.0, 1.0, 0.0,
+        0.0, 0.0,
+        1.0, 0.0,
+        0.0, 1.0
     };
     set_reference_vertices(verts, tri_nno);
 }
@@ -55,10 +52,9 @@
     const int nno = n_nodes();
     for (int i = 0; i < num; i++)
     {
-        double u = points[3*i + 0];
-        double v = points[3*i + 1];
-        double w = points[3*i + 2];
-        tri_shape(u, v, w, &values[nno*i]);
+        double u = points[2*i + 0];
+        double v = points[2*i + 1];
+        tri_shape(u, v, &values[nno*i]);
     }
 }
 
@@ -69,10 +65,9 @@
     const int stride = nno * celldim;
     for (int i = 0; i < num; i++)
     {
-        double u = points[3*i + 0];
-        double v = points[3*i + 1];
-        double w = points[3*i + 2];
-        tri_grad_shape(u, v, w, &values[stride*i]);
+        double u = points[2*i + 0];
+        double v = points[2*i + 1];
+        tri_grad_shape(u, v, &values[stride*i]);
     }
 }
 

Modified: cs/benchmark/cigma/trunk/src/Tri.h
===================================================================
--- cs/benchmark/cigma/trunk/src/Tri.h	2008-01-17 01:25:09 UTC (rev 9082)
+++ cs/benchmark/cigma/trunk/src/Tri.h	2008-01-17 01:25:10 UTC (rev 9083)
@@ -16,7 +16,7 @@
 
 public:
     int n_nodes() { return 3; }
-    int n_celldim() { return 3; } // XXX: change to 2
+    int n_celldim() { return 2; }
     int n_dim() { return 3; }
 
 public:

Modified: cs/benchmark/cigma/trunk/src/tests/TestQuad.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestQuad.cpp	2008-01-17 01:25:09 UTC (rev 9082)
+++ cs/benchmark/cigma/trunk/src/tests/TestQuad.cpp	2008-01-17 01:25:10 UTC (rev 9083)
@@ -17,24 +17,24 @@
     Quad quadcell;
     int ndofs = quadcell.n_nodes();
     const int npts = 6;
-    const int nsd = 3;
-    double refpts[npts*nsd] = {
-        -1.0, -1.0, 0.0,
-        +1.0, -1.0, 0.0,
-        +1.0, +1.0, 0.0,
-        -1.0, +1.0, 0.0,
-         0.0,  0.0, 0.0,
-         0.5,  0.5, 0.5,
+    const int celldim = 2;
+    double refpts[npts * celldim] = {
+        -1.0, -1.0,
+        +1.0, -1.0,
+        +1.0, +1.0,
+        -1.0, +1.0,
+         0.0,  0.0,
+         0.5,  0.5
     };
 
     double tab[npts*ndofs];
-    double tab_jet[npts*ndofs*3];
+    double tab_jet[npts*ndofs*celldim];
     quadcell.shape(npts, refpts, tab);
     quadcell.grad_shape(npts, refpts, tab_jet);
 
     for (int i = 0; i < npts; i++)
     {
-        double *pt = &refpts[nsd*i];
+        double *pt = &refpts[celldim*i];
         double u = pt[0];
         double v = pt[1];
         double w = pt[2];
@@ -42,8 +42,7 @@
         cout << i << " : ";
         cout << "x = ("
              << u << " "
-             << v << " "
-             << w << ")  ";
+             << v << ")  ";
 
         bool inside = quadcell.interior(u, v, w);
         cout << "in = " << inside << "  ";
@@ -55,23 +54,19 @@
              << phi[2] << " "
              << phi[3] << ")  ";
 
-        double *grad_phi = &tab_jet[i*ndofs*nsd];
+        double *grad_phi = &tab_jet[i*ndofs*celldim];
         cout << "grad_phi = ("
-             << "(" << grad_phi[3*0 + 0] << " "
-                    << grad_phi[3*0 + 1] << " "
-                    << grad_phi[3*0 + 2] << "),"
+             << "(" << grad_phi[2*0 + 0] << " "
+                    << grad_phi[2*0 + 1] << "),"
 
-             << "(" << grad_phi[3*1 + 0] << " "
-                    << grad_phi[3*1 + 1] << " "
-                    << grad_phi[3*1 + 2] << "),"
+             << "(" << grad_phi[2*1 + 0] << " "
+                    << grad_phi[2*1 + 1] << "),"
 
-             << "(" << grad_phi[3*2 + 0] << " "
-                    << grad_phi[3*2 + 1] << " "
-                    << grad_phi[3*2 + 2] << "),"
+             << "(" << grad_phi[2*2 + 0] << " "
+                    << grad_phi[2*2 + 1] << "),"
 
-             << "(" << grad_phi[3*3 + 0] << " "
-                    << grad_phi[3*3 + 1] << " "
-                    << grad_phi[3*3 + 2] << ")"
+             << "(" << grad_phi[2*3 + 0] << " "
+                    << grad_phi[2*3 + 1] << ")"
              << ")  ";
 
         double J[3][3];

Modified: cs/benchmark/cigma/trunk/src/tests/TestTri.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestTri.cpp	2008-01-17 01:25:09 UTC (rev 9082)
+++ cs/benchmark/cigma/trunk/src/tests/TestTri.cpp	2008-01-17 01:25:10 UTC (rev 9083)
@@ -16,25 +16,26 @@
 
     Tri tricell;
 
-    int ndofs = tricell.n_nodes();
+
     const int npts = 4;
-    const int nsd = 3;
+    const int celldim = 2;
+    const int ndofs = tricell.n_nodes();
 
-    double refpts[npts*nsd] = {
-        0.0, 0.0, 0.0,
-        1.0, 0.0, 0.0,
-        0.0, 1.0, 0.0,
-        0.5, 0.5, 0.0,
+    double refpts[npts*celldim] = {
+        0.0, 0.0,
+        1.0, 0.0,
+        0.0, 1.0,
+        0.5, 0.5
     };
 
     double tab[npts*ndofs];
-    double tab_jet[npts*ndofs*nsd];
+    double tab_jet[npts*ndofs*celldim];
     tricell.shape(npts, refpts, tab);
     tricell.grad_shape(npts, refpts, tab_jet);
 
     for (int i = 0; i < npts; i++)
     {
-        double *pt = &refpts[nsd*i];
+        double *pt = &refpts[celldim*i];
         double u = pt[0];
         double v = pt[1];
         double w = pt[2];
@@ -43,8 +44,7 @@
 
         cout << "x = ("
              << u << " "
-             << v << " "
-             << w << ")  ";
+             << v << ")  ";
 
         bool inside = tricell.interior(u,v,w);
         cout << "in = " << inside << "  ";
@@ -55,19 +55,16 @@
              << phi[1] << " "
              << phi[2] << ")  ";
 
-        double *grad_phi = &tab_jet[i*ndofs*nsd];
+        double *grad_phi = &tab_jet[i*ndofs*celldim];
         cout << "grad_phi = ("
-             << "(" << grad_phi[3*0 + 0] << " "
-                    << grad_phi[3*0 + 1] << " "
-                    << grad_phi[3*0 + 2] << "),"
+             << "(" << grad_phi[2*0 + 0] << " "
+                    << grad_phi[2*0 + 1] << "),"
 
-             << "(" << grad_phi[3*1 + 0] << " "
-                    << grad_phi[3*1 + 1] << " "
-                    << grad_phi[3*1 + 2] << "),"
+             << "(" << grad_phi[2*1 + 0] << " "
+                    << grad_phi[2*1 + 1] << "),"
 
-             << "(" << grad_phi[3*2 + 0] << " "
-                    << grad_phi[3*2 + 1] << " "
-                    << grad_phi[3*2 + 2] << ")"
+             << "(" << grad_phi[2*2 + 0] << " "
+                    << grad_phi[2*2 + 1] << ")"
              << ")  ";
 
         double J[3][3];



More information about the cig-commits mailing list