[cig-commits] r13503 - in cs/cigma/trunk: src tests/libcigma

luis at geodynamics.org luis at geodynamics.org
Tue Dec 9 18:12:45 PST 2008


Author: luis
Date: 2008-12-09 18:12:45 -0800 (Tue, 09 Dec 2008)
New Revision: 13503

Modified:
   cs/cigma/trunk/src/AnnLocator.cpp
   cs/cigma/trunk/src/MeshPart.cpp
   cs/cigma/trunk/src/MeshPart.h
   cs/cigma/trunk/tests/libcigma/LocatorTest.cpp
   cs/cigma/trunk/tests/libcigma/MeshPartTest.cpp
   cs/cigma/trunk/tests/libcigma/ResidualsTest.cpp
Log:
Introduce mesh->cell_type and eliminate mesh->cell

Specifically, MeshPart::selectCell(int) goes away

Modified: cs/cigma/trunk/src/AnnLocator.cpp
===================================================================
--- cs/cigma/trunk/src/AnnLocator.cpp	2008-12-10 02:12:44 UTC (rev 13502)
+++ cs/cigma/trunk/src/AnnLocator.cpp	2008-12-10 02:12:45 UTC (rev 13503)
@@ -4,6 +4,7 @@
 #include <boost/shared_ptr.hpp>
 
 using namespace cigma;
+using boost::shared_ptr;
 
 AnnLocator::AnnLocator()
 {
@@ -74,7 +75,8 @@
     double minpt[ndim];
     double maxpt[ndim];
 
-    boost::shared_ptr<Cell> cell = Cell::New(mesh.cell->cell_type());
+    //boost::shared_ptr<Cell> cell = Cell::New(mesh.cell->cell_type());
+    shared_ptr<Cell> cell = Cell::New(mesh.cell_type);
     assert(cell->cell_type() != Cell::NONE);
     
     for (i = 0; i < npts; i++)
@@ -82,7 +84,8 @@
         ANNpoint pt = dataPoints[i];
         //mesh.selectCell(i);    // XXX: use iterator
         mesh.getCell(i, *cell);
-        mesh.cell->bbox(minpt, maxpt);
+        //mesh.cell->bbox(minpt, maxpt);
+        cell->bbox(minpt, maxpt);
         for (j = 0; j < ndim; j++)
         {
             pt[ndim*0 + j] = minpt[j];

Modified: cs/cigma/trunk/src/MeshPart.cpp
===================================================================
--- cs/cigma/trunk/src/MeshPart.cpp	2008-12-10 02:12:44 UTC (rev 13502)
+++ cs/cigma/trunk/src/MeshPart.cpp	2008-12-10 02:12:45 UTC (rev 13503)
@@ -12,9 +12,15 @@
 {
 }
 
+/*
 void MeshPart::setCell(const shared_ptr<Cell>& cell)
 {
     this->cell = cell;
+} */
+
+void MeshPart::setCellType(Cell::type cell_type)
+{
+    this->cell_type = cell_type;
 }
 
 void MeshPart::setNodeCoordinates(const shared_ptr<NodeCoordinates>& nc)
@@ -34,15 +40,16 @@
     this->locator = loc;
 }
 
+/*
 void MeshPart::selectCell(int e)
 {
     assert(cell);
     this->getCellCoords(e, cell->globverts, cell->n_celldim());
-}
+} */
 
-void MeshPart::getCell(int e, Cell& c) const
+void MeshPart::getCell(int e, Cell& cell) const
 {
-    this->getCellCoords(e, c.globverts, c.n_celldim());
+    this->getCellCoords(e, cell.globverts, cell.n_celldim());
 }
 
 void MeshPart::getBoundingBox(double *minpt, double *maxpt) const
@@ -93,6 +100,9 @@
 
     *cellIndex = -1;
 
+    // XXX: use cell iterator
+    shared_ptr<Cell> cell = Cell::New(this->cell_type);
+    
     /* Attempt to use the locator if one is present */
     if (locator)
     {
@@ -103,7 +113,9 @@
             e = locator->idx(i);
             assert((0 <= e) && (e < nel));
 
-            this->selectCell(e);
+            //this->selectCell(e);
+            this->getCell(e, *cell);
+
             if (cell->global_interior(globalPoint))
             {
                 *cellIndex = e;
@@ -120,7 +132,8 @@
     static int last_cell = -1;
     if ((0 <= last_cell) && (last_cell < nel))
     {
-        selectCell(last_cell);
+        //selectCell(last_cell);
+        this->getCell(last_cell, *cell);
         if (cell->global_interior(globalPoint))
         {
             *cellIndex = last_cell;
@@ -134,7 +147,8 @@
      */
     for (e = 0; e < nel; e++)
     {
-        selectCell(e);
+        //selectCell(e);
+        this->getCell(e, *cell);
         if (cell->global_interior(globalPoint))
         {
             *cellIndex = e;

Modified: cs/cigma/trunk/src/MeshPart.h
===================================================================
--- cs/cigma/trunk/src/MeshPart.h	2008-12-10 02:12:44 UTC (rev 13502)
+++ cs/cigma/trunk/src/MeshPart.h	2008-12-10 02:12:45 UTC (rev 13503)
@@ -24,12 +24,13 @@
     int n_cells() const;
     int n_dim() const;
 
-    void setCell(const boost::shared_ptr<Cell>& cell); /* XXX: setCellType(...) */
+    //void setCell(const boost::shared_ptr<Cell>& cell); /* XXX: setCellType(...) */
+    void setCellType(Cell::type cell_type);
     void setNodeCoordinates(const boost::shared_ptr<NodeCoordinates>& nc);
     void setElementBlock(const boost::shared_ptr<ElementBlock>& eb);
     void setLocator(const boost::shared_ptr<Locator>& loc);
 
-    void selectCell(int e); /* XXX: replace by iterator */
+    //void selectCell(int e); /* XXX: replace by iterator */
     
     void getCell(int e, Cell &cell) const; // XXX
     void getBoundingBox(double *minpt, double *maxpt) const;
@@ -42,7 +43,7 @@
     boost::shared_ptr<ElementBlock> connect;
     boost::shared_ptr<NodeCoordinates> coords;
     boost::shared_ptr<Locator> locator;
-    boost::shared_ptr<Cell> cell; // XXX: only need to save the Cell::type
+    //boost::shared_ptr<Cell> cell; // XXX: only need to save the Cell::type
     Cell::type cell_type;
 };
 

Modified: cs/cigma/trunk/tests/libcigma/LocatorTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/LocatorTest.cpp	2008-12-10 02:12:44 UTC (rev 13502)
+++ cs/cigma/trunk/tests/libcigma/LocatorTest.cpp	2008-12-10 02:12:45 UTC (rev 13503)
@@ -35,7 +35,8 @@
     shared_ptr<MeshPart> mesh(new MeshPart);
     mesh->setNodeCoordinates(nc);
     mesh->setElementBlock(eb);
-    mesh->setCell(Cell::New("hex8"));
+    //mesh->setCell(Cell::New("hex8"));
+    mesh->setCellType(Cell::HEX8);
 
     //
     // Initialize Locator
@@ -62,9 +63,12 @@
     CPPUNIT_ASSERT((0 <= cellIndex) && (cellIndex < eb->n_cells()));
     CPPUNIT_ASSERT_EQUAL(6, cellIndex);
 
-    mesh->selectCell(6);
+    shared_ptr<Cell> cell = Cell::New(mesh->cell_type);
+    //mesh->selectCell(6);
+    mesh->getCell(6, *cell);
+
     //CPPUNIT_ASSERT_EQUAL(true, mesh->cell->interior(uvw));
-    CPPUNIT_ASSERT_EQUAL(true, mesh->cell->global_interior(point));
+    CPPUNIT_ASSERT_EQUAL(true, cell->global_interior(point));
 
 }
 

Modified: cs/cigma/trunk/tests/libcigma/MeshPartTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/MeshPartTest.cpp	2008-12-10 02:12:44 UTC (rev 13502)
+++ cs/cigma/trunk/tests/libcigma/MeshPartTest.cpp	2008-12-10 02:12:45 UTC (rev 13503)
@@ -47,8 +47,9 @@
     eb->setConnectivity(connect);
     mesh->setElementBlock(eb);
 
-    shared_ptr<Cell> cell(new tet4);
-    mesh->setCell(cell);
+    //shared_ptr<Cell> cell(new tet4);
+    //mesh->setCell(cell);
+    mesh->setCellType(Cell::TET4);
 
 
     int cellIndex = 2;
@@ -70,7 +71,7 @@
         }
     }
 
-    shared_ptr<Cell> it = Cell::New(mesh->cell->cell_type());
+    shared_ptr<Cell> it = Cell::New(mesh->cell_type);
     CPPUNIT_ASSERT(it->cell_type() != Cell::NONE);
     mesh->getCell(cellIndex, *it); 
     for (i = 0; i < 4; i++)

Modified: cs/cigma/trunk/tests/libcigma/ResidualsTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/ResidualsTest.cpp	2008-12-10 02:12:44 UTC (rev 13502)
+++ cs/cigma/trunk/tests/libcigma/ResidualsTest.cpp	2008-12-10 02:12:45 UTC (rev 13503)
@@ -29,8 +29,9 @@
     eb_reader = FileReader::New("tests/data/brick1/brick1_connect.dat", "r");
     eb_reader->getConnectivity("", &(eb->connect), &(eb->nel), &(eb->ndofs));
 
-    shared_ptr<Cell> cell(new hex8);
-    mesh->setCell(cell);
+    //shared_ptr<Cell> cell(new hex8);
+    //mesh->setCell(cell);
+    mesh->setCellType(Cell::HEX8);
 
     mesh->setNodeCoordinates(nc);
     mesh->setElementBlock(eb);
@@ -39,10 +40,13 @@
     shared_ptr<Residuals> residuals(new Residuals);
     residuals->setMesh(mesh);
     residuals->resetAccumulator();
+
+    shared_ptr<Cell> cell = Cell::New(mesh->cell_type);
     for (int e = 0; e < eb->n_cells(); e++)
     {
-        mesh->selectCell(e);
-        residuals->update(e, sqrt(2), mesh->cell->volume());
+        //mesh->selectCell(e);
+        mesh->getCell(e, *cell);
+        residuals->update(e, sqrt(2), cell->volume());
     }
     CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, residuals->L2(), delta);
     CPPUNIT_ASSERT_DOUBLES_EQUAL(sqrt(2), residuals->max(), delta);



More information about the CIG-COMMITS mailing list