[cig-commits] r9137 - in cs/benchmark/cigma/trunk/src: . tests
luis at geodynamics.org
luis at geodynamics.org
Fri Jan 25 07:37:26 PST 2008
Author: luis
Date: 2008-01-25 07:37:26 -0800 (Fri, 25 Jan 2008)
New Revision: 9137
Modified:
cs/benchmark/cigma/trunk/src/AnnLocator.cpp
cs/benchmark/cigma/trunk/src/AnnLocator.h
cs/benchmark/cigma/trunk/src/tests/TestAnnLocator.cpp
Log:
AnnLocator is now a subclass of Locator.
Modified: cs/benchmark/cigma/trunk/src/AnnLocator.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/AnnLocator.cpp 2008-01-25 15:37:24 UTC (rev 9136)
+++ cs/benchmark/cigma/trunk/src/AnnLocator.cpp 2008-01-25 15:37:26 UTC (rev 9137)
@@ -1,5 +1,6 @@
#include <cassert>
#include "AnnLocator.h"
+#include "MeshPart.h"
// ---------------------------------------------------------------------------
@@ -23,6 +24,7 @@
{
if (kdtree != 0) delete kdtree;
if (dataPoints != 0) annDeallocPts(dataPoints);
+
if (nnIdx != 0) delete [] nnIdx;
if (nnDists != 0) delete [] nnDists;
}
@@ -32,6 +34,8 @@
void cigma::AnnLocator::initialize(MeshPart *meshPart)
{
+ assert(nnk > 0);
+
npts = meshPart->nel;
nsd = meshPart->nsd;
dim = 2 * nsd;
@@ -51,10 +55,9 @@
for (i = 0; i < npts; i++)
{
- meshPart->set_cell(i);
- meshPart->cell->bbox(minpt, maxpt);
-
ANNpoint pt = dataPoints[i];
+ meshPart->select_cell(i);
+ meshPart->cell->bbox(minpt, maxpt);
for (j = 0; j < nsd; j++)
{
pt[nsd*0 + j] = minpt[j];
@@ -68,22 +71,15 @@
// ---------------------------------------------------------------------------
-void cigma::AnnLocator::search(double *globalPoint, int *cellIndices, int k)
+void cigma::AnnLocator::search(double *globalPoint)
{
- int i;
-
- for (i = 0; i < nsd; i++)
+ for (int i = 0; i < nsd; i++)
{
queryPoint[nsd*0 + i] = globalPoint[i];
queryPoint[nsd*1 + i] = globalPoint[i];
}
- kdtree->annkSearch(queryPoint, k, nnIdx, nnDists, epsilon);
-
- for (i = 0; i < k; i++)
- {
- cellIndices[i] = nnIdx[i];
- }
+ kdtree->annkSearch(queryPoint, nnk, nnIdx, nnDists, epsilon);
}
Modified: cs/benchmark/cigma/trunk/src/AnnLocator.h
===================================================================
--- cs/benchmark/cigma/trunk/src/AnnLocator.h 2008-01-25 15:37:24 UTC (rev 9136)
+++ cs/benchmark/cigma/trunk/src/AnnLocator.h 2008-01-25 15:37:26 UTC (rev 9137)
@@ -2,7 +2,7 @@
#define __ANN_LOCATOR_H__
#include "ANN/ANN.h"
-#include "MeshPart.h"
+#include "Locator.h"
namespace cigma
@@ -12,7 +12,7 @@
-class cigma::AnnLocator
+class cigma::AnnLocator : public cigma::Locator
{
public:
AnnLocator();
@@ -20,14 +20,15 @@
public:
void initialize(MeshPart *meshPart);
+ void search(double *globalPoint);
public:
- void search(double *globalPoint, int *cellIndices, int k);
+ int n_idx();
+ int idx(int i);
public:
int nnk; // number of nearest neighbors
int npts; // number of points (bounding boxes)
- int nsd; // spatial dimensions
int dim; // dimension of bounding box (2 * nsd)
double epsilon; // tolerance (in bbox space)
@@ -36,12 +37,28 @@
ANNkd_tree *kdtree;
public:
- ANNpoint queryPoint; // query point for find()
+ ANNpoint queryPoint; // query point for search()
ANNidxArray nnIdx; // near neighbor indices
ANNdistArray nnDists; // near neighbord distances
};
+// ---------------------------------------------------------------------------
+inline int cigma::AnnLocator::n_idx()
+{
+ return nnk;
+}
+
+inline int cigma::AnnLocator::idx(int i)
+{
+ //assert(0 <= i);
+ //assert(i < nnk);
+ return nnIdx[i];
+}
+
+
+// ---------------------------------------------------------------------------
+
#endif
Modified: cs/benchmark/cigma/trunk/src/tests/TestAnnLocator.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestAnnLocator.cpp 2008-01-25 15:37:24 UTC (rev 9136)
+++ cs/benchmark/cigma/trunk/src/tests/TestAnnLocator.cpp 2008-01-25 15:37:26 UTC (rev 9137)
@@ -52,34 +52,19 @@
MeshPart *meshPart;
- meshPart = new VtkUgMeshPart();
+ //meshPart = new VtkUgMeshPart();
+ meshPart = new MeshPart();
meshPart->set_coordinates(coords, nno, nsd);
meshPart->set_connectivity(connect, nel, ndofs);
- meshPart->cell = 0;
- switch (ndofs)
- {
- case 4:
- meshPart->cell = new Tet();
- break;
- case 8:
- meshPart->cell = new Hex();
- break;
- }
- assert(meshPart->cell != 0);
+ meshPart->set_cell();
-
-
AnnLocator *locator = new AnnLocator();
- locator->initialize(meshPart);
+ meshPart->set_locator(locator);
-
-
-
double minpt[nsd], maxpt[nsd];
meshPart->get_bbox(minpt, maxpt);
-
double *points = new double[npts * nsd];
for (i = 0; i < npts; i++)
{
@@ -92,8 +77,9 @@
- int k = locator->nnk;
- int *candidateCells= new int[k];
+ //int k = locator->nnk;
+ //int *candidateCells= new int[k];
+
int *parentCells = new int[npts];
for (i = 0; i < npts; i++)
@@ -108,13 +94,18 @@
time(&t0);
for (i = 0; i < npts; i++)
{
+ bool found = false;
double *pt = &points[nsd*i];
+
+
+
+ /*
locator->search(pt, candidateCells, k);
- bool found = false;
for (j = 0; j < k; j++)
{
int e = candidateCells[j];
+
meshPart->set_cell(e);
double uvw[3];
@@ -125,7 +116,10 @@
parentCells[i] = e;
break;
}
- }
+ } // */
+
+ found = meshPart->find_cell(pt, &parentCells[i]);
+
assert(found);
}
time(&t1);
@@ -165,7 +159,7 @@
delete [] points;
delete [] parentCells;
- delete [] candidateCells;
+ //delete [] candidateCells;
return 0;
More information about the cig-commits
mailing list