[cig-commits] r13163 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Oct 29 15:11:25 PDT 2008


Author: luis
Date: 2008-10-29 15:11:25 -0700 (Wed, 29 Oct 2008)
New Revision: 13163

Modified:
   cs/cigma/trunk/src/Cell.cpp
   cs/cigma/trunk/src/Cell.h
Log:
Updated cigma::Cell

Added length argument to Cell::set_global_vertices
Also added method Cell::interior(double*)

Modified: cs/cigma/trunk/src/Cell.cpp
===================================================================
--- cs/cigma/trunk/src/Cell.cpp	2008-10-29 22:11:24 UTC (rev 13162)
+++ cs/cigma/trunk/src/Cell.cpp	2008-10-29 22:11:25 UTC (rev 13163)
@@ -31,6 +31,10 @@
 
 void Cell::set_reference_vertices(double *vertices)
 {
+    //
+    // This function should be only be called from the subclass constructor,
+    // when assigning the reference vertices to the cell.
+    //
     int i,j;
     const int nno = n_nodes();
     const int celldim = n_celldim();
@@ -45,42 +49,41 @@
     // copy data from vertices
     for (i = 0; i < nno; i++)
     {
-        for (j = 0; j < dim; j++)
-        {
-            globverts[dim*i + j] = 0.0;
-        }
         for (j = 0; j < celldim; j++)
         {
             int n = celldim*i + j;
             refverts[n] = vertices[n];
             globverts[dim*i+j] = vertices[n];
         }
+        for (j = celldim; j < dim; j++)
+        {
+            globverts[dim*i + j] = 0.0;
+        }
     }
 
     return;
 }
 
 
-void Cell::set_global_vertices(double *vertices)
+void Cell::set_global_vertices(double *vertices, int vdim)
 {
-    // Copy reference?
-    //globverts = vertices;
-
     // Copy data instead
     int i,j;
     const int nno = n_nodes();
     const int celldim = n_celldim();
     const int dim = n_dim();
+    assert(vdim == celldim);
     for (i = 0; i < nno; i++)
     {
-        for (j = 0; j < dim; j++)
+        for (j = 0; j < vdim; j++)
         {
-            int n = dim * i + j;
-            globverts[n] = vertices[n];
+            globverts[dim*i + j] = vertices[vdim*i + j];
         }
+        for (j = vdim; j < dim; j++)
+        {
+            globverts[dim*i + j] = 0.0;
+        }
     }
-
-    return;
 }
 
 
@@ -312,7 +315,7 @@
 
 
 /* Inverse reference map */
-void cigma::Cell::xyz2uvw(double xyz[3], double uvw[3])
+void Cell::xyz2uvw(double xyz[3], double uvw[3])
 {
     #define X(i)  globverts[3*(i) + 0]
     #define Y(i)  globverts[3*(i) + 1]
@@ -381,14 +384,14 @@
 
 
 /* isoparametric reference map */
-void cigma::Cell::uvw2xyz(double uvw[3], double xyz[3])
+void Cell::uvw2xyz(double uvw[3], double xyz[3])
 {
     assert(globverts != 0);
     interpolate(globverts, uvw, xyz, 3);
 }
 
 
-void cigma::Cell::bbox(double *min, double *max)
+void Cell::bbox(double *min, double *max)
 {
     const int nno = n_nodes();
     const int nsd = n_dim();
@@ -396,15 +399,26 @@
 }
 
 
-void cigma::Cell::centroid(double c[3])
+void Cell::centroid(double c[3])
 {
     const int nno = n_nodes();
     const int nsd = n_dim();
     cigma::centroid(globverts, nno, nsd, c);
 }
 
+bool Cell::interior(double *point)
+{
+    const int celldim = n_celldim();
+    switch (celldim)
+    {
+    case 3: return this->interior(point[0], point[1], point[2]);
+    case 2: return this->interior(point[0], point[1], 0.0);
+    case 1: return this->interior(point[0], 0.0, 0.0);
+    }
+    return false;
+}
 
-bool cigma::Cell::global_interior(double xyz[3])
+bool Cell::global_interior(double xyz[3])
 {
     double uvw[3];
     xyz2uvw(xyz,uvw);

Modified: cs/cigma/trunk/src/Cell.h
===================================================================
--- cs/cigma/trunk/src/Cell.h	2008-10-29 22:11:24 UTC (rev 13162)
+++ cs/cigma/trunk/src/Cell.h	2008-10-29 22:11:25 UTC (rev 13163)
@@ -44,10 +44,12 @@
     virtual boost::shared_ptr<Quadrature> default_quadrature() = 0;
 
     void set_reference_vertices(double *vertices);
-    void set_global_vertices(double *vertices);
+    void set_global_vertices(double *vertices, int vdim);
 
     virtual double volume() = 0;
+
     virtual bool interior(double u, double v, double w) = 0;
+    virtual bool interior(double *point);
     virtual bool global_interior(double xyz[3]);
 
     void bbox(double *min, double *max);



More information about the CIG-COMMITS mailing list