[cig-commits] r5773 - in long/3D/Gale/trunk/src/StGermain: .
Discretisation/Mesh/src
walter at geodynamics.org
walter at geodynamics.org
Thu Jan 11 21:04:24 PST 2007
Author: walter
Date: 2007-01-11 21:04:23 -0800 (Thu, 11 Jan 2007)
New Revision: 5773
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_ElementType.c
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_ElementType.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:
r3282 at earth (orig r3956): LukeHodkinson | 2007-01-10 14:34:03 -0800
Cleaning up a couple of classes.
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:3955
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:3956
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_ElementType.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_ElementType.c 2007-01-12 05:04:22 UTC (rev 5772)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_ElementType.c 2007-01-12 05:04:23 UTC (rev 5773)
@@ -41,18 +41,20 @@
/* Textual name of this class */
const Type Mesh_ElementType_Type = "Mesh_ElementType";
+
/*----------------------------------------------------------------------------------------------------------------------------------
** Constructors
*/
Mesh_ElementType* _Mesh_ElementType_New( MESH_ELEMENTTYPE_DEFARGS ) {
- Mesh_ElementType* self;
+ Mesh_ElementType* self;
/* Allocate memory */
assert( sizeOfSelf >= sizeof(Mesh_ElementType) );
self = (Mesh_ElementType*)_Stg_Class_New( STG_CLASS_PASSARGS );
/* Virtual info */
+ self->updateFunc = updateFunc;
self->elementHasPointFunc = elementHasPointFunc;
self->getMinimumSeparationFunc = getMinimumSeparationFunc;
self->getCentroidFunc = getCentroidFunc;
@@ -64,6 +66,9 @@
}
void _Mesh_ElementType_Init( Mesh_ElementType* self ) {
+ assert( self && Stg_CheckType( self, Mesh_ElementType ) );
+
+ self->mesh = NULL;
}
@@ -89,8 +94,9 @@
_Stg_Class_Print( self, stream );
}
-void _Mesh_ElementType_GetCentroid( void* elementType, void* mesh, unsigned element, double* centroid ) {
+void _Mesh_ElementType_GetCentroid( void* elementType, unsigned element, double* centroid ) {
Mesh_ElementType* self = (Mesh_ElementType*)elementType;
+ Mesh* mesh;
unsigned nIncVerts, *incVerts;
unsigned nDims;
double denom;
@@ -98,6 +104,7 @@
assert( self );
+ mesh = self->mesh;
nDims = Mesh_GetDimSize( mesh );
Mesh_GetIncidence( mesh, nDims, element, MT_VERTEX, &nIncVerts, &incVerts );
@@ -117,7 +124,17 @@
** Public Functions
*/
+void Mesh_ElementType_SetMesh( void* elementType, void* mesh ) {
+ Mesh_ElementType* self = (Mesh_ElementType*)elementType;
+ assert( self && Stg_CheckType( self, Mesh_ElementType ) );
+ assert( mesh && Stg_CheckType( mesh, Mesh ) );
+
+ self->mesh = mesh;
+ Mesh_ElementType_Update( self );
+}
+
+
/*----------------------------------------------------------------------------------------------------------------------------------
** Private Functions
*/
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_ElementType.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_ElementType.h 2007-01-12 05:04:22 UTC (rev 5772)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_ElementType.h 2007-01-12 05:04:23 UTC (rev 5773)
@@ -45,10 +45,11 @@
extern const Type Mesh_ElementType_Type;
/** Virtual function types */
- typedef Bool (Mesh_ElementType_ElementHasPointFunc)( void* elementType, void* mesh, unsigned element, double* point,
+ typedef void (Mesh_ElementType_UpdateFunc)( void* elementType );
+ typedef Bool (Mesh_ElementType_ElementHasPointFunc)( void* elementType, unsigned element, double* point,
MeshTopology_Dim* dim, unsigned* ind );
- typedef double (Mesh_ElementType_GetMinimumSeparationFunc)( void* elementType, void* mesh, unsigned element, double* perDim );
- typedef void (Mesh_ElementType_GetCentroidFunc)( void* elementType, void* mesh, unsigned element, double* centroid );
+ typedef double (Mesh_ElementType_GetMinimumSeparationFunc)( void* elementType, unsigned element, double* perDim );
+ typedef void (Mesh_ElementType_GetCentroidFunc)( void* elementType, unsigned element, double* centroid );
/** Class contents */
#define __Mesh_ElementType \
@@ -56,11 +57,13 @@
__Stg_Class \
\
/* Virtual info */ \
+ Mesh_ElementType_UpdateFunc* updateFunc; \
Mesh_ElementType_ElementHasPointFunc* elementHasPointFunc; \
Mesh_ElementType_GetMinimumSeparationFunc* getMinimumSeparationFunc; \
Mesh_ElementType_GetCentroidFunc* getCentroidFunc; \
\
- /* Mesh_ElementType info */
+ /* Mesh_ElementType info */ \
+ Mesh* mesh;
struct Mesh_ElementType { __Mesh_ElementType };
@@ -70,13 +73,17 @@
#define MESH_ELEMENTTYPE_DEFARGS \
STG_CLASS_DEFARGS, \
+ Mesh_ElementType_UpdateFunc* updateFunc; \
Mesh_ElementType_ElementHasPointFunc* elementHasPointFunc, \
Mesh_ElementType_GetMinimumSeparationFunc* getMinimumSeparationFunc, \
Mesh_ElementType_GetCentroidFunc* getCentroidFunc
- #define MESH_ELEMENTTYPE_PASSARGS \
- STG_CLASS_PASSARGS, \
- elementHasPointFunc, getMinimumSeparationFunc, getCentroidFunc
+ #define MESH_ELEMENTTYPE_PASSARGS \
+ STG_CLASS_PASSARGS, \
+ updateFunc, \
+ elementHasPointFunc, \
+ getMinimumSeparationFunc, \
+ getCentroidFunc
Mesh_ElementType* _Mesh_ElementType_New( MESH_ELEMENTTYPE_DEFARGS );
void _Mesh_ElementType_Init( Mesh_ElementType* self );
@@ -87,24 +94,26 @@
void _Mesh_ElementType_Delete( void* elementType );
void _Mesh_ElementType_Print( void* elementType, Stream* stream );
- void _Mesh_ElementType_GetCentroid( void* elementType, void* mesh, unsigned element, double* centroid );
+ void _Mesh_ElementType_GetCentroid( void* elementType, unsigned element, double* centroid );
+ #define Mesh_ElementType_Update( self ) \
+ VirtualCall( self, updateFunc, self )
+
+ #define Mesh_ElementType_ElementHasPoint( self, element, point, dim, ind ) \
+ VirtualCall( self, elementHasPointFunc, self, element, point, dim, ind )
+
+ #define Mesh_ElementType_GetMinimumSeparation( elementType, element, perDim ) \
+ VirtualCall( self, getMinimumSeparationFunc, self, element, perDim )
+
+ #define Mesh_ElementType_GetCentroid( elementType, element, centroid ) \
+ VirtualCall( self, getCentroidFunc, self, element, centroid )
+
/*--------------------------------------------------------------------------------------------------------------------------
** Public functions
*/
- #define Mesh_ElementType_ElementHasPoint( elementType, mesh, element, point, dim, ind ) \
- (assert( (elementType) && ((Mesh_ElementType*)elementType)->elementHasPointFunc ), \
- ((Mesh_ElementType*)elementType)->elementHasPointFunc( elementType, mesh, element, point, dim, ind ))
+ void Mesh_ElementType_SetMesh( void* elementType, void* mesh );
- #define Mesh_ElementType_GetMinimumSeparation( elementType, mesh, element, perDim ) \
- (assert( (elementType) && ((Mesh_ElementType*)elementType)->getMinimumSeparationFunc ), \
- ((Mesh_ElementType*)elementType)->getMinimumSeparationFunc( elementType, mesh, element, perDim ))
-
- #define Mesh_ElementType_GetCentroid( elementType, mesh, element, centroid ) \
- (assert( (elementType) && ((Mesh_ElementType*)elementType)->getCentroidFunc ), \
- ((Mesh_ElementType*)elementType)->getCentroidFunc( elementType, mesh, element, centroid ))
-
/*--------------------------------------------------------------------------------------------------------------------------
** Private Member functions
*/
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:22 UTC (rev 5772)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.c 2007-01-12 05:04:23 UTC (rev 5773)
@@ -82,21 +82,6 @@
}
void _Mesh_HexType_Init( Mesh_HexType* self ) {
- self->triInds = Memory_Alloc_2DArray( unsigned, 2, 3, "Mesh_HexType::triInds" );
- 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;
-
- self->tetInds = Memory_Alloc_2DArray( unsigned, 10, 4, "Mesh_HexType::tetInds" );
- self->tetInds[0][0] = 0; self->tetInds[0][1] = 1; self->tetInds[0][2] = 2; self->tetInds[0][3] = 4;
- self->tetInds[1][0] = 1; self->tetInds[1][1] = 2; self->tetInds[1][2] = 3; self->tetInds[1][3] = 7;
- self->tetInds[2][0] = 1; self->tetInds[2][1] = 4; self->tetInds[2][2] = 5; self->tetInds[2][3] = 7;
- self->tetInds[3][0] = 2; self->tetInds[3][1] = 4; self->tetInds[3][2] = 6; self->tetInds[3][3] = 7;
- self->tetInds[4][0] = 1; self->tetInds[4][1] = 2; self->tetInds[4][2] = 4; self->tetInds[4][3] = 7;
- self->tetInds[5][0] = 0; self->tetInds[5][1] = 1; self->tetInds[5][2] = 3; self->tetInds[5][3] = 5;
- self->tetInds[6][0] = 0; self->tetInds[6][1] = 4; self->tetInds[6][2] = 5; self->tetInds[6][3] = 6;
- self->tetInds[7][0] = 0; self->tetInds[7][1] = 2; self->tetInds[7][2] = 3; self->tetInds[7][3] = 6;
- self->tetInds[8][0] = 3; self->tetInds[8][1] = 5; self->tetInds[8][2] = 6; self->tetInds[8][3] = 7;
- self->tetInds[9][0] = 0; self->tetInds[9][1] = 3; self->tetInds[9][2] = 5; self->tetInds[9][3] = 6;
}
@@ -107,9 +92,6 @@
void _Mesh_HexType_Delete( void* elementType ) {
Mesh_HexType* self = (Mesh_HexType*)elementType;
- FreeArray( self->triInds );
- FreeArray( self->tetInds );
-
/* Delete the parent. */
_Mesh_ElementType_Delete( self );
}
@@ -130,40 +112,34 @@
** Public Functions
*/
-Bool Mesh_HexType_ElementHasPoint( void* hexType, void* _mesh, unsigned elInd, double* point,
+Bool Mesh_HexType_ElementHasPoint( void* hexType, unsigned elInd, double* point,
MeshTopology_Dim* dim, unsigned* ind )
{
Mesh_HexType* self = (Mesh_HexType*)hexType;
- Mesh* mesh = (Mesh*)_mesh;
- assert( self );
- assert( mesh );
- assert( Mesh_GetDimSize( mesh ) <= 3 );
- assert( elInd < Mesh_GetDomainSize( mesh, Mesh_GetDimSize( mesh ) ) );
- assert( point );
- assert( dim );
- assert( ind );
+ assert( Mesh_GetDimSize( self->mesh ) <= 3 );
if( Mesh_GetDimSize( mesh ) == 3 )
- return Mesh_HexType_ElementHasPoint3D( self, mesh, elInd, point, dim, ind );
+ return Mesh_HexType_ElementHasPoint3D( self, elInd, point, dim, ind );
else if( Mesh_GetDimSize( mesh ) == 2 )
- return Mesh_HexType_ElementHasPoint2D( self, mesh, elInd, point, dim, ind );
+ return Mesh_HexType_ElementHasPoint2D( self, elInd, point, dim, ind );
else
- return Mesh_HexType_ElementHasPoint1D( self, mesh, elInd, point, dim, ind );
+ return Mesh_HexType_ElementHasPoint1D( self, elInd, point, dim, ind );
}
-double Mesh_HexType_GetMinimumSeparation( void* hexType, void* _mesh, unsigned elInd, double* perDim ) {
+double Mesh_HexType_GetMinimumSeparation( void* hexType, unsigned elInd, double* perDim ) {
Mesh_HexType* self = (Mesh_HexType*)hexType;
- Mesh* mesh = (Mesh*)_mesh;
+ Mesh* mesh;
double curSep;
double* dimSep;
unsigned nInc, *inc;
assert( self );
- assert( mesh );
- assert( elInd < Mesh_GetDomainSize( mesh, Mesh_GetDimSize( mesh ) ) );
- assert( Mesh_GetDimSize( mesh ) <= 3 );
+ assert( elInd < Mesh_GetDomainSize( self->mesh, Mesh_GetDimSize( self->mesh ) ) );
+ assert( Mesh_GetDimSize( self->mesh ) <= 3 );
+ mesh = self->mesh;
+
/*
** We know we're a hexahedral element but we may not be regular. This algorithm (originally from
** FeVariable.c) doesn't calculate the exact separation but provides an answer that's pretty
@@ -249,16 +225,28 @@
** Private Functions
*/
-Bool Mesh_HexType_ElementHasPoint3D( Mesh_HexType* self, Mesh* mesh, unsigned elInd, double* point,
+Bool Mesh_HexType_ElementHasPoint3D( Mesh_HexType* self, unsigned elInd, double* point,
MeshTopology_Dim* dim, unsigned* ind )
{
+ Mesh* mesh;
unsigned nInc, *inc;
double bc[4];
MeshTopology* topo;
unsigned inside;
+ static const unsigned tetInds[10][4] = {{0, 1, 2, 4}, {1, 2, 3, 7}, {1, 4, 5, 7}, {2, 4, 6, 7},
+ {1, 2, 4, 7}, {0, 1, 3, 5}, {0, 4, 5, 6}, {0, 2, 3, 6},
+ {3, 5, 6, 7}, {0, 3, 5, 6}};
+ 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;
topo = mesh->topo;
/* Get element to vertex incidence. */
@@ -729,16 +717,26 @@
return False;
}
-Bool Mesh_HexType_ElementHasPoint2D( Mesh_HexType* self, Mesh* mesh, unsigned elInd, double* point,
+Bool Mesh_HexType_ElementHasPoint2D( Mesh_HexType* self, unsigned elInd, double* point,
MeshTopology_Dim* dim, unsigned* ind )
{
-
+ Mesh* mesh;
unsigned nInc, *inc;
double bc[3];
MeshTopology* topo;
unsigned inside;
+ static const unsigned triInds[2][3] = {{0, 1, 2}, {1, 3, 2}};
+
+ 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;
topo = mesh->topo;
/* Get element to vertex incidence. */
@@ -807,11 +805,20 @@
return False;
}
-Bool Mesh_HexType_ElementHasPoint1D( Mesh_HexType* self, Mesh* mesh, unsigned elInd, double* point,
+Bool Mesh_HexType_ElementHasPoint1D( 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 );
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:22 UTC (rev 5772)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexType.h 2007-01-12 05:04:23 UTC (rev 5773)
@@ -53,9 +53,7 @@
\
/* Virtual info */ \
\
- /* Mesh_HexType info */ \
- unsigned** triInds; \
- unsigned** tetInds;
+ /* Mesh_HexType info */
struct Mesh_HexType { __Mesh_HexType };
@@ -80,14 +78,14 @@
void _Mesh_HexType_Delete( void* hexType );
void _Mesh_HexType_Print( void* hexType, Stream* stream );
+ Bool Mesh_HexType_ElementHasPoint( void* hexType, unsigned elInd, double* point,
+ MeshTopology_Dim* dim, unsigned* ind );
+ double Mesh_HexType_GetMinimumSeparation( void* hexType, unsigned elInd, double* perDim );
+
/*--------------------------------------------------------------------------------------------------------------------------
** Public functions
*/
- Bool Mesh_HexType_ElementHasPoint( void* hexType, void* mesh, unsigned elInd, double* point,
- MeshTopology_Dim* dim, unsigned* ind );
- double Mesh_HexType_GetMinimumSeparation( void* hexType, void* mesh, unsigned elInd, double* perDim );
-
/*--------------------------------------------------------------------------------------------------------------------------
** Private Member functions
*/
More information about the cig-commits
mailing list