[cig-commits] r8946 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Dec 19 12:06:40 PST 2007
Author: luis
Date: 2007-12-19 12:06:39 -0800 (Wed, 19 Dec 2007)
New Revision: 8946
Modified:
cs/benchmark/cigma/trunk/src/MeshPart.cpp
cs/benchmark/cigma/trunk/src/MeshPart.h
Log:
Some improvements to MeshPart virtual class
Modified: cs/benchmark/cigma/trunk/src/MeshPart.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/MeshPart.cpp 2007-12-19 20:06:32 UTC (rev 8945)
+++ cs/benchmark/cigma/trunk/src/MeshPart.cpp 2007-12-19 20:06:39 UTC (rev 8946)
@@ -6,37 +6,46 @@
cigma::MeshPart::
MeshPart()
{
- nno = 0;
- nsd = 0;
+ //nno = 0;
+ //nsd = 0;
coords = 0;
- nel = 0;
- ndofs = 0;
+ //nel = 0;
+ //ndofs = 0;
connect = 0;
}
+
cigma::MeshPart::
~MeshPart()
{
+ //* // XXX: don't delete if we copied the pointers
if (coords) delete [] coords;
if (connect) delete [] connect;
+ // */
}
+
// ---------------------------------------------------------------------------
-
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;
+ //this->nno = nno;
+ //this->nsd = nsd;
+ assert(nno == n_nodes());
+ assert(nsd == n_nsd());
+
+ /* // XXX: copy pointer
+ coords = coordinates;
+ // */
+
+ //* // XXX: copy data (use memcpy?)
coords = new double[nno * nsd];
-
- // XXX: memcpy?
for (int i = 0; i < nno; i++)
{
for (int j = 0; j < nsd; j++)
@@ -44,21 +53,28 @@
int n = nsd*i + j;
coords[n] = coordinates[n];
}
- }
+ } // */
}
+
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;
+ //this->nel = nel;
+ //this->ndofs = ndofs;
+ assert(nel == n_nel());
+ assert(ndofs == n_ndofs());
+
+ /* // XXX: copy pointer
+ connect = connectivity;
+ // */
+
+ //* // XXX: copy data (use memcpy?)
connect = new int[nel * ndofs];
-
- // XXX: memcpy?
for (int i = 0; i < nel; i++)
{
for (int j = 0; j < ndofs; j++)
@@ -66,25 +82,33 @@
int e = ndofs*i + j;
connect[e] = connectivity[e];
}
- }
+ } // */
}
+// ---------------------------------------------------------------------------
+
void cigma::MeshPart::
cell_coords(int cellIndex, double *globalCellCoords)
{
- assert(nsd > 0);
- assert(ndofs > 0);
+ //assert(nsd > 0);
+ //assert(ndofs > 0);
- int *conn;
+ const int nel = n_nel();
+ const int ndofs = n_ndofs();
+ const int nsd = n_nsd();
- conn = &connect[ndofs * cellIndex];
+ assert(0 <= cellIndex); assert(cellIndex < nel);
+
+ int *conn = &connect[ndofs * cellIndex];
+
for (int i = 0; i < ndofs; i++)
{
- double *coor = &coords[conn[i]];
+ double *pt = &coords[conn[i]];
for (int j = 0; j < nsd; j++)
{
- globalCellCoords[nsd*i + j] = coor[j];
+ globalCellCoords[nsd*i + j] = pt[j];
}
}
}
+
Modified: cs/benchmark/cigma/trunk/src/MeshPart.h
===================================================================
--- cs/benchmark/cigma/trunk/src/MeshPart.h 2007-12-19 20:06:32 UTC (rev 8945)
+++ cs/benchmark/cigma/trunk/src/MeshPart.h 2007-12-19 20:06:39 UTC (rev 8946)
@@ -13,6 +13,12 @@
virtual ~MeshPart();
public:
+ virtual int n_nodes() = 0;
+ virtual int n_nsd() = 0;
+ virtual int n_nel() = 0;
+ virtual int n_ndofs() = 0;
+
+public:
void set_coordinates(double *coordinates, int nno, int nsd);
void set_connectivity(int *connectivity, int nel, int ndofs);
@@ -21,13 +27,14 @@
virtual bool find_cell(double globalPoint[3], int *cellIndex) = 0;
public:
-
- int nno, nsd;
+ //int nno, nsd;
+ //int nel, ndofs;
double *coords;
-
- int nel, ndofs;
int *connect;
};
+
+// ---------------------------------------------------------------------------
+
#endif
More information about the cig-commits
mailing list