[cig-commits] r9136 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Fri Jan 25 07:37:25 PST 2008
Author: luis
Date: 2008-01-25 07:37:24 -0800 (Fri, 25 Jan 2008)
New Revision: 9136
Modified:
cs/benchmark/cigma/trunk/src/MeshPart.cpp
cs/benchmark/cigma/trunk/src/MeshPart.h
Log:
Various improvements to MeshPart class
* Added locator for use in speeding up the find_cell() method
* Added get_bbox() for finding mesh bounding box
* Added set_cell() for instantiating the appropriate Cell class
* Added select_cell() for setting global coords of current cell
* Moved implementation of find_cell() from VtkUgMeshPart
* Removing virtual keyword from methods (no longer necessary)
Modified: cs/benchmark/cigma/trunk/src/MeshPart.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/MeshPart.cpp 2008-01-25 15:37:23 UTC (rev 9135)
+++ cs/benchmark/cigma/trunk/src/MeshPart.cpp 2008-01-25 15:37:24 UTC (rev 9136)
@@ -1,6 +1,13 @@
+#include <cassert>
#include "MeshPart.h"
-#include <cassert>
+#include "Numeric.h"
+#include "Tet.h"
+#include "Hex.h"
+#include "Tri.h"
+#include "Quad.h"
+
+
// ---------------------------------------------------------------------------
cigma::MeshPart::
@@ -15,6 +22,7 @@
connect = 0;
cell = 0;
+ locator = 0;
}
@@ -33,15 +41,12 @@
void cigma::MeshPart::
set_coordinates(double *coordinates, int nno, int nsd)
{
- //assert(nno > 0);
- //assert(nsd > 0);
+ assert(nno > 0);
+ assert(nsd > 0);
this->nno = nno;
this->nsd = nsd;
- //assert(nno == n_nodes());
- //assert(nsd == n_nsd());
-
/* // XXX: copy pointer
coords = coordinates;
// */
@@ -62,15 +67,12 @@
void cigma::MeshPart::
set_connectivity(int *connectivity, int nel, int ndofs)
{
- //assert(nel > 0);
- //assert(ndofs > 0);
+ assert(nel > 0);
+ assert(ndofs > 0);
this->nel = nel;
this->ndofs = ndofs;
- //assert(nel == n_nel());
- //assert(ndofs == n_ndofs());
-
/* // XXX: copy pointer
connect = connectivity;
// */
@@ -88,18 +90,65 @@
}
+void cigma::MeshPart::
+set_locator(Locator *locator)
+{
+ this->locator = locator;
+ locator->initialize(this);
+}
+
+
+void cigma::MeshPart::
+set_cell()
+{
+ assert(nsd > 0);
+ assert(ndofs > 0);
+
+ cell = 0;
+ switch (nsd)
+ {
+ case 3:
+ switch (ndofs)
+ {
+ case 4:
+ cell = new Tet();
+ break;
+ case 8:
+ cell = new Hex();
+ break;
+ }
+ break;
+ case 2:
+ switch (ndofs)
+ {
+ case 3:
+ cell = new Tri();
+ break;
+ case 4:
+ cell = new Quad();
+ break;
+ }
+ break;
+ }
+ assert(cell != 0);
+}
+
+
// ---------------------------------------------------------------------------
void cigma::MeshPart::
+get_bbox(double *minpt, double *maxpt)
+{
+ cigma::minmax(coords, nno, nsd, minpt, maxpt);
+}
+
+
+void cigma::MeshPart::
get_cell_coords(int cellIndex, double *globalCellCoords)
{
//assert(nsd > 0);
//assert(ndofs > 0);
- //const int nel = n_nel();
- //const int ndofs = n_ndofs();
- //const int nsd = n_nsd();
-
assert(0 <= cellIndex);
assert(cellIndex < nel);
@@ -115,4 +164,74 @@
}
}
+
+void cigma::MeshPart::
+select_cell(int e)
+{
+ get_cell_coords(e, cell->globverts);
+}
+
+
+bool cigma::MeshPart::
+find_cell(double *globalPoint, int *cellIndex)
+{
+ int i;
+ int e;
+
+ *cellIndex = -1;
+
+ if (locator != 0)
+ {
+ locator->search(globalPoint);
+
+ for (i = 0; i < locator->n_idx(); i++)
+ {
+ e = locator->idx(i);
+
+ select_cell(e);
+
+ if (cell->global_interior(globalPoint))
+ {
+ *cellIndex = e;
+ return true;
+ }
+ }
+ return false; // XXX: give up here?
+ }
+
+
+ /* Check every cell for given point. Since
+ * quadrature points are clustered together in
+ * the same cell, remember the last cell
+ * that was checked and look there first.
+ */
+ static int last_cell = -1;
+
+ //*
+ if ((0 <= last_cell) && (last_cell < nel))
+ {
+ select_cell(last_cell);
+
+ if (cell->global_interior(globalPoint))
+ {
+ *cellIndex = last_cell;
+ return true;
+ }
+ } // */
+
+ for (e = 0; e < nel; e++)
+ {
+ select_cell(e);
+
+ if (cell->global_interior(globalPoint))
+ {
+ *cellIndex = e;
+ last_cell = e;
+ return true;
+ }
+ }
+
+ return false;
+}
+
// ---------------------------------------------------------------------------
Modified: cs/benchmark/cigma/trunk/src/MeshPart.h
===================================================================
--- cs/benchmark/cigma/trunk/src/MeshPart.h 2008-01-25 15:37:23 UTC (rev 9135)
+++ cs/benchmark/cigma/trunk/src/MeshPart.h 2008-01-25 15:37:24 UTC (rev 9136)
@@ -2,6 +2,7 @@
#define __MESH_PART_H__
#include "Cell.h"
+#include "Locator.h"
namespace cigma
{
@@ -12,22 +13,32 @@
{
public:
MeshPart();
- virtual ~MeshPart();
+ ~MeshPart();
public:
void set_coordinates(double *coordinates, int nno, int nsd);
void set_connectivity(int *connectivity, int nel, int ndofs);
+ void set_locator(Locator *locator);
+ void set_cell();
public:
+ void select_cell(int e);
+
+public:
+ void get_bbox(double *minpt, double *maxpt);
void get_cell_coords(int cellIndex, double *globalCoords);
- virtual bool find_cell(double globalPoint[3], int *cellIndex) = 0;
+ bool find_cell(double *globalPoint, int *cellIndex);
public:
int nno, nsd;
int nel, ndofs;
double *coords;
int *connect;
+
+public:
Cell *cell;
+ Locator *locator;
+
};
More information about the cig-commits
mailing list