[cig-commits] r6080 - in long/3D/Gale/trunk/src/StGermain: . Discretisation/Mesh/src

walter at geodynamics.org walter at geodynamics.org
Fri Feb 23 10:02:00 PST 2007


Author: walter
Date: 2007-02-23 10:02:00 -0800 (Fri, 23 Feb 2007)
New Revision: 6080

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/Init.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshClass.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_CentroidAlgorithms.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexAlgorithms.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexAlgorithms.h
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_RegularAlgorithms.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_RegularAlgorithms.h
Log:
 r3331 at earth (orig r3999):  LukeHodkinson | 2007-02-07 16:11:47 -0800
 Finished writing an optimised 'which element is an
 arbitrary coordinate in' routine for regular meshes.
 Reduces the time for updating particle cell owners by
 an order of magnitude, (e.g. a 64 cubed system
 would take about twenty minutes, now takes 2).
 



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:3994
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:3999
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-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.c	2007-02-23 18:02:00 UTC (rev 6080)
@@ -50,6 +50,8 @@
 #include "Mesh_HexType.h"
 #include "MeshClass.h"
 #include "MeshGenerator.h"
+#include "Mesh_Algorithms.h"
+#include "Mesh_RegularAlgorithms.h"
 #include "CartesianGenerator.h"
 
 
@@ -96,10 +98,11 @@
 void _CartesianGenerator_Init( CartesianGenerator* self ) {
 	assert( self && Stg_CheckType( self, CartesianGenerator ) );
 
-	self->shadowDepth = 1;
+	self->regular = False;
 	self->maxDecompDims = 0;
 	self->minDecomp = NULL;
 	self->maxDecomp = NULL;
+	self->shadowDepth = 1;
 	self->crdMin = NULL;
 	self->crdMax = NULL;
 
@@ -247,8 +250,8 @@
 	shadowDepth = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, "shadowDepth", 1 );
 	CartesianGenerator_SetShadowDepth( self, shadowDepth );
 
-	/* Check if we should build center nodes. */
-	self->enableCNodes = Stg_ComponentFactory_GetBool( cf, self->name, "enableCenterNodes", False );
+	/* Read regular flag. */
+	self->regular = Stg_ComponentFactory_GetBool( cf, self->name, "regular", False );
 
 	/* Free stuff. */
 	FreeArray( size );
@@ -813,29 +816,6 @@
 		els[e_i] = Grid_Project( globalGrid, dimInds );
 	}
 
-	/* If we need to generate center nodes, do so now. */
-	if( self->enableCNodes ) {
-		Grid*		elGrid;
-		unsigned	nOldEls;
-
-		elGrid = Grid_New();
-		Grid_SetNDims( grid, self->elGrid->nDims );
-		Grid_SetSizes( grid, self->range );
-
-		nOldEls = nEls;
-		nEls += elGrid->nPoints;
-		els = Memory_Realloc_Array( els, unsigned, nEls );
-
-		for( e_i = e_i; e_i < elGrid->nPoints; e_i++ ) {
-			Grid_Lift( self->elGrid, e_i, dimInds );
-			for( d_i = 0; d_i < grid->nDims; d_i++ )
-				dimInds[d_i] += self->origin[d_i];
-			els[nOldEls + e_i] = Grid_Project( self->elGrid, dimInds );
-		}
-
-		FreeObject( elGrid );
-	}
-
 	MeshTopology_SetElements( topo, MT_VERTEX, nEls, els );
 
 	FreeArray( dimInds );
@@ -1155,8 +1135,6 @@
 	Stream_UnIndent( stream );
 
 	vertsPerEl = (topo->nDims == 1) ? 2 : (topo->nDims == 2) ? 4 : 8;
-	if( self->enableCNodes )
-		vertsPerEl += 1;
 
 	nIncEls = Memory_Alloc_Array_Unnamed( unsigned, topo->domains[topo->nDims]->nDomains );
 	incEls = Memory_Alloc_2DArray_Unnamed( unsigned, topo->domains[topo->nDims]->nDomains, vertsPerEl );
@@ -1201,10 +1179,6 @@
 				dimInds[2]--;
 			}
 		}
-
-		if( self->enableCNodes ) {
-			incEls[e_i][curNode] = self->vertGrid->nPoints + gInd;
-		}
 	}
 
 	CartesianGenerator_MapToDomain( self, topo->domains[MT_VERTEX], topo->domains[topo->nDims]->nDomains, 
@@ -1771,6 +1745,9 @@
 	mesh->elTypeMap = Memory_Alloc_Array( unsigned, nDomainEls, "Mesh::elTypeMap" );
 	for( e_i = 0; e_i < nDomainEls; e_i++ )
 		mesh->elTypeMap[e_i] = 0;
+
+	if( self->regular )
+		Mesh_SetAlgorithms( mesh, Mesh_RegularAlgorithms_New( "" ) );
 }
 
 void CartesianGenerator_Destruct( CartesianGenerator* self ) {

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.h	2007-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/CartesianGenerator.h	2007-02-23 18:02:00 UTC (rev 6080)
@@ -54,13 +54,13 @@
 		/* Virtual info */		\
 						\
 		/* CartesianGenerator info */	\
+		Bool		regular;	\
 		unsigned	maxDecompDims;	\
 		unsigned*	minDecomp;	\
 		unsigned*	maxDecomp;	\
 		unsigned	shadowDepth;	\
 		double*		crdMin;		\
 		double*		crdMax;		\
-		Bool		enableCNodes;	\
 						\
 		Grid*		vertGrid;	\
 		Grid*		elGrid;		\

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Init.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Init.c	2007-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Init.c	2007-02-23 18:02:00 UTC (rev 6080)
@@ -60,6 +60,9 @@
 				   Mesh_CentroidAlgorithms_Type, "0", 
 				   (Stg_Component_DefaultConstructorFunction*)Mesh_CentroidAlgorithms_New );
 	Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), 
+				   Mesh_RegularAlgorithms_Type, "0", 
+				   (Stg_Component_DefaultConstructorFunction*)Mesh_RegularAlgorithms_New );
+	Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), 
 				   MeshTopology_Type, "0", (Stg_Component_DefaultConstructorFunction*)MeshTopology_New );
 	Stg_ComponentRegister_Add( Stg_ComponentRegister_Get_ComponentRegister(), 
 				   CartesianGenerator_Type, "0", (Stg_Component_DefaultConstructorFunction*)CartesianGenerator_New );
@@ -76,6 +79,7 @@
 	RegisterParent( Mesh_Algorithms_Type, Stg_Component_Type );
 	RegisterParent( Mesh_HexAlgorithms_Type, Mesh_Algorithms_Type );
 	RegisterParent( Mesh_CentroidAlgorithms_Type, Mesh_Algorithms_Type );
+	RegisterParent( Mesh_RegularAlgorithms_Type, Mesh_Algorithms_Type );
 	RegisterParent( MeshTopology_Type, Stg_Component_Type );
 	RegisterParent( Mesh_Type, Stg_Component_Type );
 	RegisterParent( MeshGenerator_Type, Stg_Component_Type );

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshClass.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshClass.c	2007-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshClass.c	2007-02-23 18:02:00 UTC (rev 6080)
@@ -97,6 +97,7 @@
 	self->maxGlobalCrd = NULL;
 
 	self->algorithms = Mesh_Algorithms_New( "" );
+	Mesh_Algorithms_SetMesh( self->algorithms, self );
 	self->nElTypes = 0;
 	self->elTypes = NULL;
 	self->elTypeMap = NULL;
@@ -154,7 +155,6 @@
 		return;
 
 	MeshGenerator_Generate( self->generator, self );
-	Mesh_Algorithms_SetMesh( self->algorithms, self );
 
 	nDims = Mesh_GetDimSize( self );
 	if( !nDims )
@@ -265,6 +265,7 @@
 	}
 	else
 		self->algorithms = Mesh_Algorithms_New( "" );
+	Mesh_Algorithms_SetMesh( self->algorithms, self );
 }
 
 unsigned Mesh_GetDimSize( void* mesh ) {
@@ -550,12 +551,12 @@
 
 	assert( self );
 
-	Mesh_Algorithms_Update( self->algorithms );
-
 	self->minSep = Mesh_Algorithms_GetMinimumSeparation( self->algorithms, self->minAxialSep );
 	Mesh_Algorithms_GetLocalCoordRange( self->algorithms, self->minLocalCrd, self->maxLocalCrd );
 	Mesh_Algorithms_GetDomainCoordRange( self->algorithms, self->minDomainCrd, self->maxDomainCrd );
 	Mesh_Algorithms_GetGlobalCoordRange( self->algorithms, self->minGlobalCrd, self->maxGlobalCrd );
+
+	Mesh_Algorithms_Update( self->algorithms );
 }
 
 void Mesh_Sync( void* mesh ) {

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-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c	2007-02-23 18:02:00 UTC (rev 6080)
@@ -69,8 +69,7 @@
 				     _Mesh_Algorithms_GetMinimumSeparation, 
 				     _Mesh_Algorithms_GetLocalCoordRange, 
 				     _Mesh_Algorithms_GetDomainCoordRange, 
-				     _Mesh_Algorithms_GetGlobalCoordRange, 
-				     _Mesh_Algorithms_Subsample );
+				     _Mesh_Algorithms_GetGlobalCoordRange );
 }
 
 Mesh_Algorithms* _Mesh_Algorithms_New( MESH_ALGORITHMS_DEFARGS ) {
@@ -90,7 +89,6 @@
 	self->getLocalCoordRangeFunc = getLocalCoordRangeFunc;
 	self->getDomainCoordRangeFunc = getDomainCoordRangeFunc;
 	self->getGlobalCoordRangeFunc = getGlobalCoordRangeFunc;
-	self->subsampleFunc = subsampleFunc;
 
 	/* Mesh_Algorithms info */
 	_Mesh_Algorithms_Init( self );
@@ -150,7 +148,6 @@
 	assert( !mesh || Stg_CheckType( mesh, Mesh ) );
 
 	self->mesh = (Mesh*)mesh;
-	Mesh_Algorithms_Update( self );
 }
 
 void _Mesh_Algorithms_Update( void* algorithms ) {
@@ -371,20 +368,7 @@
 	FreeArray( localMax );
 }
 
-void _Mesh_Algorithms_Subsample( void* algorithms, void* dstMesh ) {
-	Stream*	errorStream = Journal_Register( ErrorStream_Type, "Mesh_Algorithms::Subsample" );
 
-	Journal_Firewall( 0, 
-			  errorStream, 
-			  "\n" \
-			  "**************************************************************\n" \
-			  "* Error: There is no general implentation for subsampling an *\n" \
-			  "*        arbitrary mesh yet.                                 *\n" \
-			  "**************************************************************\n" \
-			  "\n" );
-}
-
-
 /*--------------------------------------------------------------------------------------------------------------------------
 ** Public Functions
 */

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-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.h	2007-02-23 18:02:00 UTC (rev 6080)
@@ -56,7 +56,6 @@
 	typedef void (Mesh_Algorithms_GetLocalCoordRangeFunc)( void* algorithms, double* min, double* max );
 	typedef void (Mesh_Algorithms_GetDomainCoordRangeFunc)( void* algorithms, double* min, double* max );
 	typedef void (Mesh_Algorithms_GetGlobalCoordRangeFunc)( void* algorithms, double* min, double* max );
-	typedef void (Mesh_Algorithms_SubsampleFunc)( void* algorithms, void* dstMesh );
 
 	/** Class contents */
 	#define __Mesh_Algorithms								\
@@ -73,7 +72,6 @@
 		Mesh_Algorithms_GetLocalCoordRangeFunc*		getLocalCoordRangeFunc;		\
 		Mesh_Algorithms_GetDomainCoordRangeFunc*	getDomainCoordRangeFunc;	\
 		Mesh_Algorithms_GetGlobalCoordRangeFunc*	getGlobalCoordRangeFunc;	\
-		Mesh_Algorithms_SubsampleFunc*			subsampleFunc;			\
 												\
 		/* Mesh_Algorithms info */							\
 		Mesh_Algorithms_NearestVertexFunc*	nearestVertex;				\
@@ -96,8 +94,7 @@
 		Mesh_Algorithms_GetMinimumSeparationFunc*	getMinimumSeparationFunc, 	\
 		Mesh_Algorithms_GetLocalCoordRangeFunc*		getLocalCoordRangeFunc,		\
 		Mesh_Algorithms_GetDomainCoordRangeFunc*	getDomainCoordRangeFunc,	\
-		Mesh_Algorithms_GetGlobalCoordRangeFunc*	getGlobalCoordRangeFunc,	\
-		Mesh_Algorithms_SubsampleFunc*			subsampleFunc
+		Mesh_Algorithms_GetGlobalCoordRangeFunc*	getGlobalCoordRangeFunc
 
 	#define MESH_ALGORITHMS_PASSARGS	\
 		STG_COMPONENT_PASSARGS, 	\
@@ -109,8 +106,7 @@
 		getMinimumSeparationFunc,	\
 		getLocalCoordRangeFunc, 	\
 		getDomainCoordRangeFunc, 	\
-		getGlobalCoordRangeFunc, 	\
-		subsampleFunc
+		getGlobalCoordRangeFunc
 
 	Mesh_Algorithms* Mesh_Algorithms_New( Name name );
 	Mesh_Algorithms* _Mesh_Algorithms_New( MESH_ALGORITHMS_DEFARGS );
@@ -139,7 +135,6 @@
 	void _Mesh_Algorithms_GetLocalCoordRange( void* algorithms, double* min, double* max );
 	void _Mesh_Algorithms_GetDomainCoordRange( void* algorithms, double* min, double* max );
 	void _Mesh_Algorithms_GetGlobalCoordRange( void* algorithms, double* min, double* max );
-	void _Mesh_Algorithms_Subsample( void* algorithms, void* dstMesh );
 
 	/*--------------------------------------------------------------------------------------------------------------------------
 	** Public functions
@@ -178,9 +173,6 @@
 		(assert( (algorithms) && ((Mesh_Algorithms*)algorithms)->getGlobalCoordRangeFunc ),	\
 		 ((Mesh_Algorithms*)algorithms)->getGlobalCoordRangeFunc( algorithms, min, max ))
 
-	#define Mesh_Algorithms_Subsample( self, dstMesh )		\
-		VirtualCall( self, subsampleFunc, self, dstMesh )
-
 	unsigned Mesh_Algorithms_NearestVertexWithNeighbours( void* algorithms, double* point );
 	unsigned Mesh_Algorithms_NearestVertexGeneral( void* algorithms, double* point );
 	Bool Mesh_Algorithms_SearchWithFullIncidence( void* algorithms, double* point, 

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_CentroidAlgorithms.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_CentroidAlgorithms.c	2007-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_CentroidAlgorithms.c	2007-02-23 18:02:00 UTC (rev 6080)
@@ -69,8 +69,7 @@
 					     _Mesh_Algorithms_GetMinimumSeparation, 
 					     _Mesh_Algorithms_GetLocalCoordRange, 
 					     _Mesh_Algorithms_GetDomainCoordRange, 
-					     _Mesh_Algorithms_GetGlobalCoordRange, 
-					     _Mesh_Algorithms_Subsample );
+					     _Mesh_Algorithms_GetGlobalCoordRange );
 }
 
 Mesh_CentroidAlgorithms* _Mesh_CentroidAlgorithms_New( MESH_HEXALGORITHMS_DEFARGS ) {

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexAlgorithms.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexAlgorithms.c	2007-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexAlgorithms.c	2007-02-23 18:02:00 UTC (rev 6080)
@@ -49,28 +49,27 @@
 
 Mesh_HexAlgorithms* Mesh_HexAlgorithms_New( Name name ) {
 	return _Mesh_HexAlgorithms_New( sizeof(Mesh_HexAlgorithms), 
-				     Mesh_HexAlgorithms_Type, 
-				     _Mesh_HexAlgorithms_Delete, 
-				     _Mesh_HexAlgorithms_Print, 
-				     NULL, 
-				     (void* (*)(Name))_Mesh_HexAlgorithms_New, 
-				     _Mesh_HexAlgorithms_Construct, 
-				     _Mesh_HexAlgorithms_Build, 
-				     _Mesh_HexAlgorithms_Initialise, 
-				     _Mesh_HexAlgorithms_Execute, 
-				     _Mesh_HexAlgorithms_Destroy, 
-				     name, 
-				     NON_GLOBAL, 
-				     _Mesh_Algorithms_SetMesh, 
-				     _Mesh_Algorithms_Update, 
-				     _Mesh_Algorithms_NearestVertex, 
-				     _Mesh_Algorithms_Search, 
-				     _Mesh_Algorithms_SearchElements, 
-				     _Mesh_Algorithms_GetMinimumSeparation, 
-				     _Mesh_Algorithms_GetLocalCoordRange, 
-				     _Mesh_Algorithms_GetDomainCoordRange, 
-				     _Mesh_Algorithms_GetGlobalCoordRange, 
-				     Mesh_HexAlgorithms_Subsample );
+					Mesh_HexAlgorithms_Type, 
+					_Mesh_HexAlgorithms_Delete, 
+					_Mesh_HexAlgorithms_Print, 
+					NULL, 
+					(void* (*)(Name))_Mesh_HexAlgorithms_New, 
+					_Mesh_HexAlgorithms_Construct, 
+					_Mesh_HexAlgorithms_Build, 
+					_Mesh_HexAlgorithms_Initialise, 
+					_Mesh_HexAlgorithms_Execute, 
+					_Mesh_HexAlgorithms_Destroy, 
+					name, 
+					NON_GLOBAL, 
+					_Mesh_Algorithms_SetMesh, 
+					_Mesh_Algorithms_Update, 
+					_Mesh_Algorithms_NearestVertex, 
+					_Mesh_Algorithms_Search, 
+					_Mesh_Algorithms_SearchElements, 
+					_Mesh_Algorithms_GetMinimumSeparation, 
+					_Mesh_Algorithms_GetLocalCoordRange, 
+					_Mesh_Algorithms_GetDomainCoordRange, 
+					_Mesh_Algorithms_GetGlobalCoordRange );
 }
 
 Mesh_HexAlgorithms* _Mesh_HexAlgorithms_New( MESH_HEXALGORITHMS_DEFARGS ) {
@@ -130,13 +129,7 @@
 void _Mesh_HexAlgorithms_Destroy( void* hexAlgorithms, void* data ) {
 }
 
-void Mesh_HexAlgorithms_Subsample( void* hexAlgorithms, void* dstMesh ) {
-	Mesh_HexAlgorithms*	self = (Mesh_HexAlgorithms*)hexAlgorithms;
 
-	assert( self && Stg_CheckType( self, Mesh_HexAlgorithms ) );
-}
-
-
 /*--------------------------------------------------------------------------------------------------------------------------
 ** Public Functions
 */

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexAlgorithms.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexAlgorithms.h	2007-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_HexAlgorithms.h	2007-02-23 18:02:00 UTC (rev 6080)
@@ -83,8 +83,6 @@
 	void _Mesh_HexAlgorithms_Execute( void* hexAlgorithms, void* data );
 	void _Mesh_HexAlgorithms_Destroy( void* hexAlgorithms, void* data );
 
-	void Mesh_HexAlgorithms_Subsample( void* hexAlgorithms, void* dstMesh );
-
 	/*--------------------------------------------------------------------------------------------------------------------------
 	** Public functions
 	*/

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_RegularAlgorithms.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_RegularAlgorithms.c	2007-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_RegularAlgorithms.c	2007-02-23 18:02:00 UTC (rev 6080)
@@ -61,16 +61,15 @@
 					    _Mesh_RegularAlgorithms_Destroy, 
 					    name, 
 					    NON_GLOBAL, 
-					    _Mesh_Algorithms_SetMesh, 
-					    _Mesh_Algorithms_Update, 
+					    Mesh_RegularAlgorithms_SetMesh, 
+					    Mesh_RegularAlgorithms_Update, 
 					    _Mesh_Algorithms_NearestVertex, 
 					    _Mesh_Algorithms_Search, 
 					    Mesh_RegularAlgorithms_SearchElements, 
 					    _Mesh_Algorithms_GetMinimumSeparation, 
 					    _Mesh_Algorithms_GetLocalCoordRange, 
 					    _Mesh_Algorithms_GetDomainCoordRange, 
-					    _Mesh_Algorithms_GetGlobalCoordRange, 
-					    _Mesh_Algorithms_Subsample );
+					    _Mesh_Algorithms_GetGlobalCoordRange );
 }
 
 Mesh_RegularAlgorithms* _Mesh_RegularAlgorithms_New( MESH_REGULARALGORITHMS_DEFARGS ) {
@@ -89,6 +88,9 @@
 }
 
 void _Mesh_RegularAlgorithms_Init( Mesh_RegularAlgorithms* self ) {
+	assert( self && Stg_CheckType( self, Mesh_RegularAlgorithms ) );
+
+	self->sep = NULL;
 }
 
 
@@ -99,6 +101,8 @@
 void _Mesh_RegularAlgorithms_Delete( void* algorithms ) {
 	Mesh_RegularAlgorithms*	self = (Mesh_RegularAlgorithms*)algorithms;
 
+	Mesh_RegularAlgorithms_Destruct( self );
+
 	/* Delete the parent. */
 	_Mesh_Algorithms_Delete( self );
 }
@@ -131,6 +135,34 @@
 void _Mesh_RegularAlgorithms_Destroy( void* algorithms, void* data ) {
 }
 
+void Mesh_RegularAlgorithms_SetMesh( void* algorithms, void* mesh ) {
+	Mesh_RegularAlgorithms*	self = (Mesh_RegularAlgorithms*)algorithms;
+
+	assert( self && Stg_CheckType( self, Mesh_RegularAlgorithms ) );
+
+	Mesh_RegularAlgorithms_Destruct( self );
+	_Mesh_Algorithms_SetMesh( self, mesh );
+}
+
+void Mesh_RegularAlgorithms_Update( void* algorithms ) {
+	Mesh_RegularAlgorithms*	self = (Mesh_RegularAlgorithms*)algorithms;
+	unsigned		nDims;
+	double			minSep;
+
+	assert( self && Stg_CheckType( self, Mesh_RegularAlgorithms ) );
+	assert( self->mesh );
+
+	Mesh_RegularAlgorithms_Destruct( self );
+	_Mesh_Algorithms_Update( self );
+
+	nDims = Mesh_GetDimSize( self->mesh );
+	self->sep = AllocArray( double, nDims );
+	self->minCrd = AllocArray( double, nDims );
+	self->maxCrd = AllocArray( double, nDims );
+	Mesh_GetMinimumSeparation( self->mesh, &minSep, self->sep );
+	Mesh_GetGlobalCoordRange( self->mesh, self->minCrd, self->maxCrd );
+}
+
 Bool _Mesh_RegularAlgorithms_Search( void* algorithms, void* _mesh, double* point, 
 				     MeshTopology_Dim* dim, unsigned* ind )
 {
@@ -151,9 +183,9 @@
 	Mesh_RegularAlgorithms*	self = (Mesh_RegularAlgorithms*)algorithms;
 	Mesh*			mesh;
 	unsigned		nDims;
-	unsigned		vertInd;
 	unsigned		inds[3];
-	Grid			*vertGrid, *elGrid;
+	Grid			*elGrid;
+	double			out, frac, integer;
 	unsigned		d_i;
 
 	assert( self && Stg_CheckType( self, Mesh_RegularAlgorithms ) );
@@ -162,25 +194,21 @@
 
 	mesh = self->mesh;
 	nDims = Mesh_GetDimSize( mesh );
-	vertGrid = *(Grid**)ExtensionManager_Get( mesh->info, mesh, 
-						  ExtensionManager_GetHandle( mesh->info, "vertexGrid" ) );
 	elGrid = *(Grid**)ExtensionManager_Get( mesh->info, mesh, 
 						ExtensionManager_GetHandle( mesh->info, "elementGrid" ) );
 	for( d_i = 0; d_i < nDims; d_i++ ) {
-		for( inds[d_i] = 1; inds[d_i] < vertGrid->sizes[d_i]; inds[d_i]++ ) {
-			vertInd = Grid_Project( vertGrid, inds );
-			insist( Mesh_GlobalToDomain( mesh, MT_VERTEX, vertInd, &vertInd ) );
-			if( Mesh_GetVertex( mesh, vertInd )[d_i] >= point[d_i] )
-				break;
-		}
-		if( inds[d_i] == vertGrid->sizes[d_i] )
+		if( point[d_i] < self->minCrd[d_i] || point[d_i] > self->maxCrd[d_i] )
 			return False;
-		else
+
+		out = (point[d_i] - self->minCrd[d_i]) / self->sep[d_i];
+		frac = modf( out, &integer );
+		inds[d_i] = (unsigned)integer;
+		if( inds[d_i] > 0 && Num_Approx( frac, 0.0 ) )
 			inds[d_i]--;
 	}
+
 	*elInd = Grid_Project( elGrid, inds );
-
-	return True;
+	return Mesh_GlobalToDomain( mesh, nDims, *elInd, elInd );
 }
 
 double _Mesh_RegularAlgorithms_GetMinimumSeparation( void* algorithms, void* _mesh, double* perDim ) {
@@ -236,3 +264,11 @@
 /*----------------------------------------------------------------------------------------------------------------------------------
 ** Private Functions
 */
+
+void Mesh_RegularAlgorithms_Destruct( Mesh_RegularAlgorithms* self ) {
+	assert( self && Stg_CheckType( self, Mesh_RegularAlgorithms ) );
+
+	KillArray( self->sep );
+	KillArray( self->minCrd );
+	KillArray( self->maxCrd );
+}

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_RegularAlgorithms.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_RegularAlgorithms.h	2007-02-23 18:01:05 UTC (rev 6079)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_RegularAlgorithms.h	2007-02-23 18:02:00 UTC (rev 6080)
@@ -53,7 +53,10 @@
 							\
 		/* Virtual info */			\
 							\
-		/* Mesh_RegularAlgorithms info */
+		/* Mesh_RegularAlgorithms info */	\
+		double*		sep;			\
+		double*		minCrd;			\
+		double*		maxCrd;
 
 	struct Mesh_RegularAlgorithms { __Mesh_RegularAlgorithms };
 
@@ -83,6 +86,8 @@
 	void _Mesh_RegularAlgorithms_Execute( void* algorithms, void* data );
 	void _Mesh_RegularAlgorithms_Destroy( void* algorithms, void* data );
 
+	void Mesh_RegularAlgorithms_SetMesh( void* algorithms, void* mesh );
+	void Mesh_RegularAlgorithms_Update( void* algorithms );
 	Bool Mesh_RegularAlgorithms_Search( void* algorithms, void* mesh, double* point, 
 					    MeshTopology_Dim* dim, unsigned* ind );
 	Bool Mesh_RegularAlgorithms_SearchElements( void* algorithms, double* point, unsigned* elInd );
@@ -99,4 +104,6 @@
 	** Private Member functions
 	*/
 
+	void Mesh_RegularAlgorithms_Destruct( Mesh_RegularAlgorithms* self );
+
 #endif /* __Discretisaton_Mesh_Mesh_RegularAlgorithms_h__ */



More information about the cig-commits mailing list