[cig-commits] r5776 - in long/3D/Gale/trunk/src/StGermain: .
Discretisation/Mesh/src
walter at geodynamics.org
walter at geodynamics.org
Thu Jan 11 21:04:36 PST 2007
Author: walter
Date: 2007-01-11 21:04:35 -0800 (Thu, 11 Jan 2007)
New Revision: 5776
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.h
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshTopology.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.h
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.h
Log:
r3285 at earth (orig r3964): LukeHodkinson | 2007-01-11 17:41:27 -0800
* Adding direct vertex neighbour generation to the
cartesian generator for performance.
* Modifying the element searching algorithms to use
partial incidence, thus allowing for less memory
consumption by the mesh.
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:3958
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:3964
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.c 2007-01-12 05:04:31 UTC (rev 5775)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.c 2007-01-12 05:04:35 UTC (rev 5776)
@@ -706,8 +706,12 @@
}
}
for( d_i = 0; d_i <= self->nDims; d_i++ ) {
- if( self->enabledInc[d_i][d_i] )
- MeshTopology_Neighbourhood( topo, d_i );
+ if( self->enabledInc[d_i][d_i] ) {
+ if( d_i == 0 )
+ CartesianGenerator_CompleteVertexNeighbours( self, topo, grids );
+ else
+ MeshTopology_Neighbourhood( topo, d_i );
+ }
}
/* Free allocated grids. */
@@ -1576,6 +1580,104 @@
FreeArray( dimInds );
}
+void CartesianGenerator_CompleteVertexNeighbours( CartesianGenerator* self, MeshTopology* topo, Grid*** grids ) {
+ Stream* stream = Journal_Register( Info_Type, self->type );
+ unsigned nDims;
+ unsigned nVerts;
+ unsigned* inds;
+ unsigned *nNbrs, **nbrs;
+ unsigned domain, global;
+ unsigned v_i;
+
+ assert( self );
+ assert( topo );
+ assert( grids );
+
+ Stream_Indent( stream );
+ Journal_Printf( stream, "Generating vertex neighbours...\n" );
+ Stream_UnIndent( stream );
+
+ nDims = topo->nDims;
+ nVerts = MeshTopology_GetDomainSize( topo, MT_VERTEX );
+ inds = AllocArray( unsigned, nDims );
+ nNbrs = AllocArray( unsigned, nVerts );
+ nbrs = AllocArray2D( unsigned, nVerts, (nDims == 3) ? 6 : (nDims == 2) ? 4 : 2 );
+ for( v_i = 0; v_i < nVerts; v_i++ ) {
+ nNbrs[v_i] = 0;
+ global = MeshTopology_DomainToGlobal( topo, MT_VERTEX, v_i );
+ Grid_Lift( grids[0][0], global, inds );
+
+ if( inds[0] > 0 ) {
+ inds[0]--;
+ domain = Grid_Project( grids[0][0], inds );
+ if( MeshTopology_GlobalToDomain( topo, MT_VERTEX, domain, &domain ) ) {
+ nbrs[v_i][nNbrs[v_i]] = domain;
+ nNbrs[v_i]++;
+ }
+ inds[0]++;
+ }
+
+ if( inds[0] < grids[0][0]->sizes[0] - 1 ) {
+ inds[0]++;
+ domain = Grid_Project( grids[0][0], inds );
+ if( MeshTopology_GlobalToDomain( topo, MT_VERTEX, domain, &domain ) ) {
+ nbrs[v_i][nNbrs[v_i]] = domain;
+ nNbrs[v_i]++;
+ }
+ inds[0]--;
+ }
+
+ if( nDims >= 2 ) {
+ if( inds[1] > 0 ) {
+ inds[1]--;
+ domain = Grid_Project( grids[0][0], inds );
+ if( MeshTopology_GlobalToDomain( topo, MT_VERTEX, domain, &domain ) ) {
+ nbrs[v_i][nNbrs[v_i]] = domain;
+ nNbrs[v_i]++;
+ }
+ inds[1]++;
+ }
+
+ if( inds[1] < grids[0][0]->sizes[1] - 1 ) {
+ inds[1]++;
+ domain = Grid_Project( grids[0][0], inds );
+ if( MeshTopology_GlobalToDomain( topo, MT_VERTEX, domain, &domain ) ) {
+ nbrs[v_i][nNbrs[v_i]] = domain;
+ nNbrs[v_i]++;
+ }
+ inds[1]--;
+ }
+
+ if( nDims == 3 ) {
+ if( inds[2] > 0 ) {
+ inds[2]--;
+ domain = Grid_Project( grids[0][0], inds );
+ if( MeshTopology_GlobalToDomain( topo, MT_VERTEX, domain, &domain ) ) {
+ nbrs[v_i][nNbrs[v_i]] = domain;
+ nNbrs[v_i]++;
+ }
+ inds[2]++;
+ }
+
+ if( inds[2] < grids[0][0]->sizes[2] - 1 ) {
+ inds[2]++;
+ domain = Grid_Project( grids[0][0], inds );
+ if( MeshTopology_GlobalToDomain( topo, MT_VERTEX, domain, &domain ) ) {
+ nbrs[v_i][nNbrs[v_i]] = domain;
+ nNbrs[v_i]++;
+ }
+ inds[2]--;
+ }
+ }
+ }
+ }
+
+ MeshTopology_SetIncidence( topo, MT_VERTEX, MT_VERTEX, nNbrs, nbrs );
+ FreeArray( nNbrs );
+ FreeArray( nbrs );
+ FreeArray( inds );
+}
+
void CartesianGenerator_MapToDomain( CartesianGenerator* self, Decomp_Sync* sync,
unsigned size, unsigned* nIncEls, unsigned** incEls )
{
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.h 2007-01-12 05:04:31 UTC (rev 5775)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.h 2007-01-12 05:04:35 UTC (rev 5776)
@@ -130,6 +130,7 @@
void CartesianGenerator_GenFaceVertexInc( CartesianGenerator* self, MeshTopology* topo, Grid*** grids );
void CartesianGenerator_GenFaceEdgeInc( CartesianGenerator* self, MeshTopology* topo, Grid*** grids );
void CartesianGenerator_GenEdgeVertexInc( CartesianGenerator* self, MeshTopology* topo, Grid*** grids );
+ void CartesianGenerator_CompleteVertexNeighbours( CartesianGenerator* self, MeshTopology* topo, Grid*** grids );
void CartesianGenerator_MapToDomain( CartesianGenerator* self, Decomp_Sync* sync,
unsigned size, unsigned* nIncEls, unsigned** incEls );
void CartesianGenerator_GenGeom( CartesianGenerator* self, Mesh* mesh );
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.c 2007-01-12 05:04:31 UTC (rev 5775)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshGenerator.c 2007-01-12 05:04:35 UTC (rev 5776)
@@ -151,8 +151,11 @@
enabledDimsList = Dictionary_Get( dict, "enabledDims" );
enabledIncList = Dictionary_Get( dict, "enabledIncidence" );
if( enabledDimsList || enabledIncList ) {
- memset( self->enabledDims, 0, nDims * sizeof(Bool) );
- memset( self->enabledInc, 0, nDims * nDims * sizeof(Bool) );
+ unsigned d_i;
+
+ memset( self->enabledDims, 0, (nDims + 1) * sizeof(Bool) );
+ for( d_i = 0; d_i <= nDims; d_i++ )
+ memset( self->enabledInc[d_i], 0, (nDims + 1) * sizeof(Bool) );
}
if( enabledDimsList ) {
unsigned nEnabledDims;
@@ -173,8 +176,8 @@
nEnabledInc = Dictionary_Entry_Value_GetCount( enabledIncList );
assert( nEnabledInc % 2 == 0 );
for( d_i = 0; d_i < nEnabledInc; d_i += 2 ) {
- fromDim = Dictionary_Entry_Value_AsUnsignedInt( Dictionary_Entry_Value_GetElement( enabledDimsList, d_i ) );
- toDim = Dictionary_Entry_Value_AsUnsignedInt( Dictionary_Entry_Value_GetElement( enabledDimsList, d_i + 1 ) );
+ fromDim = Dictionary_Entry_Value_AsUnsignedInt( Dictionary_Entry_Value_GetElement( enabledIncList, d_i ) );
+ toDim = Dictionary_Entry_Value_AsUnsignedInt( Dictionary_Entry_Value_GetElement( enabledIncList, d_i + 1 ) );
MeshGenerator_SetIncidenceState( self, fromDim, toDim, True );
}
}
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshTopology.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshTopology.c 2007-01-12 05:04:31 UTC (rev 5775)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshTopology.c 2007-01-12 05:04:35 UTC (rev 5776)
@@ -519,9 +519,8 @@
assert( self );
assert( dim < self->nTDims );
assert( self->domains );
- assert( self->domains[dim] );
- return Decomp_Sync_GetGlobalSize( self->domains[dim] );
+ return self->domains[dim] ? Decomp_Sync_GetGlobalSize( self->domains[dim] ) : 0;
}
unsigned MeshTopology_GetLocalSize( void* meshTopology, MeshTopology_Dim dim ) {
@@ -530,9 +529,8 @@
assert( self );
assert( dim < self->nTDims );
assert( self->domains );
- assert( self->domains[dim] );
- return Decomp_Sync_GetLocalSize( self->domains[dim] );
+ return self->domains[dim] ? Decomp_Sync_GetLocalSize( self->domains[dim] ) : 0;
}
unsigned MeshTopology_GetRemoteSize( void* meshTopology, MeshTopology_Dim dim ) {
@@ -541,9 +539,8 @@
assert( self );
assert( dim < self->nTDims );
assert( self->domains );
- assert( self->domains[dim] );
- return Decomp_Sync_GetRemoteSize( self->domains[dim] );
+ return self->domains[dim] ? Decomp_Sync_GetRemoteSize( self->domains[dim] ) : 0;
}
unsigned MeshTopology_GetDomainSize( void* meshTopology, MeshTopology_Dim dim ) {
@@ -552,9 +549,8 @@
assert( self );
assert( dim < self->nTDims );
assert( self->domains );
- assert( self->domains[dim] );
- return Decomp_Sync_GetDomainSize( self->domains[dim] );
+ return self->domains[dim] ? Decomp_Sync_GetDomainSize( self->domains[dim] ) : 0;
}
unsigned MeshTopology_GetSharedSize( void* meshTopology, MeshTopology_Dim dim ) {
@@ -563,9 +559,8 @@
assert( self );
assert( dim < self->nTDims );
assert( self->domains );
- assert( self->domains[dim] );
- return Decomp_Sync_GetSharedSize( self->domains[dim] );
+ return self->domains[dim] ? Decomp_Sync_GetSharedSize( self->domains[dim] ) : 0;
}
void MeshTopology_GetLocalElements( void* meshTopology, MeshTopology_Dim dim, unsigned* nEls, unsigned** els ) {
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c 2007-01-12 05:04:31 UTC (rev 5775)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c 2007-01-12 05:04:35 UTC (rev 5776)
@@ -155,6 +155,8 @@
void _Mesh_Algorithms_Update( void* algorithms ) {
Mesh_Algorithms* self = (Mesh_Algorithms*)algorithms;
+ unsigned nDims;
+ unsigned d_i;
assert( self && Stg_CheckType( self, Mesh_Algorithms ) );
@@ -166,8 +168,15 @@
else
self->nearestVertex = Mesh_Algorithms_NearestVertexGeneral;
- if( Mesh_HasIncidence( self->mesh, MT_VERTEX, Mesh_GetDimSize( self->mesh ) ) )
- self->search = Mesh_Algorithms_SearchWithIncidence;
+ nDims = Mesh_GetDimSize( self->mesh );
+ for( d_i = 0; d_i < nDims; d_i++ ) {
+ if( !Mesh_GetGlobalSize( self->mesh, d_i ) || !Mesh_HasIncidence( self->mesh, nDims, d_i ) )
+ break;
+ }
+ if( d_i == nDims )
+ self->search = Mesh_Algorithms_SearchWithFullIncidence;
+ else if( Mesh_HasIncidence( self->mesh, MT_VERTEX, Mesh_GetDimSize( self->mesh ) ) )
+ self->search = Mesh_Algorithms_SearchWithMinIncidence;
else
self->search = Mesh_Algorithms_SearchGeneral;
}
@@ -475,8 +484,8 @@
return minVertInd;
}
-Bool Mesh_Algorithms_SearchWithIncidence( void* algorithms, double* point,
- MeshTopology_Dim* dim, unsigned* ind )
+Bool Mesh_Algorithms_SearchWithFullIncidence( void* algorithms, double* point,
+ MeshTopology_Dim* dim, unsigned* ind )
{
Mesh_Algorithms* self = (Mesh_Algorithms*)algorithms;
Mesh* mesh;
@@ -527,6 +536,81 @@
return False;
}
+Bool Mesh_Algorithms_SearchWithMinIncidence( void* algorithms, double* point,
+ MeshTopology_Dim* dim, unsigned* ind )
+{
+ Mesh_Algorithms* self = (Mesh_Algorithms*)algorithms;
+ Mesh* mesh;
+ double maxCrd[3], minCrd[3];
+ unsigned lowest;
+ unsigned nDims;
+ unsigned nEls;
+ unsigned nearVert;
+ unsigned nInc, *inc;
+ unsigned e_i, d_i, inc_i;
+
+ assert( self );
+ assert( self->mesh );
+ assert( Mesh_HasIncidence( self->mesh, MT_VERTEX, Mesh_GetDimSize( self->mesh ) ) );
+ assert( dim );
+ assert( ind );
+
+ /* Get dimensionality. */
+ mesh = self->mesh;
+ nDims = Mesh_GetDimSize( mesh );
+
+ /* If outside local range, immediately return false. */
+ Mesh_GetDomainCoordRange( mesh, minCrd, maxCrd );
+ for( d_i = 0; d_i < nDims; d_i++ ) {
+ if( point[d_i] < minCrd[d_i] || point[d_i] > maxCrd[d_i] )
+ return False;
+ }
+
+ /* Start by locating the closest vertex. */
+ nearVert = Mesh_NearestVertex( mesh, point );
+
+ /* Get vertex/element incidence. */
+ Mesh_GetIncidence( mesh, MT_VERTEX, nearVert, nDims,
+ &nInc, &inc );
+
+ /* Search all of these elements and return the element with lowest global index. */
+ lowest = (unsigned)-1;
+ for( inc_i = 0; inc_i < nInc; inc_i++ ) {
+ if( Mesh_ElementHasPoint( mesh, inc[inc_i], point, dim, ind ) ) {
+ unsigned global;
+
+ global = Mesh_DomainToGlobal( mesh, nDims, inc[inc_i] );
+ if( global < lowest )
+ lowest = global;
+ }
+ }
+ if( lowest != (unsigned)-1 ) {
+ insist( Mesh_GlobalToDomain( mesh, nDims, lowest, ind ) );
+ *dim = nDims;
+ return True;
+ }
+
+ /* Brute force, search every element in turn (last resort). */
+ lowest = (unsigned)-1;
+ nEls = Mesh_GetDomainSize( mesh, nDims );
+ for( e_i = 0; e_i < nEls; e_i++ ) {
+ if( Mesh_ElementHasPoint( mesh, e_i, point, dim, ind ) ) {
+ unsigned global;
+
+ global = Mesh_DomainToGlobal( mesh, nDims, inc[inc_i] );
+ if( global < lowest )
+ lowest = global;
+ }
+ }
+ if( lowest != (unsigned)-1 ) {
+ insist( Mesh_GlobalToDomain( mesh, nDims, lowest, ind ) );
+ *dim = nDims;
+ return True;
+ }
+
+ return False;
+}
+
Bool Mesh_Algorithms_SearchGeneral( void* algorithms, double* point,
MeshTopology_Dim* dim, unsigned* ind )
{
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.h 2007-01-12 05:04:31 UTC (rev 5775)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.h 2007-01-12 05:04:35 UTC (rev 5776)
@@ -183,8 +183,10 @@
unsigned Mesh_Algorithms_NearestVertexWithNeighbours( void* algorithms, double* point );
unsigned Mesh_Algorithms_NearestVertexGeneral( void* algorithms, double* point );
- Bool Mesh_Algorithms_SearchWithIncidence( void* algorithms, double* point,
- MeshTopology_Dim* dim, unsigned* ind );
+ Bool Mesh_Algorithms_SearchWithFullIncidence( void* algorithms, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
+ Bool Mesh_Algorithms_SearchWithMinIncidence( void* algorithms, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
Bool Mesh_Algorithms_SearchGeneral( void* algorithms, double* point,
MeshTopology_Dim* dim, unsigned* ind );
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.c 2007-01-12 05:04:31 UTC (rev 5775)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.c 2007-01-12 05:04:35 UTC (rev 5776)
@@ -85,6 +85,8 @@
void _Mesh_HexType_Init( Mesh_HexType* self ) {
assert( self && Stg_CheckType( self, Mesh_HexType ) );
+ self->elementHasPoint = NULL;
+
self->triInds = AllocArray2D( unsigned, 2, 3 );
self->triInds[0][0] = 0; self->triInds[0][1] = 1; self->triInds[0][2] = 2;
self->triInds[1][0] = 1; self->triInds[1][1] = 3; self->triInds[1][2] = 2;
@@ -130,8 +132,47 @@
void Mesh_HexType_Update( void* hexType ) {
Mesh_HexType* self = (Mesh_HexType*)hexType;
+ unsigned nDims;
+ unsigned d_i;
assert( self && Stg_CheckType( self, Mesh_HexType ) );
+
+ nDims = Mesh_GetDimSize( self->mesh );
+ for( d_i = 0; d_i < nDims; d_i++ ) {
+ if( !Mesh_GetGlobalSize( self->mesh, d_i ) || !Mesh_HasIncidence( self->mesh, nDims, d_i ) )
+ break;
+ }
+
+ if( Mesh_GetDimSize( self->mesh ) == 3 ) {
+ if( d_i == nDims ) {
+ self->elementHasPoint =
+ (Mesh_ElementType_ElementHasPointFunc*)Mesh_HexType_ElementHasPoint3DWithIncidence;
+ }
+ else {
+ self->elementHasPoint =
+ (Mesh_ElementType_ElementHasPointFunc*)Mesh_HexType_ElementHasPoint3DGeneral;
+ }
+ }
+ else if( Mesh_GetDimSize( self->mesh ) == 2 ) {
+ if( d_i == nDims ) {
+ self->elementHasPoint =
+ (Mesh_ElementType_ElementHasPointFunc*)Mesh_HexType_ElementHasPoint2DWithIncidence;
+ }
+ else {
+ self->elementHasPoint =
+ (Mesh_ElementType_ElementHasPointFunc*)Mesh_HexType_ElementHasPoint2DGeneral;
+ }
+ }
+ else {
+ if( d_i == nDims ) {
+ self->elementHasPoint =
+ (Mesh_ElementType_ElementHasPointFunc*)Mesh_HexType_ElementHasPoint1DWithIncidence;
+ }
+ else {
+ self->elementHasPoint =
+ (Mesh_ElementType_ElementHasPointFunc*)Mesh_HexType_ElementHasPoint1DGeneral;
+ }
+ }
}
Bool Mesh_HexType_ElementHasPoint( void* hexType, unsigned elInd, double* point,
@@ -141,13 +182,9 @@
assert( self && Stg_CheckType( self, Mesh_HexType ) );
assert( Mesh_GetDimSize( self->mesh ) <= 3 );
+ assert( self->elementHasPoint );
- if( Mesh_GetDimSize( self->mesh ) == 3 )
- return Mesh_HexType_ElementHasPoint3D( self, elInd, point, dim, ind );
- else if( Mesh_GetDimSize( self->mesh ) == 2 )
- return Mesh_HexType_ElementHasPoint2D( self, elInd, point, dim, ind );
- else
- return Mesh_HexType_ElementHasPoint1D( self, elInd, point, dim, ind );
+ return self->elementHasPoint( self, elInd, point, dim, ind );
}
double Mesh_HexType_GetMinimumSeparation( void* hexType, unsigned elInd, double* perDim ) {
@@ -253,12 +290,44 @@
** Private Functions
*/
-Bool Mesh_HexType_ElementHasPoint3D( Mesh_HexType* self, unsigned elInd, double* point,
- MeshTopology_Dim* dim, unsigned* ind )
+Bool Mesh_HexType_ElementHasPoint3DGeneral( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind )
{
Mesh* mesh;
unsigned nInc, *inc;
double bc[4];
+ unsigned inside;
+
+ assert( self && Stg_CheckType( self, Mesh_HexType ) );
+ assert( Mesh_GetDimSize( self->mesh ) == 3 );
+ assert( elInd < Mesh_GetDomainSize( self->mesh, Mesh_GetDimSize( self->mesh ) ) );
+ assert( point );
+ assert( dim );
+ assert( ind );
+
+ /* Shortcuts. */
+ mesh = self->mesh;
+
+ /* Get element to vertex incidence. */
+ Mesh_GetIncidence( mesh, Mesh_GetDimSize( mesh ), elInd, MT_VERTEX, &nInc, &inc );
+ assert( nInc == 8 );
+
+ /* Search for tetrahedra. */
+ if( Simplex_Search3D( mesh->verts, inc, 10, self->tetInds, point, bc, &inside ) ) {
+ *dim = MT_VOLUME;
+ *ind = elInd;
+ return True;
+ }
+
+ return False;
+}
+
+Bool Mesh_HexType_ElementHasPoint3DWithIncidence( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind )
+{
+ Mesh* mesh;
+ unsigned nInc, *inc;
+ double bc[4];
MeshTopology* topo;
unsigned inside;
@@ -277,7 +346,7 @@
Mesh_GetIncidence( mesh, Mesh_GetDimSize( mesh ), elInd, MT_VERTEX, &nInc, &inc );
assert( nInc == 8 );
- /* Search for triangle. */
+ /* Search for tetrahedra. */
if( Simplex_Search3D( mesh->verts, inc, 10, self->tetInds, point, bc, &inside ) ) {
unsigned* inds = self->tetInds[inside];
@@ -741,12 +810,44 @@
return False;
}
-Bool Mesh_HexType_ElementHasPoint2D( Mesh_HexType* self, unsigned elInd, double* point,
- MeshTopology_Dim* dim, unsigned* ind )
+Bool Mesh_HexType_ElementHasPoint2DGeneral( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind )
{
Mesh* mesh;
unsigned nInc, *inc;
double bc[3];
+ unsigned inside;
+
+ assert( self && Stg_CheckType( self, Mesh_HexType ) );
+ assert( Mesh_GetDimSize( self->mesh ) == 2 );
+ assert( elInd < Mesh_GetDomainSize( self->mesh, Mesh_GetDimSize( self->mesh ) ) );
+ assert( point );
+ assert( dim );
+ assert( ind );
+
+ /* Shortcuts. */
+ mesh = self->mesh;
+
+ /* Get element to vertex incidence. */
+ Mesh_GetIncidence( mesh, Mesh_GetDimSize( mesh ), elInd, MT_VERTEX, &nInc, &inc );
+ assert( nInc == 4 );
+
+ /* Search for triangle. */
+ if( Simplex_Search2D( mesh->verts, inc, 2, self->triInds, point, bc, &inside ) ) {
+ *dim = MT_FACE;
+ *ind = elInd;
+ return True;
+ }
+
+ return False;
+}
+
+Bool Mesh_HexType_ElementHasPoint2DWithIncidence( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind )
+{
+ Mesh* mesh;
+ unsigned nInc, *inc;
+ double bc[3];
MeshTopology* topo;
unsigned inside;
@@ -827,8 +928,8 @@
return False;
}
-Bool Mesh_HexType_ElementHasPoint1D( Mesh_HexType* self, unsigned elInd, double* point,
- MeshTopology_Dim* dim, unsigned* ind )
+Bool Mesh_HexType_ElementHasPoint1DGeneral( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind )
{
Mesh* mesh;
unsigned nInc, *inc;
@@ -849,6 +950,32 @@
*ind = elInd;
return True;
}
+
+ return False;
+}
+
+Bool Mesh_HexType_ElementHasPoint1DWithIncidence( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind )
+{
+ Mesh* mesh;
+ unsigned nInc, *inc;
+
+ assert( self && Stg_CheckType( self, Mesh_HexType ) );
+ assert( Mesh_GetDimSize( self->mesh ) == 1 );
+ assert( elInd < Mesh_GetDomainSize( self->mesh, Mesh_GetDimSize( self->mesh ) ) );
+ assert( point );
+ assert( dim );
+ assert( ind );
+
+ mesh = self->mesh;
+ Mesh_GetIncidence( mesh, MT_EDGE, elInd, MT_VERTEX, &nInc, &inc );
+ assert( nInc == 2 );
+
+ if( point[0] > *Mesh_GetVertex( mesh, inc[0] ) && point[0] < *Mesh_GetVertex( mesh, inc[1] ) ) {
+ *dim = MT_EDGE;
+ *ind = elInd;
+ return True;
+ }
else if( point[0] == *Mesh_GetVertex( mesh, inc[0] ) ) {
*dim = MT_VERTEX;
*ind = inc[0];
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.h 2007-01-12 05:04:31 UTC (rev 5775)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.h 2007-01-12 05:04:35 UTC (rev 5776)
@@ -47,15 +47,16 @@
/** Virtual function types */
/** Class contents */
- #define __Mesh_HexType \
- /* General info */ \
- __Mesh_ElementType \
- \
- /* Virtual info */ \
- \
- /* Mesh_HexType info */ \
- unsigned** triInds; \
- unsigned** tetInds;
+ #define __Mesh_HexType \
+ /* General info */ \
+ __Mesh_ElementType \
+ \
+ /* Virtual info */ \
+ \
+ /* Mesh_HexType info */ \
+ Mesh_ElementType_ElementHasPointFunc* elementHasPoint; \
+ unsigned** triInds; \
+ unsigned** tetInds;
struct Mesh_HexType { __Mesh_HexType };
@@ -93,12 +94,18 @@
** Private Member functions
*/
- Bool Mesh_HexType_ElementHasPoint3D( Mesh_HexType* self, unsigned elInd, double* point,
- MeshTopology_Dim* dim, unsigned* ind );
- Bool Mesh_HexType_ElementHasPoint2D( Mesh_HexType* self, unsigned elInd, double* point,
- MeshTopology_Dim* dim, unsigned* ind );
- Bool Mesh_HexType_ElementHasPoint1D( Mesh_HexType* self, unsigned elInd, double* point,
- MeshTopology_Dim* dim, unsigned* ind );
+ Bool Mesh_HexType_ElementHasPoint3DGeneral( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
+ Bool Mesh_HexType_ElementHasPoint3DWithIncidence( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
+ Bool Mesh_HexType_ElementHasPoint2DGeneral( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
+ Bool Mesh_HexType_ElementHasPoint2DWithIncidence( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
+ Bool Mesh_HexType_ElementHasPoint1DGeneral( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
+ Bool Mesh_HexType_ElementHasPoint1DWithIncidence( Mesh_HexType* self, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
void Mesh_HexType_TetBarycenter( double** verts, unsigned* inc, unsigned* inds, double* point, double* bc );
void Mesh_HexType_TriBarycenter( double** verts, unsigned* inc, unsigned* inds, double* point, double* bc );
More information about the cig-commits
mailing list