[cig-commits] r13184 - cs/cigma/trunk/tests/libcigma

luis at geodynamics.org luis at geodynamics.org
Wed Oct 29 15:12:08 PDT 2008


Author: luis
Date: 2008-10-29 15:12:08 -0700 (Wed, 29 Oct 2008)
New Revision: 13184

Modified:
   cs/cigma/trunk/tests/libcigma/LocatorTest.cpp
Log:
Test fixture for locator

Modified: cs/cigma/trunk/tests/libcigma/LocatorTest.cpp
===================================================================
--- cs/cigma/trunk/tests/libcigma/LocatorTest.cpp	2008-10-29 22:12:06 UTC (rev 13183)
+++ cs/cigma/trunk/tests/libcigma/LocatorTest.cpp	2008-10-29 22:12:08 UTC (rev 13184)
@@ -2,13 +2,89 @@
 using namespace libcigma;
 
 #include "AnnLocator.h"
+#include "MeshPart.h"
+#include "nc_array.h"
+#include "eb_array.h"
+#include "Cell.h"
+#include "io_text_reader.h"
 using namespace cigma;
 
+#include <string>
+using namespace std;
+
 #include <boost/shared_ptr.hpp>
 using boost::shared_ptr;
 
 void LocatorTest::test_something()
 {
+    //
+    // Read an node and element data
+    //
+    shared_ptr<nc_array> nc(new nc_array);
+    shared_ptr<eb_array> eb(new eb_array);
+    
+    string prefix = "tests/data/brick1/";
+    string coordfile = prefix + "brick1_coords.dat";
+    string connfile = prefix + "brick1_connect.dat";
+
+    TextReader reader;
+
+    reader.getCoordinates(coordfile.c_str(), &(nc->coords), &(nc->nno), &(nc->nsd));
+    reader.close();
+
+    reader.getConnectivity(connfile.c_str(), &(eb->connect), &(eb->nel), &(eb->ndofs));
+    reader.close();
+
+    //
+    // Assign nc/eb arrays to a meshpart object
+    //
+    shared_ptr<MeshPart> mesh(new MeshPart);
+    mesh->setNodeCoordinates(nc);
+    mesh->setElementBlock(eb);
+    mesh->setCell(Cell::New("hex8"));
+
+    //
+    // Locator
+    //
     shared_ptr<AnnLocator> locator(new AnnLocator);
+    locator->init(*mesh);
+
+
+    //
+    // Finish mesh initialization
+    // XXX: is there a better way? perhaps inheritance..
+    //
+    mesh->setLocator(locator);
+
+    //
+    // Test locator
+    //
+    bool found = false;
+    double point[3] = {0.1, 0.1, 0.1};
+    double uvw[3];
+    int cellIndex = -1;
+    
+    found = mesh->findCell(point, uvw, &cellIndex);
+    //CPPUNIT_ASSERT(0 <= cellIndex);
+    //CPPUNIT_ASSERT(cellIndex < eb->n_cells());
+    CPPUNIT_ASSERT_EQUAL(6, cellIndex);
+
+    mesh->selectCell(6);
+    //CPPUNIT_ASSERT_EQUAL(true, mesh->cell->interior(uvw));
+    CPPUNIT_ASSERT_EQUAL(true, mesh->cell->global_interior(point));
+
+    /*
+    cout << "+++++++++++++\n";
+    for (int i = 0; i < 8; i++)
+    {
+        for (int j = 0; j < 3; j++)
+        {
+            cout << mesh->cell->globverts[3*i+j] << " ";
+        }
+        cout << endl;
+    }
+    cout << "++++++++++++++\n";
+    // */
+
 }
 



More information about the CIG-COMMITS mailing list