[cig-commits] commit:
Mercurial
hg at geodynamics.org
Mon Nov 24 11:58:18 PST 2008
changeset: 21:c8338a44bcc5
user: LukeHodkinson
date: Tue Jan 29 03:40:13 2008 +0000
files: Geometry/SConscript Geometry/src/SConscript Geometry/tests/SConscript Mesh/SConscript Mesh/src/CommTopology.c Mesh/src/CommTopology.c.disabled Mesh/src/CommTopology.h Mesh/src/CommTopology.h.disabled Mesh/src/DecompTransfer.c Mesh/src/DecompTransfer.c.disabled Mesh/src/DecompTransfer.h Mesh/src/DecompTransfer.h.disabled Mesh/src/Decomp_Sync.c Mesh/src/Decomp_Sync.c.disabled Mesh/src/Decomp_Sync.h Mesh/src/Decomp_Sync.h.disabled Mesh/src/Decomp_Sync_Array.c Mesh/src/Decomp_Sync_Array.c.disabled Mesh/src/Decomp_Sync_Claim.c Mesh/src/Decomp_Sync_Claim.c.disabled Mesh/src/Decomp_Sync_Negotiate.c Mesh/src/Decomp_Sync_Negotiate.c.disabled Mesh/src/Decomposer.c Mesh/src/Decomposer.c.disabled Mesh/src/DictionaryGenerator.c Mesh/src/DictionaryGenerator.c.disabled Mesh/src/DictionaryGenerator.h Mesh/src/DictionaryGenerator.h.disabled Mesh/src/HMesh.c Mesh/src/HMesh.c.disabled Mesh/src/HMesh.h Mesh/src/HMesh.h.disabled Mesh/src/SConscript Mesh/tests/SConscript SConfigure SConstruct Shape/SConscript Shape/src/SConscript Shape/tests/SConscript StgSCons Swarm/SConscript Swarm/src/SConscript Swarm/tests/SConscript Utils/SConscript Utils/src/CellRemesher.c Utils/src/CellRemesher.c.disabled Utils/src/CellRemesher.h Utils/src/CellRemesher.h.disabled Utils/src/EmbeddedSurface.c Utils/src/EmbeddedSurface.c.disabled Utils/src/EmbeddedSurface.h Utils/src/EmbeddedSurface.h.disabled Utils/src/SConscript Utils/src/SemiRegDeform.c Utils/src/SemiRegDeform.c.disabled Utils/src/SemiRegDeform.h Utils/src/SemiRegDeform.h.disabled Utils/src/StripRemesher.c Utils/src/StripRemesher.c.disabled Utils/src/StripRemesher.h Utils/src/StripRemesher.h.disabled Utils/tests/SConscript Utils/tests/testEmbeddedSurface.c Utils/tests/testEmbeddedSurface.c.disabled Utils/tests/testMeshCoarsener_Hexa..c.disabled Utils/tests/testMeshCoarsener_Hexa.c Utils/tests/testSemiRegDeform.c Utils/tests/testSemiRegDeform.c.disabled libStgDomain/SConscript libStgDomain/Toolbox/SConscript libStgDomain/src/SConscript libStgDomain/tests/SConscript meta-template.c
description:
Adding SCons to StgDomain. Once again, as a result of
using globbing to automatically extract source
files to be built, I've had to move a few source
files so that they have different extensions.
diff -r 8e9e91298ee8 -r c8338a44bcc5 Geometry/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Geometry/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,18 @@
+import os
+Import('env')
+
+# Setup current module.
+env.curModule = env['helpers']['buildModName'](env)
+
+# Execute subdirectory SConscripts.
+objs = SConscript('src/SConscript', exports='env')
+
+# Build libraries.
+libs = env.Library(env['helpers']['buildLibDir'](env), objs)
+libs += env.LoadableModule(env['helpers']['buildLibDir'](env), objs)
+env.Install(os.path.join(env['prefix'], 'lib'), libs)
+
+# Build tests.
+SConscript('tests/SConscript', exports='env')
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Geometry/src/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Geometry/src/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,10 @@
+import os
+Import('env')
+
+# Copy headers to our build directory.
+incs = env['helpers']['copyHdrs'](env)
+
+# Build our source files.
+objs = env['helpers']['buildCSrcs'](env)
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Geometry/tests/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Geometry/tests/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,5 @@
+import os
+Import('env')
+
+# Build test binaries.
+env['helpers']['buildTests'](env, libs=['StgDomainGeometry'])
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,18 @@
+import os
+Import('env')
+
+# Setup current module.
+env.curModule = env['helpers']['buildModName'](env)
+
+# Execute subdirectory SConscripts.
+objs = SConscript('src/SConscript', exports='env')
+
+# Build libraries.
+libs = env.Library(env['helpers']['buildLibDir'](env), objs)
+libs += env.LoadableModule(env['helpers']['buildLibDir'](env), objs)
+env.Install(os.path.join(env['prefix'], 'lib'), libs)
+
+# Build tests.
+SConscript('tests/SConscript', exports='env')
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/CommTopology.c
--- a/Mesh/src/CommTopology.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,397 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: CommTopology.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-#include <StgDomain/Geometry/Geometry.h>
-#include "Mesh.h"
-
-
-/* Textual name of this class */
-const Type CommTopology_Type = "CommTopology";
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-CommTopology* CommTopology_New() {
- return _CommTopology_New( sizeof(CommTopology),
- CommTopology_Type,
- _CommTopology_Delete,
- _CommTopology_Print,
- NULL );
-}
-
-CommTopology* _CommTopology_New( COMMTOPOLOGY_DEFARGS ) {
- CommTopology* self;
-
- /* Allocate memory */
- assert( sizeOfSelf >= sizeof(CommTopology) );
- self = (CommTopology*)_Stg_Class_New( STG_CLASS_PASSARGS );
-
- /* Virtual info */
-
- /* CommTopology info */
- _CommTopology_Init( self );
-
- return self;
-}
-
-void _CommTopology_Init( CommTopology* self ) {
- self->comm = MPI_COMM_WORLD;
- self->nIncRanks = 0;
- self->incRanks = NULL;
- self->glMap = UIntMap_New();
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _CommTopology_Delete( void* commTopology ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- CommTopology_Destruct( self );
- FreeObject( self->glMap );
-
- /* Delete the parent. */
- _Stg_Class_Delete( self );
-}
-
-void _CommTopology_Print( void* commTopology, Stream* stream ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- /* Set the Journal for printing informations */
- Stream* commTopologyStream;
- commTopologyStream = Journal_Register( InfoStream_Type, "CommTopologyStream" );
-
- /* Print parent */
- Journal_Printf( stream, "CommTopology (ptr): (%p)\n", self );
- _Stg_Class_Print( self, stream );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void CommTopology_SetComm( void* commTopology, MPI_Comm comm ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- assert( self );
-
- CommTopology_Destruct( self );
- self->comm = comm;
-}
-
-void CommTopology_SetIncidence( void* commTopology, unsigned nIncRanks, unsigned* incRanks ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- assert( self );
- assert( !nIncRanks || incRanks );
-
- CommTopology_Destruct( self );
- CommTopology_AddIncidence( self, nIncRanks, incRanks );
-}
-
-void CommTopology_AddIncidence( void* commTopology, unsigned nIncRanks, unsigned* incRanks ) {
- CommTopology* self = (CommTopology*)commTopology;
- unsigned r_i;
-
- assert( self );
- assert( !nIncRanks || incRanks );
- assert( CommTopology_ValidateIncidence( self, nIncRanks, incRanks ) );
-
- if( nIncRanks ) {
- unsigned* order;
-
- for( r_i = 0; r_i < nIncRanks; r_i++ )
- UIntMap_Insert( self->glMap, incRanks[r_i], self->nIncRanks + r_i );
-
- self->incRanks = ReallocNamedArray( self->incRanks, unsigned, self->nIncRanks + nIncRanks,
- "CommTopology::incRanks" );
- memcpy( self->incRanks + self->nIncRanks, incRanks, nIncRanks * sizeof(unsigned) );
- self->nIncRanks += nIncRanks;
-
- order = AllocArray( unsigned, self->nIncRanks * 2 );
- for( r_i = 0; r_i < self->nIncRanks; r_i++ ) {
- order[2 * r_i] = self->incRanks[r_i];
- order[2 * r_i + 1] = r_i;
- }
- qsort( order, self->nIncRanks, 2 * sizeof(unsigned), CommTopology_CmpRanks );
- self->order = ReallocNamedArray( self->order, unsigned, self->nIncRanks, "CommTopology::order" );
- for( r_i = 0; r_i < self->nIncRanks; r_i++ )
- self->order[r_i] = order[2 * r_i + 1];
- FreeArray( order );
- }
-}
-
-MPI_Comm CommTopology_GetComm( void* commTopology ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- assert( self );
-
- return self->comm;
-}
-
-unsigned CommTopology_GetCommSize( void* commTopology ) {
- CommTopology* self = (CommTopology*)commTopology;
- unsigned nProcs;
-
- assert( self );
-
- MPI_Comm_size( self->comm, (int*)&nProcs );
-
- return nProcs;
-}
-
-unsigned CommTopology_GetCommRank( void* commTopology ) {
- CommTopology* self = (CommTopology*)commTopology;
- unsigned rank;
-
- assert( self );
-
- MPI_Comm_rank( self->comm, (int*)&rank );
-
- return rank;
-}
-
-unsigned CommTopology_GetIncidenceSize( void* commTopology ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- assert( self );
-
- return self->nIncRanks;
-}
-
-void CommTopology_GetIncidence( void* commTopology, unsigned* nIncRanks, unsigned** incRanks ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- assert( self );
- assert( nIncRanks && incRanks );
-
- *nIncRanks = self->nIncRanks;
- *incRanks = self->incRanks;
-}
-
-unsigned CommTopology_LocalToGlobal( void* commTopology, unsigned local ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- assert( self );
- assert( local < self->nIncRanks );
- assert( self->incRanks );
- assert( self->order );
-
- return self->incRanks[local];
-}
-
-Bool CommTopology_GlobalToLocal( void* commTopology, unsigned global, unsigned* local ) {
- CommTopology* self = (CommTopology*)commTopology;
-
- assert( self );
-
- return UIntMap_Map( self->glMap, global, local );
-}
-
-void _CommTopology_Allgather( void* commTopology,
- unsigned srcSize, void* srcArray,
- unsigned** dstSizes, void*** dstArrays,
- unsigned itemSize )
-{
- CommTopology* self = (CommTopology*)commTopology;
- unsigned tag = 669;
- MPI_Status status;
- unsigned* nbrSizes;
- Stg_Byte** nbrArrays;
- unsigned p_i;
-
- assert( self );
- assert( !srcSize || srcArray );
- assert( dstSizes );
- assert( dstArrays );
-
- /* Skip this if we have no neighbours. */
- if( !self->nIncRanks ) {
- *dstSizes = NULL;
- *dstArrays = NULL;
- return;
- }
-
- /* Allocate base arrays. */
- nbrSizes = AllocArray( unsigned, self->nIncRanks );
- nbrArrays = AllocArray( Stg_Byte*, self->nIncRanks );
-
- /* Send/recv with each neighbour. There won't be deadlocks because the neighbouring
- ranks are ordered from lowest to highest. Start with sizes. */
- for( p_i = 0; p_i < self->nIncRanks; p_i++ ) {
- unsigned pos = self->order[p_i];
- unsigned nbr = self->incRanks[pos];
- unsigned tmpSize;
-
- MPI_Sendrecv( &srcSize, 1, MPI_UNSIGNED, nbr, tag,
- nbrSizes + pos, 1, MPI_UNSIGNED, nbr, tag,
- self->comm, &status );
-
- tmpSize = nbrSizes[pos] * itemSize;
-
- /* Alloc storage. */
- if( tmpSize )
- nbrArrays[pos] = AllocArray( Stg_Byte, tmpSize );
- else
- nbrArrays[pos] = NULL;
-
- MPI_Sendrecv( srcArray, srcSize * itemSize, MPI_BYTE, nbr, tag,
- nbrArrays[pos], tmpSize, MPI_BYTE, nbr, tag,
- self->comm, &status );
- }
-
- /* Store results. */
- *dstSizes = nbrSizes;
- *dstArrays = (void**)nbrArrays;
-}
-
-void _CommTopology_Alltoall( void* commTopology,
- unsigned* srcSizes, void** srcArrays,
- unsigned** dstSizes, void*** dstArrays,
- unsigned itemSize )
-{
- CommTopology* self = (CommTopology*)commTopology;
- unsigned tag = 669;
- MPI_Status status;
- unsigned* nbrSizes;
- Stg_Byte** nbrArrays;
- unsigned p_i;
-
- assert( self );
- assert( !srcSizes || srcArrays );
- assert( dstSizes );
- assert( dstArrays );
-
- /* Skip this if we have no neighbours. */
- if( !self->nIncRanks ) {
- *dstSizes = NULL;
- *dstArrays = NULL;
- return;
- }
-
- /* Allocate base array. */
- nbrSizes = AllocArray( unsigned, self->nIncRanks );
- nbrArrays = AllocArray( Stg_Byte*, self->nIncRanks );
-
- /* Send/recv with each neighbour. There won't be deadlocks because the neighbouring
- ranks are ordered from lowest to highest. Start with sizes. */
- for( p_i = 0; p_i < self->nIncRanks; p_i++ ) {
- unsigned pos = self->order[p_i];
- unsigned nbr = self->incRanks[pos];
- unsigned tmpSize;
-
- MPI_Sendrecv( srcSizes + pos, 1, MPI_UNSIGNED, nbr, tag,
- nbrSizes + pos, 1, MPI_UNSIGNED, nbr, tag,
- self->comm, &status );
-
- tmpSize = nbrSizes[pos] * itemSize;
-
- /* Alloc storage. */
- if( tmpSize )
- nbrArrays[pos] = AllocArray( Stg_Byte, tmpSize );
- else
- nbrArrays[pos] = NULL;
-
- /* Transfer between current neighbour. */
- MPI_Sendrecv( srcArrays[pos], srcSizes[pos] * itemSize, MPI_BYTE, nbr, tag,
- nbrArrays[pos], tmpSize, MPI_BYTE, nbr, tag,
- self->comm, &status );
- }
-
- /* Store results. */
- *dstSizes = nbrSizes;
- *dstArrays = (void**)nbrArrays;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-int CommTopology_CmpRanks( const void* rank0, const void* rank1 ) {
- if( *((unsigned*)rank0) < *((unsigned*)rank1) )
- return -1;
- else if( *((unsigned*)rank0) > *((unsigned*)rank1) )
- return 1;
- else
- return 0;
-}
-
-void CommTopology_Destruct( CommTopology* self ) {
- KillArray( self->incRanks );
- self->nIncRanks = 0;
- UIntMap_Clear( self->glMap );
-}
-
-#ifndef NDEBUG
-Bool CommTopology_ValidateIncidence( CommTopology* self, unsigned nIncRanks, unsigned* incRanks ) {
- RangeSet *exSet, *newSet;
- unsigned nProcs, rank;
- unsigned size;
- unsigned inc_i;
-
- assert( self );
- assert( !nIncRanks || incRanks );
-
- /* Validate basics. */
- MPI_Comm_size( self->comm, (int*)&nProcs );
- MPI_Comm_rank( self->comm, (int*)&rank );
- for( inc_i = 0; inc_i < nIncRanks; inc_i++ ) {
- if( incRanks[inc_i] >= nProcs || incRanks[inc_i] == rank )
- return False;
- }
-
- /* Ensure no existing overlap. */
- exSet = RangeSet_New();
- newSet = RangeSet_New();
- RangeSet_SetIndices( exSet, self->nIncRanks, self->incRanks );
- RangeSet_SetIndices( newSet, nIncRanks, incRanks );
- RangeSet_Intersection( newSet, exSet );
- size = RangeSet_GetSize( newSet );
- FreeObject( newSet );
- FreeObject( exSet );
- if( size )
- return False;
-
- return True;
-}
-#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/CommTopology.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/CommTopology.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,397 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: CommTopology.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include <StgDomain/Geometry/Geometry.h>
+#include "Mesh.h"
+
+
+/* Textual name of this class */
+const Type CommTopology_Type = "CommTopology";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+CommTopology* CommTopology_New() {
+ return _CommTopology_New( sizeof(CommTopology),
+ CommTopology_Type,
+ _CommTopology_Delete,
+ _CommTopology_Print,
+ NULL );
+}
+
+CommTopology* _CommTopology_New( COMMTOPOLOGY_DEFARGS ) {
+ CommTopology* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(CommTopology) );
+ self = (CommTopology*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* Virtual info */
+
+ /* CommTopology info */
+ _CommTopology_Init( self );
+
+ return self;
+}
+
+void _CommTopology_Init( CommTopology* self ) {
+ self->comm = MPI_COMM_WORLD;
+ self->nIncRanks = 0;
+ self->incRanks = NULL;
+ self->glMap = UIntMap_New();
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _CommTopology_Delete( void* commTopology ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ CommTopology_Destruct( self );
+ FreeObject( self->glMap );
+
+ /* Delete the parent. */
+ _Stg_Class_Delete( self );
+}
+
+void _CommTopology_Print( void* commTopology, Stream* stream ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ /* Set the Journal for printing informations */
+ Stream* commTopologyStream;
+ commTopologyStream = Journal_Register( InfoStream_Type, "CommTopologyStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "CommTopology (ptr): (%p)\n", self );
+ _Stg_Class_Print( self, stream );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void CommTopology_SetComm( void* commTopology, MPI_Comm comm ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ assert( self );
+
+ CommTopology_Destruct( self );
+ self->comm = comm;
+}
+
+void CommTopology_SetIncidence( void* commTopology, unsigned nIncRanks, unsigned* incRanks ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ assert( self );
+ assert( !nIncRanks || incRanks );
+
+ CommTopology_Destruct( self );
+ CommTopology_AddIncidence( self, nIncRanks, incRanks );
+}
+
+void CommTopology_AddIncidence( void* commTopology, unsigned nIncRanks, unsigned* incRanks ) {
+ CommTopology* self = (CommTopology*)commTopology;
+ unsigned r_i;
+
+ assert( self );
+ assert( !nIncRanks || incRanks );
+ assert( CommTopology_ValidateIncidence( self, nIncRanks, incRanks ) );
+
+ if( nIncRanks ) {
+ unsigned* order;
+
+ for( r_i = 0; r_i < nIncRanks; r_i++ )
+ UIntMap_Insert( self->glMap, incRanks[r_i], self->nIncRanks + r_i );
+
+ self->incRanks = ReallocNamedArray( self->incRanks, unsigned, self->nIncRanks + nIncRanks,
+ "CommTopology::incRanks" );
+ memcpy( self->incRanks + self->nIncRanks, incRanks, nIncRanks * sizeof(unsigned) );
+ self->nIncRanks += nIncRanks;
+
+ order = AllocArray( unsigned, self->nIncRanks * 2 );
+ for( r_i = 0; r_i < self->nIncRanks; r_i++ ) {
+ order[2 * r_i] = self->incRanks[r_i];
+ order[2 * r_i + 1] = r_i;
+ }
+ qsort( order, self->nIncRanks, 2 * sizeof(unsigned), CommTopology_CmpRanks );
+ self->order = ReallocNamedArray( self->order, unsigned, self->nIncRanks, "CommTopology::order" );
+ for( r_i = 0; r_i < self->nIncRanks; r_i++ )
+ self->order[r_i] = order[2 * r_i + 1];
+ FreeArray( order );
+ }
+}
+
+MPI_Comm CommTopology_GetComm( void* commTopology ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ assert( self );
+
+ return self->comm;
+}
+
+unsigned CommTopology_GetCommSize( void* commTopology ) {
+ CommTopology* self = (CommTopology*)commTopology;
+ unsigned nProcs;
+
+ assert( self );
+
+ MPI_Comm_size( self->comm, (int*)&nProcs );
+
+ return nProcs;
+}
+
+unsigned CommTopology_GetCommRank( void* commTopology ) {
+ CommTopology* self = (CommTopology*)commTopology;
+ unsigned rank;
+
+ assert( self );
+
+ MPI_Comm_rank( self->comm, (int*)&rank );
+
+ return rank;
+}
+
+unsigned CommTopology_GetIncidenceSize( void* commTopology ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ assert( self );
+
+ return self->nIncRanks;
+}
+
+void CommTopology_GetIncidence( void* commTopology, unsigned* nIncRanks, unsigned** incRanks ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ assert( self );
+ assert( nIncRanks && incRanks );
+
+ *nIncRanks = self->nIncRanks;
+ *incRanks = self->incRanks;
+}
+
+unsigned CommTopology_LocalToGlobal( void* commTopology, unsigned local ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ assert( self );
+ assert( local < self->nIncRanks );
+ assert( self->incRanks );
+ assert( self->order );
+
+ return self->incRanks[local];
+}
+
+Bool CommTopology_GlobalToLocal( void* commTopology, unsigned global, unsigned* local ) {
+ CommTopology* self = (CommTopology*)commTopology;
+
+ assert( self );
+
+ return UIntMap_Map( self->glMap, global, local );
+}
+
+void _CommTopology_Allgather( void* commTopology,
+ unsigned srcSize, void* srcArray,
+ unsigned** dstSizes, void*** dstArrays,
+ unsigned itemSize )
+{
+ CommTopology* self = (CommTopology*)commTopology;
+ unsigned tag = 669;
+ MPI_Status status;
+ unsigned* nbrSizes;
+ Stg_Byte** nbrArrays;
+ unsigned p_i;
+
+ assert( self );
+ assert( !srcSize || srcArray );
+ assert( dstSizes );
+ assert( dstArrays );
+
+ /* Skip this if we have no neighbours. */
+ if( !self->nIncRanks ) {
+ *dstSizes = NULL;
+ *dstArrays = NULL;
+ return;
+ }
+
+ /* Allocate base arrays. */
+ nbrSizes = AllocArray( unsigned, self->nIncRanks );
+ nbrArrays = AllocArray( Stg_Byte*, self->nIncRanks );
+
+ /* Send/recv with each neighbour. There won't be deadlocks because the neighbouring
+ ranks are ordered from lowest to highest. Start with sizes. */
+ for( p_i = 0; p_i < self->nIncRanks; p_i++ ) {
+ unsigned pos = self->order[p_i];
+ unsigned nbr = self->incRanks[pos];
+ unsigned tmpSize;
+
+ MPI_Sendrecv( &srcSize, 1, MPI_UNSIGNED, nbr, tag,
+ nbrSizes + pos, 1, MPI_UNSIGNED, nbr, tag,
+ self->comm, &status );
+
+ tmpSize = nbrSizes[pos] * itemSize;
+
+ /* Alloc storage. */
+ if( tmpSize )
+ nbrArrays[pos] = AllocArray( Stg_Byte, tmpSize );
+ else
+ nbrArrays[pos] = NULL;
+
+ MPI_Sendrecv( srcArray, srcSize * itemSize, MPI_BYTE, nbr, tag,
+ nbrArrays[pos], tmpSize, MPI_BYTE, nbr, tag,
+ self->comm, &status );
+ }
+
+ /* Store results. */
+ *dstSizes = nbrSizes;
+ *dstArrays = (void**)nbrArrays;
+}
+
+void _CommTopology_Alltoall( void* commTopology,
+ unsigned* srcSizes, void** srcArrays,
+ unsigned** dstSizes, void*** dstArrays,
+ unsigned itemSize )
+{
+ CommTopology* self = (CommTopology*)commTopology;
+ unsigned tag = 669;
+ MPI_Status status;
+ unsigned* nbrSizes;
+ Stg_Byte** nbrArrays;
+ unsigned p_i;
+
+ assert( self );
+ assert( !srcSizes || srcArrays );
+ assert( dstSizes );
+ assert( dstArrays );
+
+ /* Skip this if we have no neighbours. */
+ if( !self->nIncRanks ) {
+ *dstSizes = NULL;
+ *dstArrays = NULL;
+ return;
+ }
+
+ /* Allocate base array. */
+ nbrSizes = AllocArray( unsigned, self->nIncRanks );
+ nbrArrays = AllocArray( Stg_Byte*, self->nIncRanks );
+
+ /* Send/recv with each neighbour. There won't be deadlocks because the neighbouring
+ ranks are ordered from lowest to highest. Start with sizes. */
+ for( p_i = 0; p_i < self->nIncRanks; p_i++ ) {
+ unsigned pos = self->order[p_i];
+ unsigned nbr = self->incRanks[pos];
+ unsigned tmpSize;
+
+ MPI_Sendrecv( srcSizes + pos, 1, MPI_UNSIGNED, nbr, tag,
+ nbrSizes + pos, 1, MPI_UNSIGNED, nbr, tag,
+ self->comm, &status );
+
+ tmpSize = nbrSizes[pos] * itemSize;
+
+ /* Alloc storage. */
+ if( tmpSize )
+ nbrArrays[pos] = AllocArray( Stg_Byte, tmpSize );
+ else
+ nbrArrays[pos] = NULL;
+
+ /* Transfer between current neighbour. */
+ MPI_Sendrecv( srcArrays[pos], srcSizes[pos] * itemSize, MPI_BYTE, nbr, tag,
+ nbrArrays[pos], tmpSize, MPI_BYTE, nbr, tag,
+ self->comm, &status );
+ }
+
+ /* Store results. */
+ *dstSizes = nbrSizes;
+ *dstArrays = (void**)nbrArrays;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+int CommTopology_CmpRanks( const void* rank0, const void* rank1 ) {
+ if( *((unsigned*)rank0) < *((unsigned*)rank1) )
+ return -1;
+ else if( *((unsigned*)rank0) > *((unsigned*)rank1) )
+ return 1;
+ else
+ return 0;
+}
+
+void CommTopology_Destruct( CommTopology* self ) {
+ KillArray( self->incRanks );
+ self->nIncRanks = 0;
+ UIntMap_Clear( self->glMap );
+}
+
+#ifndef NDEBUG
+Bool CommTopology_ValidateIncidence( CommTopology* self, unsigned nIncRanks, unsigned* incRanks ) {
+ RangeSet *exSet, *newSet;
+ unsigned nProcs, rank;
+ unsigned size;
+ unsigned inc_i;
+
+ assert( self );
+ assert( !nIncRanks || incRanks );
+
+ /* Validate basics. */
+ MPI_Comm_size( self->comm, (int*)&nProcs );
+ MPI_Comm_rank( self->comm, (int*)&rank );
+ for( inc_i = 0; inc_i < nIncRanks; inc_i++ ) {
+ if( incRanks[inc_i] >= nProcs || incRanks[inc_i] == rank )
+ return False;
+ }
+
+ /* Ensure no existing overlap. */
+ exSet = RangeSet_New();
+ newSet = RangeSet_New();
+ RangeSet_SetIndices( exSet, self->nIncRanks, self->incRanks );
+ RangeSet_SetIndices( newSet, nIncRanks, incRanks );
+ RangeSet_Intersection( newSet, exSet );
+ size = RangeSet_GetSize( newSet );
+ FreeObject( newSet );
+ FreeObject( exSet );
+ if( size )
+ return False;
+
+ return True;
+}
+#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/CommTopology.h
--- a/Mesh/src/CommTopology.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Invariants:
-**
-** Comments:
-**
-** $Id: CommTopology.h 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Domain_Mesh_CommTopology_h__
-#define __Domain_Mesh_CommTopology_h__
-
- /** Textual name of this class */
- extern const Type CommTopology_Type;
-
- /** Virtual function types */
-
- /** Class contents */
- #define __CommTopology \
- /* General info */ \
- __Stg_Class \
- \
- /* Virtual info */ \
- \
- /* CommTopology info */ \
- MPI_Comm comm; \
- unsigned nIncRanks; \
- unsigned* incRanks; \
- unsigned* order; \
- UIntMap* glMap;
-
- struct CommTopology { __CommTopology };
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- #define COMMTOPOLOGY_DEFARGS \
- STG_CLASS_DEFARGS
-
- #define COMMTOPOLOGY_PASSARGS \
- STG_CLASS_PASSARGS
-
- CommTopology* CommTopology_New();
- CommTopology* _CommTopology_New( COMMTOPOLOGY_DEFARGS );
- void _CommTopology_Init( CommTopology* self );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _CommTopology_Delete( void* commTopology );
- void _CommTopology_Print( void* commTopology, Stream* stream );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public functions
- */
-
- void CommTopology_SetComm( void* commTopology, MPI_Comm comm );
- void CommTopology_SetIncidence( void* commTopology, unsigned nIncRanks, unsigned* incRanks );
- void CommTopology_AddIncidence( void* commTopology, unsigned nIncRanks, unsigned* incRanks );
-
- MPI_Comm CommTopology_GetComm( void* commTopology );
- unsigned CommTopology_GetCommSize( void* commTopology );
- unsigned CommTopology_GetCommRank( void* commTopology );
- unsigned CommTopology_GetIncidenceSize( void* commTopology );
- void CommTopology_GetIncidence( void* commTopology, unsigned* nIncRanks, unsigned** incRanks );
-
- unsigned CommTopology_LocalToGlobal( void* commTopology, unsigned local );
- Bool CommTopology_GlobalToLocal( void* commTopology, unsigned global, unsigned* local );
-
- void _CommTopology_Allgather( void* commTopology,
- unsigned srcSize, void* srcArray,
- unsigned** dstSizes, void*** dstArrays,
- unsigned itemSize );
- void _CommTopology_Alltoall( void* commTopology,
- unsigned* srcSizes, void** srcArrays,
- unsigned** dstSizes, void*** dstArrays,
- unsigned itemSize );
-
- #define CommTopology_Allgather( commTopology, \
- srcSize, srcArray, \
- dstSizes, dstArrays, \
- itemSize ) \
- _CommTopology_Allgather( commTopology, \
- srcSize, (void*)srcArray, \
- dstSizes, (void***)dstArrays, \
- itemSize )
-
- #define CommTopology_Alltoall( commTopology, \
- srcSizes, srcArrays, \
- dstSizes, dstArrays, \
- itemSize ) \
- _CommTopology_Alltoall( commTopology, \
- srcSizes, (void**)srcArrays, \
- dstSizes, (void***)dstArrays, \
- itemSize )
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions
- */
-
- int CommTopology_CmpRanks( const void* rank0, const void* rank1 );
- void CommTopology_Destruct( CommTopology* self );
-
-#ifndef NDEBUG
- Bool CommTopology_ValidateIncidence( CommTopology* self, unsigned nIncRanks, unsigned* incRanks );
-#endif
-
-#endif /* __Domain_Mesh_CommTopology_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/CommTopology.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/CommTopology.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,141 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: CommTopology.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Domain_Mesh_CommTopology_h__
+#define __Domain_Mesh_CommTopology_h__
+
+ /** Textual name of this class */
+ extern const Type CommTopology_Type;
+
+ /** Virtual function types */
+
+ /** Class contents */
+ #define __CommTopology \
+ /* General info */ \
+ __Stg_Class \
+ \
+ /* Virtual info */ \
+ \
+ /* CommTopology info */ \
+ MPI_Comm comm; \
+ unsigned nIncRanks; \
+ unsigned* incRanks; \
+ unsigned* order; \
+ UIntMap* glMap;
+
+ struct CommTopology { __CommTopology };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ #define COMMTOPOLOGY_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define COMMTOPOLOGY_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ CommTopology* CommTopology_New();
+ CommTopology* _CommTopology_New( COMMTOPOLOGY_DEFARGS );
+ void _CommTopology_Init( CommTopology* self );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _CommTopology_Delete( void* commTopology );
+ void _CommTopology_Print( void* commTopology, Stream* stream );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+ void CommTopology_SetComm( void* commTopology, MPI_Comm comm );
+ void CommTopology_SetIncidence( void* commTopology, unsigned nIncRanks, unsigned* incRanks );
+ void CommTopology_AddIncidence( void* commTopology, unsigned nIncRanks, unsigned* incRanks );
+
+ MPI_Comm CommTopology_GetComm( void* commTopology );
+ unsigned CommTopology_GetCommSize( void* commTopology );
+ unsigned CommTopology_GetCommRank( void* commTopology );
+ unsigned CommTopology_GetIncidenceSize( void* commTopology );
+ void CommTopology_GetIncidence( void* commTopology, unsigned* nIncRanks, unsigned** incRanks );
+
+ unsigned CommTopology_LocalToGlobal( void* commTopology, unsigned local );
+ Bool CommTopology_GlobalToLocal( void* commTopology, unsigned global, unsigned* local );
+
+ void _CommTopology_Allgather( void* commTopology,
+ unsigned srcSize, void* srcArray,
+ unsigned** dstSizes, void*** dstArrays,
+ unsigned itemSize );
+ void _CommTopology_Alltoall( void* commTopology,
+ unsigned* srcSizes, void** srcArrays,
+ unsigned** dstSizes, void*** dstArrays,
+ unsigned itemSize );
+
+ #define CommTopology_Allgather( commTopology, \
+ srcSize, srcArray, \
+ dstSizes, dstArrays, \
+ itemSize ) \
+ _CommTopology_Allgather( commTopology, \
+ srcSize, (void*)srcArray, \
+ dstSizes, (void***)dstArrays, \
+ itemSize )
+
+ #define CommTopology_Alltoall( commTopology, \
+ srcSizes, srcArrays, \
+ dstSizes, dstArrays, \
+ itemSize ) \
+ _CommTopology_Alltoall( commTopology, \
+ srcSizes, (void**)srcArrays, \
+ dstSizes, (void***)dstArrays, \
+ itemSize )
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+
+ int CommTopology_CmpRanks( const void* rank0, const void* rank1 );
+ void CommTopology_Destruct( CommTopology* self );
+
+#ifndef NDEBUG
+ Bool CommTopology_ValidateIncidence( CommTopology* self, unsigned nIncRanks, unsigned* incRanks );
+#endif
+
+#endif /* __Domain_Mesh_CommTopology_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/DecompTransfer.c
--- a/Mesh/src/DecompTransfer.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,671 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: DecompTransfer.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-
-#include "types.h"
-#include "shortcuts.h"
-#include "CommTopology.h"
-#include "Decomp.h"
-#include "DecompTransfer.h"
-
-
-/* Textual name of this class */
-const Type DecompTransfer_Type = "DecompTransfer";
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-DecompTransfer* DecompTransfer_New( Name name ) {
- return _DecompTransfer_New( sizeof(DecompTransfer),
- DecompTransfer_Type,
- _DecompTransfer_Delete,
- _DecompTransfer_Print,
- NULL,
- (void* (*)(Name))_DecompTransfer_New,
- _DecompTransfer_Construct,
- _DecompTransfer_Build,
- _DecompTransfer_Initialise,
- _DecompTransfer_Execute,
- _DecompTransfer_Destroy,
- name,
- NON_GLOBAL );
-}
-
-DecompTransfer* _DecompTransfer_New( DECOMPTRANSFER_DEFARGS ) {
- DecompTransfer* self;
-
- /* Allocate memory */
- assert( sizeOfSelf >= sizeof(DecompTransfer) );
- self = (DecompTransfer*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
-
- /* Virtual info */
-
- /* DecompTransfer info */
- _DecompTransfer_Init( self );
-
- return self;
-}
-
-void _DecompTransfer_Init( DecompTransfer* self ) {
- self->decomps[0] = NULL;
- self->decomps[1] = NULL;
- self->nIncIndices = 0;
- self->incIndices[0] = NULL;
- self->incIndices[1] = NULL;
- self->commTopo = NULL;
-
- self->netSrcs = 0;
- self->nSrcs = NULL;
- self->srcs = NULL;
- self->netSnks = 0;
- self->nSnks = NULL;
- self->snks = NULL;
-
- self->nArrays = 0;
- self->arrays = NULL;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _DecompTransfer_Delete( void* decompTransfer ) {
- DecompTransfer* self = (DecompTransfer*)decompTransfer;
-
- DecompTransfer_Destruct( self );
-
- /* Delete the parent. */
- _Stg_Component_Delete( self );
-}
-
-void _DecompTransfer_Print( void* decompTransfer, Stream* stream ) {
- DecompTransfer* self = (DecompTransfer*)decompTransfer;
-
- /* Set the Journal for printing informations */
- Stream* decompTransferStream;
- decompTransferStream = Journal_Register( InfoStream_Type, "DecompTransferStream" );
-
- /* Print parent */
- Journal_Printf( stream, "DecompTransfer (ptr): (%p)\n", self );
- _Stg_Component_Print( self, stream );
-}
-
-void _DecompTransfer_Construct( void* decompTransfer, Stg_ComponentFactory* cf, void* data ) {
-}
-
-void _DecompTransfer_Build( void* decompTransfer, void* data ) {
-}
-
-void _DecompTransfer_Initialise( void* decompTransfer, void* data ) {
-}
-
-void _DecompTransfer_Execute( void* decompTransfer, void* data ) {
-}
-
-void _DecompTransfer_Destroy( void* decompTransfer, void* data ) {
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void DecompTransfer_SetDecomps( void* decompTransfer, Decomp* fromDecomp, Decomp* toDecomp, UIntMap* mapping ) {
- DecompTransfer* self = (DecompTransfer*)decompTransfer;
-
- assert( self );
-
- DecompTransfer_Destruct( self );
-
- self->decomps[0] = fromDecomp;
- self->decomps[1] = toDecomp;
- UIntMap_GetItems( mapping, &self->nIncIndices, &self->incIndices[0], &self->incIndices[1] );
-
- DecompTransfer_BuildTables( self );
-}
-
-DecompTransfer_Array* DecompTransfer_AddArray( void* decompTransfer, void* localArray, void* remoteArray,
- size_t localStride, size_t remoteStride, size_t itemSize )
-{
- DecompTransfer* self = (DecompTransfer*)decompTransfer;
- DecompTransfer_Array* array;
-
- /* Sanity checks. */
- assert( self );
- assert( self->decomps[0] );
- assert( self->decomps[1] );
- assert( !self->decomps[0]->nLocals || localArray );
- assert( !self->decomps[1]->nLocals || remoteArray );
- assert( itemSize );
-
- /* Resize the array array (?). */
- if( self->nArrays ) {
- self->arrays = Memory_Realloc_Array( self->arrays, DecompTransfer_Array*, ++self->nArrays );
- }
- else {
- self->arrays = Memory_Alloc_Array( DecompTransfer_Array*, ++self->nArrays, "DecompTransfer::Arrays" );
- }
- self->arrays[self->nArrays - 1] = Memory_Alloc_Array_Unnamed( DecompTransfer_Array, 1 );
- array = self->arrays[self->nArrays - 1];
-
- /* Store information. */
- array->snkArray = localArray;
- array->snkStride = localStride;
- array->srcArray = remoteArray;
- array->srcStride = remoteStride;
- array->itemSize = itemSize;
-
- /* Build this array. */
- DecompTransfer_BuildArray( self, array );
-
- return array;
-}
-
-void DecompTransfer_RemoveArray( void* decompTransfer, DecompTransfer_Array* array ) {
- DecompTransfer* self = (DecompTransfer*)decompTransfer;
- unsigned a_i;
-
- assert( self );
-
- a_i = 0;
- while( self->arrays[a_i++] != array && a_i < self->nArrays );
- assert( a_i <= self->nArrays );
- for( ; a_i < self->nArrays; a_i++ )
- self->arrays[a_i - 1] = self->arrays[a_i];
-
- if( --self->nArrays == 0 ) {
- KillArray( self->arrays );
- }
- else
- self->arrays = Memory_Realloc_Array( self->arrays, DecompTransfer_Array*, self->nArrays );
-
- DecompTransfer_DestructArray( array );
-}
-
-void DecompTransfer_Transfer( void* decompTransfer ) {
- DecompTransfer* self = (DecompTransfer*)decompTransfer;
- unsigned a_i;
-
- /* Sanity checks. */
- assert( self );
- assert( !self->nArrays || self->arrays );
-
- for( a_i = 0; a_i < self->nArrays; a_i++ )
- DecompTransfer_TransferArray( self, self->arrays[a_i] );
-}
-
-void DecompTransfer_TransferArray( void* decompTransfer, DecompTransfer_Array* array ) {
- DecompTransfer* self = (DecompTransfer*)decompTransfer;
- CommTopology* commTopo;
- MPI_Comm comm;
- unsigned nInc;
- unsigned* inc;
- Stg_Byte* snkArray;
- Stg_Byte* srcArray;
- unsigned p_i, ind_i;
-
- /* Sanity checks. */
- assert( self );
- assert( self->commTopo );
- assert( array );
-
- /* Shortcuts. */
- commTopo = self->commTopo;
- comm = CommTopology_GetComm( commTopo );
-
- /* Pack from locals to a contiguous array. */
- if( self->netSnks > 0 ) {
- unsigned snk_i;
-
- snkArray = Memory_Alloc_Array_Unnamed( Stg_Byte, self->netSnks * array->itemSize );
- for( snk_i = 0; snk_i < self->netSnks; snk_i++ ) {
- memcpy( snkArray + snk_i * array->itemSize,
- (Stg_Byte*)array->snkArray + array->snkOffs[snk_i],
- array->itemSize );
- }
- }
- else
- snkArray = NULL;
-
- /* Allocate for sources. */
- if( self->netSrcs > 0 )
- srcArray = Memory_Alloc_Array_Unnamed( Stg_Byte, self->netSrcs * array->itemSize );
- else
- srcArray = NULL;
-
- /* Get incidence. */
- CommTopology_GetIncidence( commTopo, &nInc, &inc );
-
- /* Transfer. */
- for( p_i = 0; p_i < nInc; p_i++ ) {
- int snkSize = array->snkSizes[p_i];
- int snkDisp = array->snkDisps[p_i];
- int srcSize = array->srcSizes[p_i];
- int srcDisp = array->srcDisps[p_i];
- MPI_Status status;
- unsigned tag = 6669;
-
- MPI_Sendrecv( snkArray + snkDisp, snkSize, MPI_BYTE, inc[p_i], tag,
- srcArray + srcDisp, srcSize, MPI_BYTE, inc[p_i], tag,
- comm, &status );
- }
-
- /* Free the sink array. */
- FreeArray( snkArray );
-
- /* Unpack sources. */
- if( self->netSnks > 0 ) {
- unsigned src_i;
-
- for( src_i = 0; src_i < self->netSrcs; src_i++ ) {
- memcpy( (Stg_Byte*)array->srcArray + array->srcOffs[src_i],
- srcArray + src_i * array->itemSize,
- array->itemSize );
- }
- }
-
- /* Free source array. */
- FreeArray( srcArray );
-
- /*
- ** Copy local information.
- */
-
- for( ind_i = 0; ind_i < self->nLocalInds; ind_i++ ) {
- memcpy( (Stg_Byte*)array->srcArray + self->dstLocalInds[ind_i] * array->srcStride,
- (Stg_Byte*)array->snkArray + self->srcLocalInds[ind_i] * array->snkStride,
- array->itemSize );
- }
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-void DecompTransfer_BuildTables( DecompTransfer* self ) {
- MPI_Comm comm;
- unsigned nProcs, rank;
- UIntMap* invMap;
- RangeSet* lSet;
- unsigned nRemoteInds;
- unsigned* srcRemoteInds;
- unsigned* dstRemoteInds;
- RangeSet* rSet;
- unsigned nSrcBytes;
- Stg_Byte* srcBytes;
- unsigned* nDstBytes;
- Stg_Byte** dstBytes;
- RangeSet** fndSets;
- unsigned* nFndBytes;
- Stg_Byte** fndBytes;
- RangeSet** retSets;
- unsigned* nRetBytes;
- Stg_Byte** retBytes;
- unsigned nIncProcs;
- unsigned* incProcs;
- unsigned ind_i, p_i;
-
- assert( self );
-
- /*
- ** Shortcuts.
- */
-
- comm = Decomp_GetComm( self->decomps[0] );
- MPI_Comm_size( comm, (int*)&nProcs );
- MPI_Comm_rank( comm, (int*)&rank );
-
- /*
- ** Build an inverse inter-decomp mapping.
- */
-
- invMap = UIntMap_New();
- for( ind_i = 0; ind_i < self->nIncIndices; ind_i++ )
- UIntMap_Insert( invMap, self->incIndices[1][ind_i], self->incIndices[0][ind_i] );
-
- /*
- ** Separate the inter-mesh incidence into local and remote sets.
- */
-
- self->nLocalInds = 0;
- nRemoteInds = 0;
- self->srcLocalInds = Memory_Alloc_Array( unsigned, self->nIncIndices, "DecompTransfer::srcLocalInds" );
- self->dstLocalInds = Memory_Alloc_Array( unsigned, self->nIncIndices, "DecompTransfer::dstLocalInds" );
- srcRemoteInds = Memory_Alloc_Array_Unnamed( unsigned, self->nIncIndices );
- dstRemoteInds = Memory_Alloc_Array_Unnamed( unsigned, self->nIncIndices );
- for( ind_i = 0; ind_i < self->nIncIndices; ind_i++ ) {
- unsigned mappedInd;
-
- if( Decomp_GlobalToLocal( self->decomps[1], self->incIndices[1][ind_i], &mappedInd ) ) {
- self->srcLocalInds[self->nLocalInds] = self->incIndices[0][ind_i];
- self->dstLocalInds[self->nLocalInds++] = mappedInd;
- }
- else {
- srcRemoteInds[nRemoteInds] = self->incIndices[0][ind_i];
- dstRemoteInds[nRemoteInds++] = self->incIndices[1][ind_i];
- }
- }
- self->srcLocalInds = Memory_Realloc_Array( self->srcLocalInds, unsigned, self->nLocalInds );
- self->dstLocalInds = Memory_Realloc_Array( self->dstLocalInds, unsigned, self->nLocalInds );
- srcRemoteInds = Memory_Realloc_Array( srcRemoteInds, unsigned, nRemoteInds );
- dstRemoteInds = Memory_Realloc_Array( dstRemoteInds, unsigned, nRemoteInds );
-
- /*
- ** Package up the remote indices and send them off to our neighbours.
- */
-
- rSet = RangeSet_New();
- RangeSet_SetIndices( rSet, nRemoteInds, dstRemoteInds );
- FreeArray( dstRemoteInds );
- RangeSet_Pickle( rSet, &nSrcBytes, &srcBytes );
- MPIArray_Allgather( nSrcBytes, srcBytes, &nDstBytes, (void***)&dstBytes, sizeof(unsigned), comm );
- FreeArray( srcBytes );
-
- /*
- ** Determine which of the other processors' remote indices we need.
- */
-
- lSet = RangeSet_New();
- RangeSet_SetIndices( lSet, self->decomps[1]->nLocals, self->decomps[1]->locals );
- fndSets = Memory_Alloc_Array_Unnamed( RangeSet*, nProcs );
- nFndBytes = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
- fndBytes = Memory_Alloc_Array_Unnamed( Stg_Byte*, nProcs );
- for( p_i = 0; p_i < nProcs; p_i++ ) {
- if( p_i == rank || !nDstBytes[p_i] ) {
- fndSets[p_i] = NULL;
- nFndBytes[p_i] = 0;
- fndBytes[p_i] = NULL;
- continue;
- }
-
- fndSets[p_i] = RangeSet_New();
- RangeSet_Unpickle( rSet, nDstBytes[p_i], dstBytes[p_i] );
- RangeSet_Union( rSet, lSet );
-
- if( !fndSets[p_i]->nInds ) {
- KillObject( fndSets[p_i] );
- nFndBytes[p_i] = 0;
- fndBytes[p_i] = NULL;
- continue;
- }
-
- RangeSet_Pickle( rSet, nFndBytes + p_i, fndBytes + p_i );
- }
- FreeArray( dstBytes );
- FreeArray( nDstBytes );
- FreeObject( lSet );
- FreeObject( rSet );
-
- /*
- ** Send our findings back to the appropriate processors.
- */
-
- retSets = Memory_Alloc_Array_Unnamed( RangeSet*, nProcs );
- MPIArray_Alltoall( nFndBytes, (void**)fndBytes, &nRetBytes, (void***)&retBytes, sizeof(unsigned), comm );
- for( p_i = 0; p_i < nProcs; p_i++ ) {
- if( p_i == rank || !nRetBytes[p_i] ) {
- retSets[p_i] = NULL;
- continue;
- }
-
- retSets[p_i] = RangeSet_New();
- RangeSet_Unpickle( retSets[p_i], nRetBytes[p_i], retBytes[p_i] );
- FreeArray( fndBytes[p_i] );
- }
- FreeArray( nFndBytes );
- FreeArray( fndBytes );
- FreeArray( nRetBytes );
- FreeArray( retBytes );
-
- /*
- ** Build our communication topology.
- */
-
- nIncProcs = 0;
- incProcs = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
- for( p_i = 0; p_i < nProcs; p_i++ ) {
- if( fndSets[p_i] || retSets[p_i] )
- incProcs[nIncProcs++] = p_i;
- }
- self->commTopo = CommTopology_New( "" );
- CommTopology_SetComm( self->commTopo, comm );
- CommTopology_SetIncidence( self->commTopo, nIncProcs, incProcs );
- FreeArray( incProcs );
-
- /*
- ** Dump range sets into source and sink arrays.
- */
-
- if( self->commTopo->nIncRanks ) {
- self->nSnks = Memory_Alloc_Array( unsigned, self->commTopo->nIncRanks, "DecompTransfer::nSnks" );
- self->nSrcs = Memory_Alloc_Array( unsigned, self->commTopo->nIncRanks, "DecompTransfer::nSrcs" );
- self->snks = Memory_Alloc_Array( unsigned*, self->commTopo->nIncRanks, "DecompTransfer::nSnks" );
- self->srcs = Memory_Alloc_Array( unsigned*, self->commTopo->nIncRanks, "DecompTransfer::nSrcs" );
- for( p_i = 0; p_i < nProcs; p_i++ ) {
- unsigned incRank;
-
- incRank = self->commTopo->incRanks[p_i];
- if( retSets[incRank] ) {
- self->snks[p_i] = NULL;
- RangeSet_GetIndices( retSets[incRank], self->nSnks + p_i, self->snks + p_i );
- }
- else {
- self->nSnks[p_i] = 0;
- self->snks[p_i] = NULL;
- }
-
- if( fndSets[incRank] ) {
- self->srcs[p_i] = NULL;
- RangeSet_GetIndices( fndSets[incRank], self->nSrcs + p_i, self->srcs + p_i );
- }
- else {
- self->nSrcs[p_i] = 0;
- self->srcs[p_i] = NULL;
- }
-
- FreeObject( retSets[incRank] );
- FreeObject( fndSets[incRank] );
- }
- FreeArray( retSets );
- FreeArray( fndSets );
- }
- else {
- self->nSnks = NULL;
- self->nSrcs = NULL;
- self->snks = NULL;
- self->srcs = NULL;
- }
-
- /*
- ** Map the dumped indices to the source decomp and count totals.
- */
-
- self->netSnks = 0;
- self->netSrcs = 0;
- for( p_i = 0; p_i < self->commTopo->nIncRanks; p_i++ ) {
- self->netSnks += self->nSnks[p_i];
- for( ind_i = 0; ind_i < self->nSnks[p_i]; ind_i++ ) {
- insist( UIntMap_Map( invMap, self->snks[p_i][ind_i], &self->snks[p_i][ind_i] ), == True );
- insist( Decomp_GlobalToLocal( self->decomps[0], self->snks[p_i][ind_i], self->snks[p_i] + ind_i ), == True );
- }
-
- self->netSrcs += self->nSrcs[p_i];
- for( ind_i = 0; ind_i < self->nSrcs[p_i]; ind_i++ )
- insist( Decomp_GlobalToLocal( self->decomps[1], self->srcs[p_i][ind_i], self->srcs[p_i] + ind_i ), == True );
- }
- FreeObject( invMap );
-}
-
-void DecompTransfer_BuildArray( DecompTransfer* self, DecompTransfer_Array* array ) {
- unsigned nInc;
- unsigned* inc;
-
- assert( self );
- assert( self->commTopo );
-
- /* Extract incidence. */
- CommTopology_GetIncidence( self->commTopo, &nInc, &inc );
-
- if( nInc ) {
- /* Determine sink (local) information. */
- if( self->netSnks > 0 ) {
- unsigned* snkOffs;
- unsigned* snkSizes;
- unsigned* snkDisps;
- unsigned snkInd = 0;
- unsigned p_i;
-
- /* Allocate/reallocate memory. */
- snkDisps = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::snkDisps" );
- snkSizes = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::snkSizes" );
- snkOffs = Memory_Alloc_Array( unsigned, self->netSnks, "DecompTransfer_Array::snkOffs" );
-
- /* Calculate offsets and sizes. */
- for( p_i = 0; p_i < nInc; p_i++ ) {
- unsigned snk_i;
-
- snkSizes[p_i] = 0;
- for( snk_i = 0; snk_i < self->nSnks[p_i]; snk_i++ ) {
- snkOffs[snkInd] = self->snks[p_i][snk_i] * array->snkStride;
- snkSizes[p_i] += array->itemSize;
- snkInd++;
- }
- }
-
- /* Calculate the displacements. */
- snkDisps[0] = 0;
- for( p_i = 1; p_i < nInc; p_i++ )
- snkDisps[p_i] = snkDisps[p_i - 1] + snkSizes[p_i - 1];
-
- /* Store arrays. */
- array->snkOffs = snkOffs;
- array->snkDisps = snkDisps;
- array->snkSizes = snkSizes;
- }
- else {
- /* Store null information. */
- array->snkOffs = NULL;
- array->snkDisps = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::snkDisps" );
- array->snkSizes = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::snkSizes" );
- memset( array->snkDisps, 0, nInc * sizeof(unsigned) );
- memset( array->snkSizes, 0, nInc * sizeof(unsigned) );
- }
-
- /* Determine source information. */
- if( self->netSrcs > 0 ) {
- unsigned* srcOffs;
- unsigned* srcSizes;
- unsigned* srcDisps;
- unsigned srcInd = 0;
- unsigned p_i;
-
- /* Allocate/reallocate memory. */
- srcDisps = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::srcDisps" );
- srcSizes = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::srcSizes" );
- srcOffs = Memory_Alloc_Array( unsigned, self->netSrcs, "DecompTransfer_Array::srcOffs" );
-
- /* Calculate offsets and sizes. */
- for( p_i = 0; p_i < nInc; p_i++ ) {
- unsigned src_i;
-
- srcSizes[p_i] = 0;
- for( src_i = 0; src_i < self->nSrcs[p_i]; src_i++ ) {
- srcOffs[srcInd] = self->srcs[p_i][src_i] * array->srcStride;
- srcSizes[p_i] += array->itemSize;
- srcInd++;
- }
- }
-
- /* Calculate the displacements. */
- srcDisps[0] = 0;
- for( p_i = 1; p_i < nInc; p_i++ )
- srcDisps[p_i] = srcDisps[p_i - 1] + srcSizes[p_i - 1];
-
- /* Store arrays. */
- array->srcOffs = srcOffs;
- array->srcDisps = srcDisps;
- array->srcSizes = srcSizes;
- }
- else {
- /* Store null information. */
- array->srcOffs = NULL;
- array->srcDisps = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::srcDisps" );
- array->srcSizes = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::srcSizes" );
- memset( array->srcDisps, 0, nInc * sizeof(unsigned) );
- memset( array->srcSizes, 0, nInc * sizeof(unsigned) );
- }
- }
- else {
- array->snkOffs = NULL;
- array->snkDisps = NULL;
- array->snkSizes = NULL;
- array->srcOffs = NULL;
- array->srcDisps = NULL;
- array->srcSizes = NULL;
- }
-}
-
-void DecompTransfer_Destruct( DecompTransfer* self ) {
- self->netSrcs = 0;
- KillArray( self->nSrcs );
- KillArray( self->srcs );
- self->netSnks = 0;
- KillArray( self->nSnks );
- KillArray( self->snks );
-}
-
-void DecompTransfer_DestructArrays( DecompTransfer* self ) {
- unsigned a_i;
-
- for( a_i = 0; a_i < self->nArrays; a_i++ )
- DecompTransfer_DestructArray( self->arrays[a_i] );
- KillArray( self->arrays );
- self->nArrays = 0;
-}
-
-void DecompTransfer_DestructArray( DecompTransfer_Array* array ) {
- FreeArray( array->snkDisps );
- FreeArray( array->snkSizes );
- FreeArray( array->snkOffs );
- FreeArray( array->srcDisps );
- FreeArray( array->srcSizes );
- FreeArray( array->srcOffs );
- FreeArray( array );
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/DecompTransfer.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/DecompTransfer.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,671 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: DecompTransfer.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+
+#include "types.h"
+#include "shortcuts.h"
+#include "CommTopology.h"
+#include "Decomp.h"
+#include "DecompTransfer.h"
+
+
+/* Textual name of this class */
+const Type DecompTransfer_Type = "DecompTransfer";
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+DecompTransfer* DecompTransfer_New( Name name ) {
+ return _DecompTransfer_New( sizeof(DecompTransfer),
+ DecompTransfer_Type,
+ _DecompTransfer_Delete,
+ _DecompTransfer_Print,
+ NULL,
+ (void* (*)(Name))_DecompTransfer_New,
+ _DecompTransfer_Construct,
+ _DecompTransfer_Build,
+ _DecompTransfer_Initialise,
+ _DecompTransfer_Execute,
+ _DecompTransfer_Destroy,
+ name,
+ NON_GLOBAL );
+}
+
+DecompTransfer* _DecompTransfer_New( DECOMPTRANSFER_DEFARGS ) {
+ DecompTransfer* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(DecompTransfer) );
+ self = (DecompTransfer*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+ /* Virtual info */
+
+ /* DecompTransfer info */
+ _DecompTransfer_Init( self );
+
+ return self;
+}
+
+void _DecompTransfer_Init( DecompTransfer* self ) {
+ self->decomps[0] = NULL;
+ self->decomps[1] = NULL;
+ self->nIncIndices = 0;
+ self->incIndices[0] = NULL;
+ self->incIndices[1] = NULL;
+ self->commTopo = NULL;
+
+ self->netSrcs = 0;
+ self->nSrcs = NULL;
+ self->srcs = NULL;
+ self->netSnks = 0;
+ self->nSnks = NULL;
+ self->snks = NULL;
+
+ self->nArrays = 0;
+ self->arrays = NULL;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _DecompTransfer_Delete( void* decompTransfer ) {
+ DecompTransfer* self = (DecompTransfer*)decompTransfer;
+
+ DecompTransfer_Destruct( self );
+
+ /* Delete the parent. */
+ _Stg_Component_Delete( self );
+}
+
+void _DecompTransfer_Print( void* decompTransfer, Stream* stream ) {
+ DecompTransfer* self = (DecompTransfer*)decompTransfer;
+
+ /* Set the Journal for printing informations */
+ Stream* decompTransferStream;
+ decompTransferStream = Journal_Register( InfoStream_Type, "DecompTransferStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "DecompTransfer (ptr): (%p)\n", self );
+ _Stg_Component_Print( self, stream );
+}
+
+void _DecompTransfer_Construct( void* decompTransfer, Stg_ComponentFactory* cf, void* data ) {
+}
+
+void _DecompTransfer_Build( void* decompTransfer, void* data ) {
+}
+
+void _DecompTransfer_Initialise( void* decompTransfer, void* data ) {
+}
+
+void _DecompTransfer_Execute( void* decompTransfer, void* data ) {
+}
+
+void _DecompTransfer_Destroy( void* decompTransfer, void* data ) {
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void DecompTransfer_SetDecomps( void* decompTransfer, Decomp* fromDecomp, Decomp* toDecomp, UIntMap* mapping ) {
+ DecompTransfer* self = (DecompTransfer*)decompTransfer;
+
+ assert( self );
+
+ DecompTransfer_Destruct( self );
+
+ self->decomps[0] = fromDecomp;
+ self->decomps[1] = toDecomp;
+ UIntMap_GetItems( mapping, &self->nIncIndices, &self->incIndices[0], &self->incIndices[1] );
+
+ DecompTransfer_BuildTables( self );
+}
+
+DecompTransfer_Array* DecompTransfer_AddArray( void* decompTransfer, void* localArray, void* remoteArray,
+ size_t localStride, size_t remoteStride, size_t itemSize )
+{
+ DecompTransfer* self = (DecompTransfer*)decompTransfer;
+ DecompTransfer_Array* array;
+
+ /* Sanity checks. */
+ assert( self );
+ assert( self->decomps[0] );
+ assert( self->decomps[1] );
+ assert( !self->decomps[0]->nLocals || localArray );
+ assert( !self->decomps[1]->nLocals || remoteArray );
+ assert( itemSize );
+
+ /* Resize the array array (?). */
+ if( self->nArrays ) {
+ self->arrays = Memory_Realloc_Array( self->arrays, DecompTransfer_Array*, ++self->nArrays );
+ }
+ else {
+ self->arrays = Memory_Alloc_Array( DecompTransfer_Array*, ++self->nArrays, "DecompTransfer::Arrays" );
+ }
+ self->arrays[self->nArrays - 1] = Memory_Alloc_Array_Unnamed( DecompTransfer_Array, 1 );
+ array = self->arrays[self->nArrays - 1];
+
+ /* Store information. */
+ array->snkArray = localArray;
+ array->snkStride = localStride;
+ array->srcArray = remoteArray;
+ array->srcStride = remoteStride;
+ array->itemSize = itemSize;
+
+ /* Build this array. */
+ DecompTransfer_BuildArray( self, array );
+
+ return array;
+}
+
+void DecompTransfer_RemoveArray( void* decompTransfer, DecompTransfer_Array* array ) {
+ DecompTransfer* self = (DecompTransfer*)decompTransfer;
+ unsigned a_i;
+
+ assert( self );
+
+ a_i = 0;
+ while( self->arrays[a_i++] != array && a_i < self->nArrays );
+ assert( a_i <= self->nArrays );
+ for( ; a_i < self->nArrays; a_i++ )
+ self->arrays[a_i - 1] = self->arrays[a_i];
+
+ if( --self->nArrays == 0 ) {
+ KillArray( self->arrays );
+ }
+ else
+ self->arrays = Memory_Realloc_Array( self->arrays, DecompTransfer_Array*, self->nArrays );
+
+ DecompTransfer_DestructArray( array );
+}
+
+void DecompTransfer_Transfer( void* decompTransfer ) {
+ DecompTransfer* self = (DecompTransfer*)decompTransfer;
+ unsigned a_i;
+
+ /* Sanity checks. */
+ assert( self );
+ assert( !self->nArrays || self->arrays );
+
+ for( a_i = 0; a_i < self->nArrays; a_i++ )
+ DecompTransfer_TransferArray( self, self->arrays[a_i] );
+}
+
+void DecompTransfer_TransferArray( void* decompTransfer, DecompTransfer_Array* array ) {
+ DecompTransfer* self = (DecompTransfer*)decompTransfer;
+ CommTopology* commTopo;
+ MPI_Comm comm;
+ unsigned nInc;
+ unsigned* inc;
+ Stg_Byte* snkArray;
+ Stg_Byte* srcArray;
+ unsigned p_i, ind_i;
+
+ /* Sanity checks. */
+ assert( self );
+ assert( self->commTopo );
+ assert( array );
+
+ /* Shortcuts. */
+ commTopo = self->commTopo;
+ comm = CommTopology_GetComm( commTopo );
+
+ /* Pack from locals to a contiguous array. */
+ if( self->netSnks > 0 ) {
+ unsigned snk_i;
+
+ snkArray = Memory_Alloc_Array_Unnamed( Stg_Byte, self->netSnks * array->itemSize );
+ for( snk_i = 0; snk_i < self->netSnks; snk_i++ ) {
+ memcpy( snkArray + snk_i * array->itemSize,
+ (Stg_Byte*)array->snkArray + array->snkOffs[snk_i],
+ array->itemSize );
+ }
+ }
+ else
+ snkArray = NULL;
+
+ /* Allocate for sources. */
+ if( self->netSrcs > 0 )
+ srcArray = Memory_Alloc_Array_Unnamed( Stg_Byte, self->netSrcs * array->itemSize );
+ else
+ srcArray = NULL;
+
+ /* Get incidence. */
+ CommTopology_GetIncidence( commTopo, &nInc, &inc );
+
+ /* Transfer. */
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ int snkSize = array->snkSizes[p_i];
+ int snkDisp = array->snkDisps[p_i];
+ int srcSize = array->srcSizes[p_i];
+ int srcDisp = array->srcDisps[p_i];
+ MPI_Status status;
+ unsigned tag = 6669;
+
+ MPI_Sendrecv( snkArray + snkDisp, snkSize, MPI_BYTE, inc[p_i], tag,
+ srcArray + srcDisp, srcSize, MPI_BYTE, inc[p_i], tag,
+ comm, &status );
+ }
+
+ /* Free the sink array. */
+ FreeArray( snkArray );
+
+ /* Unpack sources. */
+ if( self->netSnks > 0 ) {
+ unsigned src_i;
+
+ for( src_i = 0; src_i < self->netSrcs; src_i++ ) {
+ memcpy( (Stg_Byte*)array->srcArray + array->srcOffs[src_i],
+ srcArray + src_i * array->itemSize,
+ array->itemSize );
+ }
+ }
+
+ /* Free source array. */
+ FreeArray( srcArray );
+
+ /*
+ ** Copy local information.
+ */
+
+ for( ind_i = 0; ind_i < self->nLocalInds; ind_i++ ) {
+ memcpy( (Stg_Byte*)array->srcArray + self->dstLocalInds[ind_i] * array->srcStride,
+ (Stg_Byte*)array->snkArray + self->srcLocalInds[ind_i] * array->snkStride,
+ array->itemSize );
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void DecompTransfer_BuildTables( DecompTransfer* self ) {
+ MPI_Comm comm;
+ unsigned nProcs, rank;
+ UIntMap* invMap;
+ RangeSet* lSet;
+ unsigned nRemoteInds;
+ unsigned* srcRemoteInds;
+ unsigned* dstRemoteInds;
+ RangeSet* rSet;
+ unsigned nSrcBytes;
+ Stg_Byte* srcBytes;
+ unsigned* nDstBytes;
+ Stg_Byte** dstBytes;
+ RangeSet** fndSets;
+ unsigned* nFndBytes;
+ Stg_Byte** fndBytes;
+ RangeSet** retSets;
+ unsigned* nRetBytes;
+ Stg_Byte** retBytes;
+ unsigned nIncProcs;
+ unsigned* incProcs;
+ unsigned ind_i, p_i;
+
+ assert( self );
+
+ /*
+ ** Shortcuts.
+ */
+
+ comm = Decomp_GetComm( self->decomps[0] );
+ MPI_Comm_size( comm, (int*)&nProcs );
+ MPI_Comm_rank( comm, (int*)&rank );
+
+ /*
+ ** Build an inverse inter-decomp mapping.
+ */
+
+ invMap = UIntMap_New();
+ for( ind_i = 0; ind_i < self->nIncIndices; ind_i++ )
+ UIntMap_Insert( invMap, self->incIndices[1][ind_i], self->incIndices[0][ind_i] );
+
+ /*
+ ** Separate the inter-mesh incidence into local and remote sets.
+ */
+
+ self->nLocalInds = 0;
+ nRemoteInds = 0;
+ self->srcLocalInds = Memory_Alloc_Array( unsigned, self->nIncIndices, "DecompTransfer::srcLocalInds" );
+ self->dstLocalInds = Memory_Alloc_Array( unsigned, self->nIncIndices, "DecompTransfer::dstLocalInds" );
+ srcRemoteInds = Memory_Alloc_Array_Unnamed( unsigned, self->nIncIndices );
+ dstRemoteInds = Memory_Alloc_Array_Unnamed( unsigned, self->nIncIndices );
+ for( ind_i = 0; ind_i < self->nIncIndices; ind_i++ ) {
+ unsigned mappedInd;
+
+ if( Decomp_GlobalToLocal( self->decomps[1], self->incIndices[1][ind_i], &mappedInd ) ) {
+ self->srcLocalInds[self->nLocalInds] = self->incIndices[0][ind_i];
+ self->dstLocalInds[self->nLocalInds++] = mappedInd;
+ }
+ else {
+ srcRemoteInds[nRemoteInds] = self->incIndices[0][ind_i];
+ dstRemoteInds[nRemoteInds++] = self->incIndices[1][ind_i];
+ }
+ }
+ self->srcLocalInds = Memory_Realloc_Array( self->srcLocalInds, unsigned, self->nLocalInds );
+ self->dstLocalInds = Memory_Realloc_Array( self->dstLocalInds, unsigned, self->nLocalInds );
+ srcRemoteInds = Memory_Realloc_Array( srcRemoteInds, unsigned, nRemoteInds );
+ dstRemoteInds = Memory_Realloc_Array( dstRemoteInds, unsigned, nRemoteInds );
+
+ /*
+ ** Package up the remote indices and send them off to our neighbours.
+ */
+
+ rSet = RangeSet_New();
+ RangeSet_SetIndices( rSet, nRemoteInds, dstRemoteInds );
+ FreeArray( dstRemoteInds );
+ RangeSet_Pickle( rSet, &nSrcBytes, &srcBytes );
+ MPIArray_Allgather( nSrcBytes, srcBytes, &nDstBytes, (void***)&dstBytes, sizeof(unsigned), comm );
+ FreeArray( srcBytes );
+
+ /*
+ ** Determine which of the other processors' remote indices we need.
+ */
+
+ lSet = RangeSet_New();
+ RangeSet_SetIndices( lSet, self->decomps[1]->nLocals, self->decomps[1]->locals );
+ fndSets = Memory_Alloc_Array_Unnamed( RangeSet*, nProcs );
+ nFndBytes = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
+ fndBytes = Memory_Alloc_Array_Unnamed( Stg_Byte*, nProcs );
+ for( p_i = 0; p_i < nProcs; p_i++ ) {
+ if( p_i == rank || !nDstBytes[p_i] ) {
+ fndSets[p_i] = NULL;
+ nFndBytes[p_i] = 0;
+ fndBytes[p_i] = NULL;
+ continue;
+ }
+
+ fndSets[p_i] = RangeSet_New();
+ RangeSet_Unpickle( rSet, nDstBytes[p_i], dstBytes[p_i] );
+ RangeSet_Union( rSet, lSet );
+
+ if( !fndSets[p_i]->nInds ) {
+ KillObject( fndSets[p_i] );
+ nFndBytes[p_i] = 0;
+ fndBytes[p_i] = NULL;
+ continue;
+ }
+
+ RangeSet_Pickle( rSet, nFndBytes + p_i, fndBytes + p_i );
+ }
+ FreeArray( dstBytes );
+ FreeArray( nDstBytes );
+ FreeObject( lSet );
+ FreeObject( rSet );
+
+ /*
+ ** Send our findings back to the appropriate processors.
+ */
+
+ retSets = Memory_Alloc_Array_Unnamed( RangeSet*, nProcs );
+ MPIArray_Alltoall( nFndBytes, (void**)fndBytes, &nRetBytes, (void***)&retBytes, sizeof(unsigned), comm );
+ for( p_i = 0; p_i < nProcs; p_i++ ) {
+ if( p_i == rank || !nRetBytes[p_i] ) {
+ retSets[p_i] = NULL;
+ continue;
+ }
+
+ retSets[p_i] = RangeSet_New();
+ RangeSet_Unpickle( retSets[p_i], nRetBytes[p_i], retBytes[p_i] );
+ FreeArray( fndBytes[p_i] );
+ }
+ FreeArray( nFndBytes );
+ FreeArray( fndBytes );
+ FreeArray( nRetBytes );
+ FreeArray( retBytes );
+
+ /*
+ ** Build our communication topology.
+ */
+
+ nIncProcs = 0;
+ incProcs = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
+ for( p_i = 0; p_i < nProcs; p_i++ ) {
+ if( fndSets[p_i] || retSets[p_i] )
+ incProcs[nIncProcs++] = p_i;
+ }
+ self->commTopo = CommTopology_New( "" );
+ CommTopology_SetComm( self->commTopo, comm );
+ CommTopology_SetIncidence( self->commTopo, nIncProcs, incProcs );
+ FreeArray( incProcs );
+
+ /*
+ ** Dump range sets into source and sink arrays.
+ */
+
+ if( self->commTopo->nIncRanks ) {
+ self->nSnks = Memory_Alloc_Array( unsigned, self->commTopo->nIncRanks, "DecompTransfer::nSnks" );
+ self->nSrcs = Memory_Alloc_Array( unsigned, self->commTopo->nIncRanks, "DecompTransfer::nSrcs" );
+ self->snks = Memory_Alloc_Array( unsigned*, self->commTopo->nIncRanks, "DecompTransfer::nSnks" );
+ self->srcs = Memory_Alloc_Array( unsigned*, self->commTopo->nIncRanks, "DecompTransfer::nSrcs" );
+ for( p_i = 0; p_i < nProcs; p_i++ ) {
+ unsigned incRank;
+
+ incRank = self->commTopo->incRanks[p_i];
+ if( retSets[incRank] ) {
+ self->snks[p_i] = NULL;
+ RangeSet_GetIndices( retSets[incRank], self->nSnks + p_i, self->snks + p_i );
+ }
+ else {
+ self->nSnks[p_i] = 0;
+ self->snks[p_i] = NULL;
+ }
+
+ if( fndSets[incRank] ) {
+ self->srcs[p_i] = NULL;
+ RangeSet_GetIndices( fndSets[incRank], self->nSrcs + p_i, self->srcs + p_i );
+ }
+ else {
+ self->nSrcs[p_i] = 0;
+ self->srcs[p_i] = NULL;
+ }
+
+ FreeObject( retSets[incRank] );
+ FreeObject( fndSets[incRank] );
+ }
+ FreeArray( retSets );
+ FreeArray( fndSets );
+ }
+ else {
+ self->nSnks = NULL;
+ self->nSrcs = NULL;
+ self->snks = NULL;
+ self->srcs = NULL;
+ }
+
+ /*
+ ** Map the dumped indices to the source decomp and count totals.
+ */
+
+ self->netSnks = 0;
+ self->netSrcs = 0;
+ for( p_i = 0; p_i < self->commTopo->nIncRanks; p_i++ ) {
+ self->netSnks += self->nSnks[p_i];
+ for( ind_i = 0; ind_i < self->nSnks[p_i]; ind_i++ ) {
+ insist( UIntMap_Map( invMap, self->snks[p_i][ind_i], &self->snks[p_i][ind_i] ), == True );
+ insist( Decomp_GlobalToLocal( self->decomps[0], self->snks[p_i][ind_i], self->snks[p_i] + ind_i ), == True );
+ }
+
+ self->netSrcs += self->nSrcs[p_i];
+ for( ind_i = 0; ind_i < self->nSrcs[p_i]; ind_i++ )
+ insist( Decomp_GlobalToLocal( self->decomps[1], self->srcs[p_i][ind_i], self->srcs[p_i] + ind_i ), == True );
+ }
+ FreeObject( invMap );
+}
+
+void DecompTransfer_BuildArray( DecompTransfer* self, DecompTransfer_Array* array ) {
+ unsigned nInc;
+ unsigned* inc;
+
+ assert( self );
+ assert( self->commTopo );
+
+ /* Extract incidence. */
+ CommTopology_GetIncidence( self->commTopo, &nInc, &inc );
+
+ if( nInc ) {
+ /* Determine sink (local) information. */
+ if( self->netSnks > 0 ) {
+ unsigned* snkOffs;
+ unsigned* snkSizes;
+ unsigned* snkDisps;
+ unsigned snkInd = 0;
+ unsigned p_i;
+
+ /* Allocate/reallocate memory. */
+ snkDisps = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::snkDisps" );
+ snkSizes = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::snkSizes" );
+ snkOffs = Memory_Alloc_Array( unsigned, self->netSnks, "DecompTransfer_Array::snkOffs" );
+
+ /* Calculate offsets and sizes. */
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ unsigned snk_i;
+
+ snkSizes[p_i] = 0;
+ for( snk_i = 0; snk_i < self->nSnks[p_i]; snk_i++ ) {
+ snkOffs[snkInd] = self->snks[p_i][snk_i] * array->snkStride;
+ snkSizes[p_i] += array->itemSize;
+ snkInd++;
+ }
+ }
+
+ /* Calculate the displacements. */
+ snkDisps[0] = 0;
+ for( p_i = 1; p_i < nInc; p_i++ )
+ snkDisps[p_i] = snkDisps[p_i - 1] + snkSizes[p_i - 1];
+
+ /* Store arrays. */
+ array->snkOffs = snkOffs;
+ array->snkDisps = snkDisps;
+ array->snkSizes = snkSizes;
+ }
+ else {
+ /* Store null information. */
+ array->snkOffs = NULL;
+ array->snkDisps = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::snkDisps" );
+ array->snkSizes = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::snkSizes" );
+ memset( array->snkDisps, 0, nInc * sizeof(unsigned) );
+ memset( array->snkSizes, 0, nInc * sizeof(unsigned) );
+ }
+
+ /* Determine source information. */
+ if( self->netSrcs > 0 ) {
+ unsigned* srcOffs;
+ unsigned* srcSizes;
+ unsigned* srcDisps;
+ unsigned srcInd = 0;
+ unsigned p_i;
+
+ /* Allocate/reallocate memory. */
+ srcDisps = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::srcDisps" );
+ srcSizes = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::srcSizes" );
+ srcOffs = Memory_Alloc_Array( unsigned, self->netSrcs, "DecompTransfer_Array::srcOffs" );
+
+ /* Calculate offsets and sizes. */
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ unsigned src_i;
+
+ srcSizes[p_i] = 0;
+ for( src_i = 0; src_i < self->nSrcs[p_i]; src_i++ ) {
+ srcOffs[srcInd] = self->srcs[p_i][src_i] * array->srcStride;
+ srcSizes[p_i] += array->itemSize;
+ srcInd++;
+ }
+ }
+
+ /* Calculate the displacements. */
+ srcDisps[0] = 0;
+ for( p_i = 1; p_i < nInc; p_i++ )
+ srcDisps[p_i] = srcDisps[p_i - 1] + srcSizes[p_i - 1];
+
+ /* Store arrays. */
+ array->srcOffs = srcOffs;
+ array->srcDisps = srcDisps;
+ array->srcSizes = srcSizes;
+ }
+ else {
+ /* Store null information. */
+ array->srcOffs = NULL;
+ array->srcDisps = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::srcDisps" );
+ array->srcSizes = Memory_Alloc_Array( unsigned, nInc, "DecompTransfer_Array::srcSizes" );
+ memset( array->srcDisps, 0, nInc * sizeof(unsigned) );
+ memset( array->srcSizes, 0, nInc * sizeof(unsigned) );
+ }
+ }
+ else {
+ array->snkOffs = NULL;
+ array->snkDisps = NULL;
+ array->snkSizes = NULL;
+ array->srcOffs = NULL;
+ array->srcDisps = NULL;
+ array->srcSizes = NULL;
+ }
+}
+
+void DecompTransfer_Destruct( DecompTransfer* self ) {
+ self->netSrcs = 0;
+ KillArray( self->nSrcs );
+ KillArray( self->srcs );
+ self->netSnks = 0;
+ KillArray( self->nSnks );
+ KillArray( self->snks );
+}
+
+void DecompTransfer_DestructArrays( DecompTransfer* self ) {
+ unsigned a_i;
+
+ for( a_i = 0; a_i < self->nArrays; a_i++ )
+ DecompTransfer_DestructArray( self->arrays[a_i] );
+ KillArray( self->arrays );
+ self->nArrays = 0;
+}
+
+void DecompTransfer_DestructArray( DecompTransfer_Array* array ) {
+ FreeArray( array->snkDisps );
+ FreeArray( array->snkSizes );
+ FreeArray( array->snkOffs );
+ FreeArray( array->srcDisps );
+ FreeArray( array->srcSizes );
+ FreeArray( array->srcOffs );
+ FreeArray( array );
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/DecompTransfer.h
--- a/Mesh/src/DecompTransfer.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Invariants:
-**
-** Comments:
-**
-** $Id: DecompTransfer.h 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Domain_Mesh_DecompTransfer_h__
-#define __Domain_Mesh_DecompTransfer_h__
-
- /** Textual name of this class */
- extern const Type DecompTransfer_Type;
-
- /** Virtual function types */
-
- /** Mesh class contents */
- typedef struct {
- void* snkArray;
- unsigned snkStride;
- unsigned* snkDisps;
- unsigned* snkSizes;
- unsigned* snkOffs;
-
- void* srcArray;
- unsigned srcStride;
- unsigned* srcDisps;
- unsigned* srcSizes;
- unsigned* srcOffs;
-
- size_t itemSize;
- } DecompTransfer_Array;
-
- #define __DecompTransfer \
- /* General info */ \
- __Stg_Component \
- \
- /* Virtual info */ \
- \
- /* DecompTransfer info */ \
- Decomp* decomps[2]; \
- unsigned nIncIndices; \
- unsigned* incIndices[2]; \
- CommTopology* commTopo; \
- \
- unsigned nLocalInds; \
- unsigned* srcLocalInds; \
- unsigned* dstLocalInds; \
- \
- unsigned netSrcs; \
- unsigned* nSrcs; \
- unsigned** srcs; \
- unsigned netSnks; \
- unsigned* nSnks; \
- unsigned** snks; \
- \
- unsigned nArrays; \
- DecompTransfer_Array** arrays;
-
- struct DecompTransfer { __DecompTransfer };
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- #define DECOMPTRANSFER_DEFARGS \
- STG_COMPONENT_DEFARGS
-
- #define DECOMPTRANSFER_PASSARGS \
- STG_COMPONENT_PASSARGS
-
- DecompTransfer* DecompTransfer_New( Name name );
- DecompTransfer* _DecompTransfer_New( DECOMPTRANSFER_DEFARGS );
- void _DecompTransfer_Init( DecompTransfer* self );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _DecompTransfer_Delete( void* decompTransfer );
- void _DecompTransfer_Print( void* decompTransfer, Stream* stream );
- void _DecompTransfer_Construct( void* decompTransfer, Stg_ComponentFactory* cf, void* data );
- void _DecompTransfer_Build( void* decompTransfer, void* data );
- void _DecompTransfer_Initialise( void* decompTransfer, void* data );
- void _DecompTransfer_Execute( void* decompTransfer, void* data );
- void _DecompTransfer_Destroy( void* decompTransfer, void* data );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public functions
- */
-
- void DecompTransfer_SetDecomps( void* decompTransfer, Decomp* fromDecomp, Decomp* toDecomp, UIntMap* mapping );
- DecompTransfer_Array* DecompTransfer_AddArray( void* decompTransfer, void* localArray, void* remoteArray,
- size_t localStride, size_t remoteStride, size_t itemSize );
- void DecompTransfer_RemoveArray( void* decompTransfer, DecompTransfer_Array* array );
- void DecompTransfer_Transfer( void* decompTransfer );
- void DecompTransfer_TransferArray( void* decompTransfer, DecompTransfer_Array* array );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions
- */
-
- void DecompTransfer_BuildTables( DecompTransfer* self );
- void DecompTransfer_BuildArray( DecompTransfer* self, DecompTransfer_Array* array );
- void DecompTransfer_Destruct( DecompTransfer* self );
- void DecompTransfer_DestructArrays( DecompTransfer* self );
- void DecompTransfer_DestructArray( DecompTransfer_Array* array );
-
-#endif /* __Domain_Mesh_DecompTransfer_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/DecompTransfer.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/DecompTransfer.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,141 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: DecompTransfer.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Domain_Mesh_DecompTransfer_h__
+#define __Domain_Mesh_DecompTransfer_h__
+
+ /** Textual name of this class */
+ extern const Type DecompTransfer_Type;
+
+ /** Virtual function types */
+
+ /** Mesh class contents */
+ typedef struct {
+ void* snkArray;
+ unsigned snkStride;
+ unsigned* snkDisps;
+ unsigned* snkSizes;
+ unsigned* snkOffs;
+
+ void* srcArray;
+ unsigned srcStride;
+ unsigned* srcDisps;
+ unsigned* srcSizes;
+ unsigned* srcOffs;
+
+ size_t itemSize;
+ } DecompTransfer_Array;
+
+ #define __DecompTransfer \
+ /* General info */ \
+ __Stg_Component \
+ \
+ /* Virtual info */ \
+ \
+ /* DecompTransfer info */ \
+ Decomp* decomps[2]; \
+ unsigned nIncIndices; \
+ unsigned* incIndices[2]; \
+ CommTopology* commTopo; \
+ \
+ unsigned nLocalInds; \
+ unsigned* srcLocalInds; \
+ unsigned* dstLocalInds; \
+ \
+ unsigned netSrcs; \
+ unsigned* nSrcs; \
+ unsigned** srcs; \
+ unsigned netSnks; \
+ unsigned* nSnks; \
+ unsigned** snks; \
+ \
+ unsigned nArrays; \
+ DecompTransfer_Array** arrays;
+
+ struct DecompTransfer { __DecompTransfer };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ #define DECOMPTRANSFER_DEFARGS \
+ STG_COMPONENT_DEFARGS
+
+ #define DECOMPTRANSFER_PASSARGS \
+ STG_COMPONENT_PASSARGS
+
+ DecompTransfer* DecompTransfer_New( Name name );
+ DecompTransfer* _DecompTransfer_New( DECOMPTRANSFER_DEFARGS );
+ void _DecompTransfer_Init( DecompTransfer* self );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _DecompTransfer_Delete( void* decompTransfer );
+ void _DecompTransfer_Print( void* decompTransfer, Stream* stream );
+ void _DecompTransfer_Construct( void* decompTransfer, Stg_ComponentFactory* cf, void* data );
+ void _DecompTransfer_Build( void* decompTransfer, void* data );
+ void _DecompTransfer_Initialise( void* decompTransfer, void* data );
+ void _DecompTransfer_Execute( void* decompTransfer, void* data );
+ void _DecompTransfer_Destroy( void* decompTransfer, void* data );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+ void DecompTransfer_SetDecomps( void* decompTransfer, Decomp* fromDecomp, Decomp* toDecomp, UIntMap* mapping );
+ DecompTransfer_Array* DecompTransfer_AddArray( void* decompTransfer, void* localArray, void* remoteArray,
+ size_t localStride, size_t remoteStride, size_t itemSize );
+ void DecompTransfer_RemoveArray( void* decompTransfer, DecompTransfer_Array* array );
+ void DecompTransfer_Transfer( void* decompTransfer );
+ void DecompTransfer_TransferArray( void* decompTransfer, DecompTransfer_Array* array );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+
+ void DecompTransfer_BuildTables( DecompTransfer* self );
+ void DecompTransfer_BuildArray( DecompTransfer* self, DecompTransfer_Array* array );
+ void DecompTransfer_Destruct( DecompTransfer* self );
+ void DecompTransfer_DestructArrays( DecompTransfer* self );
+ void DecompTransfer_DestructArray( DecompTransfer_Array* array );
+
+#endif /* __Domain_Mesh_DecompTransfer_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync.c
--- a/Mesh/src/Decomp_Sync.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1123 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: Decomp_Sync.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-#include "Mesh.h"
-
-
-/* Textual name of this class */
-const Type Decomp_Sync_Type = "Decomp_Sync";
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-Decomp_Sync* Decomp_Sync_New( Name name ) {
- return _Decomp_Sync_New( sizeof(Decomp_Sync),
- Decomp_Sync_Type,
- _Decomp_Sync_Delete,
- _Decomp_Sync_Print,
- NULL );
-}
-
-Decomp_Sync* _Decomp_Sync_New( DECOMP_SYNC_DEFARGS ) {
- Decomp_Sync* self;
-
- /* Allocate memory */
- assert( sizeOfSelf >= sizeof(Decomp_Sync) );
- self = (Decomp_Sync*)_Stg_Class_New( STG_CLASS_PASSARGS );
-
- /* Virtual info */
-
- /* Decomp_Sync info */
- _Decomp_Sync_Init( self );
-
- return self;
-}
-
-void _Decomp_Sync_Init( Decomp_Sync* self ) {
- self->decomp = NULL;
- self->commTopo = CommTopology_New();
- Stg_Class_AddRef( self->commTopo );
-
- self->nDomains = 0;
- self->nRemotes = 0;
- self->remotes = NULL;
- self->nShared = 0;
- self->shared = NULL;
- self->nSharers = NULL;
- self->sharers = NULL;
- self->owners = NULL;
-
- self->grMap = UIntMap_New();
- self->dsMap = UIntMap_New();
-
- self->netSrcs = 0;
- self->nSrcs = NULL;
- self->srcs = NULL;
- self->netSnks = 0;
- self->nSnks = NULL;
- self->snks = NULL;
-
- self->arrays = List_New();
- List_SetItemSize( self->arrays, sizeof(Decomp_Sync_Array*) );
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _Decomp_Sync_Delete( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- Decomp_Sync_Destruct( self );
- FreeObject( self->arrays );
-
- /* Delete the parent. */
- _Stg_Class_Delete( self );
-}
-
-void _Decomp_Sync_Print( void* sync, Stream* stream ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- /* Set the Journal for printing informations */
- Stream* syncStream;
- syncStream = Journal_Register( InfoStream_Type, "Decomp_SyncStream" );
-
- /* Print parent */
- Journal_Printf( stream, "Decomp_Sync (ptr): (%p)\n", self );
- _Stg_Class_Print( self, stream );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void Decomp_Sync_SetDecomp( void* sync, Decomp* decomp ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( Decomp_Sync_ValidateComms( self ) );
-
- Decomp_Sync_DestructDecomp( self );
- self->decomp = decomp;
- assert( Decomp_Sync_ValidateComms( self ) );
-
- if( decomp ) {
- self->nDomains = Decomp_GetLocalSize( decomp );
- List_Append( Decomp_GetSyncList( decomp ), &self );
- }
- Decomp_Sync_InitArrays( self );
-}
-
-void Decomp_Sync_SetCommTopology( void* sync, CommTopology* commTopo ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- Decomp_Sync_DestructComm( self );
- if( commTopo ) {
- self->commTopo = commTopo;
- Stg_Class_AddRef( commTopo );
- }
- else {
- self->commTopo = CommTopology_New();
- Stg_Class_AddRef( commTopo );
- if( self->decomp )
- CommTopology_SetComm( self->commTopo, Decomp_GetComm( self->decomp ) );
- }
- assert( Decomp_Sync_ValidateComms( self ) );
-
- Decomp_Sync_InitArrays( self );
-}
-
-void Decomp_Sync_AddRemoteRanks( void* sync, unsigned nRanks, unsigned* ranks ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( !nRanks || ranks );
-
- CommTopology_AddIncidence( self->commTopo, nRanks, ranks );
- Decomp_Sync_ExpandArrays( self, nRanks );
-}
-
-void Decomp_Sync_SetRemotes( void* sync, unsigned nRemotes, unsigned* remotes ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- Decomp_Sync_DestructRemotes( self );
- Decomp_Sync_AddRemotes( self, nRemotes, remotes );
-}
-
-void Decomp_Sync_AddRemotes( void* sync, unsigned nRemotes, unsigned* remotes ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
- unsigned nIncRanks, *incRanks, *ranks;
- unsigned *nSrcRemotes, **srcRemotes;
- unsigned *nSnkRemotes, **snkRemotes;
- unsigned p_i;
-
- assert( self );
- assert( self->decomp );
- assert( !nRemotes || remotes );
- assert( Decomp_Sync_ValidateRemotes( self, nRemotes, remotes ) );
-
- /* If we're not connected to anything, just exit. */
- CommTopology_GetIncidence( self->commTopo, &nIncRanks, &incRanks );
- if( !nIncRanks )
- return;
-
- /* Prepare source and sink arrays. */
- nSrcRemotes = AllocArray( unsigned, nIncRanks );
- nSnkRemotes = AllocArray( unsigned, nIncRanks );
- srcRemotes = AllocArray( unsigned*, nIncRanks );
- snkRemotes = AllocArray( unsigned*, nIncRanks );
-
- /* Split these remotes for each processor. */
- Decomp_Sync_SplitRemotes( self, nRemotes, remotes,
- nSrcRemotes, srcRemotes,
- nSnkRemotes, snkRemotes );
-
- /* Add them. */
- ranks = AllocArray( unsigned, nIncRanks );
- for( p_i = 0; p_i < nIncRanks; p_i++ )
- ranks[p_i] = p_i;
- Decomp_Sync_AddSources( self, nIncRanks, ranks, nSrcRemotes, srcRemotes );
- Decomp_Sync_AddSinks( self, nIncRanks, ranks, nSnkRemotes, snkRemotes );
- Decomp_Sync_BuildShared( self );
- FreeArray( ranks );
-
- /* Free the space. */
- FreeArray( nSrcRemotes );
- FreeArray( nSnkRemotes );
- FreeArray2D( nIncRanks, srcRemotes );
- FreeArray2D( nIncRanks, snkRemotes );
-}
-
-void Decomp_Sync_SetSources( void* sync, unsigned nRanks, unsigned* ranks,
- unsigned* nSources, unsigned** sources )
-{
- Decomp_Sync* self = (Decomp_Sync*)sync;
- unsigned p_i, s_i;
-
- assert( nRanks <= CommTopology_GetIncidenceSize( self->commTopo ) );
- assert( !nRanks || ranks );
-
- for( p_i = 0; p_i < nRanks; p_i++ ) {
- assert( ranks[p_i] < CommTopology_GetIncidenceSize( self->commTopo ) );
- for( s_i = 0; s_i < self->nSrcs[ranks[p_i]]; s_i++ )
- UIntMap_Remove( self->grMap, Decomp_Sync_DomainToGlobal( self, self->srcs[ranks[p_i]][s_i] ) );
- KillArray( self->srcs[ranks[p_i]] );
- self->netSrcs -= self->nSrcs[ranks[p_i]];
- self->nDomains -= self->nSrcs[ranks[p_i]];
- self->nRemotes -= self->nSrcs[ranks[p_i]];
- self->nSrcs[ranks[p_i]] = 0;
- }
-
- Decomp_Sync_AddSources( self, nRanks, ranks, nSources, sources );
-}
-
-void Decomp_Sync_SetSinks( void* sync, unsigned nRanks, unsigned* ranks,
- unsigned* nSinks, unsigned** sinks )
-{
- Decomp_Sync* self = (Decomp_Sync*)sync;
- unsigned p_i;
-
- assert( nRanks <= CommTopology_GetIncidenceSize( self->commTopo ) );
- assert( !nRanks || ranks );
-
- for( p_i = 0; p_i < nRanks; p_i++ ) {
- assert( ranks[p_i] < CommTopology_GetIncidenceSize( self->commTopo ) );
- KillArray( self->snks[ranks[p_i]] );
- self->netSnks -= self->nSnks[ranks[p_i]];
- self->nSnks[ranks[p_i]] = 0;
- }
-
- Decomp_Sync_AddSinks( self, nRanks, ranks, nSinks, sinks );
-}
-
-void Decomp_Sync_AddSources( void* sync, unsigned nRanks, unsigned* ranks,
- unsigned* nSources, unsigned** sources )
-{
- Decomp_Sync* self = (Decomp_Sync*)sync;
- unsigned nNewRemotes;
- unsigned domainInd;
- unsigned offs;
- unsigned p_i;
-
- assert( self );
- assert( self->decomp );
- assert( nRanks <= CommTopology_GetIncidenceSize( self->commTopo ) );
- assert( !nRanks || ranks );
- assert( nSources && sources );
-
- nNewRemotes = 0;
- for( p_i = 0; p_i < nRanks; p_i++ ) {
- assert( ranks[p_i] < CommTopology_GetIncidenceSize( self->commTopo ) );
- assert( Decomp_Sync_ValidateRemotes( self, nSources[p_i], sources[p_i] ) );
- nNewRemotes += nSources[p_i];
- }
-
- if( nNewRemotes ) {
- self->remotes = ReallocNamedArray( self->remotes, unsigned, self->nRemotes + nNewRemotes,
- "Decomp_Sync::remotes" );
- self->owners = ReallocNamedArray( self->owners, unsigned, self->nRemotes + nNewRemotes,
- "Decomp_Sync::owners" );
- offs = self->nRemotes;
- for( p_i = 0; p_i < nRanks; p_i++ ) {
- unsigned r_i;
-
- for( r_i = 0; r_i < nSources[p_i]; r_i++ ) {
- self->remotes[offs] = sources[p_i][r_i];
- UIntMap_Insert( self->grMap, sources[p_i][r_i], offs );
- self->owners[offs++] = ranks[p_i];
- }
- }
- self->nRemotes += nNewRemotes;
- self->nDomains += nNewRemotes;
- }
-
- for( p_i = 0; p_i < nRanks; p_i++ ) {
- unsigned rank = ranks[p_i];
- unsigned s_i;
-
- self->srcs[rank] = ReallocArray( self->srcs[rank], unsigned, self->nSrcs[rank] + nSources[p_i] );
- for( s_i = 0; s_i < nSources[p_i]; s_i++ ) {
- insist( Decomp_Sync_GlobalToDomain( self, sources[p_i][s_i], &domainInd ), == True );
- self->srcs[rank][self->nSrcs[rank] + s_i] = domainInd;
- }
- self->nSrcs[rank] += nSources[p_i];
- self->netSrcs += nSources[p_i];
- }
-}
-
-void Decomp_Sync_AddSinks( void* sync, unsigned nRanks, unsigned* ranks,
- unsigned* nSinks, unsigned** sinks )
-{
- Decomp_Sync* self = (Decomp_Sync*)sync;
- unsigned domainInd;
- unsigned p_i;
-
- assert( self );
- assert( self->decomp );
- assert( nRanks <= CommTopology_GetIncidenceSize( self->commTopo ) );
- assert( !nRanks || ranks );
- assert( nSinks && sinks );
-
- for( p_i = 0; p_i < nRanks; p_i++ ) {
- unsigned rank = ranks[p_i];
- unsigned s_i;
-
- assert( rank < CommTopology_GetIncidenceSize( self->commTopo ) );
- assert( Decomp_Sync_ValidateSinks( self, nSinks[p_i], sinks[p_i] ) );
- self->snks[rank] = ReallocArray( self->snks[rank], unsigned, self->nSnks[rank] + nSinks[p_i] );
- for( s_i = 0; s_i < nSinks[p_i]; s_i++ ) {
- insist( Decomp_Sync_GlobalToDomain( self, sinks[p_i][s_i], &domainInd ), == True );
- self->snks[rank][self->nSnks[rank] + s_i] = domainInd;
- }
- self->nSnks[rank] += nSinks[p_i];
- self->netSnks += nSinks[p_i];
- }
-}
-
-void Decomp_Sync_SetRequired( void* sync, unsigned nRequired, unsigned* required ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- Decomp_Sync_DestructRemotes( self );
- Decomp_Sync_AddRequired( self, nRequired, required );
-}
-
-void Decomp_Sync_AddRequired( void* sync, unsigned nRequired, unsigned* required ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
- MPI_Comm comm;
- unsigned nProcs, rank;
- RangeSet *reqSet, *remReqSet, *lSet;
- unsigned nLocals, *locals;
- unsigned nOldIncRanks, nIncRanks;
- unsigned nBytes;
- Stg_Byte* bytes;
- unsigned tag = 8849;
- unsigned p_i;
-
- assert( self && Stg_CheckType( self, Decomp_Sync ) );
- assert( Decomp_Sync_ValidateRemotes( self, nRequired, required ) );
-
- comm = CommTopology_GetComm( self->commTopo );
- MPI_Comm_rank( comm, (int*)&rank );
- MPI_Comm_size( comm, (int*)&nProcs );
-
- reqSet = RangeSet_New();
- RangeSet_SetIndices( reqSet, nRequired, required );
-
- Decomp_GetLocals( self->decomp, &nLocals, &locals );
- lSet = RangeSet_New();
- RangeSet_SetIndices( lSet, nLocals, locals );
-
- nOldIncRanks = nIncRanks;
- remReqSet = RangeSet_New();
- for( p_i = 0; p_i < nProcs; p_i++ ) {
- Stg_Byte state;
- unsigned nInds, *inds;
- unsigned localRank;
-
- if( rank == p_i )
- RangeSet_Pickle( reqSet, &nBytes, &bytes );
- MPI_Bcast( &nBytes, 1, MPI_UNSIGNED, p_i, comm );
- if( rank != p_i )
- bytes = AllocArray( Stg_Byte, nBytes );
- MPI_Bcast( bytes, nBytes, MPI_BYTE, p_i, comm );
-
- if( rank != p_i ) {
- RangeSet_Unpickle( remReqSet, nBytes, bytes );
- FreeArray( bytes );
-
- RangeSet_Intersection( remReqSet, lSet );
- if( RangeSet_GetSize( remReqSet ) ) {
- state = 1;
- MPI_Gather( &state, 1, MPI_BYTE, NULL, 1, MPI_BYTE, p_i, comm );
-
- RangeSet_Pickle( remReqSet, &nBytes, &bytes );
- MPI_Send( &nBytes, 1, MPI_UNSIGNED, p_i, tag, comm );
- MPI_Send( bytes, nBytes, MPI_BYTE, p_i, tag, comm );
- FreeArray( bytes );
-
- inds = NULL;
- RangeSet_GetIndices( remReqSet, &nInds, &inds );
- if( !CommTopology_GlobalToLocal( self->commTopo, p_i, &localRank ) ) {
- Decomp_Sync_AddRemoteRanks( self, 1, &p_i );
- insist( CommTopology_GlobalToLocal( self->commTopo, p_i, &localRank ), == True );
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
- }
- Decomp_Sync_AddSinks( sync, 1, &localRank, &nInds, &inds );
- FreeArray( inds );
- }
- else {
- state = 0;
- MPI_Gather( &state, 1, MPI_BYTE, NULL, 1, MPI_BYTE, p_i, comm );
- }
- }
- else {
- Stg_Byte* states;
- unsigned nActive, *active;
- MPI_Status status;
- unsigned nNewRanks, *newRanks;
- unsigned p_j;
-
- FreeArray( bytes );
-
- state = 0;
- states = AllocArray( Stg_Byte, nProcs );
- MPI_Gather( &state, 1, MPI_BYTE, states, 1, MPI_BYTE, p_i, comm );
- nActive = 0;
- nNewRanks = 0;
- for( p_j = 0; p_j < nProcs; p_j++ ) {
- if( states[p_j] ) {
- nActive++;
- if( !CommTopology_GlobalToLocal( self->commTopo, p_j, &localRank ) )
- nNewRanks++;
- }
- }
- active = AllocArray( unsigned, nActive );
- newRanks = AllocArray( unsigned, nNewRanks );
- nActive = 0;
- nNewRanks = 0;
- for( p_j = 0; p_j < nProcs; p_j++ ) {
- if( states[p_j] ) {
- active[nActive++] = p_j;
- if( !CommTopology_GlobalToLocal( self->commTopo, p_j, &localRank ) )
- newRanks[nNewRanks++] = p_j;
- }
- }
- FreeArray( states );
-
- Decomp_Sync_AddRemoteRanks( sync, nNewRanks, newRanks );
- if( nNewRanks )
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
- FreeArray( newRanks );
-
- for( p_j = 0; p_j < nActive; p_j++ ) {
- MPI_Recv( &nBytes, 1, MPI_UNSIGNED, active[p_j], tag, comm, &status );
- bytes = AllocArray( Stg_Byte, nBytes );
- MPI_Recv( bytes, nBytes, MPI_BYTE, active[p_j], tag, comm, &status );
- RangeSet_Unpickle( reqSet, nBytes, bytes );
- FreeArray( bytes );
- inds = NULL;
- RangeSet_GetIndices( reqSet, &nInds, &inds );
- insist( CommTopology_GlobalToLocal( self->commTopo, active[p_j], &localRank ), == True );
- Decomp_Sync_AddSources( sync, 1, &localRank, &nInds, &inds );
- FreeArray( inds );
- }
-
- FreeArray( active );
- }
- }
-
- FreeObject( reqSet );
- FreeObject( remReqSet );
- FreeObject( lSet );
-
- Decomp_Sync_BuildShared( self );
-}
-
-void Decomp_Sync_BuildShared( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
- unsigned nIncRanks;
- RangeSet *dSet, **rSets, *allSet;
- unsigned nLocals, *locals;
- unsigned nSendBytes, *nRecvBytes;
- Stg_Byte *sendBytes, **recvBytes;
- unsigned **sharers;
- unsigned nInds, *inds;
- unsigned r_i, s_i, ind_i;
-
- assert( self && Stg_CheckType( self, Decomp_Sync ) );
-
- /* Free shared info. */
- FreeArray( self->shared );
- FreeArray( self->nSharers );
- FreeArray( self->sharers );
-
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
-
- /* Communicate a range set of my domain indices to all neighbours. */
- dSet = RangeSet_New();
- RangeSet_SetIndices( dSet, self->nRemotes, self->remotes );
- Decomp_GetLocals( self->decomp, &nLocals, &locals );
- RangeSet_AddIndices( dSet, nLocals, locals );
- RangeSet_Pickle( dSet, &nSendBytes, &sendBytes );
- CommTopology_Allgather( self->commTopo,
- nSendBytes, sendBytes,
- &nRecvBytes, &recvBytes,
- sizeof(Stg_Byte) );
- FreeArray( sendBytes );
- rSets = AllocArray( RangeSet*, nIncRanks );
- allSet = RangeSet_New();
- for( r_i = 0; r_i < nIncRanks; r_i++ ) {
- rSets[r_i] = RangeSet_New();
- RangeSet_Unpickle( rSets[r_i], nRecvBytes[r_i], recvBytes[r_i] );
- RangeSet_Intersection( rSets[r_i], dSet );
- RangeSet_Union( allSet, rSets[r_i] );
- FreeArray( recvBytes[r_i] );
- }
- FreeArray( recvBytes );
- FreeArray( nRecvBytes );
-
- /* Use the 'allSet' to generate the shared indices. */
- self->shared = NULL;
- RangeSet_GetIndices( allSet, &self->nShared, &self->shared );
- FreeObject( allSet );
- for( s_i = 0; s_i < self->nShared; s_i++ ) {
- insist( Decomp_Sync_GlobalToDomain( self, self->shared[s_i], self->shared + s_i ), == True );
- UIntMap_Insert( self->dsMap, self->shared[s_i], s_i );
- }
-
- /* Now that we have each intersection, convert to shared arrays. */
- self->nSharers = AllocArray( unsigned, self->nShared );
- memset( self->nSharers, 0, self->nShared * sizeof(unsigned) );
- sharers = AllocArray2D( unsigned, self->nShared, nIncRanks );
- for( r_i = 0; r_i < nIncRanks; r_i++ ) {
- inds = NULL;
- RangeSet_GetIndices( rSets[r_i], &nInds, &inds );
- FreeObject( rSets[r_i] );
- for( ind_i = 0; ind_i < nInds; ind_i++ ) {
- insist( Decomp_Sync_GlobalToDomain( self, inds[ind_i], inds + ind_i ), == True );
- insist( Decomp_Sync_DomainToShared( self, inds[ind_i], inds + ind_i ), == True );
- sharers[inds[ind_i]][self->nSharers[inds[ind_i]]++] = r_i;
- }
- FreeArray( inds );
- }
- FreeArray( rSets );
-
- /* Store final array. */
- self->sharers = AllocComplex2D( unsigned, self->nShared, self->nSharers );
- for( s_i = 0; s_i < self->nShared; s_i++ )
- memcpy( self->sharers[s_i], sharers[s_i], self->nSharers[s_i] * sizeof(unsigned) );
- FreeArray( sharers );
-
-#if 0
- /* Create a range set of all sinks and sources. */
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
- shareSet = RangeSet_New();
- tmpSet = RangeSet_New();
- for( p_i = 0; p_i < nIncRanks; p_i++ ) {
- RangeSet_SetIndices( tmpSet, self->nSnks[p_i], self->snks[p_i] );
- RangeSet_Union( shareSet, tmpSet );
- RangeSet_SetIndices( tmpSet, self->nSrcs[p_i], self->srcs[p_i] );
- RangeSet_Union( shareSet, tmpSet );
- }
- FreeObject( tmpSet );
-
- /* These indices are the shared elements. */
- self->shared = NULL;
- RangeSet_GetIndices( shareSet, &self->nShared, &self->shared );
- FreeObject( shareSet );
-
- /* If there are no shared indices, exit now. */
- if( !self->nShared )
- return;
-
- /* Build the shared mapping. */
- for( s_i = 0; s_i < self->nShared; s_i++ )
- UIntMap_Insert( self->dsMap, self->shared[s_i], s_i );
-
- /* Create temporary storage for the sharers. */
- self->nSharers = AllocNamedArray( unsigned, self->nShared, "Decomp_Sync::nSharers" );
- sharers = Memory_Alloc_2DArray_Unnamed( unsigned, self->nShared, nIncRanks );
- memset( self->nSharers, 0, self->nShared * sizeof(unsigned) );
-
- /* Build the sharer lists. */
- for( p_i = 0; p_i < nIncRanks; p_i++ ) {
- for( s_i = 0; s_i < self->nSnks[p_i]; s_i++ ) {
- unsigned sharedInd;
- unsigned curSharer;
-
- insist( UIntMap_Map( self->dsMap, self->snks[p_i][s_i], &sharedInd ), == True );
- curSharer = self->nSharers[sharedInd]++;
- sharers[sharedInd][curSharer] = p_i;
- }
- }
-
- /* Transfer to final storage. */
- self->sharers = Memory_Alloc_2DComplex( unsigned, self->nShared, self->nSharers, "Decomp_Sync::sharers" );
- for( s_i = 0; s_i < self->nShared; s_i++ )
- memcpy( self->sharers[s_i], sharers[s_i], self->nSharers[s_i] * sizeof(unsigned) );
-
- /* Free the old sharers array. */
- FreeArray( sharers );
-#endif
-}
-
-unsigned Decomp_Sync_GetGlobalSize( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( self->decomp );
-
- return Decomp_GetGlobalSize( self->decomp );
-}
-
-unsigned Decomp_Sync_GetLocalSize( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( self->decomp );
-
- return Decomp_GetLocalSize( self->decomp );
-}
-
-unsigned Decomp_Sync_GetRemoteSize( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- return self->nRemotes;
-}
-
-unsigned Decomp_Sync_GetDomainSize( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- return self->nDomains;
-}
-
-unsigned Decomp_Sync_GetSharedSize( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- return self->nShared;
-}
-
-void Decomp_Sync_GetRemotes( void* sync, unsigned* nRemotes, unsigned** remotes ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( nRemotes );
- assert( remotes );
-
- *nRemotes = self->nRemotes;
- *remotes = self->remotes;
-}
-
-Bool Decomp_Sync_GlobalToDomain( void* sync, unsigned global, unsigned* domain ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( self->decomp );
- assert( global < self->decomp->nGlobals );
- assert( self->decomp->glMap );
- assert( self->grMap );
- assert( domain );
-
- if( Decomp_GlobalToLocal( self->decomp, global, domain ) )
- return True;
- else if( UIntMap_Map( self->grMap, global, domain ) ) {
- *domain += Decomp_GetLocalSize( self->decomp );
- return True;
- }
-
- return False;
-}
-
-unsigned Decomp_Sync_DomainToGlobal( void* sync, unsigned domain ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( self->decomp );
- assert( domain < self->decomp->nLocals + self->nRemotes );
-
- if( domain < self->decomp->nLocals )
- return Decomp_LocalToGlobal( self->decomp, domain );
- else
- return self->remotes[domain - Decomp_GetLocalSize( self->decomp )];
-}
-
-Bool Decomp_Sync_DomainToShared( void* sync, unsigned domain, unsigned* shared ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( self->decomp );
- assert( domain < self->nDomains );
- assert( self->dsMap );
- assert( shared );
-
- return UIntMap_Map( self->dsMap, domain, shared );
-}
-
-unsigned Decomp_Sync_SharedToDomain( void* sync, unsigned shared ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( shared < self->nShared );
- assert( self->shared );
-
- return self->shared[shared];
-}
-
-unsigned Decomp_Sync_GetOwner( void* sync, unsigned remote ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( remote < self->nRemotes );
- assert( self->owners );
-
- return self->owners[remote];
-}
-
-void Decomp_Sync_GetSharers( void* sync, unsigned shared,
- unsigned* nSharers, unsigned** sharers )
-{
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( shared < self->nShared );
- assert( self->nSharers );
- assert( self->sharers );
- assert( nSharers );
- assert( sharers );
-
- *nSharers = self->nSharers[shared];
- *sharers = self->sharers[shared];
-}
-
-void Decomp_Sync_GetSources( void* sync, unsigned rank, unsigned* nSources, unsigned** sources ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( rank < CommTopology_GetIncidenceSize( self->commTopo ) );
- assert( nSources && sources );
- assert( self->nSrcs && self->srcs );
-
- *nSources = self->nSrcs[rank];
- *sources = self->srcs[rank];
-}
-
-void Decomp_Sync_GetSinks( void* sync, unsigned rank, unsigned* nSinks, unsigned** sinks ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
- assert( rank < CommTopology_GetIncidenceSize( self->commTopo ) );
- assert( nSinks && sinks );
- assert( self->nSnks && self->snks );
-
- *nSinks = self->nSnks[rank];
- *sinks = self->snks[rank];
-}
-
-Decomp* Decomp_Sync_GetDecomp( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- return self->decomp;
-}
-
-CommTopology* Decomp_Sync_GetCommTopology( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- return self->commTopo;
-}
-
-void Decomp_Sync_SyncArray( void* sync, Decomp_Sync_Array* array ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
- unsigned nInc;
- unsigned* inc;
- Stg_Byte* snkArray;
- Stg_Byte* srcArray;
- unsigned p_i;
-
- /* Sanity checks. */
- assert( self );
- assert( self->decomp );
- assert( array );
-
- /* Pack from locals to a contiguous array. */
- if( self->netSnks > 0 ) {
- unsigned snk_i;
-
- snkArray = AllocArray( Stg_Byte, self->netSnks * array->itemSize );
- for( snk_i = 0; snk_i < self->netSnks; snk_i++ ) {
- memcpy( snkArray + snk_i * array->itemSize,
- (Stg_Byte*)array->snkArray + array->snkOffs[snk_i],
- array->itemSize );
- }
- }
- else
- snkArray = NULL;
-
- /* Allocate for sources. */
- srcArray = AllocArray( Stg_Byte, self->netSrcs * array->itemSize );
-
- /* Get incidence. */
- CommTopology_GetIncidence( self->commTopo, &nInc, &inc );
-
- /* Transfer. */
- for( p_i = 0; p_i < nInc; p_i++ ) {
- int snkSize = array->snkSizes[p_i];
- int snkDisp = array->snkDisps[p_i];
- int srcSize = array->srcSizes[p_i];
- int srcDisp = array->srcDisps[p_i];
- MPI_Status status;
- unsigned tag = 6669;
-
- MPI_Sendrecv( snkArray + snkDisp, snkSize, MPI_BYTE, inc[p_i], tag,
- srcArray + srcDisp, srcSize, MPI_BYTE, inc[p_i], tag,
- CommTopology_GetComm( self->commTopo ), &status );
- }
-
- /* Free the sink array. */
- FreeArray( snkArray );
-
- /* Unpack sources. */
- if( self->netSrcs > 0 ) {
- unsigned src_i;
-
- for( src_i = 0; src_i < self->netSrcs; src_i++ ) {
- memcpy( (Stg_Byte*)array->srcArray + array->srcOffs[src_i],
- srcArray + src_i * array->itemSize,
- array->itemSize );
- }
- }
-
- /* Free source array. */
- FreeArray( srcArray );
-}
-
-void Decomp_Sync_Update( void* sync ) {
- Decomp_Sync* self = (Decomp_Sync*)sync;
-
- assert( self );
-
- Decomp_Sync_DestructRemotes( self );
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-void Decomp_Sync_InitArrays( Decomp_Sync* self ) {
- unsigned nIncRanks;
-
- assert( self );
-
- if( self->commTopo ) {
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
- if( nIncRanks ) {
- self->nSrcs = AllocNamedArray( unsigned, nIncRanks, "Decomp_Sync::nSrcs" );
- self->srcs = AllocNamedArray( unsigned*, nIncRanks, "Decomp_Sync::srcs" );
- self->nSnks = AllocNamedArray( unsigned, nIncRanks, "Decomp_Sync::nSnks" );
- self->snks = AllocNamedArray( unsigned*, nIncRanks, "Decomp_Sync::snks" );
- memset( self->nSrcs, 0, nIncRanks * sizeof(unsigned) );
- memset( self->srcs, 0, nIncRanks * sizeof(unsigned*) );
- memset( self->nSnks, 0, nIncRanks * sizeof(unsigned) );
- memset( self->snks, 0, nIncRanks * sizeof(unsigned*) );
- }
- }
-}
-
-void Decomp_Sync_ExpandArrays( Decomp_Sync* self, unsigned nNewRanks ) {
- unsigned nIncRanks, nOldIncRanks;
-
- assert( self );
- assert( !self->nShared || (self->nSharers && self->sharers) );
- assert( !self->nRemotes || self->owners );
-
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
- nOldIncRanks = nIncRanks - nNewRanks;
- self->nSrcs = ReallocNamedArray( self->nSrcs, unsigned, nIncRanks, "Decomp_Sync::nSrcs" );
- self->srcs = ReallocNamedArray( self->srcs, unsigned*, nIncRanks, "Decomp_Sync::srcs" );
- self->nSnks = ReallocNamedArray( self->nSnks, unsigned, nIncRanks, "Decomp_Sync::nSnks" );
- self->snks = ReallocNamedArray( self->snks, unsigned*, nIncRanks, "Decomp_Sync::snks" );
- memset( self->nSrcs + nOldIncRanks, 0, nNewRanks * sizeof(unsigned) );
- memset( self->srcs + nOldIncRanks, 0, nNewRanks * sizeof(unsigned*) );
- memset( self->nSnks + nOldIncRanks, 0, nNewRanks * sizeof(unsigned) );
- memset( self->snks + nOldIncRanks, 0, nNewRanks * sizeof(unsigned*) );
-}
-
-void Decomp_Sync_SplitRemotes( Decomp_Sync* self, unsigned nRemotes, unsigned* remotes,
- unsigned* nSrcs, unsigned** srcs,
- unsigned* nSnks, unsigned** snks )
-{
- unsigned nLocals, *locals;
- unsigned nIncRanks;
- RangeSet *remSet, *locSet;
- unsigned nBytes, *nRemBytes, *nFndBytes;
- Stg_Byte *bytes, **remBytes, **fndBytes;
- unsigned p_i;
-
- assert( self );
- assert( self->decomp );
-
- /* Make a range set of our remotes. */
- remSet = RangeSet_New();
- RangeSet_SetIndices( remSet, nRemotes, remotes );
- RangeSet_Pickle( remSet, &nBytes, &bytes );
-
- /* Collect neighbouring remotes. */
- CommTopology_Allgather( self->commTopo,
- nBytes, bytes,
- &nRemBytes, (void***)&remBytes,
- sizeof(Stg_Byte) );
-
- /* Done with the bytes. */
- FreeArray( bytes );
-
- /* Build a range set of our locals. */
- locSet = RangeSet_New();
- Decomp_GetLocals( self->decomp, &nLocals, &locals );
- RangeSet_SetIndices( locSet, nLocals, locals );
-
- /* Intersect our locals and our neighbours remotes to build our sink sets. */
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
- remSet = RangeSet_New();
- for( p_i = 0; p_i < nIncRanks; p_i++ ) {
- RangeSet_Unpickle( remSet, nRemBytes[p_i], remBytes[p_i] );
-
- /* Done with the remote bytes. */
- FreeArray( remBytes[p_i] );
-
- RangeSet_Intersection( remSet, locSet );
- snks[p_i] = NULL;
- RangeSet_GetIndices( remSet, nSnks + p_i, snks + p_i );
- RangeSet_Pickle( remSet, nRemBytes + p_i, remBytes + p_i );
- }
-
- /* Local set is no longer needed. */
- FreeObject( locSet );
-
- /* Return what we've found. */
- CommTopology_Alltoall( self->commTopo,
- nRemBytes, (void**)remBytes,
- &nFndBytes, (void***)&fndBytes,
- sizeof(Stg_Byte) );
-
- /* Done with the remote bytes arrays. */
- FreeArray( nRemBytes );
- FreeArray2D( nIncRanks, remBytes );
-
- /* Construct our source arrays with what was found. */
- for( p_i = 0; p_i < nIncRanks; p_i++ ) {
- RangeSet_Unpickle( remSet, nFndBytes[p_i], fndBytes[p_i] );
-
- /* Empty the internal found arrays. */
- FreeArray( fndBytes[p_i] );
-
- srcs[p_i] = NULL;
- RangeSet_GetIndices( remSet, nSrcs + p_i, srcs + p_i );
- }
-
- /* Free everything else. */
- FreeArray( nFndBytes );
- FreeArray( fndBytes );
- FreeObject( remSet );
-}
-
-void Decomp_Sync_Destruct( Decomp_Sync* self ) {
- assert( self );
-
- Decomp_Sync_DestructDecomp( self );
- Decomp_Sync_DestructComm( self );
-}
-
-void Decomp_Sync_DestructDecomp( Decomp_Sync* self ) {
- assert( self );
-
- Decomp_Sync_DestructRemotes( self );
- if( self->decomp ) {
- List_Remove( Decomp_GetSyncList( self->decomp ), &self );
- self->decomp = NULL;
- }
-}
-
-void Decomp_Sync_DestructComm( Decomp_Sync* self ) {
- assert( self );
-
- Decomp_Sync_DestructRemotes( self );
- Stg_Class_RemoveRef( self->commTopo );
- self->commTopo = NULL;
- KillArray( self->nSrcs );
- KillArray( self->srcs );
- KillArray( self->nSnks );
- KillArray( self->snks );
-}
-
-void Decomp_Sync_DestructRemotes( Decomp_Sync* self ) {
- assert( self );
-
- Decomp_Sync_DestructArrays( self );
- Decomp_Sync_DestructSources( self );
- Decomp_Sync_DestructSinks( self );
-}
-
-void Decomp_Sync_DestructSources( Decomp_Sync* self ) {
- unsigned nIncRanks;
- unsigned p_i;
-
- assert( self );
-
- if( self->commTopo )
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
-
- if( self->decomp )
- self->nDomains = Decomp_GetLocalSize( self->decomp );
-
- KillArray( self->remotes );
- self->nRemotes = 0;
- UIntMap_Clear( self->grMap );
- self->netSrcs = 0;
- for( p_i = 0; p_i < nIncRanks; p_i++ )
- KillArray( self->srcs[p_i] );
-}
-
-void Decomp_Sync_DestructSinks( Decomp_Sync* self ) {
- unsigned nIncRanks;
- unsigned p_i;
-
- if( self->commTopo )
- nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
-
- KillArray( self->shared );
- self->nShared = 0;
- KillArray( self->nSharers );
- KillArray( self->sharers );
- UIntMap_Clear( self->dsMap );
- self->netSnks = 0;
- for( p_i = 0; p_i < nIncRanks; p_i++ )
- KillArray( self->snks[p_i] );
-}
-
-void Decomp_Sync_DestructArrays( Decomp_Sync* self ) {
- unsigned a_i;
-
- for( a_i = 0; a_i < List_GetSize( self->arrays ); a_i++ ) {
- Decomp_Sync_Array* array = *(Decomp_Sync_Array**)List_GetItem( self->arrays, a_i );
-
- Decomp_Sync_Array_SetSync( array, self );
- }
-
- List_Clear( self->arrays );
-}
-
-#ifndef NDEBUG
-Bool Decomp_Sync_ValidateRemotes( Decomp_Sync* self, unsigned nRemotes, unsigned* remotes ) {
- unsigned domainInd;
- unsigned r_i;
-
- for( r_i = 0; r_i < nRemotes; r_i++ ) {
- if( Decomp_Sync_GlobalToDomain( self, remotes[r_i], &domainInd ) )
- return False;
- }
-
- return True;
-}
-
-Bool Decomp_Sync_ValidateSinks( Decomp_Sync* self, unsigned nSinks, unsigned* sinks ) {
- RangeSet *lSet, *sSet;
- unsigned nLocals, *locals;
- unsigned nInds;
-
- Decomp_GetLocals( self->decomp, &nLocals, &locals );
-
- lSet = RangeSet_New();
- sSet = RangeSet_New();
- RangeSet_SetIndices( lSet, nLocals, locals );
- RangeSet_SetIndices( sSet, nSinks, sinks );
- RangeSet_Subtraction( sSet, lSet );
- nInds = RangeSet_GetSize( sSet );
- FreeObject( lSet );
- FreeObject( sSet );
-
- return !nInds;
-}
-
-Bool Decomp_Sync_ValidateComms( Decomp_Sync* self ) {
- assert( self );
-
- if( self->decomp && self->commTopo )
- return Decomp_GetComm( self->decomp ) == CommTopology_GetComm( self->commTopo );
- else
- return True;
-}
-#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/Decomp_Sync.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,1123 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: Decomp_Sync.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include "Mesh.h"
+
+
+/* Textual name of this class */
+const Type Decomp_Sync_Type = "Decomp_Sync";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+Decomp_Sync* Decomp_Sync_New( Name name ) {
+ return _Decomp_Sync_New( sizeof(Decomp_Sync),
+ Decomp_Sync_Type,
+ _Decomp_Sync_Delete,
+ _Decomp_Sync_Print,
+ NULL );
+}
+
+Decomp_Sync* _Decomp_Sync_New( DECOMP_SYNC_DEFARGS ) {
+ Decomp_Sync* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(Decomp_Sync) );
+ self = (Decomp_Sync*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* Virtual info */
+
+ /* Decomp_Sync info */
+ _Decomp_Sync_Init( self );
+
+ return self;
+}
+
+void _Decomp_Sync_Init( Decomp_Sync* self ) {
+ self->decomp = NULL;
+ self->commTopo = CommTopology_New();
+ Stg_Class_AddRef( self->commTopo );
+
+ self->nDomains = 0;
+ self->nRemotes = 0;
+ self->remotes = NULL;
+ self->nShared = 0;
+ self->shared = NULL;
+ self->nSharers = NULL;
+ self->sharers = NULL;
+ self->owners = NULL;
+
+ self->grMap = UIntMap_New();
+ self->dsMap = UIntMap_New();
+
+ self->netSrcs = 0;
+ self->nSrcs = NULL;
+ self->srcs = NULL;
+ self->netSnks = 0;
+ self->nSnks = NULL;
+ self->snks = NULL;
+
+ self->arrays = List_New();
+ List_SetItemSize( self->arrays, sizeof(Decomp_Sync_Array*) );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _Decomp_Sync_Delete( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ Decomp_Sync_Destruct( self );
+ FreeObject( self->arrays );
+
+ /* Delete the parent. */
+ _Stg_Class_Delete( self );
+}
+
+void _Decomp_Sync_Print( void* sync, Stream* stream ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ /* Set the Journal for printing informations */
+ Stream* syncStream;
+ syncStream = Journal_Register( InfoStream_Type, "Decomp_SyncStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "Decomp_Sync (ptr): (%p)\n", self );
+ _Stg_Class_Print( self, stream );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void Decomp_Sync_SetDecomp( void* sync, Decomp* decomp ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( Decomp_Sync_ValidateComms( self ) );
+
+ Decomp_Sync_DestructDecomp( self );
+ self->decomp = decomp;
+ assert( Decomp_Sync_ValidateComms( self ) );
+
+ if( decomp ) {
+ self->nDomains = Decomp_GetLocalSize( decomp );
+ List_Append( Decomp_GetSyncList( decomp ), &self );
+ }
+ Decomp_Sync_InitArrays( self );
+}
+
+void Decomp_Sync_SetCommTopology( void* sync, CommTopology* commTopo ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ Decomp_Sync_DestructComm( self );
+ if( commTopo ) {
+ self->commTopo = commTopo;
+ Stg_Class_AddRef( commTopo );
+ }
+ else {
+ self->commTopo = CommTopology_New();
+ Stg_Class_AddRef( commTopo );
+ if( self->decomp )
+ CommTopology_SetComm( self->commTopo, Decomp_GetComm( self->decomp ) );
+ }
+ assert( Decomp_Sync_ValidateComms( self ) );
+
+ Decomp_Sync_InitArrays( self );
+}
+
+void Decomp_Sync_AddRemoteRanks( void* sync, unsigned nRanks, unsigned* ranks ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( !nRanks || ranks );
+
+ CommTopology_AddIncidence( self->commTopo, nRanks, ranks );
+ Decomp_Sync_ExpandArrays( self, nRanks );
+}
+
+void Decomp_Sync_SetRemotes( void* sync, unsigned nRemotes, unsigned* remotes ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ Decomp_Sync_DestructRemotes( self );
+ Decomp_Sync_AddRemotes( self, nRemotes, remotes );
+}
+
+void Decomp_Sync_AddRemotes( void* sync, unsigned nRemotes, unsigned* remotes ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+ unsigned nIncRanks, *incRanks, *ranks;
+ unsigned *nSrcRemotes, **srcRemotes;
+ unsigned *nSnkRemotes, **snkRemotes;
+ unsigned p_i;
+
+ assert( self );
+ assert( self->decomp );
+ assert( !nRemotes || remotes );
+ assert( Decomp_Sync_ValidateRemotes( self, nRemotes, remotes ) );
+
+ /* If we're not connected to anything, just exit. */
+ CommTopology_GetIncidence( self->commTopo, &nIncRanks, &incRanks );
+ if( !nIncRanks )
+ return;
+
+ /* Prepare source and sink arrays. */
+ nSrcRemotes = AllocArray( unsigned, nIncRanks );
+ nSnkRemotes = AllocArray( unsigned, nIncRanks );
+ srcRemotes = AllocArray( unsigned*, nIncRanks );
+ snkRemotes = AllocArray( unsigned*, nIncRanks );
+
+ /* Split these remotes for each processor. */
+ Decomp_Sync_SplitRemotes( self, nRemotes, remotes,
+ nSrcRemotes, srcRemotes,
+ nSnkRemotes, snkRemotes );
+
+ /* Add them. */
+ ranks = AllocArray( unsigned, nIncRanks );
+ for( p_i = 0; p_i < nIncRanks; p_i++ )
+ ranks[p_i] = p_i;
+ Decomp_Sync_AddSources( self, nIncRanks, ranks, nSrcRemotes, srcRemotes );
+ Decomp_Sync_AddSinks( self, nIncRanks, ranks, nSnkRemotes, snkRemotes );
+ Decomp_Sync_BuildShared( self );
+ FreeArray( ranks );
+
+ /* Free the space. */
+ FreeArray( nSrcRemotes );
+ FreeArray( nSnkRemotes );
+ FreeArray2D( nIncRanks, srcRemotes );
+ FreeArray2D( nIncRanks, snkRemotes );
+}
+
+void Decomp_Sync_SetSources( void* sync, unsigned nRanks, unsigned* ranks,
+ unsigned* nSources, unsigned** sources )
+{
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+ unsigned p_i, s_i;
+
+ assert( nRanks <= CommTopology_GetIncidenceSize( self->commTopo ) );
+ assert( !nRanks || ranks );
+
+ for( p_i = 0; p_i < nRanks; p_i++ ) {
+ assert( ranks[p_i] < CommTopology_GetIncidenceSize( self->commTopo ) );
+ for( s_i = 0; s_i < self->nSrcs[ranks[p_i]]; s_i++ )
+ UIntMap_Remove( self->grMap, Decomp_Sync_DomainToGlobal( self, self->srcs[ranks[p_i]][s_i] ) );
+ KillArray( self->srcs[ranks[p_i]] );
+ self->netSrcs -= self->nSrcs[ranks[p_i]];
+ self->nDomains -= self->nSrcs[ranks[p_i]];
+ self->nRemotes -= self->nSrcs[ranks[p_i]];
+ self->nSrcs[ranks[p_i]] = 0;
+ }
+
+ Decomp_Sync_AddSources( self, nRanks, ranks, nSources, sources );
+}
+
+void Decomp_Sync_SetSinks( void* sync, unsigned nRanks, unsigned* ranks,
+ unsigned* nSinks, unsigned** sinks )
+{
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+ unsigned p_i;
+
+ assert( nRanks <= CommTopology_GetIncidenceSize( self->commTopo ) );
+ assert( !nRanks || ranks );
+
+ for( p_i = 0; p_i < nRanks; p_i++ ) {
+ assert( ranks[p_i] < CommTopology_GetIncidenceSize( self->commTopo ) );
+ KillArray( self->snks[ranks[p_i]] );
+ self->netSnks -= self->nSnks[ranks[p_i]];
+ self->nSnks[ranks[p_i]] = 0;
+ }
+
+ Decomp_Sync_AddSinks( self, nRanks, ranks, nSinks, sinks );
+}
+
+void Decomp_Sync_AddSources( void* sync, unsigned nRanks, unsigned* ranks,
+ unsigned* nSources, unsigned** sources )
+{
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+ unsigned nNewRemotes;
+ unsigned domainInd;
+ unsigned offs;
+ unsigned p_i;
+
+ assert( self );
+ assert( self->decomp );
+ assert( nRanks <= CommTopology_GetIncidenceSize( self->commTopo ) );
+ assert( !nRanks || ranks );
+ assert( nSources && sources );
+
+ nNewRemotes = 0;
+ for( p_i = 0; p_i < nRanks; p_i++ ) {
+ assert( ranks[p_i] < CommTopology_GetIncidenceSize( self->commTopo ) );
+ assert( Decomp_Sync_ValidateRemotes( self, nSources[p_i], sources[p_i] ) );
+ nNewRemotes += nSources[p_i];
+ }
+
+ if( nNewRemotes ) {
+ self->remotes = ReallocNamedArray( self->remotes, unsigned, self->nRemotes + nNewRemotes,
+ "Decomp_Sync::remotes" );
+ self->owners = ReallocNamedArray( self->owners, unsigned, self->nRemotes + nNewRemotes,
+ "Decomp_Sync::owners" );
+ offs = self->nRemotes;
+ for( p_i = 0; p_i < nRanks; p_i++ ) {
+ unsigned r_i;
+
+ for( r_i = 0; r_i < nSources[p_i]; r_i++ ) {
+ self->remotes[offs] = sources[p_i][r_i];
+ UIntMap_Insert( self->grMap, sources[p_i][r_i], offs );
+ self->owners[offs++] = ranks[p_i];
+ }
+ }
+ self->nRemotes += nNewRemotes;
+ self->nDomains += nNewRemotes;
+ }
+
+ for( p_i = 0; p_i < nRanks; p_i++ ) {
+ unsigned rank = ranks[p_i];
+ unsigned s_i;
+
+ self->srcs[rank] = ReallocArray( self->srcs[rank], unsigned, self->nSrcs[rank] + nSources[p_i] );
+ for( s_i = 0; s_i < nSources[p_i]; s_i++ ) {
+ insist( Decomp_Sync_GlobalToDomain( self, sources[p_i][s_i], &domainInd ), == True );
+ self->srcs[rank][self->nSrcs[rank] + s_i] = domainInd;
+ }
+ self->nSrcs[rank] += nSources[p_i];
+ self->netSrcs += nSources[p_i];
+ }
+}
+
+void Decomp_Sync_AddSinks( void* sync, unsigned nRanks, unsigned* ranks,
+ unsigned* nSinks, unsigned** sinks )
+{
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+ unsigned domainInd;
+ unsigned p_i;
+
+ assert( self );
+ assert( self->decomp );
+ assert( nRanks <= CommTopology_GetIncidenceSize( self->commTopo ) );
+ assert( !nRanks || ranks );
+ assert( nSinks && sinks );
+
+ for( p_i = 0; p_i < nRanks; p_i++ ) {
+ unsigned rank = ranks[p_i];
+ unsigned s_i;
+
+ assert( rank < CommTopology_GetIncidenceSize( self->commTopo ) );
+ assert( Decomp_Sync_ValidateSinks( self, nSinks[p_i], sinks[p_i] ) );
+ self->snks[rank] = ReallocArray( self->snks[rank], unsigned, self->nSnks[rank] + nSinks[p_i] );
+ for( s_i = 0; s_i < nSinks[p_i]; s_i++ ) {
+ insist( Decomp_Sync_GlobalToDomain( self, sinks[p_i][s_i], &domainInd ), == True );
+ self->snks[rank][self->nSnks[rank] + s_i] = domainInd;
+ }
+ self->nSnks[rank] += nSinks[p_i];
+ self->netSnks += nSinks[p_i];
+ }
+}
+
+void Decomp_Sync_SetRequired( void* sync, unsigned nRequired, unsigned* required ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ Decomp_Sync_DestructRemotes( self );
+ Decomp_Sync_AddRequired( self, nRequired, required );
+}
+
+void Decomp_Sync_AddRequired( void* sync, unsigned nRequired, unsigned* required ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+ MPI_Comm comm;
+ unsigned nProcs, rank;
+ RangeSet *reqSet, *remReqSet, *lSet;
+ unsigned nLocals, *locals;
+ unsigned nOldIncRanks, nIncRanks;
+ unsigned nBytes;
+ Stg_Byte* bytes;
+ unsigned tag = 8849;
+ unsigned p_i;
+
+ assert( self && Stg_CheckType( self, Decomp_Sync ) );
+ assert( Decomp_Sync_ValidateRemotes( self, nRequired, required ) );
+
+ comm = CommTopology_GetComm( self->commTopo );
+ MPI_Comm_rank( comm, (int*)&rank );
+ MPI_Comm_size( comm, (int*)&nProcs );
+
+ reqSet = RangeSet_New();
+ RangeSet_SetIndices( reqSet, nRequired, required );
+
+ Decomp_GetLocals( self->decomp, &nLocals, &locals );
+ lSet = RangeSet_New();
+ RangeSet_SetIndices( lSet, nLocals, locals );
+
+ nOldIncRanks = nIncRanks;
+ remReqSet = RangeSet_New();
+ for( p_i = 0; p_i < nProcs; p_i++ ) {
+ Stg_Byte state;
+ unsigned nInds, *inds;
+ unsigned localRank;
+
+ if( rank == p_i )
+ RangeSet_Pickle( reqSet, &nBytes, &bytes );
+ MPI_Bcast( &nBytes, 1, MPI_UNSIGNED, p_i, comm );
+ if( rank != p_i )
+ bytes = AllocArray( Stg_Byte, nBytes );
+ MPI_Bcast( bytes, nBytes, MPI_BYTE, p_i, comm );
+
+ if( rank != p_i ) {
+ RangeSet_Unpickle( remReqSet, nBytes, bytes );
+ FreeArray( bytes );
+
+ RangeSet_Intersection( remReqSet, lSet );
+ if( RangeSet_GetSize( remReqSet ) ) {
+ state = 1;
+ MPI_Gather( &state, 1, MPI_BYTE, NULL, 1, MPI_BYTE, p_i, comm );
+
+ RangeSet_Pickle( remReqSet, &nBytes, &bytes );
+ MPI_Send( &nBytes, 1, MPI_UNSIGNED, p_i, tag, comm );
+ MPI_Send( bytes, nBytes, MPI_BYTE, p_i, tag, comm );
+ FreeArray( bytes );
+
+ inds = NULL;
+ RangeSet_GetIndices( remReqSet, &nInds, &inds );
+ if( !CommTopology_GlobalToLocal( self->commTopo, p_i, &localRank ) ) {
+ Decomp_Sync_AddRemoteRanks( self, 1, &p_i );
+ insist( CommTopology_GlobalToLocal( self->commTopo, p_i, &localRank ), == True );
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+ }
+ Decomp_Sync_AddSinks( sync, 1, &localRank, &nInds, &inds );
+ FreeArray( inds );
+ }
+ else {
+ state = 0;
+ MPI_Gather( &state, 1, MPI_BYTE, NULL, 1, MPI_BYTE, p_i, comm );
+ }
+ }
+ else {
+ Stg_Byte* states;
+ unsigned nActive, *active;
+ MPI_Status status;
+ unsigned nNewRanks, *newRanks;
+ unsigned p_j;
+
+ FreeArray( bytes );
+
+ state = 0;
+ states = AllocArray( Stg_Byte, nProcs );
+ MPI_Gather( &state, 1, MPI_BYTE, states, 1, MPI_BYTE, p_i, comm );
+ nActive = 0;
+ nNewRanks = 0;
+ for( p_j = 0; p_j < nProcs; p_j++ ) {
+ if( states[p_j] ) {
+ nActive++;
+ if( !CommTopology_GlobalToLocal( self->commTopo, p_j, &localRank ) )
+ nNewRanks++;
+ }
+ }
+ active = AllocArray( unsigned, nActive );
+ newRanks = AllocArray( unsigned, nNewRanks );
+ nActive = 0;
+ nNewRanks = 0;
+ for( p_j = 0; p_j < nProcs; p_j++ ) {
+ if( states[p_j] ) {
+ active[nActive++] = p_j;
+ if( !CommTopology_GlobalToLocal( self->commTopo, p_j, &localRank ) )
+ newRanks[nNewRanks++] = p_j;
+ }
+ }
+ FreeArray( states );
+
+ Decomp_Sync_AddRemoteRanks( sync, nNewRanks, newRanks );
+ if( nNewRanks )
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+ FreeArray( newRanks );
+
+ for( p_j = 0; p_j < nActive; p_j++ ) {
+ MPI_Recv( &nBytes, 1, MPI_UNSIGNED, active[p_j], tag, comm, &status );
+ bytes = AllocArray( Stg_Byte, nBytes );
+ MPI_Recv( bytes, nBytes, MPI_BYTE, active[p_j], tag, comm, &status );
+ RangeSet_Unpickle( reqSet, nBytes, bytes );
+ FreeArray( bytes );
+ inds = NULL;
+ RangeSet_GetIndices( reqSet, &nInds, &inds );
+ insist( CommTopology_GlobalToLocal( self->commTopo, active[p_j], &localRank ), == True );
+ Decomp_Sync_AddSources( sync, 1, &localRank, &nInds, &inds );
+ FreeArray( inds );
+ }
+
+ FreeArray( active );
+ }
+ }
+
+ FreeObject( reqSet );
+ FreeObject( remReqSet );
+ FreeObject( lSet );
+
+ Decomp_Sync_BuildShared( self );
+}
+
+void Decomp_Sync_BuildShared( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+ unsigned nIncRanks;
+ RangeSet *dSet, **rSets, *allSet;
+ unsigned nLocals, *locals;
+ unsigned nSendBytes, *nRecvBytes;
+ Stg_Byte *sendBytes, **recvBytes;
+ unsigned **sharers;
+ unsigned nInds, *inds;
+ unsigned r_i, s_i, ind_i;
+
+ assert( self && Stg_CheckType( self, Decomp_Sync ) );
+
+ /* Free shared info. */
+ FreeArray( self->shared );
+ FreeArray( self->nSharers );
+ FreeArray( self->sharers );
+
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+
+ /* Communicate a range set of my domain indices to all neighbours. */
+ dSet = RangeSet_New();
+ RangeSet_SetIndices( dSet, self->nRemotes, self->remotes );
+ Decomp_GetLocals( self->decomp, &nLocals, &locals );
+ RangeSet_AddIndices( dSet, nLocals, locals );
+ RangeSet_Pickle( dSet, &nSendBytes, &sendBytes );
+ CommTopology_Allgather( self->commTopo,
+ nSendBytes, sendBytes,
+ &nRecvBytes, &recvBytes,
+ sizeof(Stg_Byte) );
+ FreeArray( sendBytes );
+ rSets = AllocArray( RangeSet*, nIncRanks );
+ allSet = RangeSet_New();
+ for( r_i = 0; r_i < nIncRanks; r_i++ ) {
+ rSets[r_i] = RangeSet_New();
+ RangeSet_Unpickle( rSets[r_i], nRecvBytes[r_i], recvBytes[r_i] );
+ RangeSet_Intersection( rSets[r_i], dSet );
+ RangeSet_Union( allSet, rSets[r_i] );
+ FreeArray( recvBytes[r_i] );
+ }
+ FreeArray( recvBytes );
+ FreeArray( nRecvBytes );
+
+ /* Use the 'allSet' to generate the shared indices. */
+ self->shared = NULL;
+ RangeSet_GetIndices( allSet, &self->nShared, &self->shared );
+ FreeObject( allSet );
+ for( s_i = 0; s_i < self->nShared; s_i++ ) {
+ insist( Decomp_Sync_GlobalToDomain( self, self->shared[s_i], self->shared + s_i ), == True );
+ UIntMap_Insert( self->dsMap, self->shared[s_i], s_i );
+ }
+
+ /* Now that we have each intersection, convert to shared arrays. */
+ self->nSharers = AllocArray( unsigned, self->nShared );
+ memset( self->nSharers, 0, self->nShared * sizeof(unsigned) );
+ sharers = AllocArray2D( unsigned, self->nShared, nIncRanks );
+ for( r_i = 0; r_i < nIncRanks; r_i++ ) {
+ inds = NULL;
+ RangeSet_GetIndices( rSets[r_i], &nInds, &inds );
+ FreeObject( rSets[r_i] );
+ for( ind_i = 0; ind_i < nInds; ind_i++ ) {
+ insist( Decomp_Sync_GlobalToDomain( self, inds[ind_i], inds + ind_i ), == True );
+ insist( Decomp_Sync_DomainToShared( self, inds[ind_i], inds + ind_i ), == True );
+ sharers[inds[ind_i]][self->nSharers[inds[ind_i]]++] = r_i;
+ }
+ FreeArray( inds );
+ }
+ FreeArray( rSets );
+
+ /* Store final array. */
+ self->sharers = AllocComplex2D( unsigned, self->nShared, self->nSharers );
+ for( s_i = 0; s_i < self->nShared; s_i++ )
+ memcpy( self->sharers[s_i], sharers[s_i], self->nSharers[s_i] * sizeof(unsigned) );
+ FreeArray( sharers );
+
+#if 0
+ /* Create a range set of all sinks and sources. */
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+ shareSet = RangeSet_New();
+ tmpSet = RangeSet_New();
+ for( p_i = 0; p_i < nIncRanks; p_i++ ) {
+ RangeSet_SetIndices( tmpSet, self->nSnks[p_i], self->snks[p_i] );
+ RangeSet_Union( shareSet, tmpSet );
+ RangeSet_SetIndices( tmpSet, self->nSrcs[p_i], self->srcs[p_i] );
+ RangeSet_Union( shareSet, tmpSet );
+ }
+ FreeObject( tmpSet );
+
+ /* These indices are the shared elements. */
+ self->shared = NULL;
+ RangeSet_GetIndices( shareSet, &self->nShared, &self->shared );
+ FreeObject( shareSet );
+
+ /* If there are no shared indices, exit now. */
+ if( !self->nShared )
+ return;
+
+ /* Build the shared mapping. */
+ for( s_i = 0; s_i < self->nShared; s_i++ )
+ UIntMap_Insert( self->dsMap, self->shared[s_i], s_i );
+
+ /* Create temporary storage for the sharers. */
+ self->nSharers = AllocNamedArray( unsigned, self->nShared, "Decomp_Sync::nSharers" );
+ sharers = Memory_Alloc_2DArray_Unnamed( unsigned, self->nShared, nIncRanks );
+ memset( self->nSharers, 0, self->nShared * sizeof(unsigned) );
+
+ /* Build the sharer lists. */
+ for( p_i = 0; p_i < nIncRanks; p_i++ ) {
+ for( s_i = 0; s_i < self->nSnks[p_i]; s_i++ ) {
+ unsigned sharedInd;
+ unsigned curSharer;
+
+ insist( UIntMap_Map( self->dsMap, self->snks[p_i][s_i], &sharedInd ), == True );
+ curSharer = self->nSharers[sharedInd]++;
+ sharers[sharedInd][curSharer] = p_i;
+ }
+ }
+
+ /* Transfer to final storage. */
+ self->sharers = Memory_Alloc_2DComplex( unsigned, self->nShared, self->nSharers, "Decomp_Sync::sharers" );
+ for( s_i = 0; s_i < self->nShared; s_i++ )
+ memcpy( self->sharers[s_i], sharers[s_i], self->nSharers[s_i] * sizeof(unsigned) );
+
+ /* Free the old sharers array. */
+ FreeArray( sharers );
+#endif
+}
+
+unsigned Decomp_Sync_GetGlobalSize( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( self->decomp );
+
+ return Decomp_GetGlobalSize( self->decomp );
+}
+
+unsigned Decomp_Sync_GetLocalSize( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( self->decomp );
+
+ return Decomp_GetLocalSize( self->decomp );
+}
+
+unsigned Decomp_Sync_GetRemoteSize( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ return self->nRemotes;
+}
+
+unsigned Decomp_Sync_GetDomainSize( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ return self->nDomains;
+}
+
+unsigned Decomp_Sync_GetSharedSize( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ return self->nShared;
+}
+
+void Decomp_Sync_GetRemotes( void* sync, unsigned* nRemotes, unsigned** remotes ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( nRemotes );
+ assert( remotes );
+
+ *nRemotes = self->nRemotes;
+ *remotes = self->remotes;
+}
+
+Bool Decomp_Sync_GlobalToDomain( void* sync, unsigned global, unsigned* domain ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( self->decomp );
+ assert( global < self->decomp->nGlobals );
+ assert( self->decomp->glMap );
+ assert( self->grMap );
+ assert( domain );
+
+ if( Decomp_GlobalToLocal( self->decomp, global, domain ) )
+ return True;
+ else if( UIntMap_Map( self->grMap, global, domain ) ) {
+ *domain += Decomp_GetLocalSize( self->decomp );
+ return True;
+ }
+
+ return False;
+}
+
+unsigned Decomp_Sync_DomainToGlobal( void* sync, unsigned domain ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( self->decomp );
+ assert( domain < self->decomp->nLocals + self->nRemotes );
+
+ if( domain < self->decomp->nLocals )
+ return Decomp_LocalToGlobal( self->decomp, domain );
+ else
+ return self->remotes[domain - Decomp_GetLocalSize( self->decomp )];
+}
+
+Bool Decomp_Sync_DomainToShared( void* sync, unsigned domain, unsigned* shared ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( self->decomp );
+ assert( domain < self->nDomains );
+ assert( self->dsMap );
+ assert( shared );
+
+ return UIntMap_Map( self->dsMap, domain, shared );
+}
+
+unsigned Decomp_Sync_SharedToDomain( void* sync, unsigned shared ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( shared < self->nShared );
+ assert( self->shared );
+
+ return self->shared[shared];
+}
+
+unsigned Decomp_Sync_GetOwner( void* sync, unsigned remote ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( remote < self->nRemotes );
+ assert( self->owners );
+
+ return self->owners[remote];
+}
+
+void Decomp_Sync_GetSharers( void* sync, unsigned shared,
+ unsigned* nSharers, unsigned** sharers )
+{
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( shared < self->nShared );
+ assert( self->nSharers );
+ assert( self->sharers );
+ assert( nSharers );
+ assert( sharers );
+
+ *nSharers = self->nSharers[shared];
+ *sharers = self->sharers[shared];
+}
+
+void Decomp_Sync_GetSources( void* sync, unsigned rank, unsigned* nSources, unsigned** sources ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( rank < CommTopology_GetIncidenceSize( self->commTopo ) );
+ assert( nSources && sources );
+ assert( self->nSrcs && self->srcs );
+
+ *nSources = self->nSrcs[rank];
+ *sources = self->srcs[rank];
+}
+
+void Decomp_Sync_GetSinks( void* sync, unsigned rank, unsigned* nSinks, unsigned** sinks ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+ assert( rank < CommTopology_GetIncidenceSize( self->commTopo ) );
+ assert( nSinks && sinks );
+ assert( self->nSnks && self->snks );
+
+ *nSinks = self->nSnks[rank];
+ *sinks = self->snks[rank];
+}
+
+Decomp* Decomp_Sync_GetDecomp( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ return self->decomp;
+}
+
+CommTopology* Decomp_Sync_GetCommTopology( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ return self->commTopo;
+}
+
+void Decomp_Sync_SyncArray( void* sync, Decomp_Sync_Array* array ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+ unsigned nInc;
+ unsigned* inc;
+ Stg_Byte* snkArray;
+ Stg_Byte* srcArray;
+ unsigned p_i;
+
+ /* Sanity checks. */
+ assert( self );
+ assert( self->decomp );
+ assert( array );
+
+ /* Pack from locals to a contiguous array. */
+ if( self->netSnks > 0 ) {
+ unsigned snk_i;
+
+ snkArray = AllocArray( Stg_Byte, self->netSnks * array->itemSize );
+ for( snk_i = 0; snk_i < self->netSnks; snk_i++ ) {
+ memcpy( snkArray + snk_i * array->itemSize,
+ (Stg_Byte*)array->snkArray + array->snkOffs[snk_i],
+ array->itemSize );
+ }
+ }
+ else
+ snkArray = NULL;
+
+ /* Allocate for sources. */
+ srcArray = AllocArray( Stg_Byte, self->netSrcs * array->itemSize );
+
+ /* Get incidence. */
+ CommTopology_GetIncidence( self->commTopo, &nInc, &inc );
+
+ /* Transfer. */
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ int snkSize = array->snkSizes[p_i];
+ int snkDisp = array->snkDisps[p_i];
+ int srcSize = array->srcSizes[p_i];
+ int srcDisp = array->srcDisps[p_i];
+ MPI_Status status;
+ unsigned tag = 6669;
+
+ MPI_Sendrecv( snkArray + snkDisp, snkSize, MPI_BYTE, inc[p_i], tag,
+ srcArray + srcDisp, srcSize, MPI_BYTE, inc[p_i], tag,
+ CommTopology_GetComm( self->commTopo ), &status );
+ }
+
+ /* Free the sink array. */
+ FreeArray( snkArray );
+
+ /* Unpack sources. */
+ if( self->netSrcs > 0 ) {
+ unsigned src_i;
+
+ for( src_i = 0; src_i < self->netSrcs; src_i++ ) {
+ memcpy( (Stg_Byte*)array->srcArray + array->srcOffs[src_i],
+ srcArray + src_i * array->itemSize,
+ array->itemSize );
+ }
+ }
+
+ /* Free source array. */
+ FreeArray( srcArray );
+}
+
+void Decomp_Sync_Update( void* sync ) {
+ Decomp_Sync* self = (Decomp_Sync*)sync;
+
+ assert( self );
+
+ Decomp_Sync_DestructRemotes( self );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void Decomp_Sync_InitArrays( Decomp_Sync* self ) {
+ unsigned nIncRanks;
+
+ assert( self );
+
+ if( self->commTopo ) {
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+ if( nIncRanks ) {
+ self->nSrcs = AllocNamedArray( unsigned, nIncRanks, "Decomp_Sync::nSrcs" );
+ self->srcs = AllocNamedArray( unsigned*, nIncRanks, "Decomp_Sync::srcs" );
+ self->nSnks = AllocNamedArray( unsigned, nIncRanks, "Decomp_Sync::nSnks" );
+ self->snks = AllocNamedArray( unsigned*, nIncRanks, "Decomp_Sync::snks" );
+ memset( self->nSrcs, 0, nIncRanks * sizeof(unsigned) );
+ memset( self->srcs, 0, nIncRanks * sizeof(unsigned*) );
+ memset( self->nSnks, 0, nIncRanks * sizeof(unsigned) );
+ memset( self->snks, 0, nIncRanks * sizeof(unsigned*) );
+ }
+ }
+}
+
+void Decomp_Sync_ExpandArrays( Decomp_Sync* self, unsigned nNewRanks ) {
+ unsigned nIncRanks, nOldIncRanks;
+
+ assert( self );
+ assert( !self->nShared || (self->nSharers && self->sharers) );
+ assert( !self->nRemotes || self->owners );
+
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+ nOldIncRanks = nIncRanks - nNewRanks;
+ self->nSrcs = ReallocNamedArray( self->nSrcs, unsigned, nIncRanks, "Decomp_Sync::nSrcs" );
+ self->srcs = ReallocNamedArray( self->srcs, unsigned*, nIncRanks, "Decomp_Sync::srcs" );
+ self->nSnks = ReallocNamedArray( self->nSnks, unsigned, nIncRanks, "Decomp_Sync::nSnks" );
+ self->snks = ReallocNamedArray( self->snks, unsigned*, nIncRanks, "Decomp_Sync::snks" );
+ memset( self->nSrcs + nOldIncRanks, 0, nNewRanks * sizeof(unsigned) );
+ memset( self->srcs + nOldIncRanks, 0, nNewRanks * sizeof(unsigned*) );
+ memset( self->nSnks + nOldIncRanks, 0, nNewRanks * sizeof(unsigned) );
+ memset( self->snks + nOldIncRanks, 0, nNewRanks * sizeof(unsigned*) );
+}
+
+void Decomp_Sync_SplitRemotes( Decomp_Sync* self, unsigned nRemotes, unsigned* remotes,
+ unsigned* nSrcs, unsigned** srcs,
+ unsigned* nSnks, unsigned** snks )
+{
+ unsigned nLocals, *locals;
+ unsigned nIncRanks;
+ RangeSet *remSet, *locSet;
+ unsigned nBytes, *nRemBytes, *nFndBytes;
+ Stg_Byte *bytes, **remBytes, **fndBytes;
+ unsigned p_i;
+
+ assert( self );
+ assert( self->decomp );
+
+ /* Make a range set of our remotes. */
+ remSet = RangeSet_New();
+ RangeSet_SetIndices( remSet, nRemotes, remotes );
+ RangeSet_Pickle( remSet, &nBytes, &bytes );
+
+ /* Collect neighbouring remotes. */
+ CommTopology_Allgather( self->commTopo,
+ nBytes, bytes,
+ &nRemBytes, (void***)&remBytes,
+ sizeof(Stg_Byte) );
+
+ /* Done with the bytes. */
+ FreeArray( bytes );
+
+ /* Build a range set of our locals. */
+ locSet = RangeSet_New();
+ Decomp_GetLocals( self->decomp, &nLocals, &locals );
+ RangeSet_SetIndices( locSet, nLocals, locals );
+
+ /* Intersect our locals and our neighbours remotes to build our sink sets. */
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+ remSet = RangeSet_New();
+ for( p_i = 0; p_i < nIncRanks; p_i++ ) {
+ RangeSet_Unpickle( remSet, nRemBytes[p_i], remBytes[p_i] );
+
+ /* Done with the remote bytes. */
+ FreeArray( remBytes[p_i] );
+
+ RangeSet_Intersection( remSet, locSet );
+ snks[p_i] = NULL;
+ RangeSet_GetIndices( remSet, nSnks + p_i, snks + p_i );
+ RangeSet_Pickle( remSet, nRemBytes + p_i, remBytes + p_i );
+ }
+
+ /* Local set is no longer needed. */
+ FreeObject( locSet );
+
+ /* Return what we've found. */
+ CommTopology_Alltoall( self->commTopo,
+ nRemBytes, (void**)remBytes,
+ &nFndBytes, (void***)&fndBytes,
+ sizeof(Stg_Byte) );
+
+ /* Done with the remote bytes arrays. */
+ FreeArray( nRemBytes );
+ FreeArray2D( nIncRanks, remBytes );
+
+ /* Construct our source arrays with what was found. */
+ for( p_i = 0; p_i < nIncRanks; p_i++ ) {
+ RangeSet_Unpickle( remSet, nFndBytes[p_i], fndBytes[p_i] );
+
+ /* Empty the internal found arrays. */
+ FreeArray( fndBytes[p_i] );
+
+ srcs[p_i] = NULL;
+ RangeSet_GetIndices( remSet, nSrcs + p_i, srcs + p_i );
+ }
+
+ /* Free everything else. */
+ FreeArray( nFndBytes );
+ FreeArray( fndBytes );
+ FreeObject( remSet );
+}
+
+void Decomp_Sync_Destruct( Decomp_Sync* self ) {
+ assert( self );
+
+ Decomp_Sync_DestructDecomp( self );
+ Decomp_Sync_DestructComm( self );
+}
+
+void Decomp_Sync_DestructDecomp( Decomp_Sync* self ) {
+ assert( self );
+
+ Decomp_Sync_DestructRemotes( self );
+ if( self->decomp ) {
+ List_Remove( Decomp_GetSyncList( self->decomp ), &self );
+ self->decomp = NULL;
+ }
+}
+
+void Decomp_Sync_DestructComm( Decomp_Sync* self ) {
+ assert( self );
+
+ Decomp_Sync_DestructRemotes( self );
+ Stg_Class_RemoveRef( self->commTopo );
+ self->commTopo = NULL;
+ KillArray( self->nSrcs );
+ KillArray( self->srcs );
+ KillArray( self->nSnks );
+ KillArray( self->snks );
+}
+
+void Decomp_Sync_DestructRemotes( Decomp_Sync* self ) {
+ assert( self );
+
+ Decomp_Sync_DestructArrays( self );
+ Decomp_Sync_DestructSources( self );
+ Decomp_Sync_DestructSinks( self );
+}
+
+void Decomp_Sync_DestructSources( Decomp_Sync* self ) {
+ unsigned nIncRanks;
+ unsigned p_i;
+
+ assert( self );
+
+ if( self->commTopo )
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+
+ if( self->decomp )
+ self->nDomains = Decomp_GetLocalSize( self->decomp );
+
+ KillArray( self->remotes );
+ self->nRemotes = 0;
+ UIntMap_Clear( self->grMap );
+ self->netSrcs = 0;
+ for( p_i = 0; p_i < nIncRanks; p_i++ )
+ KillArray( self->srcs[p_i] );
+}
+
+void Decomp_Sync_DestructSinks( Decomp_Sync* self ) {
+ unsigned nIncRanks;
+ unsigned p_i;
+
+ if( self->commTopo )
+ nIncRanks = CommTopology_GetIncidenceSize( self->commTopo );
+
+ KillArray( self->shared );
+ self->nShared = 0;
+ KillArray( self->nSharers );
+ KillArray( self->sharers );
+ UIntMap_Clear( self->dsMap );
+ self->netSnks = 0;
+ for( p_i = 0; p_i < nIncRanks; p_i++ )
+ KillArray( self->snks[p_i] );
+}
+
+void Decomp_Sync_DestructArrays( Decomp_Sync* self ) {
+ unsigned a_i;
+
+ for( a_i = 0; a_i < List_GetSize( self->arrays ); a_i++ ) {
+ Decomp_Sync_Array* array = *(Decomp_Sync_Array**)List_GetItem( self->arrays, a_i );
+
+ Decomp_Sync_Array_SetSync( array, self );
+ }
+
+ List_Clear( self->arrays );
+}
+
+#ifndef NDEBUG
+Bool Decomp_Sync_ValidateRemotes( Decomp_Sync* self, unsigned nRemotes, unsigned* remotes ) {
+ unsigned domainInd;
+ unsigned r_i;
+
+ for( r_i = 0; r_i < nRemotes; r_i++ ) {
+ if( Decomp_Sync_GlobalToDomain( self, remotes[r_i], &domainInd ) )
+ return False;
+ }
+
+ return True;
+}
+
+Bool Decomp_Sync_ValidateSinks( Decomp_Sync* self, unsigned nSinks, unsigned* sinks ) {
+ RangeSet *lSet, *sSet;
+ unsigned nLocals, *locals;
+ unsigned nInds;
+
+ Decomp_GetLocals( self->decomp, &nLocals, &locals );
+
+ lSet = RangeSet_New();
+ sSet = RangeSet_New();
+ RangeSet_SetIndices( lSet, nLocals, locals );
+ RangeSet_SetIndices( sSet, nSinks, sinks );
+ RangeSet_Subtraction( sSet, lSet );
+ nInds = RangeSet_GetSize( sSet );
+ FreeObject( lSet );
+ FreeObject( sSet );
+
+ return !nInds;
+}
+
+Bool Decomp_Sync_ValidateComms( Decomp_Sync* self ) {
+ assert( self );
+
+ if( self->decomp && self->commTopo )
+ return Decomp_GetComm( self->decomp ) == CommTopology_GetComm( self->commTopo );
+ else
+ return True;
+}
+#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync.h
--- a/Mesh/src/Decomp_Sync.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Invariants:
-**
-** Comments:
-**
-** $Id: Decomp_Sync.h 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Domain_Mesh_Decomp_Sync_h__
-#define __Domain_Mesh_Decomp_Sync_h__
-
- /** Textual name of this class */
- extern const Type Decomp_Sync_Type;
-
- /** Virtual function types */
-
- /** Mesh class contents */
- #define __Decomp_Sync \
- /* General info */ \
- __Stg_Component \
- \
- /* Virtual info */ \
- \
- /* Decomp_Sync info */ \
- Decomp* decomp; \
- CommTopology* commTopo; \
- \
- unsigned nDomains; \
- unsigned nRemotes; \
- unsigned* remotes; \
- unsigned nShared; \
- unsigned* shared; \
- unsigned* nSharers; \
- unsigned** sharers; \
- unsigned* owners; \
- \
- UIntMap* grMap; \
- UIntMap* dsMap; \
- \
- unsigned netSrcs; \
- unsigned* nSrcs; \
- unsigned** srcs; \
- unsigned netSnks; \
- unsigned* nSnks; \
- unsigned** snks; \
- \
- List* arrays;
-
- struct Decomp_Sync { __Decomp_Sync };
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- #define DECOMP_SYNC_DEFARGS \
- STG_CLASS_DEFARGS
-
- #define DECOMP_SYNC_PASSARGS \
- STG_CLASS_PASSARGS
-
- Decomp_Sync* Decomp_Sync_New();
- Decomp_Sync* _Decomp_Sync_New( DECOMP_SYNC_DEFARGS );
- void _Decomp_Sync_Init( Decomp_Sync* self );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _Decomp_Sync_Delete( void* sync );
- void _Decomp_Sync_Print( void* sync, Stream* stream );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public functions
- */
-
- void Decomp_Sync_SetDecomp( void* sync, Decomp* decomp );
- void Decomp_Sync_SetCommTopology( void* sync, CommTopology* commTopo );
- void Decomp_Sync_AddRemoteRanks( void* sync, unsigned nRanks, unsigned* ranks );
- void Decomp_Sync_SetRemotes( void* sync, unsigned nRemotes, unsigned* remotes );
- void Decomp_Sync_AddRemotes( void* sync, unsigned nRemotes, unsigned* remotes );
- void Decomp_Sync_SetSources( void* sync, unsigned nRanks, unsigned* ranks,
- unsigned* nSources, unsigned** sources );
- void Decomp_Sync_SetSinks( void* sync, unsigned nRanks, unsigned* ranks,
- unsigned* nSinks, unsigned** sinks );
- void Decomp_Sync_AddSources( void* sync, unsigned nRanks, unsigned* ranks,
- unsigned* nSources, unsigned** sources );
- void Decomp_Sync_AddSinks( void* sync, unsigned nRanks, unsigned* ranks,
- unsigned* nSinks, unsigned** sinks );
- void Decomp_Sync_SetRequired( void* sync, unsigned nRequired, unsigned* required );
- void Decomp_Sync_AddRequired( void* sync, unsigned nRequired, unsigned* required );
- void Decomp_Sync_BuildShared( void* sync );
-
- unsigned Decomp_Sync_GetGlobalSize( void* sync );
- unsigned Decomp_Sync_GetLocalSize( void* sync );
- unsigned Decomp_Sync_GetRemoteSize( void* sync );
- unsigned Decomp_Sync_GetDomainSize( void* sync );
- unsigned Decomp_Sync_GetSharedSize( void* sync );
- Decomp* Decomp_Sync_GetDecomp( void* sync );
- CommTopology* Decomp_Sync_GetCommTopology( void* sync );
- void Decomp_Sync_GetRemotes( void* sync, unsigned* nRemotes, unsigned** remotes );
- unsigned Decomp_Sync_GetOwner( void* sync, unsigned remote );
- void Decomp_Sync_GetSharers( void* sync, unsigned shared,
- unsigned* nSharers, unsigned** sharers );
- void Decomp_Sync_GetSources( void* sync, unsigned rank, unsigned* nSources, unsigned** sources );
- void Decomp_Sync_GetSinks( void* sync, unsigned rank, unsigned* nSinks, unsigned** sinks );
-
- Bool Decomp_Sync_GlobalToDomain( void* sync, unsigned global, unsigned* domain );
- unsigned Decomp_Sync_DomainToGlobal( void* sync, unsigned domain );
- Bool Decomp_Sync_DomainToShared( void* sync, unsigned domain, unsigned* shared );
- unsigned Decomp_Sync_SharedToDomain( void* sync, unsigned shared );
-
- void Decomp_Sync_SyncArray( void* sync, Decomp_Sync_Array* array );
-
- void Decomp_Sync_Update( void* sync );
-
- void Decomp_Sync_AddRef( void* sync );
- void Decomp_Sync_RemoveRef( void* sync );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions
- */
-
- void Decomp_Sync_InitArrays( Decomp_Sync* self );
- void Decomp_Sync_ExpandArrays( Decomp_Sync* self, unsigned nNewRanks );
-
- void Decomp_Sync_SplitRemotes( Decomp_Sync* self, unsigned nRemotes, unsigned* remotes,
- unsigned* nSrcs, unsigned** srcs,
- unsigned* nSnks, unsigned** snks );
-
- void Decomp_Sync_Destruct( Decomp_Sync* self );
- void Decomp_Sync_DestructDecomp( Decomp_Sync* self );
- void Decomp_Sync_DestructComm( Decomp_Sync* self );
- void Decomp_Sync_DestructRemotes( Decomp_Sync* self );
- void Decomp_Sync_DestructSources( Decomp_Sync* self );
- void Decomp_Sync_DestructSinks( Decomp_Sync* self );
- void Decomp_Sync_DestructArrays( Decomp_Sync* self );
-
-#ifndef NDEBUG
- Bool Decomp_Sync_ValidateRemotes( Decomp_Sync* self, unsigned nRemotes, unsigned* remotes );
- Bool Decomp_Sync_ValidateSinks( Decomp_Sync* self, unsigned nSinks, unsigned* sinks );
- Bool Decomp_Sync_ValidateComms( Decomp_Sync* self );
-#endif
-
-#endif /* __Domain_Mesh_Decomp_Sync_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/Decomp_Sync.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,176 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: Decomp_Sync.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Domain_Mesh_Decomp_Sync_h__
+#define __Domain_Mesh_Decomp_Sync_h__
+
+ /** Textual name of this class */
+ extern const Type Decomp_Sync_Type;
+
+ /** Virtual function types */
+
+ /** Mesh class contents */
+ #define __Decomp_Sync \
+ /* General info */ \
+ __Stg_Component \
+ \
+ /* Virtual info */ \
+ \
+ /* Decomp_Sync info */ \
+ Decomp* decomp; \
+ CommTopology* commTopo; \
+ \
+ unsigned nDomains; \
+ unsigned nRemotes; \
+ unsigned* remotes; \
+ unsigned nShared; \
+ unsigned* shared; \
+ unsigned* nSharers; \
+ unsigned** sharers; \
+ unsigned* owners; \
+ \
+ UIntMap* grMap; \
+ UIntMap* dsMap; \
+ \
+ unsigned netSrcs; \
+ unsigned* nSrcs; \
+ unsigned** srcs; \
+ unsigned netSnks; \
+ unsigned* nSnks; \
+ unsigned** snks; \
+ \
+ List* arrays;
+
+ struct Decomp_Sync { __Decomp_Sync };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ #define DECOMP_SYNC_DEFARGS \
+ STG_CLASS_DEFARGS
+
+ #define DECOMP_SYNC_PASSARGS \
+ STG_CLASS_PASSARGS
+
+ Decomp_Sync* Decomp_Sync_New();
+ Decomp_Sync* _Decomp_Sync_New( DECOMP_SYNC_DEFARGS );
+ void _Decomp_Sync_Init( Decomp_Sync* self );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _Decomp_Sync_Delete( void* sync );
+ void _Decomp_Sync_Print( void* sync, Stream* stream );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+ void Decomp_Sync_SetDecomp( void* sync, Decomp* decomp );
+ void Decomp_Sync_SetCommTopology( void* sync, CommTopology* commTopo );
+ void Decomp_Sync_AddRemoteRanks( void* sync, unsigned nRanks, unsigned* ranks );
+ void Decomp_Sync_SetRemotes( void* sync, unsigned nRemotes, unsigned* remotes );
+ void Decomp_Sync_AddRemotes( void* sync, unsigned nRemotes, unsigned* remotes );
+ void Decomp_Sync_SetSources( void* sync, unsigned nRanks, unsigned* ranks,
+ unsigned* nSources, unsigned** sources );
+ void Decomp_Sync_SetSinks( void* sync, unsigned nRanks, unsigned* ranks,
+ unsigned* nSinks, unsigned** sinks );
+ void Decomp_Sync_AddSources( void* sync, unsigned nRanks, unsigned* ranks,
+ unsigned* nSources, unsigned** sources );
+ void Decomp_Sync_AddSinks( void* sync, unsigned nRanks, unsigned* ranks,
+ unsigned* nSinks, unsigned** sinks );
+ void Decomp_Sync_SetRequired( void* sync, unsigned nRequired, unsigned* required );
+ void Decomp_Sync_AddRequired( void* sync, unsigned nRequired, unsigned* required );
+ void Decomp_Sync_BuildShared( void* sync );
+
+ unsigned Decomp_Sync_GetGlobalSize( void* sync );
+ unsigned Decomp_Sync_GetLocalSize( void* sync );
+ unsigned Decomp_Sync_GetRemoteSize( void* sync );
+ unsigned Decomp_Sync_GetDomainSize( void* sync );
+ unsigned Decomp_Sync_GetSharedSize( void* sync );
+ Decomp* Decomp_Sync_GetDecomp( void* sync );
+ CommTopology* Decomp_Sync_GetCommTopology( void* sync );
+ void Decomp_Sync_GetRemotes( void* sync, unsigned* nRemotes, unsigned** remotes );
+ unsigned Decomp_Sync_GetOwner( void* sync, unsigned remote );
+ void Decomp_Sync_GetSharers( void* sync, unsigned shared,
+ unsigned* nSharers, unsigned** sharers );
+ void Decomp_Sync_GetSources( void* sync, unsigned rank, unsigned* nSources, unsigned** sources );
+ void Decomp_Sync_GetSinks( void* sync, unsigned rank, unsigned* nSinks, unsigned** sinks );
+
+ Bool Decomp_Sync_GlobalToDomain( void* sync, unsigned global, unsigned* domain );
+ unsigned Decomp_Sync_DomainToGlobal( void* sync, unsigned domain );
+ Bool Decomp_Sync_DomainToShared( void* sync, unsigned domain, unsigned* shared );
+ unsigned Decomp_Sync_SharedToDomain( void* sync, unsigned shared );
+
+ void Decomp_Sync_SyncArray( void* sync, Decomp_Sync_Array* array );
+
+ void Decomp_Sync_Update( void* sync );
+
+ void Decomp_Sync_AddRef( void* sync );
+ void Decomp_Sync_RemoveRef( void* sync );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+
+ void Decomp_Sync_InitArrays( Decomp_Sync* self );
+ void Decomp_Sync_ExpandArrays( Decomp_Sync* self, unsigned nNewRanks );
+
+ void Decomp_Sync_SplitRemotes( Decomp_Sync* self, unsigned nRemotes, unsigned* remotes,
+ unsigned* nSrcs, unsigned** srcs,
+ unsigned* nSnks, unsigned** snks );
+
+ void Decomp_Sync_Destruct( Decomp_Sync* self );
+ void Decomp_Sync_DestructDecomp( Decomp_Sync* self );
+ void Decomp_Sync_DestructComm( Decomp_Sync* self );
+ void Decomp_Sync_DestructRemotes( Decomp_Sync* self );
+ void Decomp_Sync_DestructSources( Decomp_Sync* self );
+ void Decomp_Sync_DestructSinks( Decomp_Sync* self );
+ void Decomp_Sync_DestructArrays( Decomp_Sync* self );
+
+#ifndef NDEBUG
+ Bool Decomp_Sync_ValidateRemotes( Decomp_Sync* self, unsigned nRemotes, unsigned* remotes );
+ Bool Decomp_Sync_ValidateSinks( Decomp_Sync* self, unsigned nSinks, unsigned* sinks );
+ Bool Decomp_Sync_ValidateComms( Decomp_Sync* self );
+#endif
+
+#endif /* __Domain_Mesh_Decomp_Sync_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync_Array.c
--- a/Mesh/src/Decomp_Sync_Array.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,312 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: Decomp_Sync.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-
-#include "types.h"
-#include "shortcuts.h"
-#include "CommTopology.h"
-#include "Decomp.h"
-#include "Decomp_Sync.h"
-#include "Decomp_Sync_Array.h"
-
-
-/* Textual name of this class */
-const Type Decomp_Sync_Array_Type = "Decomp_Sync_Array";
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-Decomp_Sync_Array* Decomp_Sync_Array_New() {
- return _Decomp_Sync_Array_New( sizeof(Decomp_Sync_Array),
- Decomp_Sync_Array_Type,
- _Decomp_Sync_Array_Delete,
- _Decomp_Sync_Array_Print,
- NULL );
-}
-
-Decomp_Sync_Array* _Decomp_Sync_Array_New( DECOMP_SYNC_ARRAY_DEFARGS ) {
- Decomp_Sync_Array* self;
-
- /* Allocate memory */
- assert( sizeOfSelf >= sizeof(Decomp_Sync_Array) );
- self = (Decomp_Sync_Array*)_Stg_Class_New( STG_CLASS_PASSARGS );
-
- /* Virtual info */
-
- /* Decomp_Sync_Array info */
- _Decomp_Sync_Array_Init( self );
-
- return self;
-}
-
-void _Decomp_Sync_Array_Init( Decomp_Sync_Array* self ) {
- self->sync = NULL;
-
- self->snkArray = NULL;
- self->snkStride = 0;
- self->snkDisps = NULL;
- self->snkSizes = NULL;
- self->snkOffs = NULL;
-
- self->srcArray = NULL;
- self->srcStride = 0;
- self->srcDisps = NULL;
- self->srcSizes = NULL;
- self->srcOffs = NULL;
-
- self->itemSize = 0;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _Decomp_Sync_Array_Delete( void* sync ) {
- Decomp_Sync_Array* self = (Decomp_Sync_Array*)sync;
-
- Decomp_Sync_Array_Destruct( self );
-
- /* Delete the parent. */
- _Stg_Class_Delete( self );
-}
-
-void _Decomp_Sync_Array_Print( void* sync, Stream* stream ) {
- Decomp_Sync_Array* self = (Decomp_Sync_Array*)sync;
-
- /* Set the Journal for printing informations */
- Stream* syncStream;
- syncStream = Journal_Register( InfoStream_Type, "Decomp_Sync_ArrayStream" );
-
- /* Print parent */
- Journal_Printf( stream, "Decomp_Sync_Array (ptr): (%p)\n", self );
- _Stg_Class_Print( self, stream );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void Decomp_Sync_Array_SetSync( void* array, Decomp_Sync* sync ) {
- Decomp_Sync_Array* self = (Decomp_Sync_Array*)array;
-
- assert( self );
-
- Decomp_Sync_Array_Destruct( self );
-
- self->sync = sync;
- if( sync )
- List_Append( sync->arrays, &self );
-}
-
-void Decomp_Sync_Array_SetMemory( void* array,
- void* localArray, void* remoteArray,
- size_t localStride, size_t remoteStride,
- size_t itemSize )
-{
- Decomp_Sync_Array* self = (Decomp_Sync_Array*)array;
-
- /* Sanity checks. */
- assert( self );
- assert( self->sync );
-
- /* Store information. */
- self->snkArray = localArray;
- self->snkStride = localStride;
- self->srcArray = remoteArray;
- self->srcStride = remoteStride;
- self->itemSize = itemSize;
-
- /* Build this array. */
- Decomp_Sync_Array_BuildArray( self );
-}
-
-void Decomp_Sync_Array_Sync( void* array ) {
- Decomp_Sync_Array* self = (Decomp_Sync_Array*)array;
-
- assert( self );
-
- Decomp_Sync_SyncArray( self->sync, self );
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-void Decomp_Sync_Array_BuildArray( Decomp_Sync_Array* self ) {
- Decomp* decomp;
- CommTopology* commTopo;
- unsigned nInc, *inc;
-
- assert( self );
- assert( self->sync );
-
- /* Shortcuts. */
- decomp = Decomp_Sync_GetDecomp( self->sync );
- commTopo = Decomp_Sync_GetCommTopology( self->sync );
-
- /* Extract incidence. */
- CommTopology_GetIncidence( commTopo, &nInc, &inc );
-
- if( nInc ) {
- /* Determine sink (local) information. */
- if( self->sync->netSnks > 0 ) {
- unsigned* snkOffs;
- unsigned* snkSizes;
- unsigned* snkDisps;
- unsigned snkInd = 0;
- unsigned p_i;
-
- /* Allocate/reallocate memory. */
- snkDisps = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::snkDisps" );
- snkSizes = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::snkSizes" );
- snkOffs = Memory_Alloc_Array( unsigned, self->sync->netSnks, "Decomp_Sync_Array::snkOffs" );
-
- /* Calculate offsets and sizes. */
- for( p_i = 0; p_i < nInc; p_i++ ) {
- unsigned snk_i;
-
- snkSizes[p_i] = 0;
- for( snk_i = 0; snk_i < self->sync->nSnks[p_i]; snk_i++ ) {
- unsigned dInd;
-
- dInd = self->sync->snks[p_i][snk_i];
- snkOffs[snkInd] = dInd * self->snkStride;
- snkSizes[p_i] += self->itemSize;
- snkInd++;
- }
- }
-
- /* Calculate the displacements. */
- snkDisps[0] = 0;
- for( p_i = 1; p_i < nInc; p_i++ )
- snkDisps[p_i] = snkDisps[p_i - 1] + snkSizes[p_i - 1];
-
- /* Store arrays. */
- self->snkOffs = snkOffs;
- self->snkDisps = snkDisps;
- self->snkSizes = snkSizes;
- }
- else {
- /* Store null information. */
- self->snkOffs = NULL;
- self->snkDisps = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::snkDisps" );
- self->snkSizes = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::snkSizes" );
- memset( self->snkDisps, 0, nInc * sizeof(unsigned) );
- memset( self->snkSizes, 0, nInc * sizeof(unsigned) );
- }
-
- /* Determine source (shadow) information. */
- if( self->sync->netSrcs > 0 ) {
- unsigned* srcOffs;
- unsigned* srcSizes;
- unsigned* srcDisps;
- unsigned srcInd = 0;
- unsigned p_i;
-
- /* Allocate/reallocate memory. */
- srcDisps = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::srcDisps" );
- srcSizes = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::srcSizes" );
- srcOffs = Memory_Alloc_Array( unsigned, self->sync->netSrcs, "Decomp_Sync_Array::srcOffs" );
-
- /* Calculate offsets and sizes. */
- for( p_i = 0; p_i < nInc; p_i++ ) {
- unsigned src_i;
-
- srcSizes[p_i] = 0;
- for( src_i = 0; src_i < self->sync->nSrcs[p_i]; src_i++ ) {
- unsigned sInd;
-
- sInd = self->sync->srcs[p_i][src_i];
- assert( sInd >= Decomp_GetLocalSize( decomp ) );
- sInd -= Decomp_GetLocalSize( decomp );
- srcOffs[srcInd] = sInd * self->srcStride;
- srcSizes[p_i] += self->itemSize;
- srcInd++;
- }
- }
-
- /* Calculate the displacements. */
- srcDisps[0] = 0;
- for( p_i = 1; p_i < nInc; p_i++ )
- srcDisps[p_i] = srcDisps[p_i - 1] + srcSizes[p_i - 1];
-
- /* Store arrays. */
- self->srcOffs = srcOffs;
- self->srcDisps = srcDisps;
- self->srcSizes = srcSizes;
- }
- else {
- /* Store null information. */
- self->srcOffs = NULL;
- self->srcDisps = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::srcDisps" );
- self->srcSizes = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::srcSizes" );
- memset( self->srcDisps, 0, nInc * sizeof(unsigned) );
- memset( self->srcSizes, 0, nInc * sizeof(unsigned) );
- }
- }
- else {
- self->snkOffs = NULL;
- self->snkDisps = NULL;
- self->snkSizes = NULL;
- self->srcOffs = NULL;
- self->srcDisps = NULL;
- self->srcSizes = NULL;
- }
-}
-
-void Decomp_Sync_Array_Destruct( Decomp_Sync_Array* self ) {
- if( self->sync )
- List_Remove( self->sync->arrays, &self );
-
- self->snkArray = NULL;
- self->snkStride = 0;
- self->srcArray = NULL;
- self->srcStride = 0;
- self->itemSize = 0;
-
- KillArray( self->snkDisps );
- KillArray( self->snkSizes );
- KillArray( self->snkOffs );
- KillArray( self->srcDisps );
- KillArray( self->srcSizes );
- KillArray( self->srcOffs );
- self->itemSize = 0;
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync_Array.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/Decomp_Sync_Array.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,312 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: Decomp_Sync.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+
+#include "types.h"
+#include "shortcuts.h"
+#include "CommTopology.h"
+#include "Decomp.h"
+#include "Decomp_Sync.h"
+#include "Decomp_Sync_Array.h"
+
+
+/* Textual name of this class */
+const Type Decomp_Sync_Array_Type = "Decomp_Sync_Array";
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+Decomp_Sync_Array* Decomp_Sync_Array_New() {
+ return _Decomp_Sync_Array_New( sizeof(Decomp_Sync_Array),
+ Decomp_Sync_Array_Type,
+ _Decomp_Sync_Array_Delete,
+ _Decomp_Sync_Array_Print,
+ NULL );
+}
+
+Decomp_Sync_Array* _Decomp_Sync_Array_New( DECOMP_SYNC_ARRAY_DEFARGS ) {
+ Decomp_Sync_Array* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(Decomp_Sync_Array) );
+ self = (Decomp_Sync_Array*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* Virtual info */
+
+ /* Decomp_Sync_Array info */
+ _Decomp_Sync_Array_Init( self );
+
+ return self;
+}
+
+void _Decomp_Sync_Array_Init( Decomp_Sync_Array* self ) {
+ self->sync = NULL;
+
+ self->snkArray = NULL;
+ self->snkStride = 0;
+ self->snkDisps = NULL;
+ self->snkSizes = NULL;
+ self->snkOffs = NULL;
+
+ self->srcArray = NULL;
+ self->srcStride = 0;
+ self->srcDisps = NULL;
+ self->srcSizes = NULL;
+ self->srcOffs = NULL;
+
+ self->itemSize = 0;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _Decomp_Sync_Array_Delete( void* sync ) {
+ Decomp_Sync_Array* self = (Decomp_Sync_Array*)sync;
+
+ Decomp_Sync_Array_Destruct( self );
+
+ /* Delete the parent. */
+ _Stg_Class_Delete( self );
+}
+
+void _Decomp_Sync_Array_Print( void* sync, Stream* stream ) {
+ Decomp_Sync_Array* self = (Decomp_Sync_Array*)sync;
+
+ /* Set the Journal for printing informations */
+ Stream* syncStream;
+ syncStream = Journal_Register( InfoStream_Type, "Decomp_Sync_ArrayStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "Decomp_Sync_Array (ptr): (%p)\n", self );
+ _Stg_Class_Print( self, stream );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void Decomp_Sync_Array_SetSync( void* array, Decomp_Sync* sync ) {
+ Decomp_Sync_Array* self = (Decomp_Sync_Array*)array;
+
+ assert( self );
+
+ Decomp_Sync_Array_Destruct( self );
+
+ self->sync = sync;
+ if( sync )
+ List_Append( sync->arrays, &self );
+}
+
+void Decomp_Sync_Array_SetMemory( void* array,
+ void* localArray, void* remoteArray,
+ size_t localStride, size_t remoteStride,
+ size_t itemSize )
+{
+ Decomp_Sync_Array* self = (Decomp_Sync_Array*)array;
+
+ /* Sanity checks. */
+ assert( self );
+ assert( self->sync );
+
+ /* Store information. */
+ self->snkArray = localArray;
+ self->snkStride = localStride;
+ self->srcArray = remoteArray;
+ self->srcStride = remoteStride;
+ self->itemSize = itemSize;
+
+ /* Build this array. */
+ Decomp_Sync_Array_BuildArray( self );
+}
+
+void Decomp_Sync_Array_Sync( void* array ) {
+ Decomp_Sync_Array* self = (Decomp_Sync_Array*)array;
+
+ assert( self );
+
+ Decomp_Sync_SyncArray( self->sync, self );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void Decomp_Sync_Array_BuildArray( Decomp_Sync_Array* self ) {
+ Decomp* decomp;
+ CommTopology* commTopo;
+ unsigned nInc, *inc;
+
+ assert( self );
+ assert( self->sync );
+
+ /* Shortcuts. */
+ decomp = Decomp_Sync_GetDecomp( self->sync );
+ commTopo = Decomp_Sync_GetCommTopology( self->sync );
+
+ /* Extract incidence. */
+ CommTopology_GetIncidence( commTopo, &nInc, &inc );
+
+ if( nInc ) {
+ /* Determine sink (local) information. */
+ if( self->sync->netSnks > 0 ) {
+ unsigned* snkOffs;
+ unsigned* snkSizes;
+ unsigned* snkDisps;
+ unsigned snkInd = 0;
+ unsigned p_i;
+
+ /* Allocate/reallocate memory. */
+ snkDisps = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::snkDisps" );
+ snkSizes = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::snkSizes" );
+ snkOffs = Memory_Alloc_Array( unsigned, self->sync->netSnks, "Decomp_Sync_Array::snkOffs" );
+
+ /* Calculate offsets and sizes. */
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ unsigned snk_i;
+
+ snkSizes[p_i] = 0;
+ for( snk_i = 0; snk_i < self->sync->nSnks[p_i]; snk_i++ ) {
+ unsigned dInd;
+
+ dInd = self->sync->snks[p_i][snk_i];
+ snkOffs[snkInd] = dInd * self->snkStride;
+ snkSizes[p_i] += self->itemSize;
+ snkInd++;
+ }
+ }
+
+ /* Calculate the displacements. */
+ snkDisps[0] = 0;
+ for( p_i = 1; p_i < nInc; p_i++ )
+ snkDisps[p_i] = snkDisps[p_i - 1] + snkSizes[p_i - 1];
+
+ /* Store arrays. */
+ self->snkOffs = snkOffs;
+ self->snkDisps = snkDisps;
+ self->snkSizes = snkSizes;
+ }
+ else {
+ /* Store null information. */
+ self->snkOffs = NULL;
+ self->snkDisps = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::snkDisps" );
+ self->snkSizes = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::snkSizes" );
+ memset( self->snkDisps, 0, nInc * sizeof(unsigned) );
+ memset( self->snkSizes, 0, nInc * sizeof(unsigned) );
+ }
+
+ /* Determine source (shadow) information. */
+ if( self->sync->netSrcs > 0 ) {
+ unsigned* srcOffs;
+ unsigned* srcSizes;
+ unsigned* srcDisps;
+ unsigned srcInd = 0;
+ unsigned p_i;
+
+ /* Allocate/reallocate memory. */
+ srcDisps = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::srcDisps" );
+ srcSizes = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::srcSizes" );
+ srcOffs = Memory_Alloc_Array( unsigned, self->sync->netSrcs, "Decomp_Sync_Array::srcOffs" );
+
+ /* Calculate offsets and sizes. */
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ unsigned src_i;
+
+ srcSizes[p_i] = 0;
+ for( src_i = 0; src_i < self->sync->nSrcs[p_i]; src_i++ ) {
+ unsigned sInd;
+
+ sInd = self->sync->srcs[p_i][src_i];
+ assert( sInd >= Decomp_GetLocalSize( decomp ) );
+ sInd -= Decomp_GetLocalSize( decomp );
+ srcOffs[srcInd] = sInd * self->srcStride;
+ srcSizes[p_i] += self->itemSize;
+ srcInd++;
+ }
+ }
+
+ /* Calculate the displacements. */
+ srcDisps[0] = 0;
+ for( p_i = 1; p_i < nInc; p_i++ )
+ srcDisps[p_i] = srcDisps[p_i - 1] + srcSizes[p_i - 1];
+
+ /* Store arrays. */
+ self->srcOffs = srcOffs;
+ self->srcDisps = srcDisps;
+ self->srcSizes = srcSizes;
+ }
+ else {
+ /* Store null information. */
+ self->srcOffs = NULL;
+ self->srcDisps = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::srcDisps" );
+ self->srcSizes = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync_Array::srcSizes" );
+ memset( self->srcDisps, 0, nInc * sizeof(unsigned) );
+ memset( self->srcSizes, 0, nInc * sizeof(unsigned) );
+ }
+ }
+ else {
+ self->snkOffs = NULL;
+ self->snkDisps = NULL;
+ self->snkSizes = NULL;
+ self->srcOffs = NULL;
+ self->srcDisps = NULL;
+ self->srcSizes = NULL;
+ }
+}
+
+void Decomp_Sync_Array_Destruct( Decomp_Sync_Array* self ) {
+ if( self->sync )
+ List_Remove( self->sync->arrays, &self );
+
+ self->snkArray = NULL;
+ self->snkStride = 0;
+ self->srcArray = NULL;
+ self->srcStride = 0;
+ self->itemSize = 0;
+
+ KillArray( self->snkDisps );
+ KillArray( self->snkSizes );
+ KillArray( self->snkOffs );
+ KillArray( self->srcDisps );
+ KillArray( self->srcSizes );
+ KillArray( self->srcOffs );
+ self->itemSize = 0;
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync_Claim.c
--- a/Mesh/src/Decomp_Sync_Claim.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,270 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: Decomp_Sync_Claim.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-
-#include "types.h"
-#include "shortcuts.h"
-#include "CommTopology.h"
-#include "Decomp.h"
-#include "Decomp_Sync.h"
-#include "Decomp_Sync_Claim.h"
-
-
-/* Textual name of this class */
-const Type Decomp_Sync_Claim_Type = "Decomp_Sync_Claim";
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-Decomp_Sync_Claim* Decomp_Sync_Claim_New( Name name ) {
- return _Decomp_Sync_Claim_New( sizeof(Decomp_Sync_Claim),
- Decomp_Sync_Claim_Type,
- _Decomp_Sync_Claim_Delete,
- _Decomp_Sync_Claim_Print,
- _Decomp_Sync_Claim_Copy,
- (void* (*)(Name))_Decomp_Sync_Claim_New,
- _Decomp_Sync_Claim_Construct,
- _Decomp_Sync_Claim_Build,
- _Decomp_Sync_Claim_Initialise,
- _Decomp_Sync_Claim_Execute,
- _Decomp_Sync_Claim_Destroy,
- name,
- NON_GLOBAL,
- Decomp_Sync_Claim_Select );
-}
-
-Decomp_Sync_Claim* _Decomp_Sync_Claim_New( DECOMP_SYNC_CLAIM_DEFARGS ) {
- Decomp_Sync_Claim* self;
-
- /* Allocate memory */
- assert( sizeOfSelf >= sizeof(Decomp_Sync_Claim) );
- self = (Decomp_Sync_Claim*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
-
- /* Virtual info */
- self->selectFunc = selectFunc;
-
- /* Decomp_Sync_Claim info */
- _Decomp_Sync_Claim_Init( self );
-
- return self;
-}
-
-void _Decomp_Sync_Claim_Init( Decomp_Sync_Claim* self ) {
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _Decomp_Sync_Claim_Delete( void* claim ) {
- Decomp_Sync_Claim* self = (Decomp_Sync_Claim*)claim;
-
- /* Delete the parent. */
- _Stg_Component_Delete( self );
-}
-
-void _Decomp_Sync_Claim_Print( void* claim, Stream* stream ) {
- Decomp_Sync_Claim* self = (Decomp_Sync_Claim*)claim;
-
- /* Set the Journal for printing informations */
- Stream* claimStream;
- claimStream = Journal_Register( InfoStream_Type, "Decomp_Sync_ClaimStream" );
-
- /* Print parent */
- Journal_Printf( stream, "Decomp_Sync_Claim (ptr): (%p)\n", self );
- _Stg_Component_Print( self, stream );
-}
-
-void* _Decomp_Sync_Claim_Copy( void* claim, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
-#if 0
- Decomp_Sync_Claim* self = (Decomp_Sync_Claim*)claim;
- Decomp_Sync_Claim* newDecomp_Sync_Claim;
- PtrMap* map = ptrMap;
- Bool ownMap = False;
-
- /* Damn me for making copying so difficult... what was I thinking? */
-
- /* We need to create a map if it doesn't already exist. */
- if( !map ) {
- map = PtrMap_New( 10 );
- ownMap = True;
- }
-
- newDecomp_Sync_Claim = (Decomp_Sync_Claim*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
-
- /* Copy the virtual methods here. */
-
- /* Deep or shallow? */
- if( deep ) {
- }
- else {
- }
-
- /* If we own the map, get rid of it here. */
- if( ownMap ) Stg_Class_Delete( map );
-
- return (void*)newDecomp_Sync_Claim;
-#endif
-
- return NULL;
-}
-
-void _Decomp_Sync_Claim_Construct( void* claim, Stg_ComponentFactory* cf, void* data ) {
-}
-
-void _Decomp_Sync_Claim_Build( void* claim, void* data ) {
-}
-
-void _Decomp_Sync_Claim_Initialise( void* claim, void* data ) {
-}
-
-void _Decomp_Sync_Claim_Execute( void* claim, void* data ) {
-}
-
-void _Decomp_Sync_Claim_Destroy( void* claim, void* data ) {
-}
-
-void Decomp_Sync_Claim_Select( void* claim, Decomp_Sync* sync, unsigned nRequired, unsigned* required,
- unsigned* nLocals, unsigned** locals )
-{
- Decomp_Sync_Claim* self = (Decomp_Sync_Claim*)claim;
- RangeSet* lSet;
-
- assert( self );
- assert( !nRequired || required );
-
- /* Build a range set of local indices. */
- lSet = RangeSet_New();
- RangeSet_SetIndices( lSet, nRequired, required );
-
- /* Determine ownership. */
- Decomp_Sync_Claim_ClaimOwnership( self, sync->commTopo, nRequired, required, lSet, sync->isects,
- nLocals, locals, &sync->nRemotes, &sync->remotes );
-
- /* Free the local set. */
- FreeObject( lSet );
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-void Decomp_Sync_Claim_ClaimOwnership( Decomp_Sync_Claim* self, CommTopology* topo, unsigned nRequired, unsigned* required,
- RangeSet* lSet, RangeSet** isects,
- unsigned* nLocals, unsigned** locals, unsigned* nRemotes, unsigned** remotes )
-{
- unsigned rank, nProcs;
- MPI_Comm comm;
- unsigned nInc;
- unsigned* inc;
- unsigned nBytes;
- Stg_Byte* bytes;
- RangeSet* tmpClaimed;
- unsigned tag = 6669;
- unsigned p_i, p_j;
-
- /* Get basic MPI info. */
- rank = CommTopology_GetGlobalCommRank( topo );
- nProcs = CommTopology_GetGlobalCommSize( topo );
- comm = CommTopology_GetGlobalComm( topo );
-
- /* Extract our neighbouring processors. */
- CommTopology_GetIncidence( topo, &nInc, &inc );
-
- /* Figure out where info is coming from and going to. Note that the incidence
- is always ordered from lowest to highest rank. */
- tmpClaimed = RangeSet_New();
- for( p_i = 0; p_i < nInc; p_i++ ) {
- MPI_Status status;
-
- if( inc[p_i] > rank )
- break;
-
- /* Receive from neighbour which indices it has taken. */
- MPI_Recv( &nBytes, 1, MPI_UNSIGNED, inc[p_i], tag, comm, &status );
- bytes = Memory_Alloc_Array_Unnamed( Stg_Byte, nBytes );
- MPI_Recv( bytes, nBytes, MPI_BYTE, inc[p_i], tag, comm, &status );
- RangeSet_Unpickle( tmpClaimed, nBytes, bytes );
- FreeArray( bytes );
-
- /* Subtract from our claimed set. */
- RangeSet_Subtraction( lSet, tmpClaimed );
- }
- FreeObject( tmpClaimed );
-
- /* Extract our ownership. */
- Decomp_Sync_Claim_BuildIndices( self, nRequired, required, lSet,
- nLocals, locals, nRemotes, remotes );
-
- /* Update remaining neighbours as to which indices we've taken. */
- for( p_j = p_i; p_j < nInc; p_j++ ) {
- RangeSet* intersect;
-
- intersect = RangeSet_DeepCopy( isects[p_j] );
- RangeSet_Intersection( intersect, lSet );
- RangeSet_Pickle( intersect, &nBytes, &bytes );
- MPI_Send( &nBytes, 1, MPI_UNSIGNED, inc[p_j], tag, comm );
- MPI_Send( bytes, nBytes, MPI_BYTE, inc[p_j], tag, comm );
- FreeArray( bytes );
- }
-}
-
-void Decomp_Sync_Claim_BuildIndices( Decomp_Sync_Claim* self, unsigned nRequired, unsigned* required, RangeSet* claimed,
- unsigned* nLocals, unsigned** locals, unsigned* nRemotes, unsigned** remotes )
-{
- RangeSet* rSet;
-
- /* Extract indices. */
- RangeSet_GetIndices( claimed, nLocals, locals );
-
- /* Build a set of remotes. */
- rSet = RangeSet_New();
- RangeSet_SetIndices( rSet, nRequired, required );
- RangeSet_Subtraction( rSet, claimed );
- RangeSet_GetIndices( rSet, nRemotes, remotes );
-
- /* Destroy rental set. */
- FreeObject( rSet );
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync_Claim.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/Decomp_Sync_Claim.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,270 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: Decomp_Sync_Claim.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+
+#include "types.h"
+#include "shortcuts.h"
+#include "CommTopology.h"
+#include "Decomp.h"
+#include "Decomp_Sync.h"
+#include "Decomp_Sync_Claim.h"
+
+
+/* Textual name of this class */
+const Type Decomp_Sync_Claim_Type = "Decomp_Sync_Claim";
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+Decomp_Sync_Claim* Decomp_Sync_Claim_New( Name name ) {
+ return _Decomp_Sync_Claim_New( sizeof(Decomp_Sync_Claim),
+ Decomp_Sync_Claim_Type,
+ _Decomp_Sync_Claim_Delete,
+ _Decomp_Sync_Claim_Print,
+ _Decomp_Sync_Claim_Copy,
+ (void* (*)(Name))_Decomp_Sync_Claim_New,
+ _Decomp_Sync_Claim_Construct,
+ _Decomp_Sync_Claim_Build,
+ _Decomp_Sync_Claim_Initialise,
+ _Decomp_Sync_Claim_Execute,
+ _Decomp_Sync_Claim_Destroy,
+ name,
+ NON_GLOBAL,
+ Decomp_Sync_Claim_Select );
+}
+
+Decomp_Sync_Claim* _Decomp_Sync_Claim_New( DECOMP_SYNC_CLAIM_DEFARGS ) {
+ Decomp_Sync_Claim* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(Decomp_Sync_Claim) );
+ self = (Decomp_Sync_Claim*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+ /* Virtual info */
+ self->selectFunc = selectFunc;
+
+ /* Decomp_Sync_Claim info */
+ _Decomp_Sync_Claim_Init( self );
+
+ return self;
+}
+
+void _Decomp_Sync_Claim_Init( Decomp_Sync_Claim* self ) {
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _Decomp_Sync_Claim_Delete( void* claim ) {
+ Decomp_Sync_Claim* self = (Decomp_Sync_Claim*)claim;
+
+ /* Delete the parent. */
+ _Stg_Component_Delete( self );
+}
+
+void _Decomp_Sync_Claim_Print( void* claim, Stream* stream ) {
+ Decomp_Sync_Claim* self = (Decomp_Sync_Claim*)claim;
+
+ /* Set the Journal for printing informations */
+ Stream* claimStream;
+ claimStream = Journal_Register( InfoStream_Type, "Decomp_Sync_ClaimStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "Decomp_Sync_Claim (ptr): (%p)\n", self );
+ _Stg_Component_Print( self, stream );
+}
+
+void* _Decomp_Sync_Claim_Copy( void* claim, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+#if 0
+ Decomp_Sync_Claim* self = (Decomp_Sync_Claim*)claim;
+ Decomp_Sync_Claim* newDecomp_Sync_Claim;
+ PtrMap* map = ptrMap;
+ Bool ownMap = False;
+
+ /* Damn me for making copying so difficult... what was I thinking? */
+
+ /* We need to create a map if it doesn't already exist. */
+ if( !map ) {
+ map = PtrMap_New( 10 );
+ ownMap = True;
+ }
+
+ newDecomp_Sync_Claim = (Decomp_Sync_Claim*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
+
+ /* Copy the virtual methods here. */
+
+ /* Deep or shallow? */
+ if( deep ) {
+ }
+ else {
+ }
+
+ /* If we own the map, get rid of it here. */
+ if( ownMap ) Stg_Class_Delete( map );
+
+ return (void*)newDecomp_Sync_Claim;
+#endif
+
+ return NULL;
+}
+
+void _Decomp_Sync_Claim_Construct( void* claim, Stg_ComponentFactory* cf, void* data ) {
+}
+
+void _Decomp_Sync_Claim_Build( void* claim, void* data ) {
+}
+
+void _Decomp_Sync_Claim_Initialise( void* claim, void* data ) {
+}
+
+void _Decomp_Sync_Claim_Execute( void* claim, void* data ) {
+}
+
+void _Decomp_Sync_Claim_Destroy( void* claim, void* data ) {
+}
+
+void Decomp_Sync_Claim_Select( void* claim, Decomp_Sync* sync, unsigned nRequired, unsigned* required,
+ unsigned* nLocals, unsigned** locals )
+{
+ Decomp_Sync_Claim* self = (Decomp_Sync_Claim*)claim;
+ RangeSet* lSet;
+
+ assert( self );
+ assert( !nRequired || required );
+
+ /* Build a range set of local indices. */
+ lSet = RangeSet_New();
+ RangeSet_SetIndices( lSet, nRequired, required );
+
+ /* Determine ownership. */
+ Decomp_Sync_Claim_ClaimOwnership( self, sync->commTopo, nRequired, required, lSet, sync->isects,
+ nLocals, locals, &sync->nRemotes, &sync->remotes );
+
+ /* Free the local set. */
+ FreeObject( lSet );
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void Decomp_Sync_Claim_ClaimOwnership( Decomp_Sync_Claim* self, CommTopology* topo, unsigned nRequired, unsigned* required,
+ RangeSet* lSet, RangeSet** isects,
+ unsigned* nLocals, unsigned** locals, unsigned* nRemotes, unsigned** remotes )
+{
+ unsigned rank, nProcs;
+ MPI_Comm comm;
+ unsigned nInc;
+ unsigned* inc;
+ unsigned nBytes;
+ Stg_Byte* bytes;
+ RangeSet* tmpClaimed;
+ unsigned tag = 6669;
+ unsigned p_i, p_j;
+
+ /* Get basic MPI info. */
+ rank = CommTopology_GetGlobalCommRank( topo );
+ nProcs = CommTopology_GetGlobalCommSize( topo );
+ comm = CommTopology_GetGlobalComm( topo );
+
+ /* Extract our neighbouring processors. */
+ CommTopology_GetIncidence( topo, &nInc, &inc );
+
+ /* Figure out where info is coming from and going to. Note that the incidence
+ is always ordered from lowest to highest rank. */
+ tmpClaimed = RangeSet_New();
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ MPI_Status status;
+
+ if( inc[p_i] > rank )
+ break;
+
+ /* Receive from neighbour which indices it has taken. */
+ MPI_Recv( &nBytes, 1, MPI_UNSIGNED, inc[p_i], tag, comm, &status );
+ bytes = Memory_Alloc_Array_Unnamed( Stg_Byte, nBytes );
+ MPI_Recv( bytes, nBytes, MPI_BYTE, inc[p_i], tag, comm, &status );
+ RangeSet_Unpickle( tmpClaimed, nBytes, bytes );
+ FreeArray( bytes );
+
+ /* Subtract from our claimed set. */
+ RangeSet_Subtraction( lSet, tmpClaimed );
+ }
+ FreeObject( tmpClaimed );
+
+ /* Extract our ownership. */
+ Decomp_Sync_Claim_BuildIndices( self, nRequired, required, lSet,
+ nLocals, locals, nRemotes, remotes );
+
+ /* Update remaining neighbours as to which indices we've taken. */
+ for( p_j = p_i; p_j < nInc; p_j++ ) {
+ RangeSet* intersect;
+
+ intersect = RangeSet_DeepCopy( isects[p_j] );
+ RangeSet_Intersection( intersect, lSet );
+ RangeSet_Pickle( intersect, &nBytes, &bytes );
+ MPI_Send( &nBytes, 1, MPI_UNSIGNED, inc[p_j], tag, comm );
+ MPI_Send( bytes, nBytes, MPI_BYTE, inc[p_j], tag, comm );
+ FreeArray( bytes );
+ }
+}
+
+void Decomp_Sync_Claim_BuildIndices( Decomp_Sync_Claim* self, unsigned nRequired, unsigned* required, RangeSet* claimed,
+ unsigned* nLocals, unsigned** locals, unsigned* nRemotes, unsigned** remotes )
+{
+ RangeSet* rSet;
+
+ /* Extract indices. */
+ RangeSet_GetIndices( claimed, nLocals, locals );
+
+ /* Build a set of remotes. */
+ rSet = RangeSet_New();
+ RangeSet_SetIndices( rSet, nRequired, required );
+ RangeSet_Subtraction( rSet, claimed );
+ RangeSet_GetIndices( rSet, nRemotes, remotes );
+
+ /* Destroy rental set. */
+ FreeObject( rSet );
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync_Negotiate.c
--- a/Mesh/src/Decomp_Sync_Negotiate.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,363 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: Decomp_Sync_Negotiate.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-
-#include "types.h"
-#include "shortcuts.h"
-#include "CommTopology.h"
-#include "Decomp.h"
-#include "Decomp_Sync.h"
-#include "Decomp_Sync_Negotiate.h"
-
-
-/* Textual name of this class */
-const Type Decomp_Sync_Negotiate_Type = "Decomp_Sync_Negotiate";
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-Decomp_Sync_Negotiate* Decomp_Sync_Negotiate_New( Name name ) {
- return _Decomp_Sync_Negotiate_New( sizeof(Decomp_Sync_Negotiate),
- Decomp_Sync_Negotiate_Type,
- _Decomp_Sync_Negotiate_Delete,
- _Decomp_Sync_Negotiate_Print,
- _Decomp_Sync_Negotiate_Copy,
- (void* (*)(Name))_Decomp_Sync_Negotiate_New,
- _Decomp_Sync_Negotiate_Construct,
- _Decomp_Sync_Negotiate_Build,
- _Decomp_Sync_Negotiate_Initialise,
- _Decomp_Sync_Negotiate_Execute,
- _Decomp_Sync_Negotiate_Destroy,
- name,
- NON_GLOBAL,
- Decomp_Sync_Negotiate_Select );
-}
-
-Decomp_Sync_Negotiate* _Decomp_Sync_Negotiate_New( DECOMP_SYNC_NEGOTIATE_DEFARGS ) {
- Decomp_Sync_Negotiate* self;
-
- /* Allocate memory */
- assert( sizeOfSelf >= sizeof(Decomp_Sync_Negotiate) );
- self = (Decomp_Sync_Negotiate*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
-
- /* Virtual info */
- self->selectFunc = selectFunc;
-
- /* Decomp_Sync_Negotiate info */
- _Decomp_Sync_Negotiate_Init( self );
-
- return self;
-}
-
-void _Decomp_Sync_Negotiate_Init( Decomp_Sync_Negotiate* self ) {
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _Decomp_Sync_Negotiate_Delete( void* negotiate ) {
- Decomp_Sync_Negotiate* self = (Decomp_Sync_Negotiate*)negotiate;
-
- /* Delete the parent. */
- _Stg_Component_Delete( self );
-}
-
-void _Decomp_Sync_Negotiate_Print( void* negotiate, Stream* stream ) {
- Decomp_Sync_Negotiate* self = (Decomp_Sync_Negotiate*)negotiate;
-
- /* Set the Journal for printing informations */
- Stream* negotiateStream;
- negotiateStream = Journal_Register( InfoStream_Type, "Decomp_Sync_NegotiateStream" );
-
- /* Print parent */
- Journal_Printf( stream, "Decomp_Sync_Negotiate (ptr): (%p)\n", self );
- _Stg_Component_Print( self, stream );
-}
-
-void* _Decomp_Sync_Negotiate_Copy( void* negotiate, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
-#if 0
- Decomp_Sync_Negotiate* self = (Decomp_Sync_Negotiate*)negotiate;
- Decomp_Sync_Negotiate* newDecomp_Sync_Negotiate;
- PtrMap* map = ptrMap;
- Bool ownMap = False;
-
- /* Damn me for making copying so difficult... what was I thinking? */
-
- /* We need to create a map if it doesn't already exist. */
- if( !map ) {
- map = PtrMap_New( 10 );
- ownMap = True;
- }
-
- newDecomp_Sync_Negotiate = (Decomp_Sync_Negotiate*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
-
- /* Copy the virtual methods here. */
-
- /* Deep or shallow? */
- if( deep ) {
- }
- else {
- }
-
- /* If we own the map, get rid of it here. */
- if( ownMap ) Stg_Class_Delete( map );
-
- return (void*)newDecomp_Sync_Negotiate;
-#endif
-
- return NULL;
-}
-
-void _Decomp_Sync_Negotiate_Construct( void* negotiate, Stg_ComponentFactory* cf, void* data ) {
-}
-
-void _Decomp_Sync_Negotiate_Build( void* negotiate, void* data ) {
-}
-
-void _Decomp_Sync_Negotiate_Initialise( void* negotiate, void* data ) {
-}
-
-void _Decomp_Sync_Negotiate_Execute( void* negotiate, void* data ) {
-}
-
-void _Decomp_Sync_Negotiate_Destroy( void* negotiate, void* data ) {
-}
-
-void Decomp_Sync_Negotiate_Select( void* negotiate, Decomp_Sync* sync ) {
- Decomp_Sync_Negotiate* self = (Decomp_Sync_Negotiate*)negotiate;
- CommTopology* commTopo;
- unsigned rank;
- unsigned nInc;
- unsigned* inc;
- unsigned* nFound;
- unsigned** found;
- unsigned* nUniques;
- unsigned** uniques;
- unsigned mostUniques;
- unsigned** srcs;
- unsigned p_i;
-
- assert( self );
- assert( sync );
- assert( sync->commTopo );
-
- /* Shortcuts. */
- commTopo = sync->commTopo;
- rank = CommTopology_GetGlobalCommRank( commTopo );
-
- /* Locate remote indices. */
- Decomp_Sync_Negotiate_RemoteSearch( self, sync, &nFound, &found );
-
- /* Get processor incidence. */
- CommTopology_GetIncidence( commTopo, &nInc, &inc );
-
- if( nInc ) {
- /* Set up the source arrays. */
- sync->nSrcs = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync::nSrcs" );
- srcs = Memory_Alloc_Array_Unnamed( unsigned*, nInc );
- memset( sync->nSrcs, 0, nInc * sizeof(unsigned) );
- memset( srcs, 0, nInc * sizeof(unsigned*) );
-
- /* Select source procs from which to retrieve required nodes such that communications are minimized. */
- nUniques = Memory_Alloc_Array_Unnamed( unsigned, nInc );
- uniques = Memory_Alloc_2DComplex_Unnamed( unsigned, nInc, nFound );
- memset( nUniques, 0, nInc * sizeof(unsigned) );
-
- do {
- unsigned mostProc = 0;
-
- /* Loop over procs and find unique nodes per proc. ie. the most nodes not already covered by
- an existing source. */
- mostUniques = 0;
- for( p_i = 0; p_i < nInc; p_i++ ) {
- unsigned fnd_i;
-
- /* Clear the number of uniques. */
- nUniques[p_i] = 0;
-
- /* If there are no founds for this proc or we've already sourced it, then skip. */
- if( nFound[p_i] == 0 || sync->nSrcs[p_i] > 0 )
- continue;
-
- /* Hunt down unique global indices. */
- for( fnd_i = 0; fnd_i < nFound[p_i]; fnd_i++ ) {
- unsigned p_j;
-
- for( p_j = 0; p_j < nInc; p_j++ ) {
- unsigned src_i;
-
- for( src_i = 0; src_i < sync->nSrcs[p_i]; src_i++ ) {
- if( srcs[p_i][src_i] == found[p_i][fnd_i] )
- break;
- }
- if( src_i < sync->nSrcs[p_i] )
- break;
- }
- if( p_j == nInc )
- uniques[p_i][nUniques[p_i]++] = found[p_i][fnd_i];
- }
-
- /* Determine which proc has the most uniques and store. */
- if( nUniques[p_i] > mostUniques ) {
- mostUniques = nUniques[p_i];
- mostProc = p_i;
- }
- }
-
- /* Store result. */
- if( mostUniques ) {
- sync->nSrcs[mostProc] = mostUniques;
- if( mostUniques ) {
- srcs[mostProc] = Memory_Alloc_Array_Unnamed( unsigned, mostUniques );
- memcpy( srcs[mostProc], uniques[mostProc], mostUniques * sizeof(unsigned) );
- }
- }
- }
- while( mostUniques );
-
- /* Proper allocation. */
- sync->srcs = Memory_Alloc_2DComplex( unsigned, nInc, sync->nSrcs, "Decomp_Sync::srcs" );
- for( p_i = 0; p_i < nInc; p_i++ ) {
- if( sync->nSrcs[p_i] )
- memcpy( sync->srcs[p_i], srcs[p_i], sync->nSrcs[p_i] * sizeof(unsigned) );
- }
-
- /* Get rid of all the resources so far. */
- FreeArray2D( nInc, srcs );
- FreeArray( nUniques );
- FreeArray( uniques );
-
- /* Communicate back to all procs our selection. Note that even though most procs will not need to send
- anything here, we still need to let them know that. */
- CommTopology_Alltoall( commTopo,
- sync->nSrcs, (void**)sync->srcs,
- &sync->nSnks, (void***)&sync->snks,
- sizeof(unsigned) );
-
- /* Calculate net values for source and sink. */
- for( p_i = 0; p_i < nInc; p_i++ ) {
- sync->netSrcs += sync->nSrcs[p_i];
- sync->netSnks += sync->nSnks[p_i];
- }
- }
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-void Decomp_Sync_Negotiate_RemoteSearch( Decomp_Sync_Negotiate* self, Decomp_Sync* sync,
- unsigned** nRemFound, unsigned*** remFound )
-{
- unsigned* nFound;
- unsigned** found;
- RangeSet* rSet;
- unsigned nBytes;
- Stg_Byte* bytes;
- unsigned* remNBytes;
- unsigned** remBytes;
- RangeSet** remSets;
- unsigned p_i;
-
- assert( self );
- assert( sync );
- assert( nRemFound );
- assert( remFound );
-
- if( sync->commTopo->nInc ) {
- /* Build a range set of our remotes and pickle. */
- rSet = RangeSet_New();
- RangeSet_SetIndices( rSet, sync->nRemotes, sync->remotes );
- RangeSet_Pickle( rSet, &nBytes, &bytes );
-
- /* Broadcast our remotes to neighbours. */
- CommTopology_Allgather( sync->commTopo,
- nBytes, bytes,
- &remNBytes, (void***)&remBytes,
- sizeof(Stg_Byte) );
-
- /* Free bytes. */
- FreeArray( bytes );
-
- /* Unpickle range sets. */
- remSets = Memory_Alloc_Array_Unnamed( RangeSet*, sync->commTopo->nInc );
- for( p_i = 0; p_i < sync->commTopo->nInc; p_i++ ) {
- remSets[p_i] = RangeSet_New();
- RangeSet_Unpickle( remSets[p_i], remNBytes[p_i], (void*)remBytes[p_i] );
- }
-
- /* Free remote bytes. */
- FreeArray( remNBytes );
- FreeArray( remBytes );
-
- /* Replace our remote range set with a local one, then intersect remote sets. */
- RangeSet_SetIndices( rSet, sync->decomp->nLocals, sync->decomp->locals );
- nFound = Memory_Alloc_Array_Unnamed( unsigned, sync->commTopo->nInc );
- found = Memory_Alloc_Array_Unnamed( unsigned*, sync->commTopo->nInc );
- for( p_i = 0; p_i < sync->commTopo->nInc; p_i++ ) {
- RangeSet_Intersection( remSets[p_i], rSet );
- RangeSet_GetIndices( remSets[p_i], nFound + p_i, found + p_i );
- FreeObject( remSets[p_i] );
- }
-
- /* Free remote set array. */
- FreeArray( remSets );
-
- /* Send back all the ones we found and receive from all others all our requireds they found. */
- CommTopology_Alltoall( sync->commTopo,
- nFound, (void**)found,
- nRemFound, (void***)remFound,
- sizeof(unsigned) );
-
- /* Release some memory. */
- FreeArray( nFound );
- FreeArray2D( sync->commTopo->nInc, found );
- }
- else {
- *nRemFound = 0;
- *remFound = NULL;
- }
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomp_Sync_Negotiate.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/Decomp_Sync_Negotiate.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,363 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: Decomp_Sync_Negotiate.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+
+#include "types.h"
+#include "shortcuts.h"
+#include "CommTopology.h"
+#include "Decomp.h"
+#include "Decomp_Sync.h"
+#include "Decomp_Sync_Negotiate.h"
+
+
+/* Textual name of this class */
+const Type Decomp_Sync_Negotiate_Type = "Decomp_Sync_Negotiate";
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+Decomp_Sync_Negotiate* Decomp_Sync_Negotiate_New( Name name ) {
+ return _Decomp_Sync_Negotiate_New( sizeof(Decomp_Sync_Negotiate),
+ Decomp_Sync_Negotiate_Type,
+ _Decomp_Sync_Negotiate_Delete,
+ _Decomp_Sync_Negotiate_Print,
+ _Decomp_Sync_Negotiate_Copy,
+ (void* (*)(Name))_Decomp_Sync_Negotiate_New,
+ _Decomp_Sync_Negotiate_Construct,
+ _Decomp_Sync_Negotiate_Build,
+ _Decomp_Sync_Negotiate_Initialise,
+ _Decomp_Sync_Negotiate_Execute,
+ _Decomp_Sync_Negotiate_Destroy,
+ name,
+ NON_GLOBAL,
+ Decomp_Sync_Negotiate_Select );
+}
+
+Decomp_Sync_Negotiate* _Decomp_Sync_Negotiate_New( DECOMP_SYNC_NEGOTIATE_DEFARGS ) {
+ Decomp_Sync_Negotiate* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(Decomp_Sync_Negotiate) );
+ self = (Decomp_Sync_Negotiate*)_Stg_Component_New( STG_COMPONENT_PASSARGS );
+
+ /* Virtual info */
+ self->selectFunc = selectFunc;
+
+ /* Decomp_Sync_Negotiate info */
+ _Decomp_Sync_Negotiate_Init( self );
+
+ return self;
+}
+
+void _Decomp_Sync_Negotiate_Init( Decomp_Sync_Negotiate* self ) {
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _Decomp_Sync_Negotiate_Delete( void* negotiate ) {
+ Decomp_Sync_Negotiate* self = (Decomp_Sync_Negotiate*)negotiate;
+
+ /* Delete the parent. */
+ _Stg_Component_Delete( self );
+}
+
+void _Decomp_Sync_Negotiate_Print( void* negotiate, Stream* stream ) {
+ Decomp_Sync_Negotiate* self = (Decomp_Sync_Negotiate*)negotiate;
+
+ /* Set the Journal for printing informations */
+ Stream* negotiateStream;
+ negotiateStream = Journal_Register( InfoStream_Type, "Decomp_Sync_NegotiateStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "Decomp_Sync_Negotiate (ptr): (%p)\n", self );
+ _Stg_Component_Print( self, stream );
+}
+
+void* _Decomp_Sync_Negotiate_Copy( void* negotiate, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+#if 0
+ Decomp_Sync_Negotiate* self = (Decomp_Sync_Negotiate*)negotiate;
+ Decomp_Sync_Negotiate* newDecomp_Sync_Negotiate;
+ PtrMap* map = ptrMap;
+ Bool ownMap = False;
+
+ /* Damn me for making copying so difficult... what was I thinking? */
+
+ /* We need to create a map if it doesn't already exist. */
+ if( !map ) {
+ map = PtrMap_New( 10 );
+ ownMap = True;
+ }
+
+ newDecomp_Sync_Negotiate = (Decomp_Sync_Negotiate*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
+
+ /* Copy the virtual methods here. */
+
+ /* Deep or shallow? */
+ if( deep ) {
+ }
+ else {
+ }
+
+ /* If we own the map, get rid of it here. */
+ if( ownMap ) Stg_Class_Delete( map );
+
+ return (void*)newDecomp_Sync_Negotiate;
+#endif
+
+ return NULL;
+}
+
+void _Decomp_Sync_Negotiate_Construct( void* negotiate, Stg_ComponentFactory* cf, void* data ) {
+}
+
+void _Decomp_Sync_Negotiate_Build( void* negotiate, void* data ) {
+}
+
+void _Decomp_Sync_Negotiate_Initialise( void* negotiate, void* data ) {
+}
+
+void _Decomp_Sync_Negotiate_Execute( void* negotiate, void* data ) {
+}
+
+void _Decomp_Sync_Negotiate_Destroy( void* negotiate, void* data ) {
+}
+
+void Decomp_Sync_Negotiate_Select( void* negotiate, Decomp_Sync* sync ) {
+ Decomp_Sync_Negotiate* self = (Decomp_Sync_Negotiate*)negotiate;
+ CommTopology* commTopo;
+ unsigned rank;
+ unsigned nInc;
+ unsigned* inc;
+ unsigned* nFound;
+ unsigned** found;
+ unsigned* nUniques;
+ unsigned** uniques;
+ unsigned mostUniques;
+ unsigned** srcs;
+ unsigned p_i;
+
+ assert( self );
+ assert( sync );
+ assert( sync->commTopo );
+
+ /* Shortcuts. */
+ commTopo = sync->commTopo;
+ rank = CommTopology_GetGlobalCommRank( commTopo );
+
+ /* Locate remote indices. */
+ Decomp_Sync_Negotiate_RemoteSearch( self, sync, &nFound, &found );
+
+ /* Get processor incidence. */
+ CommTopology_GetIncidence( commTopo, &nInc, &inc );
+
+ if( nInc ) {
+ /* Set up the source arrays. */
+ sync->nSrcs = Memory_Alloc_Array( unsigned, nInc, "Decomp_Sync::nSrcs" );
+ srcs = Memory_Alloc_Array_Unnamed( unsigned*, nInc );
+ memset( sync->nSrcs, 0, nInc * sizeof(unsigned) );
+ memset( srcs, 0, nInc * sizeof(unsigned*) );
+
+ /* Select source procs from which to retrieve required nodes such that communications are minimized. */
+ nUniques = Memory_Alloc_Array_Unnamed( unsigned, nInc );
+ uniques = Memory_Alloc_2DComplex_Unnamed( unsigned, nInc, nFound );
+ memset( nUniques, 0, nInc * sizeof(unsigned) );
+
+ do {
+ unsigned mostProc = 0;
+
+ /* Loop over procs and find unique nodes per proc. ie. the most nodes not already covered by
+ an existing source. */
+ mostUniques = 0;
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ unsigned fnd_i;
+
+ /* Clear the number of uniques. */
+ nUniques[p_i] = 0;
+
+ /* If there are no founds for this proc or we've already sourced it, then skip. */
+ if( nFound[p_i] == 0 || sync->nSrcs[p_i] > 0 )
+ continue;
+
+ /* Hunt down unique global indices. */
+ for( fnd_i = 0; fnd_i < nFound[p_i]; fnd_i++ ) {
+ unsigned p_j;
+
+ for( p_j = 0; p_j < nInc; p_j++ ) {
+ unsigned src_i;
+
+ for( src_i = 0; src_i < sync->nSrcs[p_i]; src_i++ ) {
+ if( srcs[p_i][src_i] == found[p_i][fnd_i] )
+ break;
+ }
+ if( src_i < sync->nSrcs[p_i] )
+ break;
+ }
+ if( p_j == nInc )
+ uniques[p_i][nUniques[p_i]++] = found[p_i][fnd_i];
+ }
+
+ /* Determine which proc has the most uniques and store. */
+ if( nUniques[p_i] > mostUniques ) {
+ mostUniques = nUniques[p_i];
+ mostProc = p_i;
+ }
+ }
+
+ /* Store result. */
+ if( mostUniques ) {
+ sync->nSrcs[mostProc] = mostUniques;
+ if( mostUniques ) {
+ srcs[mostProc] = Memory_Alloc_Array_Unnamed( unsigned, mostUniques );
+ memcpy( srcs[mostProc], uniques[mostProc], mostUniques * sizeof(unsigned) );
+ }
+ }
+ }
+ while( mostUniques );
+
+ /* Proper allocation. */
+ sync->srcs = Memory_Alloc_2DComplex( unsigned, nInc, sync->nSrcs, "Decomp_Sync::srcs" );
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ if( sync->nSrcs[p_i] )
+ memcpy( sync->srcs[p_i], srcs[p_i], sync->nSrcs[p_i] * sizeof(unsigned) );
+ }
+
+ /* Get rid of all the resources so far. */
+ FreeArray2D( nInc, srcs );
+ FreeArray( nUniques );
+ FreeArray( uniques );
+
+ /* Communicate back to all procs our selection. Note that even though most procs will not need to send
+ anything here, we still need to let them know that. */
+ CommTopology_Alltoall( commTopo,
+ sync->nSrcs, (void**)sync->srcs,
+ &sync->nSnks, (void***)&sync->snks,
+ sizeof(unsigned) );
+
+ /* Calculate net values for source and sink. */
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ sync->netSrcs += sync->nSrcs[p_i];
+ sync->netSnks += sync->nSnks[p_i];
+ }
+ }
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void Decomp_Sync_Negotiate_RemoteSearch( Decomp_Sync_Negotiate* self, Decomp_Sync* sync,
+ unsigned** nRemFound, unsigned*** remFound )
+{
+ unsigned* nFound;
+ unsigned** found;
+ RangeSet* rSet;
+ unsigned nBytes;
+ Stg_Byte* bytes;
+ unsigned* remNBytes;
+ unsigned** remBytes;
+ RangeSet** remSets;
+ unsigned p_i;
+
+ assert( self );
+ assert( sync );
+ assert( nRemFound );
+ assert( remFound );
+
+ if( sync->commTopo->nInc ) {
+ /* Build a range set of our remotes and pickle. */
+ rSet = RangeSet_New();
+ RangeSet_SetIndices( rSet, sync->nRemotes, sync->remotes );
+ RangeSet_Pickle( rSet, &nBytes, &bytes );
+
+ /* Broadcast our remotes to neighbours. */
+ CommTopology_Allgather( sync->commTopo,
+ nBytes, bytes,
+ &remNBytes, (void***)&remBytes,
+ sizeof(Stg_Byte) );
+
+ /* Free bytes. */
+ FreeArray( bytes );
+
+ /* Unpickle range sets. */
+ remSets = Memory_Alloc_Array_Unnamed( RangeSet*, sync->commTopo->nInc );
+ for( p_i = 0; p_i < sync->commTopo->nInc; p_i++ ) {
+ remSets[p_i] = RangeSet_New();
+ RangeSet_Unpickle( remSets[p_i], remNBytes[p_i], (void*)remBytes[p_i] );
+ }
+
+ /* Free remote bytes. */
+ FreeArray( remNBytes );
+ FreeArray( remBytes );
+
+ /* Replace our remote range set with a local one, then intersect remote sets. */
+ RangeSet_SetIndices( rSet, sync->decomp->nLocals, sync->decomp->locals );
+ nFound = Memory_Alloc_Array_Unnamed( unsigned, sync->commTopo->nInc );
+ found = Memory_Alloc_Array_Unnamed( unsigned*, sync->commTopo->nInc );
+ for( p_i = 0; p_i < sync->commTopo->nInc; p_i++ ) {
+ RangeSet_Intersection( remSets[p_i], rSet );
+ RangeSet_GetIndices( remSets[p_i], nFound + p_i, found + p_i );
+ FreeObject( remSets[p_i] );
+ }
+
+ /* Free remote set array. */
+ FreeArray( remSets );
+
+ /* Send back all the ones we found and receive from all others all our requireds they found. */
+ CommTopology_Alltoall( sync->commTopo,
+ nFound, (void**)found,
+ nRemFound, (void***)remFound,
+ sizeof(unsigned) );
+
+ /* Release some memory. */
+ FreeArray( nFound );
+ FreeArray2D( sync->commTopo->nInc, found );
+ }
+ else {
+ *nRemFound = 0;
+ *remFound = NULL;
+ }
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomposer.c
--- a/Mesh/src/Decomposer.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,463 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: Decomposer.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-#include "Mesh.h"
-
-
-/* Textual name of this class */
-const Type Decomposer_Type = "Decomposer";
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-Decomposer* Decomposer_New( Name name ) {
- return _Decomposer_New( sizeof(Decomposer),
- Decomposer_Type,
- _Decomposer_Delete,
- _Decomposer_Print,
- NULL,
- _Decomposer_Decompose );
-}
-
-Decomposer* _Decomposer_New( DECOMPOSER_DEFARGS ) {
- Decomposer* self;
-
- /* Allocate memory */
- assert( sizeOfSelf >= sizeof(Decomposer) );
- self = (Decomposer*)_Stg_Class_New( STG_CLASS_PASSARGS );
-
- /* Virtual info */
- self->decomposeFunc = decomposeFunc;
-
- /* Decomposer info */
- _Decomposer_Init( self );
-
- return self;
-}
-
-void _Decomposer_Init( Decomposer* self ) {
- self->comm = MPI_COMM_WORLD;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _Decomposer_Delete( void* decomposer ) {
- Decomposer* self = (Decomposer*)decomposer;
-
- /* Delete the parent. */
- _Stg_Class_Delete( self );
-}
-
-void _Decomposer_Print( void* decomposer, Stream* stream ) {
- Decomposer* self = (Decomposer*)decomposer;
-
- /* Set the Journal for printing informations */
- Stream* decomposerStream;
- decomposerStream = Journal_Register( InfoStream_Type, "DecomposerStream" );
-
- /* Print parent */
- Journal_Printf( stream, "Decomposer (ptr): (%p)\n", self );
- _Stg_Class_Print( self, stream );
-}
-
-void _Decomposer_Decompose( void* decomposer, unsigned nDomains, unsigned* domains,
- CommTopology** commTopo, Decomp** decomp, Decomp_Sync** sync )
-{
- Decomposer* self = (Decomposer*)decomposer;
- CommTopology* tmpCommTopo;
- Decomp* tmpDecomp;
- RangeSet** isects;
-
- assert( self );
- assert( sync );
-
- if( commTopo && *commTopo ) {
- Decomposer_BuildLocalIntersections( self, nDomains, domains,
- *commTopo, &isects );
- tmpCommTopo = *commTopo;
- }
- else {
- Decomposer_BuildCommTopology( self, nDomains, domains,
- &tmpCommTopo, &isects );
-
- /* Keep communication topology? */
- if( commTopo )
- *commTopo = tmpCommTopo;
- }
-
- Decomposer_Claim( self, tmpCommTopo, isects, nDomains, domains,
- &tmpDecomp, sync );
-
- /* Interested in keeping decomp? */
- if( decomp )
- *decomp = tmpDecomp;
-}
-
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void Decomposer_SetComm( void* decomposer, MPI_Comm comm ) {
- Decomposer* self = (Decomposer*)decomposer;
-
- assert( self );
-
- self->comm = comm;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-void Decomposer_BuildCommTopology( Decomposer* self, unsigned nDomains, unsigned* domains,
- CommTopology** commTopo, RangeSet*** isects )
-{
- unsigned rank, nProcs;
- RangeSet* lSet;
- MPI_Group worldGroup;
- unsigned* worldRanks;
- unsigned* subRanks;
- unsigned nCommInc;
- unsigned* commInc;
- RangeSet** iSets;
- unsigned nInc;
- unsigned* inc;
- unsigned p_i;
-
- assert( self );
- assert( !nDomains || domains );
- assert( commTopo );
- assert( isects );
-
- /* Get basic MPI info. */
- MPI_Comm_rank( self->comm, (int*)&rank );
- MPI_Comm_size( self->comm, (int*)&nProcs );
-
- /* We'll need to modify the world group. */
- MPI_Comm_group( self->comm, &worldGroup );
- worldRanks = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
- subRanks = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
-
- /* We need space to store index intersections. */
- iSets = Memory_Alloc_Array_Unnamed( RangeSet*, nProcs );
- memset( iSets, 0, nProcs * sizeof(RangeSet*) );
-
- /* Create a local set of required indices. */
- lSet = RangeSet_New();
- RangeSet_SetIndices( lSet, nDomains, domains );
-
- /* Tackle each processor one at a time. */
- for( p_i = 0; p_i < nProcs - 1; p_i++ ) {
- int groupRange[3];
- MPI_Group subGroup;
- MPI_Comm subComm;
- unsigned p_j;
-
- /* Set the processor range. */
- groupRange[0] = p_i;
- groupRange[1] = nProcs - 1;
- groupRange[2] = 1;
-
- /* We'll need a new group, as we only want to communicate using a triangular scheme. */
- MPI_Group_range_incl( worldGroup, 1, &groupRange, &subGroup );
- MPI_Comm_create( self->comm, subGroup, &subComm );
-
- /* Only continue if we're part of the sub-communicator. */
- if( rank >= p_i ) {
- unsigned nBytes;
- Stg_Byte* bytes;
- unsigned* nFounds;
- Stg_Byte** founds;
-
- /* Create a mapping between ranks. */
- for( p_j = p_i; p_j < nProcs; p_j++ )
- subRanks[p_j] = p_j - p_i;
- MPI_Group_translate_ranks( subGroup, nProcs - p_i, (int*)(subRanks + p_i),
- worldGroup, (int*)worldRanks );
-
- if( p_i == rank )
- RangeSet_Pickle( lSet, &nBytes, &bytes );
-
- MPIArray_Bcast( &nBytes, (void**)&bytes, sizeof(Stg_Byte), subRanks[p_i], subComm );
-
- if( p_i != rank ) {
- /* Create the intersection. */
- iSets[p_i] = RangeSet_New();
- RangeSet_Unpickle( iSets[p_i], nBytes, bytes );
- RangeSet_Intersection( iSets[p_i], lSet );
-
- /* Pickle the intersection to send back. */
- FreeArray( bytes );
- RangeSet_Pickle( iSets[p_i], &nBytes, &bytes );
- }
- else {
- KillArray( bytes );
- nBytes = 0;
- }
-
- /* Retrieve the results and unpickle each of them. */
- MPIArray_Gather( nBytes, bytes, &nFounds, (void***)&founds, sizeof(Stg_Byte),
- subRanks[p_i], subComm );
- if( p_i == rank ) {
- for( p_j = 0; p_j < nProcs - p_i; p_j++ ) {
- if( !nFounds[p_j] )
- continue;
-
- iSets[worldRanks[p_j]] = RangeSet_New();
- RangeSet_Unpickle( iSets[worldRanks[p_j]], nFounds[p_j], founds[p_j] );
- }
-
- /* Free the found arrays. */
- FreeArray( nFounds );
- FreeArray( founds );
- }
- else {
- /* Free pickled range set. */
- FreeArray( bytes );
- }
-
- /* Destroy the sub-communicator. */
- MPI_Comm_free( &subComm );
- }
-
- /* Destroy the sub-group. */
- MPI_Group_free( &subGroup );
- }
-
- /* Free rank translation arrays and local range set. */
- FreeArray( worldRanks );
- FreeArray( subRanks );
-
- /* Build a set of communication incidence. */
- nCommInc = 0;
- commInc = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
- for( p_i = 0; p_i < nProcs; p_i++ ) {
- if( iSets[p_i] && iSets[p_i]->nInds )
- commInc[nCommInc++] = p_i;
- }
-
- /* Create the communication topology, unless one has already been specified. */
- *commTopo = CommTopology_New();
- CommTopology_SetComm( *commTopo, self->comm );
- CommTopology_SetIncidence( *commTopo, nCommInc, commInc );
- FreeArray( commInc );
-
- /* Build final intersections. */
- CommTopology_GetIncidence( *commTopo, &nInc, &inc );
- if( nInc ) {
- unsigned inc_i;
-
- *isects = Memory_Alloc_Array_Unnamed( RangeSet*, nInc );
- for( inc_i = 0; inc_i < nInc; inc_i++ )
- (*isects)[inc_i] = iSets[inc[inc_i]];
- }
- else
- *isects = NULL;
-
- /* Free intersection array. */
- FreeArray( iSets );
-}
-
-void Decomposer_BuildLocalIntersections( Decomposer* self, unsigned nDomains, unsigned* domains,
- CommTopology* commTopo, RangeSet*** isects )
-{
- unsigned nIncRanks;
- RangeSet* lSet;
- unsigned nBytes, *nRemBytes, *nFndBytes;
- Stg_Byte *bytes, **remBytes, **fndBytes;
- unsigned p_i;
-
- assert( self );
- assert( !nDomains || domains );
- assert( commTopo );
- assert( isects );
-
- /* Get some crap. */
- nIncRanks = CommTopology_GetIncidenceSize( commTopo );
-
- /* We need space to store index intersections. */
- *isects = Memory_Alloc_Array_Unnamed( RangeSet*, nIncRanks );
- memset( *isects, 0, nIncRanks * sizeof(RangeSet*) );
-
- /* Create a local set of required indices, send to everyone. */
- lSet = RangeSet_New();
- RangeSet_SetIndices( lSet, nDomains, domains );
- RangeSet_Pickle( lSet, &nBytes, &bytes );
- CommTopology_Allgather( commTopo,
- nBytes, bytes,
- &nRemBytes, &remBytes,
- sizeof(Stg_Byte) );
-
- /* Done with bytes. */
- FreeArray( bytes );
-
- /* Build intersections. */
- for( p_i = 0; p_i < nIncRanks; p_i++ ) {
- (*isects)[p_i] = RangeSet_New();
- RangeSet_Unpickle( (*isects)[p_i], nRemBytes[p_i], remBytes[p_i] );
- RangeSet_Intersection( (*isects)[p_i], lSet );
- FreeArray( remBytes[p_i] );
- RangeSet_Pickle( (*isects)[p_i], nRemBytes + p_i, remBytes + p_i );
- }
-
- /* Send back. */
- CommTopology_Alltoall( commTopo,
- nRemBytes, remBytes,
- &nFndBytes, &fndBytes,
- sizeof(Stg_Byte) );
-
- /* Free unused arrays. */
- FreeArray( nRemBytes );
- FreeArray2D( nIncRanks, remBytes );
-
- /* Extract our intersections. */
- for( p_i = 0; p_i < nIncRanks; p_i++ )
- RangeSet_Unpickle( (*isects)[p_i], nFndBytes[p_i], fndBytes[p_i] );
-
- /* Free remaining arrays. */
- FreeArray( nFndBytes );
- FreeArray2D( nIncRanks, fndBytes );
-}
-
-void Decomposer_Claim( Decomposer* self, CommTopology* commTopo, RangeSet** isects,
- unsigned nDomains, unsigned* domains,
- Decomp** decomp, Decomp_Sync** sync )
-{
- unsigned rank, nProcs;
- MPI_Comm comm;
- unsigned nInc;
- unsigned* inc;
- RangeSet* lSet;
- unsigned nBytes;
- Stg_Byte* bytes;
- RangeSet* tmpClaimed;
- unsigned tag = 6669;
- unsigned p_i, p_j;
-
- /* Get basic MPI info. */
- comm = CommTopology_GetComm( commTopo );
- MPI_Comm_rank( comm, (int*)&rank );
- MPI_Comm_size( comm, (int*)&nProcs );
-
- /* Build a set of domains. */
- lSet = RangeSet_New();
- RangeSet_SetIndices( lSet, nDomains, domains );
-
- /* Extract our neighbouring processors. */
- CommTopology_GetIncidence( commTopo, &nInc, &inc );
-
- /* Figure out where info is coming from and going to. Note that the incidence
- is always ordered from lowest to highest rank. */
- tmpClaimed = RangeSet_New();
- for( p_i = 0; p_i < nInc; p_i++ ) {
- MPI_Status status;
-
- if( inc[p_i] > rank )
- break;
-
- /* Receive from neighbour which indices it has taken. */
- MPI_Recv( &nBytes, 1, MPI_UNSIGNED, inc[p_i], tag, comm, &status );
- bytes = Memory_Alloc_Array_Unnamed( Stg_Byte, nBytes );
- MPI_Recv( bytes, nBytes, MPI_BYTE, inc[p_i], tag, comm, &status );
- RangeSet_Unpickle( tmpClaimed, nBytes, bytes );
- FreeArray( bytes );
-
- /* Subtract from our claimed set. */
- RangeSet_Subtraction( lSet, tmpClaimed );
- }
- FreeObject( tmpClaimed );
-
- /* Update remaining neighbours as to which indices we've taken. */
- for( p_j = p_i; p_j < nInc; p_j++ ) {
- RangeSet* intersect;
-
- intersect = RangeSet_DeepCopy( isects[p_j] );
- RangeSet_Intersection( intersect, lSet );
- RangeSet_Pickle( intersect, &nBytes, &bytes );
- MPI_Send( &nBytes, 1, MPI_UNSIGNED, inc[p_j], tag, comm );
- MPI_Send( bytes, nBytes, MPI_BYTE, inc[p_j], tag, comm );
- FreeArray( bytes );
- FreeObject( intersect );
- }
-
- /* Extract our ownership. */
- Decomposer_BuildIndices( self, nDomains, domains, lSet,
- commTopo, decomp, sync );
-
- /* Free local range set. */
- FreeObject( lSet );
-}
-
-void Decomposer_BuildIndices( Decomposer* self, unsigned nDomains, unsigned* domains, RangeSet* claimed,
- CommTopology* commTopo, Decomp** decomp, Decomp_Sync** sync )
-{
- RangeSet* rSet;
- unsigned nLocals, *locals;
- unsigned nRemotes, *remotes;
-
- /* Extract local indices. */
- *decomp = Decomp_New();
- Decomp_SetComm( *decomp, self->comm );
- locals = NULL;
- RangeSet_GetIndices( claimed, &nLocals, &locals );
- Decomp_SetLocals( *decomp, nLocals, locals );
- FreeArray( locals );
-
- /* Build a set of remotes. */
- rSet = RangeSet_New();
- RangeSet_SetIndices( rSet, nDomains, domains );
- RangeSet_Subtraction( rSet, claimed );
-
- /* Set remote indices. */
- *sync = Decomp_Sync_New();
- Decomp_Sync_SetDecomp( *sync, *decomp );
- Decomp_Sync_SetCommTopology( *sync, commTopo );
- remotes = NULL;
- RangeSet_GetIndices( rSet, &nRemotes, &remotes );
- Decomp_Sync_SetRemotes( *sync, nRemotes, remotes );
- FreeArray( remotes );
-
- /* Destroy rental set. */
- FreeObject( rSet );
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/Decomposer.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/Decomposer.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,463 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: Decomposer.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include "Mesh.h"
+
+
+/* Textual name of this class */
+const Type Decomposer_Type = "Decomposer";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+Decomposer* Decomposer_New( Name name ) {
+ return _Decomposer_New( sizeof(Decomposer),
+ Decomposer_Type,
+ _Decomposer_Delete,
+ _Decomposer_Print,
+ NULL,
+ _Decomposer_Decompose );
+}
+
+Decomposer* _Decomposer_New( DECOMPOSER_DEFARGS ) {
+ Decomposer* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(Decomposer) );
+ self = (Decomposer*)_Stg_Class_New( STG_CLASS_PASSARGS );
+
+ /* Virtual info */
+ self->decomposeFunc = decomposeFunc;
+
+ /* Decomposer info */
+ _Decomposer_Init( self );
+
+ return self;
+}
+
+void _Decomposer_Init( Decomposer* self ) {
+ self->comm = MPI_COMM_WORLD;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _Decomposer_Delete( void* decomposer ) {
+ Decomposer* self = (Decomposer*)decomposer;
+
+ /* Delete the parent. */
+ _Stg_Class_Delete( self );
+}
+
+void _Decomposer_Print( void* decomposer, Stream* stream ) {
+ Decomposer* self = (Decomposer*)decomposer;
+
+ /* Set the Journal for printing informations */
+ Stream* decomposerStream;
+ decomposerStream = Journal_Register( InfoStream_Type, "DecomposerStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "Decomposer (ptr): (%p)\n", self );
+ _Stg_Class_Print( self, stream );
+}
+
+void _Decomposer_Decompose( void* decomposer, unsigned nDomains, unsigned* domains,
+ CommTopology** commTopo, Decomp** decomp, Decomp_Sync** sync )
+{
+ Decomposer* self = (Decomposer*)decomposer;
+ CommTopology* tmpCommTopo;
+ Decomp* tmpDecomp;
+ RangeSet** isects;
+
+ assert( self );
+ assert( sync );
+
+ if( commTopo && *commTopo ) {
+ Decomposer_BuildLocalIntersections( self, nDomains, domains,
+ *commTopo, &isects );
+ tmpCommTopo = *commTopo;
+ }
+ else {
+ Decomposer_BuildCommTopology( self, nDomains, domains,
+ &tmpCommTopo, &isects );
+
+ /* Keep communication topology? */
+ if( commTopo )
+ *commTopo = tmpCommTopo;
+ }
+
+ Decomposer_Claim( self, tmpCommTopo, isects, nDomains, domains,
+ &tmpDecomp, sync );
+
+ /* Interested in keeping decomp? */
+ if( decomp )
+ *decomp = tmpDecomp;
+}
+
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void Decomposer_SetComm( void* decomposer, MPI_Comm comm ) {
+ Decomposer* self = (Decomposer*)decomposer;
+
+ assert( self );
+
+ self->comm = comm;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void Decomposer_BuildCommTopology( Decomposer* self, unsigned nDomains, unsigned* domains,
+ CommTopology** commTopo, RangeSet*** isects )
+{
+ unsigned rank, nProcs;
+ RangeSet* lSet;
+ MPI_Group worldGroup;
+ unsigned* worldRanks;
+ unsigned* subRanks;
+ unsigned nCommInc;
+ unsigned* commInc;
+ RangeSet** iSets;
+ unsigned nInc;
+ unsigned* inc;
+ unsigned p_i;
+
+ assert( self );
+ assert( !nDomains || domains );
+ assert( commTopo );
+ assert( isects );
+
+ /* Get basic MPI info. */
+ MPI_Comm_rank( self->comm, (int*)&rank );
+ MPI_Comm_size( self->comm, (int*)&nProcs );
+
+ /* We'll need to modify the world group. */
+ MPI_Comm_group( self->comm, &worldGroup );
+ worldRanks = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
+ subRanks = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
+
+ /* We need space to store index intersections. */
+ iSets = Memory_Alloc_Array_Unnamed( RangeSet*, nProcs );
+ memset( iSets, 0, nProcs * sizeof(RangeSet*) );
+
+ /* Create a local set of required indices. */
+ lSet = RangeSet_New();
+ RangeSet_SetIndices( lSet, nDomains, domains );
+
+ /* Tackle each processor one at a time. */
+ for( p_i = 0; p_i < nProcs - 1; p_i++ ) {
+ int groupRange[3];
+ MPI_Group subGroup;
+ MPI_Comm subComm;
+ unsigned p_j;
+
+ /* Set the processor range. */
+ groupRange[0] = p_i;
+ groupRange[1] = nProcs - 1;
+ groupRange[2] = 1;
+
+ /* We'll need a new group, as we only want to communicate using a triangular scheme. */
+ MPI_Group_range_incl( worldGroup, 1, &groupRange, &subGroup );
+ MPI_Comm_create( self->comm, subGroup, &subComm );
+
+ /* Only continue if we're part of the sub-communicator. */
+ if( rank >= p_i ) {
+ unsigned nBytes;
+ Stg_Byte* bytes;
+ unsigned* nFounds;
+ Stg_Byte** founds;
+
+ /* Create a mapping between ranks. */
+ for( p_j = p_i; p_j < nProcs; p_j++ )
+ subRanks[p_j] = p_j - p_i;
+ MPI_Group_translate_ranks( subGroup, nProcs - p_i, (int*)(subRanks + p_i),
+ worldGroup, (int*)worldRanks );
+
+ if( p_i == rank )
+ RangeSet_Pickle( lSet, &nBytes, &bytes );
+
+ MPIArray_Bcast( &nBytes, (void**)&bytes, sizeof(Stg_Byte), subRanks[p_i], subComm );
+
+ if( p_i != rank ) {
+ /* Create the intersection. */
+ iSets[p_i] = RangeSet_New();
+ RangeSet_Unpickle( iSets[p_i], nBytes, bytes );
+ RangeSet_Intersection( iSets[p_i], lSet );
+
+ /* Pickle the intersection to send back. */
+ FreeArray( bytes );
+ RangeSet_Pickle( iSets[p_i], &nBytes, &bytes );
+ }
+ else {
+ KillArray( bytes );
+ nBytes = 0;
+ }
+
+ /* Retrieve the results and unpickle each of them. */
+ MPIArray_Gather( nBytes, bytes, &nFounds, (void***)&founds, sizeof(Stg_Byte),
+ subRanks[p_i], subComm );
+ if( p_i == rank ) {
+ for( p_j = 0; p_j < nProcs - p_i; p_j++ ) {
+ if( !nFounds[p_j] )
+ continue;
+
+ iSets[worldRanks[p_j]] = RangeSet_New();
+ RangeSet_Unpickle( iSets[worldRanks[p_j]], nFounds[p_j], founds[p_j] );
+ }
+
+ /* Free the found arrays. */
+ FreeArray( nFounds );
+ FreeArray( founds );
+ }
+ else {
+ /* Free pickled range set. */
+ FreeArray( bytes );
+ }
+
+ /* Destroy the sub-communicator. */
+ MPI_Comm_free( &subComm );
+ }
+
+ /* Destroy the sub-group. */
+ MPI_Group_free( &subGroup );
+ }
+
+ /* Free rank translation arrays and local range set. */
+ FreeArray( worldRanks );
+ FreeArray( subRanks );
+
+ /* Build a set of communication incidence. */
+ nCommInc = 0;
+ commInc = Memory_Alloc_Array_Unnamed( unsigned, nProcs );
+ for( p_i = 0; p_i < nProcs; p_i++ ) {
+ if( iSets[p_i] && iSets[p_i]->nInds )
+ commInc[nCommInc++] = p_i;
+ }
+
+ /* Create the communication topology, unless one has already been specified. */
+ *commTopo = CommTopology_New();
+ CommTopology_SetComm( *commTopo, self->comm );
+ CommTopology_SetIncidence( *commTopo, nCommInc, commInc );
+ FreeArray( commInc );
+
+ /* Build final intersections. */
+ CommTopology_GetIncidence( *commTopo, &nInc, &inc );
+ if( nInc ) {
+ unsigned inc_i;
+
+ *isects = Memory_Alloc_Array_Unnamed( RangeSet*, nInc );
+ for( inc_i = 0; inc_i < nInc; inc_i++ )
+ (*isects)[inc_i] = iSets[inc[inc_i]];
+ }
+ else
+ *isects = NULL;
+
+ /* Free intersection array. */
+ FreeArray( iSets );
+}
+
+void Decomposer_BuildLocalIntersections( Decomposer* self, unsigned nDomains, unsigned* domains,
+ CommTopology* commTopo, RangeSet*** isects )
+{
+ unsigned nIncRanks;
+ RangeSet* lSet;
+ unsigned nBytes, *nRemBytes, *nFndBytes;
+ Stg_Byte *bytes, **remBytes, **fndBytes;
+ unsigned p_i;
+
+ assert( self );
+ assert( !nDomains || domains );
+ assert( commTopo );
+ assert( isects );
+
+ /* Get some crap. */
+ nIncRanks = CommTopology_GetIncidenceSize( commTopo );
+
+ /* We need space to store index intersections. */
+ *isects = Memory_Alloc_Array_Unnamed( RangeSet*, nIncRanks );
+ memset( *isects, 0, nIncRanks * sizeof(RangeSet*) );
+
+ /* Create a local set of required indices, send to everyone. */
+ lSet = RangeSet_New();
+ RangeSet_SetIndices( lSet, nDomains, domains );
+ RangeSet_Pickle( lSet, &nBytes, &bytes );
+ CommTopology_Allgather( commTopo,
+ nBytes, bytes,
+ &nRemBytes, &remBytes,
+ sizeof(Stg_Byte) );
+
+ /* Done with bytes. */
+ FreeArray( bytes );
+
+ /* Build intersections. */
+ for( p_i = 0; p_i < nIncRanks; p_i++ ) {
+ (*isects)[p_i] = RangeSet_New();
+ RangeSet_Unpickle( (*isects)[p_i], nRemBytes[p_i], remBytes[p_i] );
+ RangeSet_Intersection( (*isects)[p_i], lSet );
+ FreeArray( remBytes[p_i] );
+ RangeSet_Pickle( (*isects)[p_i], nRemBytes + p_i, remBytes + p_i );
+ }
+
+ /* Send back. */
+ CommTopology_Alltoall( commTopo,
+ nRemBytes, remBytes,
+ &nFndBytes, &fndBytes,
+ sizeof(Stg_Byte) );
+
+ /* Free unused arrays. */
+ FreeArray( nRemBytes );
+ FreeArray2D( nIncRanks, remBytes );
+
+ /* Extract our intersections. */
+ for( p_i = 0; p_i < nIncRanks; p_i++ )
+ RangeSet_Unpickle( (*isects)[p_i], nFndBytes[p_i], fndBytes[p_i] );
+
+ /* Free remaining arrays. */
+ FreeArray( nFndBytes );
+ FreeArray2D( nIncRanks, fndBytes );
+}
+
+void Decomposer_Claim( Decomposer* self, CommTopology* commTopo, RangeSet** isects,
+ unsigned nDomains, unsigned* domains,
+ Decomp** decomp, Decomp_Sync** sync )
+{
+ unsigned rank, nProcs;
+ MPI_Comm comm;
+ unsigned nInc;
+ unsigned* inc;
+ RangeSet* lSet;
+ unsigned nBytes;
+ Stg_Byte* bytes;
+ RangeSet* tmpClaimed;
+ unsigned tag = 6669;
+ unsigned p_i, p_j;
+
+ /* Get basic MPI info. */
+ comm = CommTopology_GetComm( commTopo );
+ MPI_Comm_rank( comm, (int*)&rank );
+ MPI_Comm_size( comm, (int*)&nProcs );
+
+ /* Build a set of domains. */
+ lSet = RangeSet_New();
+ RangeSet_SetIndices( lSet, nDomains, domains );
+
+ /* Extract our neighbouring processors. */
+ CommTopology_GetIncidence( commTopo, &nInc, &inc );
+
+ /* Figure out where info is coming from and going to. Note that the incidence
+ is always ordered from lowest to highest rank. */
+ tmpClaimed = RangeSet_New();
+ for( p_i = 0; p_i < nInc; p_i++ ) {
+ MPI_Status status;
+
+ if( inc[p_i] > rank )
+ break;
+
+ /* Receive from neighbour which indices it has taken. */
+ MPI_Recv( &nBytes, 1, MPI_UNSIGNED, inc[p_i], tag, comm, &status );
+ bytes = Memory_Alloc_Array_Unnamed( Stg_Byte, nBytes );
+ MPI_Recv( bytes, nBytes, MPI_BYTE, inc[p_i], tag, comm, &status );
+ RangeSet_Unpickle( tmpClaimed, nBytes, bytes );
+ FreeArray( bytes );
+
+ /* Subtract from our claimed set. */
+ RangeSet_Subtraction( lSet, tmpClaimed );
+ }
+ FreeObject( tmpClaimed );
+
+ /* Update remaining neighbours as to which indices we've taken. */
+ for( p_j = p_i; p_j < nInc; p_j++ ) {
+ RangeSet* intersect;
+
+ intersect = RangeSet_DeepCopy( isects[p_j] );
+ RangeSet_Intersection( intersect, lSet );
+ RangeSet_Pickle( intersect, &nBytes, &bytes );
+ MPI_Send( &nBytes, 1, MPI_UNSIGNED, inc[p_j], tag, comm );
+ MPI_Send( bytes, nBytes, MPI_BYTE, inc[p_j], tag, comm );
+ FreeArray( bytes );
+ FreeObject( intersect );
+ }
+
+ /* Extract our ownership. */
+ Decomposer_BuildIndices( self, nDomains, domains, lSet,
+ commTopo, decomp, sync );
+
+ /* Free local range set. */
+ FreeObject( lSet );
+}
+
+void Decomposer_BuildIndices( Decomposer* self, unsigned nDomains, unsigned* domains, RangeSet* claimed,
+ CommTopology* commTopo, Decomp** decomp, Decomp_Sync** sync )
+{
+ RangeSet* rSet;
+ unsigned nLocals, *locals;
+ unsigned nRemotes, *remotes;
+
+ /* Extract local indices. */
+ *decomp = Decomp_New();
+ Decomp_SetComm( *decomp, self->comm );
+ locals = NULL;
+ RangeSet_GetIndices( claimed, &nLocals, &locals );
+ Decomp_SetLocals( *decomp, nLocals, locals );
+ FreeArray( locals );
+
+ /* Build a set of remotes. */
+ rSet = RangeSet_New();
+ RangeSet_SetIndices( rSet, nDomains, domains );
+ RangeSet_Subtraction( rSet, claimed );
+
+ /* Set remote indices. */
+ *sync = Decomp_Sync_New();
+ Decomp_Sync_SetDecomp( *sync, *decomp );
+ Decomp_Sync_SetCommTopology( *sync, commTopo );
+ remotes = NULL;
+ RangeSet_GetIndices( rSet, &nRemotes, &remotes );
+ Decomp_Sync_SetRemotes( *sync, nRemotes, remotes );
+ FreeArray( remotes );
+
+ /* Destroy rental set. */
+ FreeObject( rSet );
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/DictionaryGenerator.c
--- a/Mesh/src/DictionaryGenerator.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: DictionaryGenerator.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include <mpi.h>
-#include <StGermain/StGermain.h>
-
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-
-#include "Mesh.h"
-
-
-/* Textual name of this class */
-const Type DictionaryGenerator_Type = "DictionaryGenerator";
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-DictionaryGenerator* DictionaryGenerator_New( Name name ) {
- return _DictionaryGenerator_New( sizeof(DictionaryGenerator),
- DictionaryGenerator_Type,
- _DictionaryGenerator_Delete,
- _DictionaryGenerator_Print,
- NULL,
- (void* (*)(Name))_DictionaryGenerator_New,
- _DictionaryGenerator_Construct,
- _DictionaryGenerator_Build,
- _DictionaryGenerator_Initialise,
- _DictionaryGenerator_Execute,
- _DictionaryGenerator_Destroy,
- name,
- NON_GLOBAL,
- DictionaryGenerator_Generate );
-}
-
-DictionaryGenerator* _DictionaryGenerator_New( DICTIONARYGENERATOR_DEFARGS ) {
- DictionaryGenerator* self;
-
- /* Allocate memory */
- assert( sizeOfSelf >= sizeof(DictionaryGenerator) );
- self = (DictionaryGenerator*)_MeshGenerator_New( MESHGENERATOR_PASSARGS );
-
- /* Virtual info */
-
- /* DictionaryGenerator info */
- _DictionaryGenerator_Init( self );
-
- return self;
-}
-
-void _DictionaryGenerator_Init( DictionaryGenerator* self ) {
- self->dict = NULL;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _DictionaryGenerator_Delete( void* generator ) {
- DictionaryGenerator* self = (DictionaryGenerator*)generator;
-
- /* Delete the parent. */
- _MeshGenerator_Delete( self );
-}
-
-void _DictionaryGenerator_Print( void* generator, Stream* stream ) {
- DictionaryGenerator* self = (DictionaryGenerator*)generator;
-
- /* Set the Journal for printing informations */
- Stream* generatorStream;
- generatorStream = Journal_Register( InfoStream_Type, "DictionaryGeneratorStream" );
-
- /* Print parent */
- Journal_Printf( stream, "DictionaryGenerator (ptr): (%p)\n", self );
- _MeshGenerator_Print( self, stream );
-}
-
-void _DictionaryGenerator_Construct( void* generator, Stg_ComponentFactory* cf, void* data ) {
- DictionaryGenerator* self = (DictionaryGenerator*)generator;
- Dictionary* dict;
-
- assert( self );
- assert( cf );
-
- /* Call parent construct. */
- _MeshGenerator_Construct( self, cf, data );
-
- /* Set the dictionary to the component dictionary. */
- DictionaryGenerator_SetDictionary( self, cf->componentDict );
-}
-
-void _DictionaryGenerator_Build( void* generator, void* data ) {
- _MeshGenerator_Build( generator, data );
-}
-
-void _DictionaryGenerator_Initialise( void* generator, void* data ) {
-}
-
-void _DictionaryGenerator_Execute( void* generator, void* data ) {
-}
-
-void _DictionaryGenerator_Destroy( void* generator, void* data ) {
-}
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void DictionaryGenerator_Generate( void* generator, void* _mesh ) {
- DictionaryGenerator* self = (DictionaryGenerator*)generator;
- Mesh* mesh = (Mesh*)_mesh;
-
- /* Sanity check. */
- assert( self );
- assert( self->dict );
-
- /* For now, this can only work in serial. */
-
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/DictionaryGenerator.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/DictionaryGenerator.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,159 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: DictionaryGenerator.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+
+#include "Mesh.h"
+
+
+/* Textual name of this class */
+const Type DictionaryGenerator_Type = "DictionaryGenerator";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+DictionaryGenerator* DictionaryGenerator_New( Name name ) {
+ return _DictionaryGenerator_New( sizeof(DictionaryGenerator),
+ DictionaryGenerator_Type,
+ _DictionaryGenerator_Delete,
+ _DictionaryGenerator_Print,
+ NULL,
+ (void* (*)(Name))_DictionaryGenerator_New,
+ _DictionaryGenerator_Construct,
+ _DictionaryGenerator_Build,
+ _DictionaryGenerator_Initialise,
+ _DictionaryGenerator_Execute,
+ _DictionaryGenerator_Destroy,
+ name,
+ NON_GLOBAL,
+ DictionaryGenerator_Generate );
+}
+
+DictionaryGenerator* _DictionaryGenerator_New( DICTIONARYGENERATOR_DEFARGS ) {
+ DictionaryGenerator* self;
+
+ /* Allocate memory */
+ assert( sizeOfSelf >= sizeof(DictionaryGenerator) );
+ self = (DictionaryGenerator*)_MeshGenerator_New( MESHGENERATOR_PASSARGS );
+
+ /* Virtual info */
+
+ /* DictionaryGenerator info */
+ _DictionaryGenerator_Init( self );
+
+ return self;
+}
+
+void _DictionaryGenerator_Init( DictionaryGenerator* self ) {
+ self->dict = NULL;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _DictionaryGenerator_Delete( void* generator ) {
+ DictionaryGenerator* self = (DictionaryGenerator*)generator;
+
+ /* Delete the parent. */
+ _MeshGenerator_Delete( self );
+}
+
+void _DictionaryGenerator_Print( void* generator, Stream* stream ) {
+ DictionaryGenerator* self = (DictionaryGenerator*)generator;
+
+ /* Set the Journal for printing informations */
+ Stream* generatorStream;
+ generatorStream = Journal_Register( InfoStream_Type, "DictionaryGeneratorStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "DictionaryGenerator (ptr): (%p)\n", self );
+ _MeshGenerator_Print( self, stream );
+}
+
+void _DictionaryGenerator_Construct( void* generator, Stg_ComponentFactory* cf, void* data ) {
+ DictionaryGenerator* self = (DictionaryGenerator*)generator;
+ Dictionary* dict;
+
+ assert( self );
+ assert( cf );
+
+ /* Call parent construct. */
+ _MeshGenerator_Construct( self, cf, data );
+
+ /* Set the dictionary to the component dictionary. */
+ DictionaryGenerator_SetDictionary( self, cf->componentDict );
+}
+
+void _DictionaryGenerator_Build( void* generator, void* data ) {
+ _MeshGenerator_Build( generator, data );
+}
+
+void _DictionaryGenerator_Initialise( void* generator, void* data ) {
+}
+
+void _DictionaryGenerator_Execute( void* generator, void* data ) {
+}
+
+void _DictionaryGenerator_Destroy( void* generator, void* data ) {
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void DictionaryGenerator_Generate( void* generator, void* _mesh ) {
+ DictionaryGenerator* self = (DictionaryGenerator*)generator;
+ Mesh* mesh = (Mesh*)_mesh;
+
+ /* Sanity check. */
+ assert( self );
+ assert( self->dict );
+
+ /* For now, this can only work in serial. */
+
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/DictionaryGenerator.h
--- a/Mesh/src/DictionaryGenerator.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Invariants:
-**
-** Comments:
-**
-** $Id: DictionaryGenerator.h 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Domain_Mesh_DictionaryGenerator_h__
-#define __Domain_Mesh_DictionaryGenerator_h__
-
- /** Textual name of this class */
- extern const Type DictionaryGenerator_Type;
-
- /** Virtual function types */
-
- /** DictionaryGenerator class contents */
- #define __DictionaryGenerator \
- /* General info */ \
- __MeshGenerator \
- \
- /* Virtual info */ \
- \
- /* DictionaryGenerator info */ \
- Dictionary* dict;
-
- struct DictionaryGenerator { __DictionaryGenerator };
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- #define DICTIONARYGENERATOR_DEFARGS \
- MESHGENERATOR_DEFARGS
-
- #define DICTIONARYGENERATOR_PASSARGS \
- MESHGENERATOR_PASSARGS
-
- DictionaryGenerator* DictionaryGenerator_New( Name name );
- DictionaryGenerator* _DictionaryGenerator_New( DICTIONARYGENERATOR_DEFARGS );
- void _DictionaryGenerator_Init( DictionaryGenerator* self );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _DictionaryGenerator_Delete( void* generator );
- void _DictionaryGenerator_Print( void* generator, Stream* stream );
- void _DictionaryGenerator_Construct( void* generator, Stg_ComponentFactory* cf, void* data );
- void _DictionaryGenerator_Build( void* generator, void* data );
- void _DictionaryGenerator_Initialise( void* generator, void* data );
- void _DictionaryGenerator_Execute( void* generator, void* data );
- void _DictionaryGenerator_Destroy( void* generator, void* data );
-
- void DictionaryGenerator_Generate( void* generator, void* _mesh );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public functions
- */
-
- void DictionaryGenerator_SetDictionary( void* generator, Dictionary* dict );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions
- */
-
-#endif /* __Domain_Mesh_DictionaryGenerator_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/DictionaryGenerator.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/DictionaryGenerator.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,99 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: DictionaryGenerator.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Domain_Mesh_DictionaryGenerator_h__
+#define __Domain_Mesh_DictionaryGenerator_h__
+
+ /** Textual name of this class */
+ extern const Type DictionaryGenerator_Type;
+
+ /** Virtual function types */
+
+ /** DictionaryGenerator class contents */
+ #define __DictionaryGenerator \
+ /* General info */ \
+ __MeshGenerator \
+ \
+ /* Virtual info */ \
+ \
+ /* DictionaryGenerator info */ \
+ Dictionary* dict;
+
+ struct DictionaryGenerator { __DictionaryGenerator };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ #define DICTIONARYGENERATOR_DEFARGS \
+ MESHGENERATOR_DEFARGS
+
+ #define DICTIONARYGENERATOR_PASSARGS \
+ MESHGENERATOR_PASSARGS
+
+ DictionaryGenerator* DictionaryGenerator_New( Name name );
+ DictionaryGenerator* _DictionaryGenerator_New( DICTIONARYGENERATOR_DEFARGS );
+ void _DictionaryGenerator_Init( DictionaryGenerator* self );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _DictionaryGenerator_Delete( void* generator );
+ void _DictionaryGenerator_Print( void* generator, Stream* stream );
+ void _DictionaryGenerator_Construct( void* generator, Stg_ComponentFactory* cf, void* data );
+ void _DictionaryGenerator_Build( void* generator, void* data );
+ void _DictionaryGenerator_Initialise( void* generator, void* data );
+ void _DictionaryGenerator_Execute( void* generator, void* data );
+ void _DictionaryGenerator_Destroy( void* generator, void* data );
+
+ void DictionaryGenerator_Generate( void* generator, void* _mesh );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+ void DictionaryGenerator_SetDictionary( void* generator, Dictionary* dict );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+
+#endif /* __Domain_Mesh_DictionaryGenerator_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/HMesh.c
--- a/Mesh/src/HMesh.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,651 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: HMesh.c 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include <mpi.h>
-#include <StGermain/StGermain.h>
-
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-
-#include "types.h"
-#include "shortcuts.h"
-#include "MeshClass.h"
-#include "HMesh.h"
-
-
-#define HMESH_WELD_RESOLUTION 1e-5;
-
-
-/* Textual name of this class */
-const Type HMesh_Type = "HMesh";
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-HMesh* HMesh_DefaultNew( Name name ) {
- return _HMesh_New( sizeof(HMesh),
- HMesh_Type,
- _HMesh_Delete,
- _HMesh_Print,
- _HMesh_Copy,
- (void*)HMesh_DefaultNew,
- _HMesh_Construct,
- _HMesh_Build,
- _HMesh_Initialise,
- _HMesh_Execute,
- _HMesh_Destroy,
- name,
- False,
- _Mesh_Node_IsLocal1D,
- _Mesh_Node_IsShadow1D,
- _Mesh_Element_IsLocal1D,
- _Mesh_Element_IsShadow1D,
- NULL,
- 0,
- 0,
- NULL,
- NULL );
-}
-
-HMesh* HMesh_New( Name name,
- void* layout,
- SizeT _nodeSize,
- SizeT _elementSize,
- void* extension_Register,
- Dictionary* dictionary )
-{
- return _HMesh_New( sizeof(HMesh),
- HMesh_Type,
- _HMesh_Delete,
- _HMesh_Print,
- _HMesh_Copy,
- (void*)HMesh_DefaultNew,
- _HMesh_Construct,
- _HMesh_Build,
- _HMesh_Initialise,
- _HMesh_Execute,
- _HMesh_Destroy,
- name,
- True,
- _Mesh_Node_IsLocal1D,
- _Mesh_Node_IsShadow1D,
- _Mesh_Element_IsLocal1D,
- _Mesh_Element_IsShadow1D,
- layout,
- _nodeSize,
- _elementSize,
- extension_Register,
- dictionary );
-}
-
-void HMesh_Init( HMesh* self,
- Name name,
- void* layout,
- SizeT _nodeSize,
- SizeT _elementSize,
- void* extensionMgr_Register,
- Dictionary* dictionary )
-{
- /* General info */
- self->type = HMesh_Type;
- self->_sizeOfSelf = sizeof(HMesh);
- self->_deleteSelf = False;
- self->dictionary = dictionary;
-
- /* Virtual info */
- self->_delete = _HMesh_Delete;
- self->_print = _HMesh_Print;
- self->_copy = _HMesh_Copy;
- self->_defaultConstructor = (void*)HMesh_DefaultNew;
- self->_construct = _HMesh_Construct;
- self->_build = _HMesh_Build;
- self->_initialise = _HMesh_Initialise;
- self->_execute = _HMesh_Execute;
- self->_destroy = _HMesh_Destroy;
- self->nodeIsLocal = _Mesh_Node_IsLocal1D;
- self->nodeIsShadow = _Mesh_Node_IsShadow1D;
- self->elementIsLocal = _Mesh_Element_IsLocal1D;
- self->elementIsShadow = _Mesh_Element_IsShadow1D;
-
- _Stg_Class_Init( (Stg_Class*)self );
- _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
- _Stg_Component_Init( (Stg_Component*)self );
- _Mesh_Init( (Mesh*)self, layout, _nodeSize, _elementSize, extensionMgr_Register );
- _HMesh_Init( self );
-}
-
-HMesh* _HMesh_New( SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- Mesh_Node_IsLocalFunction* nodeIsLocal,
- Mesh_Node_IsShadowFunction* nodeIsShadow,
- Mesh_Element_IsLocalFunction* elementIsLocal,
- Mesh_Element_IsShadowFunction* elementIsShadow,
- void* layout,
- SizeT _nodeSize,
- SizeT _elementSize,
- void* extension_Register,
- Dictionary* dictionary )
-{
- HMesh* self;
-
- /* Allocate memory */
- assert( _sizeOfSelf >= sizeof(HMesh) );
- self = (HMesh*)_Mesh_New( _sizeOfSelf, type, _delete, _print, _copy,
- _defaultConstructor, _construct,
- _build, _initialise, _execute, _destroy,
- name, NON_GLOBAL,
- nodeIsLocal, nodeIsShadow, elementIsLocal, elementIsShadow,
- layout, _nodeSize, _elementSize,
- extension_Register, dictionary );
-
- /* Virtual info */
-
- /* HMesh info */
- if( initFlag ) _HMesh_Init( self );
-
- return self;
-}
-
-void _HMesh_Init( HMesh* self ) {
- /* At this point, _Mesh_Init will have been called. */
- self->nLevels = 0;
- self->levels = NULL;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _HMesh_Construct( void* mesh, Stg_ComponentFactory* cf, void* data ) {
- HMesh* self = (HMesh*)mesh;
- Dictionary* dict;
- unsigned nLevels;
- char* meshName;
- Mesh* baseMesh;
- unsigned baseLevel;
-
- /* As far as I can tell, we don't really want to construct the super-class. */
- /*_Mesh_Construct( mesh, cf );*/
-
- /* Sort out my own initialisation. */
- _HMesh_Init( (HMesh*)self );
-
- /* Shortcuts. */
- dict = cf->componentDict;
-
- /* Read the base mesh from the dictionary. */
- meshName = Stg_ComponentFactory_GetString( cf, self->name, "base-mesh", NULL );
- if( meshName && strcmp( meshName, "" ) ) {
- baseMesh = Stg_ComponentFactory_ConstructByName( cf, meshName, Mesh, True, data );
- }
- else
- baseMesh = NULL;
-
- /* Read the number of levels expected. */
- nLevels = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, "levels", 1 );
-
- /* Read the base mesh's level. */
- baseLevel = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, "base-level", 0 );
- assert( baseLevel < nLevels );
-
- /* Set everything up. */
- HMesh_SetNLevels( self, nLevels, baseLevel );
- if( baseMesh )
- HMesh_SetMesh( self, baseLevel, baseMesh, False );
-}
-
-void _HMesh_Destroy( void* mesh, void* data ) {
- /* What the hell is supposed to go in here anyway? I was under the impression that *_Delete takes
- care of all the destruction around here... anyway, destroy the super-class. */
- _Mesh_Destroy( mesh, data );
-}
-
-void _HMesh_Delete( void* mesh ) {
- HMesh* self = (HMesh*)mesh;
-
- /* Delete the parent. */
- _Mesh_Delete( self );
-}
-
-void _HMesh_Print( void* mesh, Stream* stream ) {
- HMesh* self = (HMesh*)mesh;
-
- /* Set the Journal for printing informations */
- Stream* meshStream;
- meshStream = Journal_Register( InfoStream_Type, "HMeshStream" );
-
- /* Print parent */
- Journal_Printf( stream, "HMesh (ptr): (%p)\n", self );
- _Mesh_Print( self, stream );
-}
-
-void* _HMesh_Copy( void* mesh, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
- HMesh* self = (HMesh*)mesh;
- HMesh* newHMesh;
- PtrMap* map = ptrMap;
- Bool ownMap = False;
-
- /* Damn me for making copying so difficult... what was I thinking? */
-
- /* We need to create a map if it doesn't already exist. */
- if( !map ) {
- map = PtrMap_New( 10 );
- ownMap = True;
- }
-
- newHMesh = (HMesh*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
-
- /* Copy the virtual methods here. */
-
- /* Deep or shallow? */
- if( deep ) {
- }
- else {
- }
-
- /* If we own the map, get rid of it here. */
- if( ownMap ) Stg_Class_Delete( map );
-
- return (void*)newHMesh;
-}
-
-void _HMesh_Build( void* mesh, void* data ) {
- HMesh* self = (HMesh*)mesh;
- unsigned l_i;
-
- assert( self );
-
- /* Build parent mesh. */
- _Mesh_Build( mesh, data );
-
- /* Build each level. */
- for( l_i = 0; l_i < self->nLevels; l_i++ )
- Build( self->levels[l_i].mesh, data, False );
-}
-
-void _HMesh_Initialise( void* mesh, void* data ) {
- HMesh* self = (HMesh*)mesh;
- unsigned l_i;
-
- assert( self );
-
- /* Initalise the parent mesh. */
- _Mesh_Initialise( mesh, data );
-
- /* Initialise all levels, we'll need each mesh's data. */
- for( l_i = 0; l_i < self->nLevels; l_i++ )
- Initialise( self->levels[l_i].mesh, data, False );
-
- /* Here is where we construct our topographical mesh, the composite of all levels.
- These routines also take care of building the mappings bewtween levels and to the
- topographical mesh. Essentially, this is where the bulk of the work is done. */
- HMesh_BuildNodes( self );
- HMesh_BuildElements( self );
-}
-
-void _HMesh_Execute( void* mesh, void* data ) {
- /* Execute parent mesh. */
- _Mesh_Execute( mesh, data );
-}
-
-/*--------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void HMesh_SetNLevels( HMesh* self, unsigned nLevels, unsigned baseLevel ) {
- assert( self );
- assert( !nLevels || baseLevel < nLevels );
-
- /* If this is being set after a previous construction, kill everything. */
- if( self->nLevels ) {
- unsigned l_i;
-
- for( l_i = 0; l_i < self->nLevels; l_i++ )
- HMesh_DeleteLevel( self->levels + l_i );
- KillArray( self->levels );
- }
-
- /* Set the levels and resize everything. */
- self->nLevels = nLevels;
- self->baseLevel = baseLevel;
- if( self->nLevels ) {
- self->levels = Memory_Alloc_Array( HMesh_Level, self->nLevels, "HMesh::levels" );
- memset( self->levels, 0, self->nLevels * sizeof(HMesh_Level) );
- }
-}
-
-void HMesh_SetMesh( HMesh* self, unsigned level, Mesh* mesh, Bool own ) {
- assert( self );
- assert( level < self->nLevels );
-
- /* Make sure the level we're looking at is empty. */
- HMesh_DeleteLevel( self->levels + level );
-
- /* Store the new mesh. */
- self->levels[level].mesh = mesh;
- self->levels[level].ownMesh = own;
-}
-
-Mesh* HMesh_GenMesh( HMesh* self, unsigned level ) {
- char* name;
-
- assert( self );
- assert( level < self->nLevels );
-
- /* Make sure the level we're looking at is empty. */
- HMesh_DeleteLevel( self->levels + level );
-
- /* Create a new mesh for this level. */
- name = HMesh_GenName( self, level );
- self->levels[level].mesh = Mesh_DefaultNew( name );
- self->levels[level].ownMesh = True;
- Memory_Free( name );
-
- return self->levels[level].mesh;
-}
-
-Mesh* HMesh_GetMesh( HMesh* self, unsigned level ) {
- assert( self );
- assert( level < self->nLevels );
- assert( self->levels );
-
- return self->levels[level].mesh;
-}
-
-Mesh* HMesh_GetBaseMesh( HMesh* self ) {
- assert( self );
- assert( self->levels );
-
- return self->levels[self->baseLevel].mesh;
-}
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-char* HMesh_GenName( HMesh* self, unsigned level ) {
- unsigned len;
- unsigned width;
- char* name;
-
- assert( self );
- assert( level < self->nLevels );
-
- /* Calculate the length of the new name. */
- len = self->name ? strlen(self->name) : 0;
- width = self->nLevels ? log(self->nLevels) + 1 : 0;
- len += width + 2;
-
- /* Construct the new name. */
- name = Memory_Alloc_Array( char, len, "HMesh::<mesh name>" );
- sprintf( name, "%s_%0*d", self->name ? self->name : "", width, level );
-
- return name;
-}
-
-void HMesh_BuildNodes( HMesh* self ) {
- unsigned l_i;
-
- assert( self );
-
- /* Make sure nodes aren't already set, if they are kill'em. */
- /* TODO */
-
- /* Higher levels require some additional crap to allow node welding. */
- for( l_i = 0; l_i < self->nLevels; l_i++ ) {
- HMesh_Level* level = self->levels + l_i;
- HMesh_Level* prevLevel = self->levels + l_i - 1;
- Mesh* mesh = level->mesh;
- Mesh* prevMesh = prevLevel->mesh;
- unsigned n_i;
-
- /* The coarsest level is a bit of an exception, we can just copy his
- nodal values directly, no messing about. */
- if( l_i == 0 ) {
- self->nodeLocalCount = mesh->nodeLocalCount;
- self->nodeShadowCount = mesh->nodeShadowCount;
- self->nodeDomainCount = mesh->nodeDomainCount;
- self->nodeCoord = Memory_Alloc_Array( Coord, self->nodeDomainCount, "HMesh::nodeCoord" );
- memcpy( self->nodeCoord, mesh->nodeCoord, self->nodeDomainCount * sizeof(Coord) );
- level->nodeUp = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_InterMap::upToLow" );
- level->nodeGlobals = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_Level::nodeGlobals" );
- for( n_i = 0; n_i < prevMesh->nodeDomainCount; n_i++ ) {
- level->nodeUp[n_i] = -1;
- level->nodeGlobals[n_i] = n_i;
- }
- continue;
- }
-
- /* Allocate space on this level for the mappings. */
- level->nodeUp = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_Level::nodeUp" );
- level->nodeDown = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_Level::nodeDown" );
- level->nodeGlobals = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_Level::nodeGlobals" );
-
- /* Initialise the up map to invalid values. */
- for( n_i = 0; n_i < prevMesh->nodeDomainCount; n_i++ )
- level->nodeUp[n_i] = -1;
-
- /* Search the previous level for overlapping nodes (i.e. nodes that
- are within a certain radius) and use their storage instead of creating new space. */
- for( n_i = 0; n_i < mesh->nodeDomainCount; n_i++ ) {
- unsigned weld;
-
- if( HMesh_FindWeld( self, l_i, mesh->nodeCoord[n_i], &weld ) ) {
- /* If we found a node to weld to, do it. */
- level->nodeDown[n_i] = weld;
- prevLevel->nodeUp[weld] = n_i;
- level->nodeGlobals[n_i] = prevLevel->nodeGlobals[weld];
- }
- else {
- /* If we didn't find one, add a new node. */
- self->nodeDomainCount++;
- self->nodeCoord = Memory_Realloc_Array( self->nodeCoord, Coord, self->nodeDomainCount );
- memcpy( self->nodeCoord + self->nodeDomainCount - 1,
- mesh->nodeCoord + n_i,
- sizeof(Coord) );
- level->nodeDown[n_i] = -1;
- level->nodeGlobals[n_i] = self->nodeDomainCount - 1;
- }
- }
- }
-}
-
-void HMesh_BuildElements( HMesh* self ) {
- unsigned l_i;
-
- assert( self );
-
- /* To construct this level's down elements we can check which down element each of
- this element's nodes falls in. If there are more than one, this element spans
- many lower elements, meaning something sinister is afoot. */
- for( l_i = 0; l_i < self->nLevels; l_i++ ) {
- HMesh_Level* level = self->levels + l_i;
- HMesh_Level* prevLevel;
- Mesh* mesh = level->mesh;
- Mesh* prevMesh;
- unsigned e_i;
-
- /* We can skip the coarsest level, as it has no down map. */
- if( l_i == 0 ) continue;
-
- /* Shortcuts. */
- prevLevel = self->levels + l_i - 1;
- prevMesh = prevLevel->mesh;
-
- /* Allocate space on this level for the mappings. */
- level->elDown = Memory_Alloc_Array( unsigned, mesh->elementDomainCount, "HMesh_Level::elDown" );
-
- /* Search all the elements. */
- for( e_i = 0; e_i < mesh->elementDomainCount; e_i++ ) {
- unsigned elInd;
- unsigned en_i;
-
- /* Search all the elements' nodes. */
- for( en_i = 0; en_i < mesh->elementNodeCountTbl[e_i]; en_i++ ) {
- unsigned nInd = mesh->elementNodeTbl[e_i][en_i];
- unsigned curElInd;
-
- /* They all have to be in the same coarser element. */
- curElInd = Mesh_ElementWithPoint( prevMesh, mesh->nodeCoord[nInd],
- INCLUSIVE_UPPER_BOUNDARY );
- if( en_i == 0 ) elInd = curElInd;
- else if( curElInd != elInd ) {
- fprintf( stderr, "*** ERROR: Overlapping element.\n" );
- abort();
- }
- }
-
- /* Success! */
- level->elDown[e_i] = elInd;
- }
- }
-
- /* Now that we have the down mapping, we can construct the up mapping... */
- for( l_i = 0; l_i < self->nLevels; l_i++ ) {
- HMesh_Level* level = self->levels + l_i;
- HMesh_Level* nextLevel;
- Mesh* mesh = level->mesh;
- Mesh* nextMesh;
- unsigned e_i;
-
- /* We can skip the finest level, as it has no up map. */
- if( l_i == self->nLevels - 1 ) continue;
-
- /* Shortcuts. */
- nextLevel = self->levels + l_i + 1;
- nextMesh = nextLevel->mesh;
-
- /* Allocate space on this level for the mappings. */
- level->nElsUp = Memory_Alloc_Array( unsigned, mesh->elementDomainCount, "HMesh_Level::nElsUp" );
- level->elUp = Memory_Alloc_Array( unsigned*, mesh->elementDomainCount, "HMesh_Level::elUp" );
-
- /* Search the upper mesh's elements. */
- for( e_i = 0; e_i < nextMesh->elementDomainCount; e_i++ ) {
- unsigned elInd = nextLevel->elDown[e_i];
-
- /* Resize our element list. */
- level->nElsUp[elInd]++;
- if( level->elUp[elInd] ) {
- level->elUp[elInd] = Memory_Realloc_Array( level->elUp[elInd], unsigned, level->nElsUp[elInd] );
- }
- else {
- level->elUp[elInd] = Memory_Alloc_Array( unsigned, 1, "HMesh_Level::elUp[]" );
- }
-
- /* Add the up element. */
- level->elUp[elInd][level->nElsUp[elInd] - 1] = e_i;
- }
-
- /* Use the up mapping to determine how many elements we have left unrefined on this level. */
- for( e_i = 0; e_i < mesh->elementDomainCount; e_i++ )
- if( !level->elUp[e_i] ) self->elementDomainCount++;
- }
-}
-
-Bool HMesh_FindWeld( HMesh* self, unsigned level, Coord crd, unsigned* weld ) {
- unsigned node;
- Mesh* mesh;
- Coord tmp;
-
- assert( self );
- assert( level > 0 && level < self->nLevels );
-
- /* If there is no lower mesh, then what the hell are we doing here? */
- mesh = self->levels[level - 1].mesh;
- assert( mesh );
-
- /* Find the closest node from lower mesh, check if it's close enough */
- node = Mesh_ClosestNode( mesh, crd );
- Vector_Sub( tmp, crd, mesh->nodeCoord[node] );
- if( Vector_Mag( tmp ) < self->levels[level].weldEpsilon ) {
- *weld = node;
- return True;
- }
-
- return False;
-}
-
-void HMesh_CalcWeldEpsilons( HMesh* self ) {
- unsigned l_i;
- double lsep, sep;
-
- assert( self );
-
- /* If we don't have enough levels, skip the lot. */
- if( self->nLevels <= 1 ) return;
-
- /* Calculate the nodal separation for the coarsest mesh before
- entering the loop; kind of an optimisation. */
- lsep = Mesh_NodeSeparation( self->levels[0].mesh );
- for( l_i = 1; l_i < self->nLevels; l_i++ ) {
- Mesh* upper = self->levels[l_i].mesh;
- double usep;
-
- /* Get the minimum distance between any two nodes of each mesh. */
- usep = Mesh_NodeSeparation( upper );
- sep = usep < lsep ? usep : lsep;
-
- /* Factor in the weld resolution. */
- self->levels[l_i].weldEpsilon = sep * HMESH_WELD_RESOLUTION;
-
- /* Flip the separations. */
- lsep = usep;
- }
-}
-
-void HMesh_DeleteLevel( HMesh_Level* level ) {
- assert( level );
-
- if( level->mesh && level->ownMesh ) Stg_Class_Delete( level->mesh );
- else level->mesh = NULL;
- KillArray( level->nodeUp );
- KillArray( level->nodeDown );
- KillArray( level->nodeGlobals );
- KillArray2D( level->mesh->elementDomainCount, level->elUp );
- KillArray( level->elDown );
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/HMesh.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/HMesh.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,651 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: HMesh.c 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+
+#include "types.h"
+#include "shortcuts.h"
+#include "MeshClass.h"
+#include "HMesh.h"
+
+
+#define HMESH_WELD_RESOLUTION 1e-5;
+
+
+/* Textual name of this class */
+const Type HMesh_Type = "HMesh";
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+HMesh* HMesh_DefaultNew( Name name ) {
+ return _HMesh_New( sizeof(HMesh),
+ HMesh_Type,
+ _HMesh_Delete,
+ _HMesh_Print,
+ _HMesh_Copy,
+ (void*)HMesh_DefaultNew,
+ _HMesh_Construct,
+ _HMesh_Build,
+ _HMesh_Initialise,
+ _HMesh_Execute,
+ _HMesh_Destroy,
+ name,
+ False,
+ _Mesh_Node_IsLocal1D,
+ _Mesh_Node_IsShadow1D,
+ _Mesh_Element_IsLocal1D,
+ _Mesh_Element_IsShadow1D,
+ NULL,
+ 0,
+ 0,
+ NULL,
+ NULL );
+}
+
+HMesh* HMesh_New( Name name,
+ void* layout,
+ SizeT _nodeSize,
+ SizeT _elementSize,
+ void* extension_Register,
+ Dictionary* dictionary )
+{
+ return _HMesh_New( sizeof(HMesh),
+ HMesh_Type,
+ _HMesh_Delete,
+ _HMesh_Print,
+ _HMesh_Copy,
+ (void*)HMesh_DefaultNew,
+ _HMesh_Construct,
+ _HMesh_Build,
+ _HMesh_Initialise,
+ _HMesh_Execute,
+ _HMesh_Destroy,
+ name,
+ True,
+ _Mesh_Node_IsLocal1D,
+ _Mesh_Node_IsShadow1D,
+ _Mesh_Element_IsLocal1D,
+ _Mesh_Element_IsShadow1D,
+ layout,
+ _nodeSize,
+ _elementSize,
+ extension_Register,
+ dictionary );
+}
+
+void HMesh_Init( HMesh* self,
+ Name name,
+ void* layout,
+ SizeT _nodeSize,
+ SizeT _elementSize,
+ void* extensionMgr_Register,
+ Dictionary* dictionary )
+{
+ /* General info */
+ self->type = HMesh_Type;
+ self->_sizeOfSelf = sizeof(HMesh);
+ self->_deleteSelf = False;
+ self->dictionary = dictionary;
+
+ /* Virtual info */
+ self->_delete = _HMesh_Delete;
+ self->_print = _HMesh_Print;
+ self->_copy = _HMesh_Copy;
+ self->_defaultConstructor = (void*)HMesh_DefaultNew;
+ self->_construct = _HMesh_Construct;
+ self->_build = _HMesh_Build;
+ self->_initialise = _HMesh_Initialise;
+ self->_execute = _HMesh_Execute;
+ self->_destroy = _HMesh_Destroy;
+ self->nodeIsLocal = _Mesh_Node_IsLocal1D;
+ self->nodeIsShadow = _Mesh_Node_IsShadow1D;
+ self->elementIsLocal = _Mesh_Element_IsLocal1D;
+ self->elementIsShadow = _Mesh_Element_IsShadow1D;
+
+ _Stg_Class_Init( (Stg_Class*)self );
+ _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
+ _Stg_Component_Init( (Stg_Component*)self );
+ _Mesh_Init( (Mesh*)self, layout, _nodeSize, _elementSize, extensionMgr_Register );
+ _HMesh_Init( self );
+}
+
+HMesh* _HMesh_New( SizeT _sizeOfSelf,
+ Type type,
+ Stg_Class_DeleteFunction* _delete,
+ Stg_Class_PrintFunction* _print,
+ Stg_Class_CopyFunction* _copy,
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor,
+ Stg_Component_ConstructFunction* _construct,
+ Stg_Component_BuildFunction* _build,
+ Stg_Component_InitialiseFunction* _initialise,
+ Stg_Component_ExecuteFunction* _execute,
+ Stg_Component_DestroyFunction* _destroy,
+ Name name,
+ Bool initFlag,
+ Mesh_Node_IsLocalFunction* nodeIsLocal,
+ Mesh_Node_IsShadowFunction* nodeIsShadow,
+ Mesh_Element_IsLocalFunction* elementIsLocal,
+ Mesh_Element_IsShadowFunction* elementIsShadow,
+ void* layout,
+ SizeT _nodeSize,
+ SizeT _elementSize,
+ void* extension_Register,
+ Dictionary* dictionary )
+{
+ HMesh* self;
+
+ /* Allocate memory */
+ assert( _sizeOfSelf >= sizeof(HMesh) );
+ self = (HMesh*)_Mesh_New( _sizeOfSelf, type, _delete, _print, _copy,
+ _defaultConstructor, _construct,
+ _build, _initialise, _execute, _destroy,
+ name, NON_GLOBAL,
+ nodeIsLocal, nodeIsShadow, elementIsLocal, elementIsShadow,
+ layout, _nodeSize, _elementSize,
+ extension_Register, dictionary );
+
+ /* Virtual info */
+
+ /* HMesh info */
+ if( initFlag ) _HMesh_Init( self );
+
+ return self;
+}
+
+void _HMesh_Init( HMesh* self ) {
+ /* At this point, _Mesh_Init will have been called. */
+ self->nLevels = 0;
+ self->levels = NULL;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _HMesh_Construct( void* mesh, Stg_ComponentFactory* cf, void* data ) {
+ HMesh* self = (HMesh*)mesh;
+ Dictionary* dict;
+ unsigned nLevels;
+ char* meshName;
+ Mesh* baseMesh;
+ unsigned baseLevel;
+
+ /* As far as I can tell, we don't really want to construct the super-class. */
+ /*_Mesh_Construct( mesh, cf );*/
+
+ /* Sort out my own initialisation. */
+ _HMesh_Init( (HMesh*)self );
+
+ /* Shortcuts. */
+ dict = cf->componentDict;
+
+ /* Read the base mesh from the dictionary. */
+ meshName = Stg_ComponentFactory_GetString( cf, self->name, "base-mesh", NULL );
+ if( meshName && strcmp( meshName, "" ) ) {
+ baseMesh = Stg_ComponentFactory_ConstructByName( cf, meshName, Mesh, True, data );
+ }
+ else
+ baseMesh = NULL;
+
+ /* Read the number of levels expected. */
+ nLevels = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, "levels", 1 );
+
+ /* Read the base mesh's level. */
+ baseLevel = Stg_ComponentFactory_GetUnsignedInt( cf, self->name, "base-level", 0 );
+ assert( baseLevel < nLevels );
+
+ /* Set everything up. */
+ HMesh_SetNLevels( self, nLevels, baseLevel );
+ if( baseMesh )
+ HMesh_SetMesh( self, baseLevel, baseMesh, False );
+}
+
+void _HMesh_Destroy( void* mesh, void* data ) {
+ /* What the hell is supposed to go in here anyway? I was under the impression that *_Delete takes
+ care of all the destruction around here... anyway, destroy the super-class. */
+ _Mesh_Destroy( mesh, data );
+}
+
+void _HMesh_Delete( void* mesh ) {
+ HMesh* self = (HMesh*)mesh;
+
+ /* Delete the parent. */
+ _Mesh_Delete( self );
+}
+
+void _HMesh_Print( void* mesh, Stream* stream ) {
+ HMesh* self = (HMesh*)mesh;
+
+ /* Set the Journal for printing informations */
+ Stream* meshStream;
+ meshStream = Journal_Register( InfoStream_Type, "HMeshStream" );
+
+ /* Print parent */
+ Journal_Printf( stream, "HMesh (ptr): (%p)\n", self );
+ _Mesh_Print( self, stream );
+}
+
+void* _HMesh_Copy( void* mesh, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
+ HMesh* self = (HMesh*)mesh;
+ HMesh* newHMesh;
+ PtrMap* map = ptrMap;
+ Bool ownMap = False;
+
+ /* Damn me for making copying so difficult... what was I thinking? */
+
+ /* We need to create a map if it doesn't already exist. */
+ if( !map ) {
+ map = PtrMap_New( 10 );
+ ownMap = True;
+ }
+
+ newHMesh = (HMesh*)_Mesh_Copy( self, destProc_I, deep, nameExt, map );
+
+ /* Copy the virtual methods here. */
+
+ /* Deep or shallow? */
+ if( deep ) {
+ }
+ else {
+ }
+
+ /* If we own the map, get rid of it here. */
+ if( ownMap ) Stg_Class_Delete( map );
+
+ return (void*)newHMesh;
+}
+
+void _HMesh_Build( void* mesh, void* data ) {
+ HMesh* self = (HMesh*)mesh;
+ unsigned l_i;
+
+ assert( self );
+
+ /* Build parent mesh. */
+ _Mesh_Build( mesh, data );
+
+ /* Build each level. */
+ for( l_i = 0; l_i < self->nLevels; l_i++ )
+ Build( self->levels[l_i].mesh, data, False );
+}
+
+void _HMesh_Initialise( void* mesh, void* data ) {
+ HMesh* self = (HMesh*)mesh;
+ unsigned l_i;
+
+ assert( self );
+
+ /* Initalise the parent mesh. */
+ _Mesh_Initialise( mesh, data );
+
+ /* Initialise all levels, we'll need each mesh's data. */
+ for( l_i = 0; l_i < self->nLevels; l_i++ )
+ Initialise( self->levels[l_i].mesh, data, False );
+
+ /* Here is where we construct our topographical mesh, the composite of all levels.
+ These routines also take care of building the mappings bewtween levels and to the
+ topographical mesh. Essentially, this is where the bulk of the work is done. */
+ HMesh_BuildNodes( self );
+ HMesh_BuildElements( self );
+}
+
+void _HMesh_Execute( void* mesh, void* data ) {
+ /* Execute parent mesh. */
+ _Mesh_Execute( mesh, data );
+}
+
+/*--------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void HMesh_SetNLevels( HMesh* self, unsigned nLevels, unsigned baseLevel ) {
+ assert( self );
+ assert( !nLevels || baseLevel < nLevels );
+
+ /* If this is being set after a previous construction, kill everything. */
+ if( self->nLevels ) {
+ unsigned l_i;
+
+ for( l_i = 0; l_i < self->nLevels; l_i++ )
+ HMesh_DeleteLevel( self->levels + l_i );
+ KillArray( self->levels );
+ }
+
+ /* Set the levels and resize everything. */
+ self->nLevels = nLevels;
+ self->baseLevel = baseLevel;
+ if( self->nLevels ) {
+ self->levels = Memory_Alloc_Array( HMesh_Level, self->nLevels, "HMesh::levels" );
+ memset( self->levels, 0, self->nLevels * sizeof(HMesh_Level) );
+ }
+}
+
+void HMesh_SetMesh( HMesh* self, unsigned level, Mesh* mesh, Bool own ) {
+ assert( self );
+ assert( level < self->nLevels );
+
+ /* Make sure the level we're looking at is empty. */
+ HMesh_DeleteLevel( self->levels + level );
+
+ /* Store the new mesh. */
+ self->levels[level].mesh = mesh;
+ self->levels[level].ownMesh = own;
+}
+
+Mesh* HMesh_GenMesh( HMesh* self, unsigned level ) {
+ char* name;
+
+ assert( self );
+ assert( level < self->nLevels );
+
+ /* Make sure the level we're looking at is empty. */
+ HMesh_DeleteLevel( self->levels + level );
+
+ /* Create a new mesh for this level. */
+ name = HMesh_GenName( self, level );
+ self->levels[level].mesh = Mesh_DefaultNew( name );
+ self->levels[level].ownMesh = True;
+ Memory_Free( name );
+
+ return self->levels[level].mesh;
+}
+
+Mesh* HMesh_GetMesh( HMesh* self, unsigned level ) {
+ assert( self );
+ assert( level < self->nLevels );
+ assert( self->levels );
+
+ return self->levels[level].mesh;
+}
+
+Mesh* HMesh_GetBaseMesh( HMesh* self ) {
+ assert( self );
+ assert( self->levels );
+
+ return self->levels[self->baseLevel].mesh;
+}
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+char* HMesh_GenName( HMesh* self, unsigned level ) {
+ unsigned len;
+ unsigned width;
+ char* name;
+
+ assert( self );
+ assert( level < self->nLevels );
+
+ /* Calculate the length of the new name. */
+ len = self->name ? strlen(self->name) : 0;
+ width = self->nLevels ? log(self->nLevels) + 1 : 0;
+ len += width + 2;
+
+ /* Construct the new name. */
+ name = Memory_Alloc_Array( char, len, "HMesh::<mesh name>" );
+ sprintf( name, "%s_%0*d", self->name ? self->name : "", width, level );
+
+ return name;
+}
+
+void HMesh_BuildNodes( HMesh* self ) {
+ unsigned l_i;
+
+ assert( self );
+
+ /* Make sure nodes aren't already set, if they are kill'em. */
+ /* TODO */
+
+ /* Higher levels require some additional crap to allow node welding. */
+ for( l_i = 0; l_i < self->nLevels; l_i++ ) {
+ HMesh_Level* level = self->levels + l_i;
+ HMesh_Level* prevLevel = self->levels + l_i - 1;
+ Mesh* mesh = level->mesh;
+ Mesh* prevMesh = prevLevel->mesh;
+ unsigned n_i;
+
+ /* The coarsest level is a bit of an exception, we can just copy his
+ nodal values directly, no messing about. */
+ if( l_i == 0 ) {
+ self->nodeLocalCount = mesh->nodeLocalCount;
+ self->nodeShadowCount = mesh->nodeShadowCount;
+ self->nodeDomainCount = mesh->nodeDomainCount;
+ self->nodeCoord = Memory_Alloc_Array( Coord, self->nodeDomainCount, "HMesh::nodeCoord" );
+ memcpy( self->nodeCoord, mesh->nodeCoord, self->nodeDomainCount * sizeof(Coord) );
+ level->nodeUp = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_InterMap::upToLow" );
+ level->nodeGlobals = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_Level::nodeGlobals" );
+ for( n_i = 0; n_i < prevMesh->nodeDomainCount; n_i++ ) {
+ level->nodeUp[n_i] = -1;
+ level->nodeGlobals[n_i] = n_i;
+ }
+ continue;
+ }
+
+ /* Allocate space on this level for the mappings. */
+ level->nodeUp = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_Level::nodeUp" );
+ level->nodeDown = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_Level::nodeDown" );
+ level->nodeGlobals = Memory_Alloc_Array( unsigned, mesh->nodeDomainCount, "HMesh_Level::nodeGlobals" );
+
+ /* Initialise the up map to invalid values. */
+ for( n_i = 0; n_i < prevMesh->nodeDomainCount; n_i++ )
+ level->nodeUp[n_i] = -1;
+
+ /* Search the previous level for overlapping nodes (i.e. nodes that
+ are within a certain radius) and use their storage instead of creating new space. */
+ for( n_i = 0; n_i < mesh->nodeDomainCount; n_i++ ) {
+ unsigned weld;
+
+ if( HMesh_FindWeld( self, l_i, mesh->nodeCoord[n_i], &weld ) ) {
+ /* If we found a node to weld to, do it. */
+ level->nodeDown[n_i] = weld;
+ prevLevel->nodeUp[weld] = n_i;
+ level->nodeGlobals[n_i] = prevLevel->nodeGlobals[weld];
+ }
+ else {
+ /* If we didn't find one, add a new node. */
+ self->nodeDomainCount++;
+ self->nodeCoord = Memory_Realloc_Array( self->nodeCoord, Coord, self->nodeDomainCount );
+ memcpy( self->nodeCoord + self->nodeDomainCount - 1,
+ mesh->nodeCoord + n_i,
+ sizeof(Coord) );
+ level->nodeDown[n_i] = -1;
+ level->nodeGlobals[n_i] = self->nodeDomainCount - 1;
+ }
+ }
+ }
+}
+
+void HMesh_BuildElements( HMesh* self ) {
+ unsigned l_i;
+
+ assert( self );
+
+ /* To construct this level's down elements we can check which down element each of
+ this element's nodes falls in. If there are more than one, this element spans
+ many lower elements, meaning something sinister is afoot. */
+ for( l_i = 0; l_i < self->nLevels; l_i++ ) {
+ HMesh_Level* level = self->levels + l_i;
+ HMesh_Level* prevLevel;
+ Mesh* mesh = level->mesh;
+ Mesh* prevMesh;
+ unsigned e_i;
+
+ /* We can skip the coarsest level, as it has no down map. */
+ if( l_i == 0 ) continue;
+
+ /* Shortcuts. */
+ prevLevel = self->levels + l_i - 1;
+ prevMesh = prevLevel->mesh;
+
+ /* Allocate space on this level for the mappings. */
+ level->elDown = Memory_Alloc_Array( unsigned, mesh->elementDomainCount, "HMesh_Level::elDown" );
+
+ /* Search all the elements. */
+ for( e_i = 0; e_i < mesh->elementDomainCount; e_i++ ) {
+ unsigned elInd;
+ unsigned en_i;
+
+ /* Search all the elements' nodes. */
+ for( en_i = 0; en_i < mesh->elementNodeCountTbl[e_i]; en_i++ ) {
+ unsigned nInd = mesh->elementNodeTbl[e_i][en_i];
+ unsigned curElInd;
+
+ /* They all have to be in the same coarser element. */
+ curElInd = Mesh_ElementWithPoint( prevMesh, mesh->nodeCoord[nInd],
+ INCLUSIVE_UPPER_BOUNDARY );
+ if( en_i == 0 ) elInd = curElInd;
+ else if( curElInd != elInd ) {
+ fprintf( stderr, "*** ERROR: Overlapping element.\n" );
+ abort();
+ }
+ }
+
+ /* Success! */
+ level->elDown[e_i] = elInd;
+ }
+ }
+
+ /* Now that we have the down mapping, we can construct the up mapping... */
+ for( l_i = 0; l_i < self->nLevels; l_i++ ) {
+ HMesh_Level* level = self->levels + l_i;
+ HMesh_Level* nextLevel;
+ Mesh* mesh = level->mesh;
+ Mesh* nextMesh;
+ unsigned e_i;
+
+ /* We can skip the finest level, as it has no up map. */
+ if( l_i == self->nLevels - 1 ) continue;
+
+ /* Shortcuts. */
+ nextLevel = self->levels + l_i + 1;
+ nextMesh = nextLevel->mesh;
+
+ /* Allocate space on this level for the mappings. */
+ level->nElsUp = Memory_Alloc_Array( unsigned, mesh->elementDomainCount, "HMesh_Level::nElsUp" );
+ level->elUp = Memory_Alloc_Array( unsigned*, mesh->elementDomainCount, "HMesh_Level::elUp" );
+
+ /* Search the upper mesh's elements. */
+ for( e_i = 0; e_i < nextMesh->elementDomainCount; e_i++ ) {
+ unsigned elInd = nextLevel->elDown[e_i];
+
+ /* Resize our element list. */
+ level->nElsUp[elInd]++;
+ if( level->elUp[elInd] ) {
+ level->elUp[elInd] = Memory_Realloc_Array( level->elUp[elInd], unsigned, level->nElsUp[elInd] );
+ }
+ else {
+ level->elUp[elInd] = Memory_Alloc_Array( unsigned, 1, "HMesh_Level::elUp[]" );
+ }
+
+ /* Add the up element. */
+ level->elUp[elInd][level->nElsUp[elInd] - 1] = e_i;
+ }
+
+ /* Use the up mapping to determine how many elements we have left unrefined on this level. */
+ for( e_i = 0; e_i < mesh->elementDomainCount; e_i++ )
+ if( !level->elUp[e_i] ) self->elementDomainCount++;
+ }
+}
+
+Bool HMesh_FindWeld( HMesh* self, unsigned level, Coord crd, unsigned* weld ) {
+ unsigned node;
+ Mesh* mesh;
+ Coord tmp;
+
+ assert( self );
+ assert( level > 0 && level < self->nLevels );
+
+ /* If there is no lower mesh, then what the hell are we doing here? */
+ mesh = self->levels[level - 1].mesh;
+ assert( mesh );
+
+ /* Find the closest node from lower mesh, check if it's close enough */
+ node = Mesh_ClosestNode( mesh, crd );
+ Vector_Sub( tmp, crd, mesh->nodeCoord[node] );
+ if( Vector_Mag( tmp ) < self->levels[level].weldEpsilon ) {
+ *weld = node;
+ return True;
+ }
+
+ return False;
+}
+
+void HMesh_CalcWeldEpsilons( HMesh* self ) {
+ unsigned l_i;
+ double lsep, sep;
+
+ assert( self );
+
+ /* If we don't have enough levels, skip the lot. */
+ if( self->nLevels <= 1 ) return;
+
+ /* Calculate the nodal separation for the coarsest mesh before
+ entering the loop; kind of an optimisation. */
+ lsep = Mesh_NodeSeparation( self->levels[0].mesh );
+ for( l_i = 1; l_i < self->nLevels; l_i++ ) {
+ Mesh* upper = self->levels[l_i].mesh;
+ double usep;
+
+ /* Get the minimum distance between any two nodes of each mesh. */
+ usep = Mesh_NodeSeparation( upper );
+ sep = usep < lsep ? usep : lsep;
+
+ /* Factor in the weld resolution. */
+ self->levels[l_i].weldEpsilon = sep * HMESH_WELD_RESOLUTION;
+
+ /* Flip the separations. */
+ lsep = usep;
+ }
+}
+
+void HMesh_DeleteLevel( HMesh_Level* level ) {
+ assert( level );
+
+ if( level->mesh && level->ownMesh ) Stg_Class_Delete( level->mesh );
+ else level->mesh = NULL;
+ KillArray( level->nodeUp );
+ KillArray( level->nodeDown );
+ KillArray( level->nodeGlobals );
+ KillArray2D( level->mesh->elementDomainCount, level->elUp );
+ KillArray( level->elDown );
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/HMesh.h
--- a/Mesh/src/HMesh.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Invariants:
-**
-** Comments:
-**
-** $Id: HMesh.h 3584 2006-05-16 11:11:07Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Domain_Mesh_HMesh_h__
-#define __Domain_Mesh_HMesh_h__
-
- /** Textual name of this class */
- extern const Type HMesh_Type;
-
- /** Virtual function types */
-
- /** Mesh class contents */
- typedef struct {
- Mesh* mesh;
- Bool ownMesh;
- unsigned* nodeUp;
- unsigned* nodeDown;
- unsigned* nodeGlobals;
- unsigned* nElsUp;
- unsigned** elUp;
- unsigned* elDown;
- double weldEpsilon;
- } HMesh_Level;
-
- #define __HMesh \
- /* General info */ \
- __Mesh \
- \
- /* Virtual info */ \
- \
- /* HMesh info */ \
- unsigned nLevels; \
- unsigned baseLevel; \
- HMesh_Level* levels; \
-
- struct _HMesh { __HMesh };
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- /* Create a HMesh */
- HMesh* HMesh_DefaultNew( Name name );
-
- HMesh* HMesh_New( Name name,
- void* layout,
- SizeT _nodeSize,
- SizeT _elementSize,
- void* extension_Register,
- Dictionary* dictionary );
-
- /* Initialise a Mesh */
- void HMesh_Init( HMesh* self,
- Name name,
- void* layout,
- SizeT _nodeSize,
- SizeT _elementSize,
- void* extension_Register,
- Dictionary* dictionary );
-
- /* Creation implementation */
- HMesh* _HMesh_New( SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name,
- Bool initFlag,
- Mesh_Node_IsLocalFunction* nodeIsLocal,
- Mesh_Node_IsShadowFunction* nodeIsShadow,
- Mesh_Element_IsLocalFunction* elementIsLocal,
- Mesh_Element_IsShadowFunction* elementIsShadow,
- void* layout,
- SizeT _nodeSize,
- SizeT _elementSize,
- void* extension_Register,
- Dictionary* dictionary );
-
- void _HMesh_LoadFromDict( void* mesh,
- Dictionary* subDict,
- Dictionary* dictionary,
- Stg_ObjectList* objList);
-
- /* Initialisation implementation functions */
- void _HMesh_Init( HMesh* self );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _HMesh_Delete( void* mesh );
- void _HMesh_Print( void* mesh, Stream* stream );
-
- #define HMesh_Copy( self ) \
- (Mesh*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
- #define HMesh_DeepCopy( self ) \
- (Mesh*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
- void* _HMesh_Copy( void* mesh, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
-
- void _HMesh_Build( void* mesh, void* data );
- void _HMesh_Construct( void* mesh, Stg_ComponentFactory* cf, void* data );
- void _HMesh_Initialise( void* mesh, void* data );
- void _HMesh_Execute( void* mesh, void* data );
- void _HMesh_Destroy( void* mesh, void* data );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Public functions
- */
-
- void HMesh_SetNLevels( HMesh* self, unsigned nLevels, unsigned baseLevel );
- void HMesh_SetMesh( HMesh* self, unsigned level, Mesh* mesh, Bool own );
- Mesh* HMesh_GenMesh( HMesh* self, unsigned level );
- Mesh* HMesh_GetMesh( HMesh* self, unsigned level );
- Mesh* HMesh_GetBaseMesh( HMesh* self );
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions
- */
-
- char* HMesh_GenName( HMesh* self, unsigned level );
- void HMesh_BuildNodes( HMesh* self );
- void HMesh_BuildElements( HMesh* self );
- Bool HMesh_FindWeld( HMesh* self, unsigned level, Coord crd, unsigned* weld );
- void HMesh_CalcWeldEpsilons( HMesh* self );
- void HMesh_DeleteLevel( HMesh_Level* level );
-
-#endif /* __Domain_Mesh_HMesh_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/HMesh.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/HMesh.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,170 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: HMesh.h 3584 2006-05-16 11:11:07Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Domain_Mesh_HMesh_h__
+#define __Domain_Mesh_HMesh_h__
+
+ /** Textual name of this class */
+ extern const Type HMesh_Type;
+
+ /** Virtual function types */
+
+ /** Mesh class contents */
+ typedef struct {
+ Mesh* mesh;
+ Bool ownMesh;
+ unsigned* nodeUp;
+ unsigned* nodeDown;
+ unsigned* nodeGlobals;
+ unsigned* nElsUp;
+ unsigned** elUp;
+ unsigned* elDown;
+ double weldEpsilon;
+ } HMesh_Level;
+
+ #define __HMesh \
+ /* General info */ \
+ __Mesh \
+ \
+ /* Virtual info */ \
+ \
+ /* HMesh info */ \
+ unsigned nLevels; \
+ unsigned baseLevel; \
+ HMesh_Level* levels; \
+
+ struct _HMesh { __HMesh };
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ /* Create a HMesh */
+ HMesh* HMesh_DefaultNew( Name name );
+
+ HMesh* HMesh_New( Name name,
+ void* layout,
+ SizeT _nodeSize,
+ SizeT _elementSize,
+ void* extension_Register,
+ Dictionary* dictionary );
+
+ /* Initialise a Mesh */
+ void HMesh_Init( HMesh* self,
+ Name name,
+ void* layout,
+ SizeT _nodeSize,
+ SizeT _elementSize,
+ void* extension_Register,
+ Dictionary* dictionary );
+
+ /* Creation implementation */
+ HMesh* _HMesh_New( SizeT _sizeOfSelf,
+ Type type,
+ Stg_Class_DeleteFunction* _delete,
+ Stg_Class_PrintFunction* _print,
+ Stg_Class_CopyFunction* _copy,
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor,
+ Stg_Component_ConstructFunction* _construct,
+ Stg_Component_BuildFunction* _build,
+ Stg_Component_InitialiseFunction* _initialise,
+ Stg_Component_ExecuteFunction* _execute,
+ Stg_Component_DestroyFunction* _destroy,
+ Name name,
+ Bool initFlag,
+ Mesh_Node_IsLocalFunction* nodeIsLocal,
+ Mesh_Node_IsShadowFunction* nodeIsShadow,
+ Mesh_Element_IsLocalFunction* elementIsLocal,
+ Mesh_Element_IsShadowFunction* elementIsShadow,
+ void* layout,
+ SizeT _nodeSize,
+ SizeT _elementSize,
+ void* extension_Register,
+ Dictionary* dictionary );
+
+ void _HMesh_LoadFromDict( void* mesh,
+ Dictionary* subDict,
+ Dictionary* dictionary,
+ Stg_ObjectList* objList);
+
+ /* Initialisation implementation functions */
+ void _HMesh_Init( HMesh* self );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _HMesh_Delete( void* mesh );
+ void _HMesh_Print( void* mesh, Stream* stream );
+
+ #define HMesh_Copy( self ) \
+ (Mesh*)Stg_Class_Copy( self, NULL, False, NULL, NULL )
+ #define HMesh_DeepCopy( self ) \
+ (Mesh*)Stg_Class_Copy( self, NULL, True, NULL, NULL )
+ void* _HMesh_Copy( void* mesh, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap );
+
+ void _HMesh_Build( void* mesh, void* data );
+ void _HMesh_Construct( void* mesh, Stg_ComponentFactory* cf, void* data );
+ void _HMesh_Initialise( void* mesh, void* data );
+ void _HMesh_Execute( void* mesh, void* data );
+ void _HMesh_Destroy( void* mesh, void* data );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+ void HMesh_SetNLevels( HMesh* self, unsigned nLevels, unsigned baseLevel );
+ void HMesh_SetMesh( HMesh* self, unsigned level, Mesh* mesh, Bool own );
+ Mesh* HMesh_GenMesh( HMesh* self, unsigned level );
+ Mesh* HMesh_GetMesh( HMesh* self, unsigned level );
+ Mesh* HMesh_GetBaseMesh( HMesh* self );
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+
+ char* HMesh_GenName( HMesh* self, unsigned level );
+ void HMesh_BuildNodes( HMesh* self );
+ void HMesh_BuildElements( HMesh* self );
+ Bool HMesh_FindWeld( HMesh* self, unsigned level, Coord crd, unsigned* weld );
+ void HMesh_CalcWeldEpsilons( HMesh* self );
+ void HMesh_DeleteLevel( HMesh_Level* level );
+
+#endif /* __Domain_Mesh_HMesh_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/src/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/src/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,11 @@
+import os
+Import('env')
+
+# Copy headers to our build directory.
+incs = env['helpers']['copyHdrs'](env)
+incs.append(env['helpers']['copyDefs'](env))
+
+# Build our source files.
+objs = env['helpers']['buildCSrcs'](env)
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Mesh/tests/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Mesh/tests/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,7 @@
+import os
+Import('env')
+
+# Build test binaries.
+env['helpers']['buildTests'](env, libs=['StgDomainGeometry',
+ 'StgDomainShape',
+ 'StgDomainMesh'])
diff -r 8e9e91298ee8 -r c8338a44bcc5 SConfigure
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SConfigure Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,318 @@
+import os, sys
+Import('env opts')
+
+#
+# Helper functions.
+#
+
+def getPETScArch(baseDir):
+ petscconf = os.path.join(baseDir, 'bmake', 'petscconf')
+ if not os.path.exists(petscconf):
+ return None
+ f = file(petscconf, 'r')
+ arch = f.readline().split('=')[1][:-1]
+ f.close()
+ return arch
+
+def setupPETScHdrPath(env, baseDir):
+ arch = getPETScArch(baseDir)
+ if arch:
+ return os.path.join(baseDir, 'bmake', arch)
+ else:
+ return None
+
+def setupPETScLibPath(env, baseDir):
+ arch = getPETScArch(baseDir)
+ if arch:
+ return os.path.join(baseDir, 'lib', arch)
+ else:
+ return None
+
+def pushPaths(env, cppPaths=[], libPaths=[]):
+ state = ['', '']
+ state[0] = env['CPPPATH'] if 'CPPPATH' in env._dict else None
+ state[1] = env['LIBPATH'] if 'LIBPATH' in env._dict else None
+ for p in cppPaths:
+ env.AppendUnique(CPPPATH=[p])
+ for p in libPaths:
+ env.AppendUnique(LIBPATH=[p])
+ return state
+
+def popPaths(env, state):
+ env.Replace(CPPPATH=state[0])
+ env.Replace(LIBPATH=state[1])
+
+def appendExts(baseDir, exts):
+ paths = []
+ for e in exts:
+ if isinstance(e, str):
+ paths.append(os.path.join(baseDir, e))
+ else:
+ paths.append(e(env, baseDir))
+ return paths
+
+def packageSearch(cfg, name, check,
+ places=[],
+ hdrExts=['include'], libExts=['lib'],
+ useSplit=True, useRPATH=False):
+ env = cfg.env
+
+ # If user specified paths, use that specifically.
+ key = name.lower() + 'Dir'
+ if key in env._dict:
+ cppPaths = appendExts(env[key], hdrExts)
+ libPaths = appendExts(env[key], libExts)
+ state = pushPaths(env, cppPaths, libPaths)
+ if check(cfg):
+ if useRPATH:
+ env.Append(RPATH=libPaths)
+ return
+ popPaths(env, state)
+ print "\nInvalid %s path: %s\n" % (name, env[key])
+ env.Exit()
+
+ if useSplit:
+ key = name.lower() + 'IncDir'
+ cppPaths = [env[key]] if key in env._dict else []
+ key = name.lower() + 'LibDir'
+ libPaths = [env[key]] if key in env._dict else []
+ if len(cppPaths) + len(libPaths) > 0:
+ state = pushPaths(env, cppPaths, libPaths)
+ if check(cfg):
+ if useRPATH:
+ env.Append(RPATH=libPaths)
+ return
+ popPaths(env, state)
+ print ''
+ if len(cppPaths):
+ print "Invalid %s header path: %s" % (name, cppPaths[0])
+ if len(libPaths):
+ print "Invalid %s library path: %s" % (name, libPaths[0])
+ print ''
+ env.Exit()
+
+ # Otherwise check if it is in a default location.
+ if check(cfg):
+ return
+ print "\nCouldn't find %s in a location the compiler knew" % name
+ print "about, looking in a few standard places...\n"
+
+ # Lastly, search any common installations.
+ for p in places:
+ if isinstance(p, str):
+ # 'p' is a base directory.
+ cppPaths = appendExts(p, hdrExts)
+ libPaths = appendExts(p, libExts)
+ state = pushPaths(env, cppPaths, libPaths)
+ else:
+ # 'p' must be a tuple with include and library paths.
+ cppPaths = [p[0]] if p[0] is not None else []
+ libPaths = [p[1]] if p[1] is not None else []
+ state = pushPaths(env, cppPaths, libPaths)
+ if check(cfg):
+ if useRPATH:
+ env.Append(RPATH=libPaths)
+ print ''
+ if len(cppPaths):
+ print 'Using include path: %s' % cppPaths[0]
+ if len(libPaths):
+ print 'Using library path: %s' % libPaths[0]
+ print ''
+ return
+ popPaths(env, state)
+
+ # If we end up here we couldn't find the package.
+ key = name.lower()
+ print "Please specify your %s installation on the" % name
+ print "commandline using any of the following:"
+ print " %sDir=<path to %s base directory>" % (key, name)
+ if useSplit:
+ print " %sIncDir=<path to %s header directory>" % (key, name)
+ print " %sLibDir=<path to %s library directory>\n" % (key, name)
+ env.Exit()
+
+#
+# Custom configuration checks.
+#
+
+def CheckMPICH(ctx):
+ src = """
+#include<mpi.h>
+int main(int argc, char** argv) {
+MPI_Init(&argc, &argv);
+MPI_Finalize();
+return 0;
+}
+"""
+ env = ctx.env
+ ctx.Message('Checking for MPICH... ')
+
+ env.Replace(LIBS=['mpich'])
+ res = ctx.TryLink(src, '.c')
+ if res:
+ ctx.Result(res)
+ return res
+
+ env.Replace(LIBS=['mpich', 'pmpich'])
+ res = ctx.TryLink(src, '.c')
+ if res:
+ ctx.Result(res)
+ return res
+
+ env.Replace(LIBS=['mpich', 'rt'])
+ res = ctx.TryLink(src, '.c')
+ if res:
+ ctx.Result(res)
+ return res
+
+ env.Replace(LIBS=['mpich', 'pmpich', 'rt'])
+ res = ctx.TryLink(src, '.c')
+
+ ctx.Result(res)
+ return res
+
+def CheckFortranSymbol(ctx):
+ fSrc = """
+ Program Conftest
+ external method
+ integer i
+ call method(i)
+ stop
+ end
+"""
+ cSrc = """
+#include <stdio.h>
+void method(int *i){printf("-DFORTRAN_NORMAL");}
+void method_(int *i){printf("-DFORTRAN_SINGLE_TRAILINGBAR");}
+void method__(int *i){printf("-DFORTRAN_DOUBLE_TRAILINGBAR");}
+void METHOD(int *i){printf("-DFORTRAN_UPPERCASE");}
+"""
+ env = ctx.env
+ ctx.Message('Checking for fortran symbol type... ')
+
+ res = ctx.TryCompile(cSrc, '.c')
+ if not res:
+ ctx.Result(res)
+ return res
+ cObj = ctx.lastTarget
+
+ oldLINK = env['LINK'] if 'LINK' in env._dict else None
+ oldLINKFLAGS = env['LINKFLAGS'] if 'LINKFLAGS' in env._dict else None
+ oldLIBS = env['LIBS'] if 'LIBS' in env._dict else None
+ env['LINK'] = env['_FORTRAND']
+ env['LINKFLAGS'] = str(cObj)
+ env['LIBS'] = []
+ res = ctx.TryRun(fSrc, '.F')
+ env['LINK'] = oldLINK
+ env['LINKFLAGS'] = oldLINKFLAGS
+ env['LIBS'] = oldLIBS
+ if not res[0]:
+ ctx.Result(res[0])
+ return res[0]
+
+ env.Append(CPPFLAGS=[res[1]])
+ ctx.Result(res[0])
+ return res[0]
+
+#
+# Configuration script.
+#
+
+# Setup some check functions for package searching.
+def checkMPICH(cfg):
+ return cfg.CheckMPICH()
+
+def checkLibXML2(cfg):
+ return cfg.CheckLibWithHeader('xml2', 'libxml/xmlIO.h', 'C')
+
+def checkStGermain(cfg):
+ return cfg.CheckLibWithHeader('StGermain', 'StGermain/StGermain.h',
+ 'C')
+
+# Do configuration.
+if not env.GetOption('clean'):
+ cfg = Configure(env,
+ custom_tests={'CheckMPICH':
+ CheckMPICH,
+ 'CheckFortranSymbol':
+ CheckFortranSymbol})
+
+ #
+ # Check for the C math library.
+ #
+
+ if not cfg.CheckLib('m'):
+ print "Couldn't find the C standard math libaray."
+ env.Exit()
+
+ #
+ # Check for MPI.
+ #
+
+ packageSearch(cfg, 'MPICH', checkMPICH,
+ ['/usr/local/mpich'])
+ opts.Save('config.cache', env)
+
+ #
+ # Check for libXML2.
+ #
+
+ packageSearch(cfg, 'libXML2', checkLibXML2,
+ [('/usr/include/libxml2', None)])
+ opts.Save('config.cache', env)
+
+ #
+ # Check for StGermain.
+ #
+
+ packageSearch(cfg, 'StGermain', checkStGermain,
+ [os.path.abspath('../StGermain/build')],
+ useRPATH=True)
+ opts.Save('config.cache', env)
+
+ #
+ # Check Fortran symbol type.
+ #
+
+ if not cfg.CheckFortranSymbol():
+ print 'Fortran symbol check failed.'
+ env.Exit()
+
+ #
+ # Extract revision number.
+ #
+
+ svnPath = os.path.join('.svn', 'entries')
+ if not os.path.exists(svnPath):
+ print "\nYou appear to be building the code from something"
+ print "that wasn't checked out of a repository. Bummer."
+ env.Exit()
+ f = file(svnPath, 'r')
+ f.readline()
+ f.readline()
+ f.readline()
+ ver = '\\"' + str(int(f.readline())) + '\\"'
+ env.Append(CPPDEFINES=[('VERSION', ver)])
+ f.close()
+
+ #
+ # Add module extension to build commands.
+ #
+
+ ext = '\\"' + env['SHLIBSUFFIX'][1:] + '\\"'
+ env.Append(CPPDEFINES=[('MODULE_EXT', ext)])
+
+ #
+ # Add the library directory.
+ #
+
+ libDir = '\\"' + os.path.join(Dir('.').abspath, 'build', 'lib') + '\\"'
+ env.Append(CPPDEFINES=[('LIB_DIR', libDir)])
+
+ #
+ # Setup the dynamic library search paths.
+ #
+
+ env.Append(RPATH=[os.path.join(Dir('.').abspath, 'build', 'lib')])
+
+ env = cfg.Finish()
diff -r 8e9e91298ee8 -r c8338a44bcc5 SConstruct
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SConstruct Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,70 @@
+import os, glob
+
+# Check versions of some things.
+EnsurePythonVersion(2, 5)
+EnsureSConsVersion(0, 97)
+
+#
+# Setup our option database.
+#
+
+opts = Options('config.cache')
+opts.AddOptions(
+ BoolOption('debug', 'Enable debugging version', 1),
+ BoolOption('useMpiRecord', 'Don''t know what this does...', 0),
+ PathOption('prefix', 'Installation path',
+ '/usr/local', PathOption.PathIsDirCreate),
+ PathOption('mpichDir', 'MPI installation path',
+ None, PathOption.PathIsDir),
+ PathOption('mpichIncDir', 'MPICH header installation path',
+ None, PathOption.PathIsDir),
+ PathOption('mpichLibDir', 'MPICH library installation path',
+ None, PathOption.PathIsDir),
+ PathOption('petscDir', 'PETSc installation path',
+ None, PathOption.PathIsDir),
+ PathOption('libxml2Dir', 'libXML2 installation path',
+ None, PathOption.PathIsDir),
+ PathOption('libxml2IncDir', 'libXML2 header installation path',
+ None, PathOption.PathIsDir),
+ PackageOption('csoap', 'Enable use of the package CSoap', 'no'))
+
+#
+# Create our substitution environment.
+#
+
+env = Environment(CC='cc', ENV=os.environ, options=opts)
+if env['debug']:
+ env.Append(CCFLAGS='-g')
+env.Append(CPPPATH=['#build/include'])
+env.Append(CPPPATH=['#build/include/StgDomain'])
+env.Append(LIBPATH=['#build/lib'])
+env.Alias('install', env['prefix'])
+
+# Add any variables that get used throughout the whole build.
+env.proj = 'StgDomain'
+
+# Add any helper functions we may need.
+SConscript('StgSCons', exports='env')
+
+#
+# Configuration section.
+#
+
+SConscript('SConfigure', exports='env opts')
+
+#
+# Target specification section.
+#
+
+# Specify build and source directories.
+env.BuildDir('build', '.', duplicate=0)
+
+# Recurse into subdirectories to build source.
+objs = SConscript('build/Geometry/SConscript', exports='env')
+objs += SConscript('build/Shape/SConscript', exports='env')
+objs += SConscript('build/Mesh/SConscript', exports='env')
+objs += SConscript('build/Utils/SConscript', exports='env')
+objs += SConscript('build/Swarm/SConscript', exports='env')
+
+# Build the StgDomain library.
+SConscript('build/libStgDomain/SConscript', exports='env objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Shape/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Shape/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,18 @@
+import os
+Import('env')
+
+# Setup current module.
+env.curModule = env['helpers']['buildModName'](env)
+
+# Execute subdirectory SConscripts.
+objs = SConscript('src/SConscript', exports='env')
+
+# Build libraries.
+libs = env.Library(env['helpers']['buildLibDir'](env), objs)
+libs += env.LoadableModule(env['helpers']['buildLibDir'](env), objs)
+env.Install(os.path.join(env['prefix'], 'lib'), libs)
+
+# Build tests.
+SConscript('tests/SConscript', exports='env')
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Shape/src/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Shape/src/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,10 @@
+import os
+Import('env')
+
+# Copy headers to our build directory.
+incs = env['helpers']['copyHdrs'](env)
+
+# Build our source files.
+objs = env['helpers']['buildCSrcs'](env)
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Shape/tests/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Shape/tests/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,6 @@
+import os
+Import('env')
+
+# Build test binaries.
+env['helpers']['buildTests'](env, libs=['StgDomainGeometry',
+ 'StgDomainShape'])
diff -r 8e9e91298ee8 -r c8338a44bcc5 StgSCons
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/StgSCons Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,135 @@
+import os, glob
+Import('env')
+
+#
+# Helper functions.
+#
+
+def buildHdrPath(env, hdr):
+ hdr = File(hdr)
+ dirs = hdr.path.split(os.path.sep)
+ del dirs[-2]
+ dirs.insert(1, env.proj)
+ dirs.insert(1, 'include')
+ return os.path.sep.join(dirs)
+
+def buildModName(env):
+ ext = Dir('.').srcnode().path.replace(os.path.sep, '')
+ return env.proj + ext
+
+def buildLibDir(env):
+ return '#build/lib/' + buildModName(env)
+
+def copyFile(env, name, dstPath):
+ # If we're cleaning, forget about it.
+ if env.GetOption(['clean']):
+ return
+ src = File(name).srcnode().abspath
+ dstFile = File('#' + dstPath)
+ dst = dstFile.abspath
+ dstDir = os.path.dirname(dst)
+ if not os.path.exists(dstDir):
+ Execute(Mkdir(dstDir))
+ if not dstFile.current():
+ Execute(Copy(dst, src))
+ return dstFile
+
+def copyHdrs(env):
+ nodes = []
+ ptrn = os.path.join(Dir('.').srcnode().abspath, '*.h')
+ hdrs = [os.path.basename(h) for h in glob.iglob(ptrn)]
+ for h in hdrs:
+ dstDir = '#' + os.path.dirname(buildHdrPath(env, h))
+ nodes.append(env.Install(dstDir, h))
+ return nodes
+
+def copyDefs(env):
+ nodes = []
+ ptrn = os.path.join(Dir('.').srcnode().abspath, '*.def')
+ defs = [os.path.basename(d) for d in glob.iglob(ptrn)]
+ for d in defs:
+ if d == 'Makefile.def':
+ continue
+ hdrPath = buildHdrPath(env, d)
+ dstDir = '#' + os.path.dirname(hdrPath)
+ nodes.append(env.Install(dstDir, d))
+ # We need to copy straight away because of bogus deps.
+ copyFile(env, d, hdrPath)
+ return nodes
+
+def buildCSrcs(env, **kw):
+ nodes = []
+
+ # Collect standard C files.
+ ptrn = os.path.join(Dir('.').srcnode().abspath, '*.c')
+ srcs = [os.path.basename(s) for s in glob.iglob(ptrn)]
+
+ # Now add meta files.
+ ptrn = os.path.join(Dir('.').srcnode().abspath, '*.meta')
+ metas = [os.path.basename(s) for s in glob.iglob(ptrn)]
+ srcs.append(env.Meta(metas))
+
+ # Go for it.
+ modName = ('CURR_MODULE_NAME', '\\"' + env.curModule + '\\"')
+ curDefs = env['CPPDEFINES'] if 'CPPDEFINES' in env._dict else []
+ for s in srcs:
+ nodes.append(env.SharedObject(s, CPPDEFINES=curDefs +
+ [modName]))
+ return nodes
+
+def buildTests(env, objs=[], libs=[]):
+ ptrn = os.path.join(Dir('.').srcnode().abspath, 'test*.c')
+ srcs = [os.path.basename(s) for s in glob.iglob(ptrn)]
+ ptrn = os.path.join(Dir('.').srcnode().abspath, '*Suite.c')
+ srcs += [os.path.basename(s) for s in glob.iglob(ptrn)]
+ modName = ('CURR_MODULE_NAME', '\\"' + env.curModule + '\\"')
+ curDefs = env['CPPDEFINES'] if 'CPPDEFINES' in env._dict else []
+ curLibs = env['LIBS'] if 'LIBS' in env._dict else []
+ for s in srcs:
+ env.Program('#build/tests/' + os.path.splitext(s)[0], [s, objs],
+ LIBS=curLibs + [libs],
+ CPPDEFINES=curDefs + [modName])
+
+# Add any helper functions we want to use in child SConscripts.
+env['helpers'] = {}
+env['helpers']['buildHdrPath'] = buildHdrPath
+env['helpers']['buildModName'] = buildModName
+env['helpers']['buildLibDir'] = buildLibDir
+env['helpers']['copyFile'] = copyFile
+env['helpers']['copyHdrs'] = copyHdrs
+env['helpers']['copyDefs'] = copyDefs
+env['helpers']['buildCSrcs'] = buildCSrcs
+env['helpers']['buildTests'] = buildTests
+
+#
+# Custom builders.
+#
+
+# Builder for generating meta files (courtesy of Walter Landry).
+def create_meta(target, source, env):
+ output_file = file(str(target[0]),'wb')
+ output_file.write("#define XML_METADATA \"")
+ xml_file = file(str(source[0]))
+ xml_lines = xml_file.readlines()
+ for l in xml_lines:
+ output_file.write(l.replace('\"','\\\"')[:-1])
+ output_file.write("\"\n#define COMPONENT_NAME ")
+ for l in xml_lines:
+ start=l.find('<param name="Name">')
+ if start!=-1:
+ end=l.find('<',start+19)
+ if end==-1:
+ raise RunTimeError('Malformed XML file. The file '
+ + str(source[0])
+ + ' does not close off <param name="Name"> on the same line.')
+ output_file.write(l[start+19:end])
+ output_file.write("\n")
+ break
+ template_file=file("meta-template.c")
+ output_file.write(template_file.read())
+
+def gen_meta_suffix(env, sources):
+ return "-meta.c"
+
+env['BUILDERS']['Meta']=Builder(action=create_meta,src_suffix="meta",
+ suffix=gen_meta_suffix,single_source=True)
diff -r 8e9e91298ee8 -r c8338a44bcc5 Swarm/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Swarm/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,18 @@
+import os
+Import('env')
+
+# Setup current module.
+env.curModule = env['helpers']['buildModName'](env)
+
+# Execute subdirectory SConscripts.
+objs = SConscript('src/SConscript', exports='env')
+
+# Build libraries.
+libs = env.Library(env['helpers']['buildLibDir'](env), objs)
+libs += env.LoadableModule(env['helpers']['buildLibDir'](env), objs)
+env.Install(os.path.join(env['prefix'], 'lib'), libs)
+
+# Build tests.
+SConscript('tests/SConscript', exports='env')
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Swarm/src/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Swarm/src/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,10 @@
+import os
+Import('env')
+
+# Copy headers to our build directory.
+incs = env['helpers']['copyHdrs'](env)
+
+# Build our source files.
+objs = env['helpers']['buildCSrcs'](env)
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Swarm/tests/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Swarm/tests/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,9 @@
+import os
+Import('env')
+
+# Build test binaries.
+env['helpers']['buildTests'](env, libs=['StgDomainGeometry',
+ 'StgDomainShape',
+ 'StgDomainMesh',
+ 'StgDomainUtils',
+ 'StgDomainSwarm'])
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,18 @@
+import os
+Import('env')
+
+# Setup current module.
+env.curModule = env['helpers']['buildModName'](env)
+
+# Execute subdirectory SConscripts.
+objs = SConscript('src/SConscript', exports='env')
+
+# Build libraries.
+libs = env.Library(env['helpers']['buildLibDir'](env), objs)
+libs += env.LoadableModule(env['helpers']['buildLibDir'](env), objs)
+env.Install(os.path.join(env['prefix'], 'lib'), libs)
+
+# Build tests.
+SConscript('tests/SConscript', exports='env')
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/CellRemesher.c
--- a/Utils/src/CellRemesher.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,303 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: CellRemesher.c 2192 2004-10-15 02:45:38Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-#include <StgDomain/Mesh/Mesh.h>
-
-#include "types.h"
-#include "Remesher.h"
-#include "CellRemesher.h"
-
-
-/* Textual name of this class */
-const Type CellRemesher_Type = "CellRemesher";
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-#define REMESHER_DEFARGS \
- sizeof(CellRemesher), \
- CellRemesher_Type, \
- _CellRemesher_Delete, \
- _CellRemesher_Print, \
- NULL, \
- (void*(*)(Name))_CellRemesher_DefaultNew, \
- _CellRemesher_Construct, \
- _CellRemesher_Build, \
- _CellRemesher_Initialise, \
- _CellRemesher_Execute, \
- _CellRemesher_Destroy, \
- name, \
- False, \
- _CellRemesher_SetMesh
-
-
-CellRemesher* CellRemesher_New( Name name ) {
- return _CellRemesher_New( REMESHER_DEFARGS );
-}
-
-
-CellRemesher* _CellRemesher_New( CLASS_ARGS,
- COMPONENT_ARGS,
- REMESHER_ARGS )
-{
- CellRemesher* self;
-
- /* Allocate memory. */
- self = (CellRemesher*)_Remesher_New( _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name,
- initFlag,
- setMeshFunc );
-
- /* CellRemesher info */
- if( initFlag ) {
- _CellRemesher_Init( self );
- }
-
- return self;
-}
-
-
-void CellRemesher_Init( CellRemesher* self ) {
- assert( 0 ); /* TODO */
-#if 0
- /* General info */
- self->type = CellRemesher_Type;
- self->_sizeOfSelf = sizeof(CellRemesher);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _CellRemesher_Delete;
- self->_print = _CellRemesher_Print;
- self->_copy = NULL;
- _Stg_Class_Init( (Stg_Class*)self );
-
- /* CellRemesher info */
- _CellRemesher_Init( self );
-#endif
-}
-
-
-void _CellRemesher_Init( CellRemesher* self ) {
- /* CellRemesher info */
- memset( &self->nDims,
- 0,
- (size_t)&self->cellMesh - (size_t)&self->nDims + sizeof(Mesh*) );
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _CellRemesher_Delete( void* cellRemesher ) {
- CellRemesher* self = (CellRemesher*)cellRemesher;
-
- /* Delete the class itself */
- _CellRemesher_Free( self );
-
- /* Delete parent */
- _Remesher_Delete( cellRemesher );
-}
-
-
-void _CellRemesher_Print( void* cellRemesher, Stream* stream ) {
- CellRemesher* self = (CellRemesher*)cellRemesher;
- Stream* myStream;
-
- /* Set the Journal for printing informations */
- myStream = Journal_Register( InfoStream_Type, "CellRemesherStream" );
-
- /* Print parent */
- _Stg_Component_Print( self, stream );
-
- /* General info */
- Journal_Printf( myStream, "CellRemesher (ptr): (%p)\n", self );
-
- /* Virtual info */
-
- /* CellRemesher info */
-}
-
-
-CellRemesher* _CellRemesher_DefaultNew( Name name ) {
- return _CellRemesher_New( REMESHER_DEFARGS );
-}
-
-
-void _CellRemesher_Construct( void* cellRemesher, Stg_ComponentFactory* cf, void* data ) {
- CellRemesher* self = (CellRemesher*)cellRemesher;
- Dictionary* dict;
- char* cmName;
-
- assert( self );
- assert( cf );
- assert( cf->componentDict );
-
- _Remesher_Construct( self, cf, data );
-
- /* Get the number of dimensions. */
- dict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( cf->componentDict, self->name ) );
-
- /* Extract cell mesh. */
- cmName = Dictionary_GetString( dict, "cellMesh" );
- assert( cmName );
- self->cellMesh = Stg_ComponentFactory_ConstructByName( cf, cmName, Mesh, True, data );
-}
-
-
-void _CellRemesher_Build( void* cellRemesher, void* data ) {
- CellRemesher* self = (CellRemesher*)cellRemesher;
-
- assert( self );
-
- if( !self->meshType ) {
- return;
- }
-
- assert( self->mesh );
-
- /* Build parent. */
- _Remesher_Build( self, data );
-
- /* Build the cell mesh. */
- Build( self->cellMesh, data, False );
- self->nDims = Mesh_GetDimSize( self->cellMesh );
-}
-
-
-void _CellRemesher_Initialise( void* cellRemesher, void* data ) {
- CellRemesher* self = (CellRemesher*)cellRemesher;
-
- assert( self );
-
- /* Initialise parent. */
- _Remesher_Initialise( self, data );
-
- /* Initialise the cell mesh. */
- Initialise( self->cellMesh, data, False );
-}
-
-
-void _CellRemesher_Execute( void* cellRemesher, void* data ) {
- CellRemesher* self = (CellRemesher*)cellRemesher;
- double** meshCrds;
- double** cellCrds;
- unsigned e_i;
-
- assert( self );
- assert( self->mesh );
- assert( self->mesh->generator );
- assert( self->cellMesh );
- assert( self->cellMesh->generator );
- /* TODO: remaining asserts */
-
- meshCrds = self->mesh->verts;
- cellCrds = self->cellMesh->verts;
-
- /* Center the cell mesh's node coordinates in the cell mesh's elements. We assume identical
- ordering. */
- for( e_i = 0; e_i < Mesh_GetLocalSize( self->cellMesh, self->nDims ); e_i++ ) {
- unsigned nElNodes;
- unsigned* elNodes;
- double fac;
- unsigned d_i;
-
- Mesh_GetIncidence( self->cellMesh, self->nDims, e_i, MT_VERTEX,
- &nElNodes, &elNodes );
- fac = 1.0 / (double)nElNodes;
-
- memset( meshCrds[e_i], 0, self->nDims * sizeof(double) );
- for( d_i = 0; d_i < self->nDims; d_i++ ) {
- unsigned en_i;
-
- for( en_i = 0; en_i < nElNodes; en_i++ )
- meshCrds[e_i][d_i] += cellCrds[elNodes[en_i]][d_i];
- meshCrds[e_i][d_i] *= fac;
- }
- }
-}
-
-
-void _CellRemesher_Destroy( void* cellRemesher, void* data ) {
- CellRemesher* self = (CellRemesher*)cellRemesher;
-
- assert( self );
-
- /* TODO: If delete deletes, what does destroy do? */
-}
-
-
-void _CellRemesher_SetMesh( void* cellRemesher, Mesh* mesh ) {
- CellRemesher* self = (CellRemesher*)cellRemesher;
-
- assert( self );
-
- /* Kill all internals. */
- _CellRemesher_Free( self );
-
- /* Store the mesh. */
- self->mesh = mesh;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-void _CellRemesher_Free( CellRemesher* self ) {
- assert( self );
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/CellRemesher.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/CellRemesher.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,303 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: CellRemesher.c 2192 2004-10-15 02:45:38Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+#include <StgDomain/Mesh/Mesh.h>
+
+#include "types.h"
+#include "Remesher.h"
+#include "CellRemesher.h"
+
+
+/* Textual name of this class */
+const Type CellRemesher_Type = "CellRemesher";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+#define REMESHER_DEFARGS \
+ sizeof(CellRemesher), \
+ CellRemesher_Type, \
+ _CellRemesher_Delete, \
+ _CellRemesher_Print, \
+ NULL, \
+ (void*(*)(Name))_CellRemesher_DefaultNew, \
+ _CellRemesher_Construct, \
+ _CellRemesher_Build, \
+ _CellRemesher_Initialise, \
+ _CellRemesher_Execute, \
+ _CellRemesher_Destroy, \
+ name, \
+ False, \
+ _CellRemesher_SetMesh
+
+
+CellRemesher* CellRemesher_New( Name name ) {
+ return _CellRemesher_New( REMESHER_DEFARGS );
+}
+
+
+CellRemesher* _CellRemesher_New( CLASS_ARGS,
+ COMPONENT_ARGS,
+ REMESHER_ARGS )
+{
+ CellRemesher* self;
+
+ /* Allocate memory. */
+ self = (CellRemesher*)_Remesher_New( _sizeOfSelf,
+ type,
+ _delete,
+ _print,
+ _copy,
+ _defaultConstructor,
+ _construct,
+ _build,
+ _initialise,
+ _execute,
+ _destroy,
+ name,
+ initFlag,
+ setMeshFunc );
+
+ /* CellRemesher info */
+ if( initFlag ) {
+ _CellRemesher_Init( self );
+ }
+
+ return self;
+}
+
+
+void CellRemesher_Init( CellRemesher* self ) {
+ assert( 0 ); /* TODO */
+#if 0
+ /* General info */
+ self->type = CellRemesher_Type;
+ self->_sizeOfSelf = sizeof(CellRemesher);
+ self->_deleteSelf = False;
+
+ /* Virtual info */
+ self->_delete = _CellRemesher_Delete;
+ self->_print = _CellRemesher_Print;
+ self->_copy = NULL;
+ _Stg_Class_Init( (Stg_Class*)self );
+
+ /* CellRemesher info */
+ _CellRemesher_Init( self );
+#endif
+}
+
+
+void _CellRemesher_Init( CellRemesher* self ) {
+ /* CellRemesher info */
+ memset( &self->nDims,
+ 0,
+ (size_t)&self->cellMesh - (size_t)&self->nDims + sizeof(Mesh*) );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _CellRemesher_Delete( void* cellRemesher ) {
+ CellRemesher* self = (CellRemesher*)cellRemesher;
+
+ /* Delete the class itself */
+ _CellRemesher_Free( self );
+
+ /* Delete parent */
+ _Remesher_Delete( cellRemesher );
+}
+
+
+void _CellRemesher_Print( void* cellRemesher, Stream* stream ) {
+ CellRemesher* self = (CellRemesher*)cellRemesher;
+ Stream* myStream;
+
+ /* Set the Journal for printing informations */
+ myStream = Journal_Register( InfoStream_Type, "CellRemesherStream" );
+
+ /* Print parent */
+ _Stg_Component_Print( self, stream );
+
+ /* General info */
+ Journal_Printf( myStream, "CellRemesher (ptr): (%p)\n", self );
+
+ /* Virtual info */
+
+ /* CellRemesher info */
+}
+
+
+CellRemesher* _CellRemesher_DefaultNew( Name name ) {
+ return _CellRemesher_New( REMESHER_DEFARGS );
+}
+
+
+void _CellRemesher_Construct( void* cellRemesher, Stg_ComponentFactory* cf, void* data ) {
+ CellRemesher* self = (CellRemesher*)cellRemesher;
+ Dictionary* dict;
+ char* cmName;
+
+ assert( self );
+ assert( cf );
+ assert( cf->componentDict );
+
+ _Remesher_Construct( self, cf, data );
+
+ /* Get the number of dimensions. */
+ dict = Dictionary_Entry_Value_AsDictionary( Dictionary_Get( cf->componentDict, self->name ) );
+
+ /* Extract cell mesh. */
+ cmName = Dictionary_GetString( dict, "cellMesh" );
+ assert( cmName );
+ self->cellMesh = Stg_ComponentFactory_ConstructByName( cf, cmName, Mesh, True, data );
+}
+
+
+void _CellRemesher_Build( void* cellRemesher, void* data ) {
+ CellRemesher* self = (CellRemesher*)cellRemesher;
+
+ assert( self );
+
+ if( !self->meshType ) {
+ return;
+ }
+
+ assert( self->mesh );
+
+ /* Build parent. */
+ _Remesher_Build( self, data );
+
+ /* Build the cell mesh. */
+ Build( self->cellMesh, data, False );
+ self->nDims = Mesh_GetDimSize( self->cellMesh );
+}
+
+
+void _CellRemesher_Initialise( void* cellRemesher, void* data ) {
+ CellRemesher* self = (CellRemesher*)cellRemesher;
+
+ assert( self );
+
+ /* Initialise parent. */
+ _Remesher_Initialise( self, data );
+
+ /* Initialise the cell mesh. */
+ Initialise( self->cellMesh, data, False );
+}
+
+
+void _CellRemesher_Execute( void* cellRemesher, void* data ) {
+ CellRemesher* self = (CellRemesher*)cellRemesher;
+ double** meshCrds;
+ double** cellCrds;
+ unsigned e_i;
+
+ assert( self );
+ assert( self->mesh );
+ assert( self->mesh->generator );
+ assert( self->cellMesh );
+ assert( self->cellMesh->generator );
+ /* TODO: remaining asserts */
+
+ meshCrds = self->mesh->verts;
+ cellCrds = self->cellMesh->verts;
+
+ /* Center the cell mesh's node coordinates in the cell mesh's elements. We assume identical
+ ordering. */
+ for( e_i = 0; e_i < Mesh_GetLocalSize( self->cellMesh, self->nDims ); e_i++ ) {
+ unsigned nElNodes;
+ unsigned* elNodes;
+ double fac;
+ unsigned d_i;
+
+ Mesh_GetIncidence( self->cellMesh, self->nDims, e_i, MT_VERTEX,
+ &nElNodes, &elNodes );
+ fac = 1.0 / (double)nElNodes;
+
+ memset( meshCrds[e_i], 0, self->nDims * sizeof(double) );
+ for( d_i = 0; d_i < self->nDims; d_i++ ) {
+ unsigned en_i;
+
+ for( en_i = 0; en_i < nElNodes; en_i++ )
+ meshCrds[e_i][d_i] += cellCrds[elNodes[en_i]][d_i];
+ meshCrds[e_i][d_i] *= fac;
+ }
+ }
+}
+
+
+void _CellRemesher_Destroy( void* cellRemesher, void* data ) {
+ CellRemesher* self = (CellRemesher*)cellRemesher;
+
+ assert( self );
+
+ /* TODO: If delete deletes, what does destroy do? */
+}
+
+
+void _CellRemesher_SetMesh( void* cellRemesher, Mesh* mesh ) {
+ CellRemesher* self = (CellRemesher*)cellRemesher;
+
+ assert( self );
+
+ /* Kill all internals. */
+ _CellRemesher_Free( self );
+
+ /* Store the mesh. */
+ self->mesh = mesh;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void _CellRemesher_Free( CellRemesher* self ) {
+ assert( self );
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/CellRemesher.h
--- a/Utils/src/CellRemesher.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Invariants:
-**
-** Comments:
-**
-** $Id: CellRemesher.h 2225 1970-01-02 13:48:23Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __StGermain_Domain_Utils_CellRemesher_h__
-#define __StGermain_Domain_Utils_CellRemesher_h__
-
- /* Textual name of this class. */
- extern const Type CellRemesher_Type;
-
- /* Virtual function types. */
-
- /* Class contents. */
- #define __CellRemesher \
- /* General info */ \
- __Remesher \
- \
- /* Virtual info */ \
- \
- /* CellRemesher info ... */ \
- unsigned nDims; \
- Mesh* cellMesh;
-
- struct CellRemesher { __CellRemesher };
-
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- /* Create a CellRemesher */
- CellRemesher* CellRemesher_New( Name name );
-
- /* Creation implementation */
- CellRemesher* _CellRemesher_New( CLASS_ARGS,
- COMPONENT_ARGS,
- REMESHER_ARGS );
-
- /* Initialise a CellRemesher */
- void CellRemesher_Init( CellRemesher* self );
-
- /* Initialisation implementation functions */
- void _CellRemesher_Init( CellRemesher* self );
-
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _CellRemesher_Delete( void* cellRemesher );
- void _CellRemesher_Print( void* cellRemesher, Stream* stream );
- CellRemesher* _CellRemesher_DefaultNew( Name name );
- void _CellRemesher_Construct( void* cellRemesher, Stg_ComponentFactory* cf, void* data );
- void _CellRemesher_Build( void* cellRemesher, void* data );
- void _CellRemesher_Initialise( void* cellRemesher, void* data );
- void _CellRemesher_Execute( void* cellRemesher, void* data );
- void _CellRemesher_Destroy( void* cellRemesher, void* data );
-
- void _CellRemesher_SetMesh( void* cellRemesher, Mesh* mesh );
-
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Public functions
- */
-
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions
- */
-
- void _CellRemesher_Free( CellRemesher* self );
-
-#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/CellRemesher.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/CellRemesher.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,109 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: CellRemesher.h 2225 1970-01-02 13:48:23Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Domain_Utils_CellRemesher_h__
+#define __StGermain_Domain_Utils_CellRemesher_h__
+
+ /* Textual name of this class. */
+ extern const Type CellRemesher_Type;
+
+ /* Virtual function types. */
+
+ /* Class contents. */
+ #define __CellRemesher \
+ /* General info */ \
+ __Remesher \
+ \
+ /* Virtual info */ \
+ \
+ /* CellRemesher info ... */ \
+ unsigned nDims; \
+ Mesh* cellMesh;
+
+ struct CellRemesher { __CellRemesher };
+
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ /* Create a CellRemesher */
+ CellRemesher* CellRemesher_New( Name name );
+
+ /* Creation implementation */
+ CellRemesher* _CellRemesher_New( CLASS_ARGS,
+ COMPONENT_ARGS,
+ REMESHER_ARGS );
+
+ /* Initialise a CellRemesher */
+ void CellRemesher_Init( CellRemesher* self );
+
+ /* Initialisation implementation functions */
+ void _CellRemesher_Init( CellRemesher* self );
+
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _CellRemesher_Delete( void* cellRemesher );
+ void _CellRemesher_Print( void* cellRemesher, Stream* stream );
+ CellRemesher* _CellRemesher_DefaultNew( Name name );
+ void _CellRemesher_Construct( void* cellRemesher, Stg_ComponentFactory* cf, void* data );
+ void _CellRemesher_Build( void* cellRemesher, void* data );
+ void _CellRemesher_Initialise( void* cellRemesher, void* data );
+ void _CellRemesher_Execute( void* cellRemesher, void* data );
+ void _CellRemesher_Destroy( void* cellRemesher, void* data );
+
+ void _CellRemesher_SetMesh( void* cellRemesher, Mesh* mesh );
+
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+
+ void _CellRemesher_Free( CellRemesher* self );
+
+#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/EmbeddedSurface.c
--- a/Utils/src/EmbeddedSurface.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,331 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: EmbeddedSurface.c 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <mpi.h>
-#include <StGermain/StGermain.h>
-
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-#include <StgDomain/Mesh/Mesh.h>
-
-#include "types.h"
-#include "EmbeddedSurface.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-
-
-const Type EmbeddedSurface_Type = "EmbeddedSurface";
-
-
-EmbeddedSurface *EmbeddedSurface_New(Mesh *surface)
-{
- return _EmbeddedSurface_New(sizeof(EmbeddedSurface),
- EmbeddedSurface_Type,
- _EmbeddedSurface_Delete,
- _EmbeddedSurface_Print,
- surface);
-}
-
-
-EmbeddedSurface *_EmbeddedSurface_New(SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Mesh *surface)
-{
- EmbeddedSurface *self;
-
- /* Allocate memory */
- self = (EmbeddedSurface *)_Stg_Class_New(_sizeOfSelf,
- type,
- _delete,
- _print);
-
- /* General info */
- self->surface = surface;
-
- /* Virtual info */
-
- /* EmbeddedSurface info */
- _EmbeddedSurface_Init(self);
-
- return self;
-}
-
-
-void EmbeddedSurface_Init(EmbeddedSurface *self)
-{
- _EmbeddedSurface_Init(self);
-}
-
-
-void _EmbeddedSurface_Init(EmbeddedSurface *self)
-{
- /* Note: assumes surface is an irregular tri surf */
- Element_GlobalIndex edc = self->surface->elementDomainCount;
- Node *nodeAt;
- Coord *node;
- Triangle_List element = ((TriSurfTopology*)self->surface->layout->topology)->elementTbl;
- Coord *edgeVector;
- Element_Index *eltBndryCnt;
- Index i;
-
- /* Build coord list */
- node = Memory_Alloc_Array( Coord, self->surface->nodeDomainCount, "node" );
- for (i = 0; i < self->surface->nodeDomainCount; i++)
- {
- nodeAt = Mesh_NodeAt(self->surface, i);
- node[i][0] = ((Advectable *)nodeAt)->coord[0];
- node[i][1] = ((Advectable *)nodeAt)->coord[1];
- node[i][2] = ((Advectable *)nodeAt)->coord[2];
- }
-
- /* Build edge list and edge face list */
- self->edgeCount = Edge_BuildList_FromTriangles(element, edc, &self->edge, &self->edgeElement);
-
- /* Generate element normals/planes */
- self->elementPlane = Memory_Alloc_Array( Plane, edc, "EmbeddedSurface->elementPlace" );
- for (i = 0; i < edc; i++)
- {
- Coord a, b;
-
- Vector_Sub(a, node[element[i][1]], node[element[i][0]]);
- Vector_Sub(b, node[element[i][2]], node[element[i][0]]);
- Vector_Cross(self->elementPlane[i], a, b);
- Vector_Norm(self->elementPlane[i], self->elementPlane[i]);
- self->elementPlane[i][3] = Vector_Dot(self->elementPlane[i], node[element[i][0]]);
- }
-
- /* Order the edge faces, ie. edgeElement[i][0] = left face, edgeElement[i][1] = right face */
- edgeVector = Memory_Alloc_Array( Coord, self->edgeCount, "edgeVector" );
- for (i = 0; i < self->edgeCount; i++)
- {
- Node_Index ni0 = self->edge[i][0];
- Node_Index ni1 = self->edge[i][1];
- Element_Index ei0 = self->edgeElement[i][0];
- Node_Index ni2 = element[ei0][0] != ni1 ? element[ei0][0] :
- (element[ei0][1] != ni1 ? element[ei0][1] :
- element[ei0][2]);
- Coord elementVector, cross;
-
- Vector_Sub(edgeVector[i], node[ni1], node[ni0]);
- Vector_Sub(elementVector, node[ni2], node[ni0]);
- Vector_Cross(cross, edgeVector[i], elementVector);
- if (Vector_Dot(cross, self->elementPlane[ei0]) >= 0.0)
- {
- self->edgeElement[i][0] = self->edgeElement[i][1];
- self->edgeElement[i][1] = ei0;
- }
- }
-
- /* Build tables for determining distance from surface to point */
- eltBndryCnt = Memory_Alloc_Array( Element_Index, edc, "eltBndryCnt" );
- memset(eltBndryCnt, 0, sizeof(Element_Index)*edc);
-
- self->elementBoundary = Memory_Alloc_Array( TriangleBoundary, edc, "EmbeddedSurface->elementBoundary" );
-
- for (i = 0; i < self->edgeCount; i++)
- {
- Coord plane;
-
- if (self->edgeElement[i][0] < edc)
- {
- Element_Index eiLeft = self->edgeElement[i][0];
- Index epiLeft = eltBndryCnt[eiLeft]++;
-
- Vector_Set(plane, self->elementPlane[eiLeft]);
-
- if (self->edgeElement[i][1] < edc)
- {
- Element_Index eiRight = self->edgeElement[i][1];
- Index epiRight = eltBndryCnt[eiRight]++;
-
- Vector_Add(plane, plane, self->elementPlane[eiRight]);
-
- Vector_Cross(self->elementBoundary[eiLeft][epiLeft], edgeVector[i], plane);
- Vector_Mult(self->elementBoundary[eiRight][epiRight], self->elementBoundary[eiLeft][epiLeft], -1.0);
- Vector_Norm(self->elementBoundary[eiLeft][epiLeft], self->elementBoundary[eiLeft][epiLeft]);
- Vector_Norm(self->elementBoundary[eiRight][epiRight], self->elementBoundary[eiRight][epiRight]);
- self->elementBoundary[eiLeft][epiLeft][3] = Vector_Dot(self->elementBoundary[eiLeft][epiLeft], node[self->edge[i][0]]);
- self->elementBoundary[eiRight][epiRight][3] = Vector_Dot(self->elementBoundary[eiRight][epiRight], node[self->edge[i][0]]);
- }
- else
- {
- Vector_Cross(self->elementBoundary[eiLeft][epiLeft], edgeVector[i], plane);
- Vector_Norm(self->elementBoundary[eiLeft][epiLeft], self->elementBoundary[eiLeft][epiLeft]);
- self->elementBoundary[eiLeft][epiLeft][3] = Vector_Dot(self->elementBoundary[eiLeft][epiLeft], node[self->edge[i][0]]);
- }
- }
- else
- {
- Element_Index eiRight = self->edgeElement[i][1];
- Index epiRight = eltBndryCnt[eiRight]++;
-
- Vector_Set(plane, self->elementPlane[eiRight]);
-
- Vector_Cross(self->elementBoundary[eiRight][epiRight], edgeVector[i], plane);
- Vector_Mult(self->elementBoundary[eiRight][epiRight], self->elementBoundary[eiRight][epiRight], -1.0);
- Vector_Norm(self->elementBoundary[eiRight][epiRight], self->elementBoundary[eiRight][epiRight]);
- self->elementBoundary[eiRight][epiRight][3] = Vector_Dot(self->elementBoundary[eiRight][epiRight], node[self->edge[i][0]]);
- }
- }
-
- if (eltBndryCnt) Memory_Free(eltBndryCnt);
- if (edgeVector) Memory_Free(edgeVector);
- if (node) Memory_Free(node);
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Generic virtual functions
-*/
-
-void _EmbeddedSurface_Delete(void *embeddedSurface)
-{
- EmbeddedSurface *self = (EmbeddedSurface *)embeddedSurface;
-
- if (self->edge) Memory_Free(self->edge);
- if (self->edgeElement) Memory_Free(self->edgeElement);
- if (self->elementPlane) Memory_Free(self->elementPlane);
- if (self->elementBoundary) Memory_Free(self->elementBoundary);
-
- /* Stg_Class_Delete parent class */
- _Stg_Class_Delete(embeddedSurface);
-}
-
-
-void _EmbeddedSurface_Print(void *embeddedSurface)
-{
- EmbeddedSurface *self = (EmbeddedSurface *)embeddedSurface;
- Element_GlobalIndex edc = self->surface->elementDomainCount;
- Index i, j;
-
- /* Set the Journal for printing informations */
- Stream* embeddedSurfaceStream = Journal_Register( InfoStream_Type, "EmbeddedSurfaceStream");
-
- Journal_Printf( embeddedSurfaceStream, "EmbeddedSurface (%p):\n", self);
- Journal_Printf( embeddedSurfaceStream, "\tsurface: %p\n", self->surface);
-
- Journal_Printf( embeddedSurfaceStream, "\tedgeCount: %u\n", self->edgeCount);
- for (i = 0; i < self->edgeCount; i++)
- Journal_Printf( embeddedSurfaceStream, "\t\tedge[%u]: %u-->%u\n", i, self->edge[i][0], self->edge[i][1]);
- for (i = 0; i < self->edgeCount; i++)
- {
- Journal_Printf( embeddedSurfaceStream, "\t\tedgeElement[%u]: ", i);
- if (self->edgeElement[i][0] < edc)
- Journal_Printf( embeddedSurfaceStream, "left %03u, ", self->edgeElement[i][0]);
- else
- Journal_Printf( embeddedSurfaceStream, "left xxx, ");
- if (self->edgeElement[i][1] < edc)
- Journal_Printf( embeddedSurfaceStream, "right %03u\n", self->edgeElement[i][1]);
- else
- Journal_Printf( embeddedSurfaceStream, "right xxx\n");
- }
-
- for (i = 0; i < edc; i++)
- Journal_Printf( embeddedSurfaceStream, "\telementPlane[%u]: %.3fx + %.3fy + %.3fz = %.3f\n", i, self->elementPlane[i][0],
- self->elementPlane[i][1], self->elementPlane[i][2], self->elementPlane[i][3]);
- for (i = 0; i < edc; i++)
- for (j = 0; j < 3; j++)
- Journal_Printf( embeddedSurfaceStream, "\telementBoundary[%u][%u]: %.3fx + %.3fy + %.3fz = %.3f\n", i, j, self->elementBoundary[i][j][0],
- self->elementBoundary[i][j][1], self->elementBoundary[i][j][2], self->elementBoundary[i][j][3]);
-
- /* Print parent class */
- _Stg_Class_Print(embeddedSurface);
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Utility functions
-*/
-
-Element_GlobalIndex EmbeddedSurface_BuildIntersection(EmbeddedSurface *self, Element_GlobalIndex *intersect)
-{
- MeshLayout *spatial = ((IrregularMeshDecomp *)self->surface->layout->decomp)->_layout;
- Node *node;
- Node_GlobalIndex ndc = self->surface->nodeDomainCount;
- Element_GlobalIndex be, intersectCnt = 0;
- Index i, j;
-
- for (i = 0; i < ndc; i++)
- {
- node = Mesh_NodeAt(self->surface, i);
- be = MeshLayout_ElementWithPoint(spatial, ((Advectable *)node)->coord);
-
- for (j = 0; j < intersectCnt; j++)
- if (intersect[j] == be) break;
- if (j < intersectCnt) continue;
-
- intersect[intersectCnt++] = be;
- }
-
- return intersectCnt;
-}
-
-
-double EmbeddedSurface_DistanceToPoint(EmbeddedSurface *self, Coord point)
-{
- Element_GlobalIndex edc = self->surface->elementDomainCount;
- double dist[2];
- Bool first = True;
- Index i, j;
-
- for (i = 0; i < edc; i++)
- {
- for (j = 0; j < 3; j++)
- {
- dist[1] = Vector_Dot(self->elementBoundary[i][j], point);
- if (dist[1] < self->elementBoundary[i][j][3])
- break;
- }
- if (j < 3) continue;
-
- dist[1] = Vector_Dot(self->elementPlane[i], point);
- dist[1] = fabs(dist[1] - self->elementPlane[i][3]);
-
- if (!first)
- {
- if (dist[1] < dist[0])
- dist[0] = dist[1];
- }
- else
- {
- dist[0] = dist[1];
- first = False;
- }
- }
-
- if (first)
- Journal_Printf( (void*) stream, *** Warning *** : Point in DistanceToPoint outside plane domain\n");
-
- return dist[0];
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/EmbeddedSurface.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/EmbeddedSurface.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,331 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: EmbeddedSurface.c 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+#include <StgDomain/Mesh/Mesh.h>
+
+#include "types.h"
+#include "EmbeddedSurface.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+
+const Type EmbeddedSurface_Type = "EmbeddedSurface";
+
+
+EmbeddedSurface *EmbeddedSurface_New(Mesh *surface)
+{
+ return _EmbeddedSurface_New(sizeof(EmbeddedSurface),
+ EmbeddedSurface_Type,
+ _EmbeddedSurface_Delete,
+ _EmbeddedSurface_Print,
+ surface);
+}
+
+
+EmbeddedSurface *_EmbeddedSurface_New(SizeT _sizeOfSelf,
+ Type type,
+ Stg_Class_DeleteFunction* _delete,
+ Stg_Class_PrintFunction* _print,
+ Mesh *surface)
+{
+ EmbeddedSurface *self;
+
+ /* Allocate memory */
+ self = (EmbeddedSurface *)_Stg_Class_New(_sizeOfSelf,
+ type,
+ _delete,
+ _print);
+
+ /* General info */
+ self->surface = surface;
+
+ /* Virtual info */
+
+ /* EmbeddedSurface info */
+ _EmbeddedSurface_Init(self);
+
+ return self;
+}
+
+
+void EmbeddedSurface_Init(EmbeddedSurface *self)
+{
+ _EmbeddedSurface_Init(self);
+}
+
+
+void _EmbeddedSurface_Init(EmbeddedSurface *self)
+{
+ /* Note: assumes surface is an irregular tri surf */
+ Element_GlobalIndex edc = self->surface->elementDomainCount;
+ Node *nodeAt;
+ Coord *node;
+ Triangle_List element = ((TriSurfTopology*)self->surface->layout->topology)->elementTbl;
+ Coord *edgeVector;
+ Element_Index *eltBndryCnt;
+ Index i;
+
+ /* Build coord list */
+ node = Memory_Alloc_Array( Coord, self->surface->nodeDomainCount, "node" );
+ for (i = 0; i < self->surface->nodeDomainCount; i++)
+ {
+ nodeAt = Mesh_NodeAt(self->surface, i);
+ node[i][0] = ((Advectable *)nodeAt)->coord[0];
+ node[i][1] = ((Advectable *)nodeAt)->coord[1];
+ node[i][2] = ((Advectable *)nodeAt)->coord[2];
+ }
+
+ /* Build edge list and edge face list */
+ self->edgeCount = Edge_BuildList_FromTriangles(element, edc, &self->edge, &self->edgeElement);
+
+ /* Generate element normals/planes */
+ self->elementPlane = Memory_Alloc_Array( Plane, edc, "EmbeddedSurface->elementPlace" );
+ for (i = 0; i < edc; i++)
+ {
+ Coord a, b;
+
+ Vector_Sub(a, node[element[i][1]], node[element[i][0]]);
+ Vector_Sub(b, node[element[i][2]], node[element[i][0]]);
+ Vector_Cross(self->elementPlane[i], a, b);
+ Vector_Norm(self->elementPlane[i], self->elementPlane[i]);
+ self->elementPlane[i][3] = Vector_Dot(self->elementPlane[i], node[element[i][0]]);
+ }
+
+ /* Order the edge faces, ie. edgeElement[i][0] = left face, edgeElement[i][1] = right face */
+ edgeVector = Memory_Alloc_Array( Coord, self->edgeCount, "edgeVector" );
+ for (i = 0; i < self->edgeCount; i++)
+ {
+ Node_Index ni0 = self->edge[i][0];
+ Node_Index ni1 = self->edge[i][1];
+ Element_Index ei0 = self->edgeElement[i][0];
+ Node_Index ni2 = element[ei0][0] != ni1 ? element[ei0][0] :
+ (element[ei0][1] != ni1 ? element[ei0][1] :
+ element[ei0][2]);
+ Coord elementVector, cross;
+
+ Vector_Sub(edgeVector[i], node[ni1], node[ni0]);
+ Vector_Sub(elementVector, node[ni2], node[ni0]);
+ Vector_Cross(cross, edgeVector[i], elementVector);
+ if (Vector_Dot(cross, self->elementPlane[ei0]) >= 0.0)
+ {
+ self->edgeElement[i][0] = self->edgeElement[i][1];
+ self->edgeElement[i][1] = ei0;
+ }
+ }
+
+ /* Build tables for determining distance from surface to point */
+ eltBndryCnt = Memory_Alloc_Array( Element_Index, edc, "eltBndryCnt" );
+ memset(eltBndryCnt, 0, sizeof(Element_Index)*edc);
+
+ self->elementBoundary = Memory_Alloc_Array( TriangleBoundary, edc, "EmbeddedSurface->elementBoundary" );
+
+ for (i = 0; i < self->edgeCount; i++)
+ {
+ Coord plane;
+
+ if (self->edgeElement[i][0] < edc)
+ {
+ Element_Index eiLeft = self->edgeElement[i][0];
+ Index epiLeft = eltBndryCnt[eiLeft]++;
+
+ Vector_Set(plane, self->elementPlane[eiLeft]);
+
+ if (self->edgeElement[i][1] < edc)
+ {
+ Element_Index eiRight = self->edgeElement[i][1];
+ Index epiRight = eltBndryCnt[eiRight]++;
+
+ Vector_Add(plane, plane, self->elementPlane[eiRight]);
+
+ Vector_Cross(self->elementBoundary[eiLeft][epiLeft], edgeVector[i], plane);
+ Vector_Mult(self->elementBoundary[eiRight][epiRight], self->elementBoundary[eiLeft][epiLeft], -1.0);
+ Vector_Norm(self->elementBoundary[eiLeft][epiLeft], self->elementBoundary[eiLeft][epiLeft]);
+ Vector_Norm(self->elementBoundary[eiRight][epiRight], self->elementBoundary[eiRight][epiRight]);
+ self->elementBoundary[eiLeft][epiLeft][3] = Vector_Dot(self->elementBoundary[eiLeft][epiLeft], node[self->edge[i][0]]);
+ self->elementBoundary[eiRight][epiRight][3] = Vector_Dot(self->elementBoundary[eiRight][epiRight], node[self->edge[i][0]]);
+ }
+ else
+ {
+ Vector_Cross(self->elementBoundary[eiLeft][epiLeft], edgeVector[i], plane);
+ Vector_Norm(self->elementBoundary[eiLeft][epiLeft], self->elementBoundary[eiLeft][epiLeft]);
+ self->elementBoundary[eiLeft][epiLeft][3] = Vector_Dot(self->elementBoundary[eiLeft][epiLeft], node[self->edge[i][0]]);
+ }
+ }
+ else
+ {
+ Element_Index eiRight = self->edgeElement[i][1];
+ Index epiRight = eltBndryCnt[eiRight]++;
+
+ Vector_Set(plane, self->elementPlane[eiRight]);
+
+ Vector_Cross(self->elementBoundary[eiRight][epiRight], edgeVector[i], plane);
+ Vector_Mult(self->elementBoundary[eiRight][epiRight], self->elementBoundary[eiRight][epiRight], -1.0);
+ Vector_Norm(self->elementBoundary[eiRight][epiRight], self->elementBoundary[eiRight][epiRight]);
+ self->elementBoundary[eiRight][epiRight][3] = Vector_Dot(self->elementBoundary[eiRight][epiRight], node[self->edge[i][0]]);
+ }
+ }
+
+ if (eltBndryCnt) Memory_Free(eltBndryCnt);
+ if (edgeVector) Memory_Free(edgeVector);
+ if (node) Memory_Free(node);
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Generic virtual functions
+*/
+
+void _EmbeddedSurface_Delete(void *embeddedSurface)
+{
+ EmbeddedSurface *self = (EmbeddedSurface *)embeddedSurface;
+
+ if (self->edge) Memory_Free(self->edge);
+ if (self->edgeElement) Memory_Free(self->edgeElement);
+ if (self->elementPlane) Memory_Free(self->elementPlane);
+ if (self->elementBoundary) Memory_Free(self->elementBoundary);
+
+ /* Stg_Class_Delete parent class */
+ _Stg_Class_Delete(embeddedSurface);
+}
+
+
+void _EmbeddedSurface_Print(void *embeddedSurface)
+{
+ EmbeddedSurface *self = (EmbeddedSurface *)embeddedSurface;
+ Element_GlobalIndex edc = self->surface->elementDomainCount;
+ Index i, j;
+
+ /* Set the Journal for printing informations */
+ Stream* embeddedSurfaceStream = Journal_Register( InfoStream_Type, "EmbeddedSurfaceStream");
+
+ Journal_Printf( embeddedSurfaceStream, "EmbeddedSurface (%p):\n", self);
+ Journal_Printf( embeddedSurfaceStream, "\tsurface: %p\n", self->surface);
+
+ Journal_Printf( embeddedSurfaceStream, "\tedgeCount: %u\n", self->edgeCount);
+ for (i = 0; i < self->edgeCount; i++)
+ Journal_Printf( embeddedSurfaceStream, "\t\tedge[%u]: %u-->%u\n", i, self->edge[i][0], self->edge[i][1]);
+ for (i = 0; i < self->edgeCount; i++)
+ {
+ Journal_Printf( embeddedSurfaceStream, "\t\tedgeElement[%u]: ", i);
+ if (self->edgeElement[i][0] < edc)
+ Journal_Printf( embeddedSurfaceStream, "left %03u, ", self->edgeElement[i][0]);
+ else
+ Journal_Printf( embeddedSurfaceStream, "left xxx, ");
+ if (self->edgeElement[i][1] < edc)
+ Journal_Printf( embeddedSurfaceStream, "right %03u\n", self->edgeElement[i][1]);
+ else
+ Journal_Printf( embeddedSurfaceStream, "right xxx\n");
+ }
+
+ for (i = 0; i < edc; i++)
+ Journal_Printf( embeddedSurfaceStream, "\telementPlane[%u]: %.3fx + %.3fy + %.3fz = %.3f\n", i, self->elementPlane[i][0],
+ self->elementPlane[i][1], self->elementPlane[i][2], self->elementPlane[i][3]);
+ for (i = 0; i < edc; i++)
+ for (j = 0; j < 3; j++)
+ Journal_Printf( embeddedSurfaceStream, "\telementBoundary[%u][%u]: %.3fx + %.3fy + %.3fz = %.3f\n", i, j, self->elementBoundary[i][j][0],
+ self->elementBoundary[i][j][1], self->elementBoundary[i][j][2], self->elementBoundary[i][j][3]);
+
+ /* Print parent class */
+ _Stg_Class_Print(embeddedSurface);
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Utility functions
+*/
+
+Element_GlobalIndex EmbeddedSurface_BuildIntersection(EmbeddedSurface *self, Element_GlobalIndex *intersect)
+{
+ MeshLayout *spatial = ((IrregularMeshDecomp *)self->surface->layout->decomp)->_layout;
+ Node *node;
+ Node_GlobalIndex ndc = self->surface->nodeDomainCount;
+ Element_GlobalIndex be, intersectCnt = 0;
+ Index i, j;
+
+ for (i = 0; i < ndc; i++)
+ {
+ node = Mesh_NodeAt(self->surface, i);
+ be = MeshLayout_ElementWithPoint(spatial, ((Advectable *)node)->coord);
+
+ for (j = 0; j < intersectCnt; j++)
+ if (intersect[j] == be) break;
+ if (j < intersectCnt) continue;
+
+ intersect[intersectCnt++] = be;
+ }
+
+ return intersectCnt;
+}
+
+
+double EmbeddedSurface_DistanceToPoint(EmbeddedSurface *self, Coord point)
+{
+ Element_GlobalIndex edc = self->surface->elementDomainCount;
+ double dist[2];
+ Bool first = True;
+ Index i, j;
+
+ for (i = 0; i < edc; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ dist[1] = Vector_Dot(self->elementBoundary[i][j], point);
+ if (dist[1] < self->elementBoundary[i][j][3])
+ break;
+ }
+ if (j < 3) continue;
+
+ dist[1] = Vector_Dot(self->elementPlane[i], point);
+ dist[1] = fabs(dist[1] - self->elementPlane[i][3]);
+
+ if (!first)
+ {
+ if (dist[1] < dist[0])
+ dist[0] = dist[1];
+ }
+ else
+ {
+ dist[0] = dist[1];
+ first = False;
+ }
+ }
+
+ if (first)
+ Journal_Printf( (void*) stream, *** Warning *** : Point in DistanceToPoint outside plane domain\n");
+
+ return dist[0];
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/EmbeddedSurface.h
--- a/Utils/src/EmbeddedSurface.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Comments:
-**
-** $Id: EmbeddedSurface.h 3462 2006-02-19 06:53:24Z WalterLandry $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-#ifndef __Domain_Utils_EmbeddedSurface_h__
-#define __Domain_Utils_EmbeddedSurface_h__
-
-
- extern const Type EmbeddedSurface_Type;
-
-
- #define __EmbeddedSurface \
- /* General info */ \
- __Stg_Class \
- Mesh *surface; \
- \
- /* Virtual info */ \
- \
- /* EmbeddedSurface info */ \
- Edge_List edge; \
- Edge_Index edgeCount; \
- EdgeFaces *edgeElement; \
- \
- Plane *elementPlane; \
- TriangleBoundary *elementBoundary;
- struct _EmbeddedSurface { __EmbeddedSurface };
-
-
- /*--------------------------------------------------------------------------------------------------------------------------
- ** Constructor
- */
-
- EmbeddedSurface *EmbeddedSurface_New(Mesh *surface);
-
- EmbeddedSurface *_EmbeddedSurface_New(SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Mesh *surface);
-
- void EmbeddedSurface_Init(EmbeddedSurface *self);
-
- void _EmbeddedSurface_Init(EmbeddedSurface *self);
-
-
- /*----------------------------------------------------------------------------------------------------------------------------------
- ** Generic virtual functions
- */
-
- void _EmbeddedSurface_Delete(void *embeddedSurface);
-
- void _EmbeddedSurface_Print(void *embeddedSurface);
-
-
- /*----------------------------------------------------------------------------------------------------------------------------------
- ** Utility functions
- */
-
- #define ES_IntersectionMax(self) \
- (self)->surface->elementDomainCount
-
- Element_GlobalIndex EmbeddedSurface_BuildIntersection(EmbeddedSurface *self, Element_GlobalIndex *intersect);
-
- double EmbeddedSurface_DistanceToPoint(EmbeddedSurface *self, Coord point);
-
-
-#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/EmbeddedSurface.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/EmbeddedSurface.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,100 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: EmbeddedSurface.h 3462 2006-02-19 06:53:24Z WalterLandry $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+#ifndef __Domain_Utils_EmbeddedSurface_h__
+#define __Domain_Utils_EmbeddedSurface_h__
+
+
+ extern const Type EmbeddedSurface_Type;
+
+
+ #define __EmbeddedSurface \
+ /* General info */ \
+ __Stg_Class \
+ Mesh *surface; \
+ \
+ /* Virtual info */ \
+ \
+ /* EmbeddedSurface info */ \
+ Edge_List edge; \
+ Edge_Index edgeCount; \
+ EdgeFaces *edgeElement; \
+ \
+ Plane *elementPlane; \
+ TriangleBoundary *elementBoundary;
+ struct _EmbeddedSurface { __EmbeddedSurface };
+
+
+ /*--------------------------------------------------------------------------------------------------------------------------
+ ** Constructor
+ */
+
+ EmbeddedSurface *EmbeddedSurface_New(Mesh *surface);
+
+ EmbeddedSurface *_EmbeddedSurface_New(SizeT _sizeOfSelf,
+ Type type,
+ Stg_Class_DeleteFunction* _delete,
+ Stg_Class_PrintFunction* _print,
+ Mesh *surface);
+
+ void EmbeddedSurface_Init(EmbeddedSurface *self);
+
+ void _EmbeddedSurface_Init(EmbeddedSurface *self);
+
+
+ /*----------------------------------------------------------------------------------------------------------------------------------
+ ** Generic virtual functions
+ */
+
+ void _EmbeddedSurface_Delete(void *embeddedSurface);
+
+ void _EmbeddedSurface_Print(void *embeddedSurface);
+
+
+ /*----------------------------------------------------------------------------------------------------------------------------------
+ ** Utility functions
+ */
+
+ #define ES_IntersectionMax(self) \
+ (self)->surface->elementDomainCount
+
+ Element_GlobalIndex EmbeddedSurface_BuildIntersection(EmbeddedSurface *self, Element_GlobalIndex *intersect);
+
+ double EmbeddedSurface_DistanceToPoint(EmbeddedSurface *self, Coord point);
+
+
+#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,11 @@
+import os
+Import('env')
+
+# Copy headers to our build directory.
+incs = env['helpers']['copyHdrs'](env)
+incs.append(env['helpers']['copyDefs'](env))
+
+# Build our source files.
+objs = env['helpers']['buildCSrcs'](env)
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/SemiRegDeform.c
--- a/Utils/src/SemiRegDeform.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,472 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: SemiRegDeform.c 2192 2004-10-15 02:45:38Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-#include <StgDomain/Mesh/Mesh.h>
-
-#include "types.h"
-#include "SemiRegDeform.h"
-
-
-/* Textual name of this class */
-const Type SemiRegDeform_Type = "SemiRegDeform";
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-SemiRegDeform* SemiRegDeform_DefaultNew( Name name ) {
- return _SemiRegDeform_New(
- sizeof(SemiRegDeform),
- SemiRegDeform_Type,
- _SemiRegDeform_Delete,
- _SemiRegDeform_Print,
- NULL,
- (Stg_Component_DefaultConstructorFunction*)SemiRegDeform_DefaultNew,
- _SemiRegDeform_Construct,
- _SemiRegDeform_Build,
- _SemiRegDeform_Initialise,
- _SemiRegDeform_Execute,
- _SemiRegDeform_Destroy,
- name );
-}
-
-SemiRegDeform* SemiRegDeform_New( Name name ) {
- return _SemiRegDeform_New(
- sizeof(SemiRegDeform),
- SemiRegDeform_Type,
- _SemiRegDeform_Delete,
- _SemiRegDeform_Print,
- NULL,
- (Stg_Component_DefaultConstructorFunction*)SemiRegDeform_DefaultNew,
- _SemiRegDeform_Construct,
- _SemiRegDeform_Build,
- _SemiRegDeform_Initialise,
- _SemiRegDeform_Execute,
- _SemiRegDeform_Destroy,
- name );
-}
-
-SemiRegDeform* _SemiRegDeform_New( SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name )
-{
- SemiRegDeform* self;
-
- /* Allocate memory. */
- self = (SemiRegDeform*)_Stg_Component_New(
- _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name,
- NON_GLOBAL );
-
- /* General info */
-
- /* Virtual info */
-
- /* SemiRegDeform info */
- _SemiRegDeform_Init( self );
-
- return self;
-}
-
-void SemiRegDeform_Init( SemiRegDeform* self, Name name ) {
- /* General info */
- self->type = SemiRegDeform_Type;
- self->_sizeOfSelf = sizeof(SemiRegDeform);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _SemiRegDeform_Delete;
- self->_print = _SemiRegDeform_Print;
- self->_copy = NULL;
- self->_defaultConstructor = (Stg_Component_DefaultConstructorFunction*)SemiRegDeform_DefaultNew;
- self->_construct = _SemiRegDeform_Construct;
- self->_build = _SemiRegDeform_Build;
- self->_execute = _SemiRegDeform_Execute;
- self->_destroy = _SemiRegDeform_Destroy;
-
- _Stg_Class_Init( (Stg_Class*)self );
- _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
- _Stg_Component_Init( (Stg_Component*)self );
-
- /* SemiRegDeform info */
- _SemiRegDeform_Init( self );
-}
-
-void _SemiRegDeform_Init( SemiRegDeform* self ) {
- self->nStrips = 0;
- self->beginInds = NULL;
- self->endInds = NULL;
- self->conDims = NULL;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _SemiRegDeform_Delete( void* srd ) {
- SemiRegDeform* self = (SemiRegDeform*)srd;
-
- /* Delete the class itself */
- SemiRegDeform_Destruct( self );
-
- /* Delete parent */
- _Stg_Class_Delete( self );
-}
-
-void _SemiRegDeform_Print( void* srd, Stream* stream ) {
- SemiRegDeform* self = (SemiRegDeform*)srd;
- Stream* myStream;
-
- /* Set the Journal for printing informations */
- myStream = Journal_Register( InfoStream_Type, "SemiRegDeformStream" );
-
- /* Print parent */
- _Stg_Class_Print( self, stream );
-
- /* General info */
- Journal_Printf( myStream, "SemiRegDeform (ptr): (%p)\n", self );
-
- /* Virtual info */
-
- /* SemiRegDeform info */
-}
-
-void _SemiRegDeform_Construct( void* srd, Stg_ComponentFactory* cf, void* data ) {
-}
-
-void _SemiRegDeform_Build( void* srd, void* data ) {
-}
-
-void _SemiRegDeform_Initialise( void* srd, void* data ) {
- SemiRegDeform* self = (SemiRegDeform*)srd;
-
- assert( self );
-
-
- /*
- ** Validate the provided strips. No two strips can occupy any of the same nodes in the same
- ** dimension.
- */
-
- /* TODO */
-
-
- /*
- ** Initialise the synchronisation.
- */
-
- SemiRegDeform_InitSync( self );
-}
-
-void _SemiRegDeform_Execute( void* srd, void* data ) {
-}
-
-void _SemiRegDeform_Destroy( void* srd, void* data ) {
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void SemiRegDeform_SetMesh( void* srd, Mesh* mesh ) {
- SemiRegDeform* self = (SemiRegDeform*)srd;
-
- assert( !self->isInitialised );
-
- SemiRegDeform_Destruct( self );
- self->mesh = mesh;
-}
-
-void SemiRegDeform_AddStrip( void* srd, unsigned begin, unsigned end ) {
- SemiRegDeform* self = (SemiRegDeform*)srd;
- Grid* vertGrid;
- unsigned short conDim;
- IJK inds[2];
- Bool store;
- unsigned s_i;
-
- assert( self->mesh );
- assert( !self->isInitialised );
-
- /* Get the vertex grid. */
- vertGrid = *(Grid**)ExtensionManager_Get( self->mesh->info, self->mesh,
- ExtensionManager_GetHandle( self->mesh->info, "vertexGrid" ) );
-
- /*
- ** Ensure the specified strip has not already been added.
- */
-
-#ifndef NDEBUG
- for( s_i = 0; s_i < self->nStrips; s_i++ ) {
- if( self->beginInds[s_i] == begin && self->endInds[s_i] == end ) {
- assert( 0 );
- }
- }
-#endif
-
-
- /*
- ** Ensure the specified strip is one dimensionally valid.
- */
-
- {
- Bool found;
- unsigned d_i;
-
- Grid_Lift( vertGrid, begin, inds[0] );
- Grid_Lift( vertGrid, end, inds[1] );
-
- /* Find the one dimension that is not in-line. */
- found = False;
- for( d_i = 0; d_i < Mesh_GetDimSize( self->mesh ); d_i++ ) {
- if( inds[0][d_i] != inds[1][d_i] ) {
- /* Check if we have found multiple connected dimensions. */
- assert( found == False );
-
- found = True;
- conDim = d_i;
- }
- }
- }
-
-
- /*
- ** If the strip has no points stored locally then don't store on this processor.
- */
-
- {
- unsigned len = inds[1][conDim] - inds[0][conDim] + 1;
- IJK cur;
- unsigned n_i;
-
- store = False;
- memcpy( cur, inds[0], sizeof(IJK) );
- for( n_i = 0; n_i < len; n_i++ ) {
- unsigned gInd, dInd;
-
- gInd = Grid_Project( vertGrid, cur );
- if( Mesh_GlobalToDomain( self->mesh, MT_VERTEX, gInd, &dInd ) &&
- dInd < Mesh_GetLocalSize( self->mesh, MT_VERTEX ) )
- {
- store = True;
- break;
- }
- cur[conDim]++;
- }
- }
-
- if( !store )
- return;
-
- /*
- ** Store.
- */
-
- self->beginInds = Memory_Realloc_Array( self->beginInds, unsigned, self->nStrips + 1 );
- self->endInds = Memory_Realloc_Array( self->endInds, unsigned, self->nStrips + 1 );
- self->conDims = Memory_Realloc_Array( self->conDims, unsigned, self->nStrips + 1 );
- self->beginInds[self->nStrips] = begin;
- self->endInds[self->nStrips] = end;
- self->conDims[self->nStrips] = conDim;
- self->nStrips++;
-}
-
-#define GET_VAL( ind ) \
- (((ind) < Mesh_GetLocalSize( self->mesh, MT_VERTEX )) ? self->mesh->verts[ind] : \
- self->remVerts[ind - Mesh_GetLocalSize( self->mesh, MT_VERTEX )])
-
-void SemiRegDeform_Deform( void* srd ) {
- SemiRegDeform* self = (SemiRegDeform*)srd;
- Grid* vertGrid;
-
- assert( self );
-
- /* Get the vertex grid. */
- vertGrid = *(Grid**)ExtensionManager_Get( self->mesh->info, self->mesh,
- ExtensionManager_GetHandle( self->mesh->info, "vertexGrid" ) );
-
- /*
- ** Actually deform the specified strips.
- */
-
- /* Import remote values. */
- Decomp_Sync_SyncArray( self->sync, self->syncArray );
-
- /* Interpolate each strip. */
- {
- unsigned nDims;
- unsigned* begin;
- unsigned* end;
- unsigned strip_i;
-
- /* Get dimensionality. */
- nDims = Mesh_GetDimSize( self->mesh );
-
- /* Allocate for the dimensions. */
- begin = Memory_Alloc_Array( unsigned, nDims, "SemiRegDeform" );
- end = Memory_Alloc_Array( unsigned, nDims, "SemiRegDeform" );
-
- for( strip_i = 0; strip_i < self->nStrips; strip_i++ ) {
- unsigned len;
- unsigned conDim;
- double first, step;
- unsigned dInd;
- unsigned node_i;
-
- /* Extract the basics. */
- Grid_Lift( vertGrid, self->beginInds[strip_i], begin );
- Grid_Lift( vertGrid, self->endInds[strip_i], end );
- conDim = self->conDims[strip_i];
- len = end[conDim] - begin[conDim] + 1;
- assert( len > 1 );
-
- insist( Sync_GlobalToDomain( self->sync, self->beginInds[strip_i], &dInd ), == True );
- first = GET_VAL( dInd )[conDim];
- insist( Sync_GlobalToDomain( self->sync, self->endInds[strip_i], &dInd ), == True );
- step = GET_VAL( dInd )[conDim];
- step = (step - first) / (len - 1);
-
- /* Loop and interpolate. */
- for( node_i = 1; node_i < len - 1; node_i++ ) {
- unsigned ind;
-
- begin[conDim]++;
- ind = Grid_Project( vertGrid, begin );
- if( Sync_GlobalToDomain( self->sync, ind, &dInd ) ) {
- GET_VAL( dInd )[conDim] = first + (double)node_i * step;
- }
- }
- }
- FreeArray( begin );
- FreeArray( end );
- }
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-
-void SemiRegDeform_InitSync( SemiRegDeform* self ) {
- unsigned nRequired;
- unsigned* required;
- unsigned nDims;
- unsigned strip_i;
-
- assert( self );
-
- /*
- ** Setup the synchronisation component.
- */
-
- /* Build required indices. */
- nRequired = 0;
- required = Memory_Alloc_Array( unsigned, self->nStrips * 2, "SemiRegDeform" );
- for( strip_i = 0; strip_i < self->nStrips; strip_i++ ) {
- unsigned dInd;
-
- if( !Mesh_GlobalToDomain( self->mesh, MT_VERTEX, self->beginInds[strip_i], &dInd ) ||
- dInd >= Mesh_GetLocalSize( self->mesh, MT_VERTEX ) )
- {
- required[nRequired++] = self->beginInds[strip_i];
- }
- if( !Mesh_GlobalToDomain( self->mesh, MT_VERTEX, self->endInds[strip_i], &dInd ) ||
- dInd >= Mesh_GetLocalSize( self->mesh, MT_VERTEX ) )
- {
- required[nRequired++] = self->endInds[strip_i];
- }
- }
- required = Memory_Realloc_Array( required, unsigned, nRequired );
-
- self->sync = Decomp_Sync_New( "" );
- Decomp_Sync_SetDecomp( self->sync, self->mesh->topo->domains[MT_VERTEX]->decomp );
- Decomp_Sync_SetRequired( self->sync, nRequired, required );
-
- /* Free arrays. */
- FreeArray( required );
-
- /* Allocate for sources. */
- nDims = Mesh_GetDimSize( self->mesh );
- self->remVerts = AllocNamedArray2D( double, Decomp_Sync_GetRemoteSize( self->sync ), nDims,
- "SemiRegDeform::remVerts" );
-
- /* Initialise array. */
- self->syncArray = Decomp_Sync_Array_New();
- Decomp_Sync_Array_SetSync( self->syncArray, self->sync );
- Decomp_Sync_Array_SetMemory( self->syncArray,
- self->mesh->verts[0], self->remVerts ? self->remVerts[0] : NULL,
- sizeof(double) * nDims, sizeof(double) * nDims,
- sizeof(double) * nDims );
-}
-
-void SemiRegDeform_Destruct( SemiRegDeform* self ) {
- assert( self );
-
- self->mesh = NULL;
- KillObject( self->syncArray );
- KillObject( self->sync );
-
- KillArray( self->beginInds );
- KillArray( self->endInds );
- KillArray( self->conDims );
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/SemiRegDeform.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/SemiRegDeform.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,472 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: SemiRegDeform.c 2192 2004-10-15 02:45:38Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+#include <StgDomain/Mesh/Mesh.h>
+
+#include "types.h"
+#include "SemiRegDeform.h"
+
+
+/* Textual name of this class */
+const Type SemiRegDeform_Type = "SemiRegDeform";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+SemiRegDeform* SemiRegDeform_DefaultNew( Name name ) {
+ return _SemiRegDeform_New(
+ sizeof(SemiRegDeform),
+ SemiRegDeform_Type,
+ _SemiRegDeform_Delete,
+ _SemiRegDeform_Print,
+ NULL,
+ (Stg_Component_DefaultConstructorFunction*)SemiRegDeform_DefaultNew,
+ _SemiRegDeform_Construct,
+ _SemiRegDeform_Build,
+ _SemiRegDeform_Initialise,
+ _SemiRegDeform_Execute,
+ _SemiRegDeform_Destroy,
+ name );
+}
+
+SemiRegDeform* SemiRegDeform_New( Name name ) {
+ return _SemiRegDeform_New(
+ sizeof(SemiRegDeform),
+ SemiRegDeform_Type,
+ _SemiRegDeform_Delete,
+ _SemiRegDeform_Print,
+ NULL,
+ (Stg_Component_DefaultConstructorFunction*)SemiRegDeform_DefaultNew,
+ _SemiRegDeform_Construct,
+ _SemiRegDeform_Build,
+ _SemiRegDeform_Initialise,
+ _SemiRegDeform_Execute,
+ _SemiRegDeform_Destroy,
+ name );
+}
+
+SemiRegDeform* _SemiRegDeform_New( SizeT _sizeOfSelf,
+ Type type,
+ Stg_Class_DeleteFunction* _delete,
+ Stg_Class_PrintFunction* _print,
+ Stg_Class_CopyFunction* _copy,
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor,
+ Stg_Component_ConstructFunction* _construct,
+ Stg_Component_BuildFunction* _build,
+ Stg_Component_InitialiseFunction* _initialise,
+ Stg_Component_ExecuteFunction* _execute,
+ Stg_Component_DestroyFunction* _destroy,
+ Name name )
+{
+ SemiRegDeform* self;
+
+ /* Allocate memory. */
+ self = (SemiRegDeform*)_Stg_Component_New(
+ _sizeOfSelf,
+ type,
+ _delete,
+ _print,
+ _copy,
+ _defaultConstructor,
+ _construct,
+ _build,
+ _initialise,
+ _execute,
+ _destroy,
+ name,
+ NON_GLOBAL );
+
+ /* General info */
+
+ /* Virtual info */
+
+ /* SemiRegDeform info */
+ _SemiRegDeform_Init( self );
+
+ return self;
+}
+
+void SemiRegDeform_Init( SemiRegDeform* self, Name name ) {
+ /* General info */
+ self->type = SemiRegDeform_Type;
+ self->_sizeOfSelf = sizeof(SemiRegDeform);
+ self->_deleteSelf = False;
+
+ /* Virtual info */
+ self->_delete = _SemiRegDeform_Delete;
+ self->_print = _SemiRegDeform_Print;
+ self->_copy = NULL;
+ self->_defaultConstructor = (Stg_Component_DefaultConstructorFunction*)SemiRegDeform_DefaultNew;
+ self->_construct = _SemiRegDeform_Construct;
+ self->_build = _SemiRegDeform_Build;
+ self->_execute = _SemiRegDeform_Execute;
+ self->_destroy = _SemiRegDeform_Destroy;
+
+ _Stg_Class_Init( (Stg_Class*)self );
+ _Stg_Object_Init( (Stg_Object*)self, name, NON_GLOBAL );
+ _Stg_Component_Init( (Stg_Component*)self );
+
+ /* SemiRegDeform info */
+ _SemiRegDeform_Init( self );
+}
+
+void _SemiRegDeform_Init( SemiRegDeform* self ) {
+ self->nStrips = 0;
+ self->beginInds = NULL;
+ self->endInds = NULL;
+ self->conDims = NULL;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _SemiRegDeform_Delete( void* srd ) {
+ SemiRegDeform* self = (SemiRegDeform*)srd;
+
+ /* Delete the class itself */
+ SemiRegDeform_Destruct( self );
+
+ /* Delete parent */
+ _Stg_Class_Delete( self );
+}
+
+void _SemiRegDeform_Print( void* srd, Stream* stream ) {
+ SemiRegDeform* self = (SemiRegDeform*)srd;
+ Stream* myStream;
+
+ /* Set the Journal for printing informations */
+ myStream = Journal_Register( InfoStream_Type, "SemiRegDeformStream" );
+
+ /* Print parent */
+ _Stg_Class_Print( self, stream );
+
+ /* General info */
+ Journal_Printf( myStream, "SemiRegDeform (ptr): (%p)\n", self );
+
+ /* Virtual info */
+
+ /* SemiRegDeform info */
+}
+
+void _SemiRegDeform_Construct( void* srd, Stg_ComponentFactory* cf, void* data ) {
+}
+
+void _SemiRegDeform_Build( void* srd, void* data ) {
+}
+
+void _SemiRegDeform_Initialise( void* srd, void* data ) {
+ SemiRegDeform* self = (SemiRegDeform*)srd;
+
+ assert( self );
+
+
+ /*
+ ** Validate the provided strips. No two strips can occupy any of the same nodes in the same
+ ** dimension.
+ */
+
+ /* TODO */
+
+
+ /*
+ ** Initialise the synchronisation.
+ */
+
+ SemiRegDeform_InitSync( self );
+}
+
+void _SemiRegDeform_Execute( void* srd, void* data ) {
+}
+
+void _SemiRegDeform_Destroy( void* srd, void* data ) {
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void SemiRegDeform_SetMesh( void* srd, Mesh* mesh ) {
+ SemiRegDeform* self = (SemiRegDeform*)srd;
+
+ assert( !self->isInitialised );
+
+ SemiRegDeform_Destruct( self );
+ self->mesh = mesh;
+}
+
+void SemiRegDeform_AddStrip( void* srd, unsigned begin, unsigned end ) {
+ SemiRegDeform* self = (SemiRegDeform*)srd;
+ Grid* vertGrid;
+ unsigned short conDim;
+ IJK inds[2];
+ Bool store;
+ unsigned s_i;
+
+ assert( self->mesh );
+ assert( !self->isInitialised );
+
+ /* Get the vertex grid. */
+ vertGrid = *(Grid**)ExtensionManager_Get( self->mesh->info, self->mesh,
+ ExtensionManager_GetHandle( self->mesh->info, "vertexGrid" ) );
+
+ /*
+ ** Ensure the specified strip has not already been added.
+ */
+
+#ifndef NDEBUG
+ for( s_i = 0; s_i < self->nStrips; s_i++ ) {
+ if( self->beginInds[s_i] == begin && self->endInds[s_i] == end ) {
+ assert( 0 );
+ }
+ }
+#endif
+
+
+ /*
+ ** Ensure the specified strip is one dimensionally valid.
+ */
+
+ {
+ Bool found;
+ unsigned d_i;
+
+ Grid_Lift( vertGrid, begin, inds[0] );
+ Grid_Lift( vertGrid, end, inds[1] );
+
+ /* Find the one dimension that is not in-line. */
+ found = False;
+ for( d_i = 0; d_i < Mesh_GetDimSize( self->mesh ); d_i++ ) {
+ if( inds[0][d_i] != inds[1][d_i] ) {
+ /* Check if we have found multiple connected dimensions. */
+ assert( found == False );
+
+ found = True;
+ conDim = d_i;
+ }
+ }
+ }
+
+
+ /*
+ ** If the strip has no points stored locally then don't store on this processor.
+ */
+
+ {
+ unsigned len = inds[1][conDim] - inds[0][conDim] + 1;
+ IJK cur;
+ unsigned n_i;
+
+ store = False;
+ memcpy( cur, inds[0], sizeof(IJK) );
+ for( n_i = 0; n_i < len; n_i++ ) {
+ unsigned gInd, dInd;
+
+ gInd = Grid_Project( vertGrid, cur );
+ if( Mesh_GlobalToDomain( self->mesh, MT_VERTEX, gInd, &dInd ) &&
+ dInd < Mesh_GetLocalSize( self->mesh, MT_VERTEX ) )
+ {
+ store = True;
+ break;
+ }
+ cur[conDim]++;
+ }
+ }
+
+ if( !store )
+ return;
+
+ /*
+ ** Store.
+ */
+
+ self->beginInds = Memory_Realloc_Array( self->beginInds, unsigned, self->nStrips + 1 );
+ self->endInds = Memory_Realloc_Array( self->endInds, unsigned, self->nStrips + 1 );
+ self->conDims = Memory_Realloc_Array( self->conDims, unsigned, self->nStrips + 1 );
+ self->beginInds[self->nStrips] = begin;
+ self->endInds[self->nStrips] = end;
+ self->conDims[self->nStrips] = conDim;
+ self->nStrips++;
+}
+
+#define GET_VAL( ind ) \
+ (((ind) < Mesh_GetLocalSize( self->mesh, MT_VERTEX )) ? self->mesh->verts[ind] : \
+ self->remVerts[ind - Mesh_GetLocalSize( self->mesh, MT_VERTEX )])
+
+void SemiRegDeform_Deform( void* srd ) {
+ SemiRegDeform* self = (SemiRegDeform*)srd;
+ Grid* vertGrid;
+
+ assert( self );
+
+ /* Get the vertex grid. */
+ vertGrid = *(Grid**)ExtensionManager_Get( self->mesh->info, self->mesh,
+ ExtensionManager_GetHandle( self->mesh->info, "vertexGrid" ) );
+
+ /*
+ ** Actually deform the specified strips.
+ */
+
+ /* Import remote values. */
+ Decomp_Sync_SyncArray( self->sync, self->syncArray );
+
+ /* Interpolate each strip. */
+ {
+ unsigned nDims;
+ unsigned* begin;
+ unsigned* end;
+ unsigned strip_i;
+
+ /* Get dimensionality. */
+ nDims = Mesh_GetDimSize( self->mesh );
+
+ /* Allocate for the dimensions. */
+ begin = Memory_Alloc_Array( unsigned, nDims, "SemiRegDeform" );
+ end = Memory_Alloc_Array( unsigned, nDims, "SemiRegDeform" );
+
+ for( strip_i = 0; strip_i < self->nStrips; strip_i++ ) {
+ unsigned len;
+ unsigned conDim;
+ double first, step;
+ unsigned dInd;
+ unsigned node_i;
+
+ /* Extract the basics. */
+ Grid_Lift( vertGrid, self->beginInds[strip_i], begin );
+ Grid_Lift( vertGrid, self->endInds[strip_i], end );
+ conDim = self->conDims[strip_i];
+ len = end[conDim] - begin[conDim] + 1;
+ assert( len > 1 );
+
+ insist( Sync_GlobalToDomain( self->sync, self->beginInds[strip_i], &dInd ), == True );
+ first = GET_VAL( dInd )[conDim];
+ insist( Sync_GlobalToDomain( self->sync, self->endInds[strip_i], &dInd ), == True );
+ step = GET_VAL( dInd )[conDim];
+ step = (step - first) / (len - 1);
+
+ /* Loop and interpolate. */
+ for( node_i = 1; node_i < len - 1; node_i++ ) {
+ unsigned ind;
+
+ begin[conDim]++;
+ ind = Grid_Project( vertGrid, begin );
+ if( Sync_GlobalToDomain( self->sync, ind, &dInd ) ) {
+ GET_VAL( dInd )[conDim] = first + (double)node_i * step;
+ }
+ }
+ }
+ FreeArray( begin );
+ FreeArray( end );
+ }
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+
+void SemiRegDeform_InitSync( SemiRegDeform* self ) {
+ unsigned nRequired;
+ unsigned* required;
+ unsigned nDims;
+ unsigned strip_i;
+
+ assert( self );
+
+ /*
+ ** Setup the synchronisation component.
+ */
+
+ /* Build required indices. */
+ nRequired = 0;
+ required = Memory_Alloc_Array( unsigned, self->nStrips * 2, "SemiRegDeform" );
+ for( strip_i = 0; strip_i < self->nStrips; strip_i++ ) {
+ unsigned dInd;
+
+ if( !Mesh_GlobalToDomain( self->mesh, MT_VERTEX, self->beginInds[strip_i], &dInd ) ||
+ dInd >= Mesh_GetLocalSize( self->mesh, MT_VERTEX ) )
+ {
+ required[nRequired++] = self->beginInds[strip_i];
+ }
+ if( !Mesh_GlobalToDomain( self->mesh, MT_VERTEX, self->endInds[strip_i], &dInd ) ||
+ dInd >= Mesh_GetLocalSize( self->mesh, MT_VERTEX ) )
+ {
+ required[nRequired++] = self->endInds[strip_i];
+ }
+ }
+ required = Memory_Realloc_Array( required, unsigned, nRequired );
+
+ self->sync = Decomp_Sync_New( "" );
+ Decomp_Sync_SetDecomp( self->sync, self->mesh->topo->domains[MT_VERTEX]->decomp );
+ Decomp_Sync_SetRequired( self->sync, nRequired, required );
+
+ /* Free arrays. */
+ FreeArray( required );
+
+ /* Allocate for sources. */
+ nDims = Mesh_GetDimSize( self->mesh );
+ self->remVerts = AllocNamedArray2D( double, Decomp_Sync_GetRemoteSize( self->sync ), nDims,
+ "SemiRegDeform::remVerts" );
+
+ /* Initialise array. */
+ self->syncArray = Decomp_Sync_Array_New();
+ Decomp_Sync_Array_SetSync( self->syncArray, self->sync );
+ Decomp_Sync_Array_SetMemory( self->syncArray,
+ self->mesh->verts[0], self->remVerts ? self->remVerts[0] : NULL,
+ sizeof(double) * nDims, sizeof(double) * nDims,
+ sizeof(double) * nDims );
+}
+
+void SemiRegDeform_Destruct( SemiRegDeform* self ) {
+ assert( self );
+
+ self->mesh = NULL;
+ KillObject( self->syncArray );
+ KillObject( self->sync );
+
+ KillArray( self->beginInds );
+ KillArray( self->endInds );
+ KillArray( self->conDims );
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/SemiRegDeform.h
--- a/Utils/src/SemiRegDeform.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Invariants:
-**
-** Comments:
-**
-** $Id: SemiRegDeform.h 2225 1970-01-02 13:48:23Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __Domain_Utils_SemiRegDeform_h__
-#define __Domain_Utils_SemiRegDeform_h__
-
- /* Textual name of this class */
- extern const Type SemiRegDeform_Type;
-
- /* Virtual function types */
-
- /* Class contents */
- #define __SemiRegDeform \
- /* General info */ \
- __Stg_Component \
- \
- /* Virtual info */ \
- \
- /* SemiRegDeform info ... */ \
- Mesh* mesh; \
- Sync* sync; \
- \
- double** remVerts; \
- unsigned nStrips; \
- unsigned* beginInds; \
- unsigned* endInds; \
- unsigned* conDims;
-
- struct SemiRegDeform { __SemiRegDeform };
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- SemiRegDeform* SemiRegDeform_New( Name name );
- SemiRegDeform* _SemiRegDeform_New(SizeT _sizeOfSelf,
- Type type,
- Stg_Class_DeleteFunction* _delete,
- Stg_Class_PrintFunction* _print,
- Stg_Class_CopyFunction* _copy,
- Stg_Component_DefaultConstructorFunction* _defaultConstructor,
- Stg_Component_ConstructFunction* _construct,
- Stg_Component_BuildFunction* _build,
- Stg_Component_InitialiseFunction* _initialise,
- Stg_Component_ExecuteFunction* _execute,
- Stg_Component_DestroyFunction* _destroy,
- Name name );
- void _SemiRegDeform_Init( SemiRegDeform* self );
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _SemiRegDeform_Delete( void* srd );
- void _SemiRegDeform_Print( void* srd, Stream* stream );
- void _SemiRegDeform_Construct( void* srd, Stg_ComponentFactory* cf, void* data );
- void _SemiRegDeform_Build( void* srd, void* data );
- void _SemiRegDeform_Initialise( void* srd, void* data );
- void _SemiRegDeform_Execute( void* srd, void* data );
- void _SemiRegDeform_Destroy( void* srd, void* data );
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Public functions
- */
-
- void SemiRegDeform_SetMesh( void* srd, Mesh* mesh );
- void SemiRegDeform_AddStrip( void* srd, unsigned begin, unsigned end );
- void SemiRegDeform_Deform( void* srd );
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions
- */
- void SemiRegDeform_InitSync( SemiRegDeform* self );
- void SemiRegDeform_Destruct( SemiRegDeform* self );
-
-#endif /* __Domain_Utils_SemiRegDeform_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/SemiRegDeform.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/SemiRegDeform.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,113 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: SemiRegDeform.h 2225 1970-01-02 13:48:23Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __Domain_Utils_SemiRegDeform_h__
+#define __Domain_Utils_SemiRegDeform_h__
+
+ /* Textual name of this class */
+ extern const Type SemiRegDeform_Type;
+
+ /* Virtual function types */
+
+ /* Class contents */
+ #define __SemiRegDeform \
+ /* General info */ \
+ __Stg_Component \
+ \
+ /* Virtual info */ \
+ \
+ /* SemiRegDeform info ... */ \
+ Mesh* mesh; \
+ Sync* sync; \
+ \
+ double** remVerts; \
+ unsigned nStrips; \
+ unsigned* beginInds; \
+ unsigned* endInds; \
+ unsigned* conDims;
+
+ struct SemiRegDeform { __SemiRegDeform };
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ SemiRegDeform* SemiRegDeform_New( Name name );
+ SemiRegDeform* _SemiRegDeform_New(SizeT _sizeOfSelf,
+ Type type,
+ Stg_Class_DeleteFunction* _delete,
+ Stg_Class_PrintFunction* _print,
+ Stg_Class_CopyFunction* _copy,
+ Stg_Component_DefaultConstructorFunction* _defaultConstructor,
+ Stg_Component_ConstructFunction* _construct,
+ Stg_Component_BuildFunction* _build,
+ Stg_Component_InitialiseFunction* _initialise,
+ Stg_Component_ExecuteFunction* _execute,
+ Stg_Component_DestroyFunction* _destroy,
+ Name name );
+ void _SemiRegDeform_Init( SemiRegDeform* self );
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _SemiRegDeform_Delete( void* srd );
+ void _SemiRegDeform_Print( void* srd, Stream* stream );
+ void _SemiRegDeform_Construct( void* srd, Stg_ComponentFactory* cf, void* data );
+ void _SemiRegDeform_Build( void* srd, void* data );
+ void _SemiRegDeform_Initialise( void* srd, void* data );
+ void _SemiRegDeform_Execute( void* srd, void* data );
+ void _SemiRegDeform_Destroy( void* srd, void* data );
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+ void SemiRegDeform_SetMesh( void* srd, Mesh* mesh );
+ void SemiRegDeform_AddStrip( void* srd, unsigned begin, unsigned end );
+ void SemiRegDeform_Deform( void* srd );
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+ void SemiRegDeform_InitSync( SemiRegDeform* self );
+ void SemiRegDeform_Destruct( SemiRegDeform* self );
+
+#endif /* __Domain_Utils_SemiRegDeform_h__ */
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/StripRemesher.c
--- a/Utils/src/StripRemesher.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,346 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: StripRemesher.c 2192 2004-10-15 02:45:38Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-#include <StgDomain/Mesh/Mesh.h>
-
-#include "types.h"
-#include "Remesher.h"
-#include "SemiRegDeform.h"
-#include "StripRemesher.h"
-
-
-/* Textual name of this class */
-const Type StripRemesher_Type = "StripRemesher";
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Constructors
-*/
-
-#define REMESHER_DEFARGS \
- sizeof(StripRemesher), \
- StripRemesher_Type, \
- _StripRemesher_Delete, \
- _StripRemesher_Print, \
- NULL, \
- (void*(*)(Name))_StripRemesher_DefaultNew, \
- _StripRemesher_Construct, \
- _StripRemesher_Build, \
- _StripRemesher_Initialise, \
- _StripRemesher_Execute, \
- _StripRemesher_Destroy, \
- name, \
- False, \
- _StripRemesher_SetMesh
-
-
-StripRemesher* StripRemesher_New( Name name ) {
- return _StripRemesher_New( REMESHER_DEFARGS );
-}
-
-
-StripRemesher* _StripRemesher_New( CLASS_ARGS,
- COMPONENT_ARGS,
- REMESHER_ARGS )
-{
- StripRemesher* self;
-
- /* Allocate memory. */
- self = (StripRemesher*)_Remesher_New( _sizeOfSelf,
- type,
- _delete,
- _print,
- _copy,
- _defaultConstructor,
- _construct,
- _build,
- _initialise,
- _execute,
- _destroy,
- name,
- initFlag,
- setMeshFunc );
-
- /* StripRemesher info */
- if( initFlag ) {
- _StripRemesher_Init( self );
- }
-
- return self;
-}
-
-
-void StripRemesher_Init( StripRemesher* self ) {
- assert( 0 ); /* TODO */
-#if 0
- /* General info */
- self->type = StripRemesher_Type;
- self->_sizeOfSelf = sizeof(StripRemesher);
- self->_deleteSelf = False;
-
- /* Virtual info */
- self->_delete = _StripRemesher_Delete;
- self->_print = _StripRemesher_Print;
- self->_copy = NULL;
- _Stg_Class_Init( (Stg_Class*)self );
-
- /* StripRemesher info */
- _StripRemesher_Init( self );
-#endif
-}
-
-
-void _StripRemesher_Init( StripRemesher* self ) {
- /* StripRemesher info */
- memset( &self->nDims,
- 0,
- (size_t)&self->srd - (size_t)&self->nDims + sizeof(SemiRegDeform*) );
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Virtual functions
-*/
-
-void _StripRemesher_Delete( void* stripRemesher ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
-
- /* Delete the class itself */
- _StripRemesher_Free( self );
-
- /* Delete parent */
- _Stg_Component_Delete( stripRemesher );
-}
-
-
-void _StripRemesher_Print( void* stripRemesher, Stream* stream ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
- Stream* myStream;
-
- /* Set the Journal for printing informations */
- myStream = Journal_Register( InfoStream_Type, "StripRemesherStream" );
-
- /* Print parent */
- _Stg_Component_Print( self, stream );
-
- /* General info */
- Journal_Printf( myStream, "StripRemesher (ptr): (%p)\n", self );
-
- /* Virtual info */
-
- /* StripRemesher info */
-}
-
-
-StripRemesher* _StripRemesher_DefaultNew( Name name ) {
- return _StripRemesher_New( REMESHER_DEFARGS );
-}
-
-
-void _StripRemesher_Construct( void* stripRemesher, Stg_ComponentFactory* cf, void* data ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
- Dictionary_Entry_Value* dimLst;
-
- assert( self );
- assert( cf );
- assert( cf->componentDict );
-
- _Remesher_Construct( self, cf, data );
-
- /* Extract enabled dimensions. */
- dimLst = Dictionary_Entry_Value_GetMember( Dictionary_Get( cf->componentDict, self->name ), "dims" );
- if( dimLst ) {
- unsigned dim_i;
-
- self->nDims = Dictionary_Entry_Value_GetCount( dimLst );
- self->deformDims = Memory_Alloc_Array_Unnamed( unsigned, self->nDims );
- for( dim_i = 0; dim_i < self->nDims; dim_i++ ) {
- self->deformDims[dim_i] = Dictionary_Entry_Value_AsBool( Dictionary_Entry_Value_GetElement( dimLst, dim_i ) );
- }
- }
-}
-
-
-void _StripRemesher_Build( void* stripRemesher, void* data ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
-
- assert( self );
-
- if( !self->meshType ) {
- return;
- }
-
- assert( self->mesh );
-
- /* Build parent. */
- _Remesher_Build( self, data );
-
- /* Build the SRD. */
- StripRemesher_SetDims( self, self->deformDims );
-}
-
-
-void _StripRemesher_Initialise( void* stripRemesher, void* data ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
-
- assert( self );
-
- /* Initialise parent. */
- _Remesher_Initialise( self, data );
-}
-
-
-void _StripRemesher_Execute( void* stripRemesher, void* data ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
-
- assert( self );
- assert( self->mesh );
- /* TODO: remaining asserts */
-
- SemiRegDeform_Deform( self->srd );
-}
-
-
-void _StripRemesher_Destroy( void* stripRemesher, void* data ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
-
- assert( self );
-
- /* TODO: If delete deletes, what does destroy do? */
-}
-
-
-void _StripRemesher_SetMesh( void* stripRemesher, Mesh* mesh ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
-
- assert( self );
-
- /* Kill all internals. */
- _StripRemesher_Free( self );
-
- /* Store the mesh. */
- self->mesh = mesh;
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Public Functions
-*/
-
-void StripRemesher_SetDims( void* stripRemesher, Bool* dims ) {
- StripRemesher* self = (StripRemesher*)stripRemesher;
- unsigned d_i;
-
- assert( self );
- assert( self->mesh );
- assert( dims );
-
- if( self->srd ) {
- Stg_Class_Delete( self->srd );
- }
-
- self->srd = SemiRegDeform_New( "" );
- SemiRegDeform_SetMesh( self->srd, self->mesh );
-
- for( d_i = 0; d_i < Mesh_GetDimSize( self->srd->mesh ); d_i++ ) {
- IJK ijkLow;
- IJK ijkUpp;
-
- if( !dims[d_i] ) {
- continue;
- }
-
- _StripRemesher_BuildStrips( self->srd, 0, d_i,
- ijkLow, ijkUpp );
- }
-
- /* Build and initialise the SRD. */
- Build( self->srd, NULL, False );
- Initialise( self->srd, NULL, False );
-}
-
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
-void _StripRemesher_Free( StripRemesher* self ) {
- assert( self );
-
- if( self->srd ) {
- Stg_Class_Delete( self->srd );
- self->srd = NULL;
- }
-}
-
-
-void _StripRemesher_BuildStrips( SemiRegDeform* srd, unsigned dim, unsigned deformDim,
- IJK ijkLow, IJK ijkUpp )
-{
- unsigned n_i;
- Grid* vertGrid;
-
- vertGrid = *(Grid**)ExtensionManager_Get( srd->mesh->info, srd->mesh,
- ExtensionManager_GetHandle( srd->mesh->info, "vertexGrid" ) );
-
- if( dim < Mesh_GetDimSize( srd->mesh ) ) {
- if( dim != deformDim ) {
- for( n_i = 0; n_i < vertGrid->sizes[dim]; n_i++ ) {
- ijkLow[dim] = n_i;
- ijkUpp[dim] = n_i;
- _StripRemesher_BuildStrips( srd, dim + 1, deformDim,
- ijkLow, ijkUpp );
- }
- }
- else {
- ijkLow[dim] = 0;
- ijkUpp[dim] = vertGrid->sizes[dim] - 1;
- _StripRemesher_BuildStrips( srd, dim + 1, deformDim,
- ijkLow, ijkUpp );
- }
- }
- else {
- unsigned low, upp;
-
- low = Grid_Project( vertGrid, ijkLow );
- upp = Grid_Project( vertGrid, ijkUpp );
- SemiRegDeform_AddStrip( srd, low, upp );
- }
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/StripRemesher.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/StripRemesher.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,346 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: StripRemesher.c 2192 2004-10-15 02:45:38Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+#include <StgDomain/Mesh/Mesh.h>
+
+#include "types.h"
+#include "Remesher.h"
+#include "SemiRegDeform.h"
+#include "StripRemesher.h"
+
+
+/* Textual name of this class */
+const Type StripRemesher_Type = "StripRemesher";
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Constructors
+*/
+
+#define REMESHER_DEFARGS \
+ sizeof(StripRemesher), \
+ StripRemesher_Type, \
+ _StripRemesher_Delete, \
+ _StripRemesher_Print, \
+ NULL, \
+ (void*(*)(Name))_StripRemesher_DefaultNew, \
+ _StripRemesher_Construct, \
+ _StripRemesher_Build, \
+ _StripRemesher_Initialise, \
+ _StripRemesher_Execute, \
+ _StripRemesher_Destroy, \
+ name, \
+ False, \
+ _StripRemesher_SetMesh
+
+
+StripRemesher* StripRemesher_New( Name name ) {
+ return _StripRemesher_New( REMESHER_DEFARGS );
+}
+
+
+StripRemesher* _StripRemesher_New( CLASS_ARGS,
+ COMPONENT_ARGS,
+ REMESHER_ARGS )
+{
+ StripRemesher* self;
+
+ /* Allocate memory. */
+ self = (StripRemesher*)_Remesher_New( _sizeOfSelf,
+ type,
+ _delete,
+ _print,
+ _copy,
+ _defaultConstructor,
+ _construct,
+ _build,
+ _initialise,
+ _execute,
+ _destroy,
+ name,
+ initFlag,
+ setMeshFunc );
+
+ /* StripRemesher info */
+ if( initFlag ) {
+ _StripRemesher_Init( self );
+ }
+
+ return self;
+}
+
+
+void StripRemesher_Init( StripRemesher* self ) {
+ assert( 0 ); /* TODO */
+#if 0
+ /* General info */
+ self->type = StripRemesher_Type;
+ self->_sizeOfSelf = sizeof(StripRemesher);
+ self->_deleteSelf = False;
+
+ /* Virtual info */
+ self->_delete = _StripRemesher_Delete;
+ self->_print = _StripRemesher_Print;
+ self->_copy = NULL;
+ _Stg_Class_Init( (Stg_Class*)self );
+
+ /* StripRemesher info */
+ _StripRemesher_Init( self );
+#endif
+}
+
+
+void _StripRemesher_Init( StripRemesher* self ) {
+ /* StripRemesher info */
+ memset( &self->nDims,
+ 0,
+ (size_t)&self->srd - (size_t)&self->nDims + sizeof(SemiRegDeform*) );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Virtual functions
+*/
+
+void _StripRemesher_Delete( void* stripRemesher ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+
+ /* Delete the class itself */
+ _StripRemesher_Free( self );
+
+ /* Delete parent */
+ _Stg_Component_Delete( stripRemesher );
+}
+
+
+void _StripRemesher_Print( void* stripRemesher, Stream* stream ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+ Stream* myStream;
+
+ /* Set the Journal for printing informations */
+ myStream = Journal_Register( InfoStream_Type, "StripRemesherStream" );
+
+ /* Print parent */
+ _Stg_Component_Print( self, stream );
+
+ /* General info */
+ Journal_Printf( myStream, "StripRemesher (ptr): (%p)\n", self );
+
+ /* Virtual info */
+
+ /* StripRemesher info */
+}
+
+
+StripRemesher* _StripRemesher_DefaultNew( Name name ) {
+ return _StripRemesher_New( REMESHER_DEFARGS );
+}
+
+
+void _StripRemesher_Construct( void* stripRemesher, Stg_ComponentFactory* cf, void* data ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+ Dictionary_Entry_Value* dimLst;
+
+ assert( self );
+ assert( cf );
+ assert( cf->componentDict );
+
+ _Remesher_Construct( self, cf, data );
+
+ /* Extract enabled dimensions. */
+ dimLst = Dictionary_Entry_Value_GetMember( Dictionary_Get( cf->componentDict, self->name ), "dims" );
+ if( dimLst ) {
+ unsigned dim_i;
+
+ self->nDims = Dictionary_Entry_Value_GetCount( dimLst );
+ self->deformDims = Memory_Alloc_Array_Unnamed( unsigned, self->nDims );
+ for( dim_i = 0; dim_i < self->nDims; dim_i++ ) {
+ self->deformDims[dim_i] = Dictionary_Entry_Value_AsBool( Dictionary_Entry_Value_GetElement( dimLst, dim_i ) );
+ }
+ }
+}
+
+
+void _StripRemesher_Build( void* stripRemesher, void* data ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+
+ assert( self );
+
+ if( !self->meshType ) {
+ return;
+ }
+
+ assert( self->mesh );
+
+ /* Build parent. */
+ _Remesher_Build( self, data );
+
+ /* Build the SRD. */
+ StripRemesher_SetDims( self, self->deformDims );
+}
+
+
+void _StripRemesher_Initialise( void* stripRemesher, void* data ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+
+ assert( self );
+
+ /* Initialise parent. */
+ _Remesher_Initialise( self, data );
+}
+
+
+void _StripRemesher_Execute( void* stripRemesher, void* data ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+
+ assert( self );
+ assert( self->mesh );
+ /* TODO: remaining asserts */
+
+ SemiRegDeform_Deform( self->srd );
+}
+
+
+void _StripRemesher_Destroy( void* stripRemesher, void* data ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+
+ assert( self );
+
+ /* TODO: If delete deletes, what does destroy do? */
+}
+
+
+void _StripRemesher_SetMesh( void* stripRemesher, Mesh* mesh ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+
+ assert( self );
+
+ /* Kill all internals. */
+ _StripRemesher_Free( self );
+
+ /* Store the mesh. */
+ self->mesh = mesh;
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Public Functions
+*/
+
+void StripRemesher_SetDims( void* stripRemesher, Bool* dims ) {
+ StripRemesher* self = (StripRemesher*)stripRemesher;
+ unsigned d_i;
+
+ assert( self );
+ assert( self->mesh );
+ assert( dims );
+
+ if( self->srd ) {
+ Stg_Class_Delete( self->srd );
+ }
+
+ self->srd = SemiRegDeform_New( "" );
+ SemiRegDeform_SetMesh( self->srd, self->mesh );
+
+ for( d_i = 0; d_i < Mesh_GetDimSize( self->srd->mesh ); d_i++ ) {
+ IJK ijkLow;
+ IJK ijkUpp;
+
+ if( !dims[d_i] ) {
+ continue;
+ }
+
+ _StripRemesher_BuildStrips( self->srd, 0, d_i,
+ ijkLow, ijkUpp );
+ }
+
+ /* Build and initialise the SRD. */
+ Build( self->srd, NULL, False );
+ Initialise( self->srd, NULL, False );
+}
+
+
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
+
+void _StripRemesher_Free( StripRemesher* self ) {
+ assert( self );
+
+ if( self->srd ) {
+ Stg_Class_Delete( self->srd );
+ self->srd = NULL;
+ }
+}
+
+
+void _StripRemesher_BuildStrips( SemiRegDeform* srd, unsigned dim, unsigned deformDim,
+ IJK ijkLow, IJK ijkUpp )
+{
+ unsigned n_i;
+ Grid* vertGrid;
+
+ vertGrid = *(Grid**)ExtensionManager_Get( srd->mesh->info, srd->mesh,
+ ExtensionManager_GetHandle( srd->mesh->info, "vertexGrid" ) );
+
+ if( dim < Mesh_GetDimSize( srd->mesh ) ) {
+ if( dim != deformDim ) {
+ for( n_i = 0; n_i < vertGrid->sizes[dim]; n_i++ ) {
+ ijkLow[dim] = n_i;
+ ijkUpp[dim] = n_i;
+ _StripRemesher_BuildStrips( srd, dim + 1, deformDim,
+ ijkLow, ijkUpp );
+ }
+ }
+ else {
+ ijkLow[dim] = 0;
+ ijkUpp[dim] = vertGrid->sizes[dim] - 1;
+ _StripRemesher_BuildStrips( srd, dim + 1, deformDim,
+ ijkLow, ijkUpp );
+ }
+ }
+ else {
+ unsigned low, upp;
+
+ low = Grid_Project( vertGrid, ijkLow );
+ upp = Grid_Project( vertGrid, ijkUpp );
+ SemiRegDeform_AddStrip( srd, low, upp );
+ }
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/StripRemesher.h
--- a/Utils/src/StripRemesher.h Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-*/
-/** \file
-** Role:
-**
-** Assumptions:
-**
-** Invariants:
-**
-** Comments:
-**
-** $Id: StripRemesher.h 2225 1970-01-02 13:48:23Z LukeHodkinson $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#ifndef __StGermain_Domain_Utils_StripRemesher_h__
-#define __StGermain_Domain_Utils_StripRemesher_h__
-
- /* Textual name of this class. */
- extern const Type StripRemesher_Type;
-
- /* Virtual function types. */
-
- /* Class contents. */
- #define __StripRemesher \
- /* General info */ \
- __Remesher \
- \
- /* Virtual info */ \
- \
- /* StripRemesher info ... */ \
- unsigned nDims; \
- Bool* deformDims; \
- SemiRegDeform* srd;
-
- struct StripRemesher { __StripRemesher };
-
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Constructors
- */
-
- /* Create a StripRemesher */
- StripRemesher* StripRemesher_New( Name name );
-
- /* Creation implementation */
- StripRemesher* _StripRemesher_New( CLASS_ARGS,
- COMPONENT_ARGS,
- REMESHER_ARGS );
-
- /* Initialise a StripRemesher */
- void StripRemesher_Init( StripRemesher* self );
-
- /* Initialisation implementation functions */
- void _StripRemesher_Init( StripRemesher* self );
-
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Virtual functions
- */
-
- void _StripRemesher_Delete( void* stripRemesher );
- void _StripRemesher_Print( void* stripRemesher, Stream* stream );
- StripRemesher* _StripRemesher_DefaultNew( Name name );
- void _StripRemesher_Construct( void* stripRemesher, Stg_ComponentFactory* cf, void* data );
- void _StripRemesher_Build( void* stripRemesher, void* data );
- void _StripRemesher_Initialise( void* stripRemesher, void* data );
- void _StripRemesher_Execute( void* stripRemesher, void* data );
- void _StripRemesher_Destroy( void* stripRemesher, void* data );
-
- void _StripRemesher_SetMesh( void* stripRemesher, Mesh* mesh );
-
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Public functions
- */
-
- void StripRemesher_SetDims( void* stripRemesher, Bool* dims );
-
-
- /*-----------------------------------------------------------------------------------------------------------------------------
- ** Private Member functions
- */
-
- void _StripRemesher_Free( StripRemesher* self );
- void _StripRemesher_BuildStrips( SemiRegDeform* srd, unsigned dim, unsigned deformDim,
- IJK ijkLow, IJK ijkUpp );
-
-#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/src/StripRemesher.h.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/src/StripRemesher.h.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,114 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Invariants:
+**
+** Comments:
+**
+** $Id: StripRemesher.h 2225 1970-01-02 13:48:23Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __StGermain_Domain_Utils_StripRemesher_h__
+#define __StGermain_Domain_Utils_StripRemesher_h__
+
+ /* Textual name of this class. */
+ extern const Type StripRemesher_Type;
+
+ /* Virtual function types. */
+
+ /* Class contents. */
+ #define __StripRemesher \
+ /* General info */ \
+ __Remesher \
+ \
+ /* Virtual info */ \
+ \
+ /* StripRemesher info ... */ \
+ unsigned nDims; \
+ Bool* deformDims; \
+ SemiRegDeform* srd;
+
+ struct StripRemesher { __StripRemesher };
+
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Constructors
+ */
+
+ /* Create a StripRemesher */
+ StripRemesher* StripRemesher_New( Name name );
+
+ /* Creation implementation */
+ StripRemesher* _StripRemesher_New( CLASS_ARGS,
+ COMPONENT_ARGS,
+ REMESHER_ARGS );
+
+ /* Initialise a StripRemesher */
+ void StripRemesher_Init( StripRemesher* self );
+
+ /* Initialisation implementation functions */
+ void _StripRemesher_Init( StripRemesher* self );
+
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Virtual functions
+ */
+
+ void _StripRemesher_Delete( void* stripRemesher );
+ void _StripRemesher_Print( void* stripRemesher, Stream* stream );
+ StripRemesher* _StripRemesher_DefaultNew( Name name );
+ void _StripRemesher_Construct( void* stripRemesher, Stg_ComponentFactory* cf, void* data );
+ void _StripRemesher_Build( void* stripRemesher, void* data );
+ void _StripRemesher_Initialise( void* stripRemesher, void* data );
+ void _StripRemesher_Execute( void* stripRemesher, void* data );
+ void _StripRemesher_Destroy( void* stripRemesher, void* data );
+
+ void _StripRemesher_SetMesh( void* stripRemesher, Mesh* mesh );
+
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Public functions
+ */
+
+ void StripRemesher_SetDims( void* stripRemesher, Bool* dims );
+
+
+ /*-----------------------------------------------------------------------------------------------------------------------------
+ ** Private Member functions
+ */
+
+ void _StripRemesher_Free( StripRemesher* self );
+ void _StripRemesher_BuildStrips( SemiRegDeform* srd, unsigned dim, unsigned deformDim,
+ IJK ijkLow, IJK ijkUpp );
+
+#endif
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/tests/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/tests/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,8 @@
+import os
+Import('env')
+
+# Build test binaries.
+env['helpers']['buildTests'](env, libs=['StgDomainGeometry',
+ 'StgDomainShape',
+ 'StgDomainMesh',
+ 'StgDomainUtils'])
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/tests/testEmbeddedSurface.c
--- a/Utils/tests/testEmbeddedSurface.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: testEmbeddedSurface.c 3995 2007-02-07 02:20:14Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-
-#include <mpi.h>
-#include <StGermain/StGermain.h>
-
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-#include <StgDomain/Mesh/Mesh.h>
-#include <StgDomain/Utils/Utils.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-
-struct _Node {
- struct { __Advectable };
- double temp;
-};
-
-
-struct _Element {
- struct { __Advectable };
- double temp;
-};
-
-
-int main(int argc, char **argv)
-{
- MPI_Comm CommWorld;
- XML_IO_Handler *io_handler = XML_IO_Handler_New();
- int rank, procCount, procToWatch;
- Dictionary *dictionary;
- EmbeddedSurface *surface;
- MeshTopology *rmt, *imt;
- MeshGeometry *rmg, *img;
- MeshDecomp *rmd, *imd;
- MeshLayout *rml, *isl;
- ExtensionManager_Register *extensionMgr_Register;
- Mesh *mesh;
- Element_GlobalIndex intersectCnt, *intersect;
- Index i;
-
- /* Initialise MPI, get world info */
- MPI_Init( &argc, &argv );
- MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
- MPI_Comm_size( CommWorld, &procCount );
- MPI_Comm_rank( CommWorld, &rank );
-
- StGermain_Init( &argc, &argv );
-
- StgDomainGeometry_Init( &argc, &argv );
- StgDomainShape_Init( &argc, &argv );
- StgDomainMesh_Init( &argc, &argv );
- StgDomainUtils_Init( &argc, &argv );
- MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */
-
- if( argc >= 2 )
- procToWatch = atoi( argv[1] );
- else
- procToWatch = 0;
- if( rank == procToWatch ) printf( "Watching rank: %i\n", rank );
-
- dictionary = Dictionary_New();
- Dictionary_Add(dictionary, "outputPath", Dictionary_Entry_Value_FromString("./output"));
- Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
- Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( procCount ) );
- Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 2 ) );
- Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 2 ) );
- Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 4 ) );
- Dictionary_Add( dictionary, "allowUnusedCPUs", Dictionary_Entry_Value_FromBool( True ) );
- Dictionary_Add( dictionary, "allowPartitionOnElement", Dictionary_Entry_Value_FromBool( True ) );
- Dictionary_Add( dictionary, "allowPartitionOnNode", Dictionary_Entry_Value_FromBool( True ) );
- Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 0 ) );
- IO_Handler_ReadAllFromFile(io_handler, "data/surface.xml", dictionary);
-
- rmt = (MeshTopology *)HexaMeshTopology_New(dictionary);
- rmg = (MeshGeometry *)HexaMeshGeometry_New(dictionary);
- rmd = (MeshDecomp *)HexaMeshDecomp_New(dictionary, MPI_COMM_WORLD, (HexaMeshTopology *)rmt);
- rml = MeshLayout_New(dictionary, rmt, rmg, rmd);
-
- imt = (MeshTopology *)TriSurfTopology_New(dictionary, "imElements");
- img = (MeshGeometry *)TriSurfGeometry_New(dictionary, "imNodes");
- imd = (MeshDecomp *)IrregularMeshDecomp_New1(dictionary, MPI_COMM_WORLD, imt, img, rml);
- isl = MeshLayout_New(dictionary, imt, img, imd);
-
- extensionMgr_Register = ExtensionManager_Register_New( );
- mesh = Mesh_New( isl, sizeof(Node), sizeof(Element), extensionMgr_Register, dictionary );
- Mesh_Build( mesh );
- Mesh_Initialise(mesh);
-
- surface = EmbeddedSurface_New(mesh);
-
- if (procToWatch == rank)
- {
- intersect = Memory_Alloc_Array( Element_GlobalIndex, isl->decomp->elementGlobalCount(isl->decomp), "intersect" );
- intersectCnt = EmbeddedSurface_BuildIntersection(surface, intersect);
-
- printf("Intersects: %u\n", intersectCnt);
- for (i = 0; i < intersectCnt; i++)
- printf("\tinstersect[%u]: %u\n", i, intersect[i]);
- printf("\n");
-
- if (intersect) Memory_Free(intersect);
-
- for (i = 0; i < isl->decomp->nodeGlobalCount(isl->decomp); i++)
- {
- Coord point;
-
- point[0] = ((TriSurfGeometry *)img)->node[i][0] + 1.0;
- point[1] = ((TriSurfGeometry *)img)->node[i][1];
- point[2] = ((TriSurfGeometry *)img)->node[i][2];
-
- printf("Distance to point {%.3f, %.3f, %.3f}: ", point[0], point[1], point[2]);
- printf("%.3f\n", EmbeddedSurface_DistanceToPoint(surface, point));
- }
- }
-
- Stg_Class_Delete(surface);
- Stg_Class_Delete(isl);
- Stg_Class_Delete(imd);
- Stg_Class_Delete(img);
- Stg_Class_Delete(imt);
- Stg_Class_Delete(rml);
- Stg_Class_Delete(rmd);
- Stg_Class_Delete(rmg);
- Stg_Class_Delete(rmt);
-
- StgDomainUtils_Finalise();
- StgDomainMesh_Finalise();
- StgDomainShape_Finalise();
- StgDomainGeometry_Finalise();
-
- StGermain_Finalise();
-
- /* Close off MPI */
- MPI_Finalize();
-
- return 0;
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/tests/testEmbeddedSurface.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/tests/testEmbeddedSurface.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,169 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: testEmbeddedSurface.c 3995 2007-02-07 02:20:14Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+#include <StgDomain/Mesh/Mesh.h>
+#include <StgDomain/Utils/Utils.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+struct _Node {
+ struct { __Advectable };
+ double temp;
+};
+
+
+struct _Element {
+ struct { __Advectable };
+ double temp;
+};
+
+
+int main(int argc, char **argv)
+{
+ MPI_Comm CommWorld;
+ XML_IO_Handler *io_handler = XML_IO_Handler_New();
+ int rank, procCount, procToWatch;
+ Dictionary *dictionary;
+ EmbeddedSurface *surface;
+ MeshTopology *rmt, *imt;
+ MeshGeometry *rmg, *img;
+ MeshDecomp *rmd, *imd;
+ MeshLayout *rml, *isl;
+ ExtensionManager_Register *extensionMgr_Register;
+ Mesh *mesh;
+ Element_GlobalIndex intersectCnt, *intersect;
+ Index i;
+
+ /* Initialise MPI, get world info */
+ MPI_Init( &argc, &argv );
+ MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
+ MPI_Comm_size( CommWorld, &procCount );
+ MPI_Comm_rank( CommWorld, &rank );
+
+ StGermain_Init( &argc, &argv );
+
+ StgDomainGeometry_Init( &argc, &argv );
+ StgDomainShape_Init( &argc, &argv );
+ StgDomainMesh_Init( &argc, &argv );
+ StgDomainUtils_Init( &argc, &argv );
+ MPI_Barrier( CommWorld ); /* Ensures copyright info always come first in output */
+
+ if( argc >= 2 )
+ procToWatch = atoi( argv[1] );
+ else
+ procToWatch = 0;
+ if( rank == procToWatch ) printf( "Watching rank: %i\n", rank );
+
+ dictionary = Dictionary_New();
+ Dictionary_Add(dictionary, "outputPath", Dictionary_Entry_Value_FromString("./output"));
+ Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
+ Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( procCount ) );
+ Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 2 ) );
+ Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 2 ) );
+ Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 4 ) );
+ Dictionary_Add( dictionary, "allowUnusedCPUs", Dictionary_Entry_Value_FromBool( True ) );
+ Dictionary_Add( dictionary, "allowPartitionOnElement", Dictionary_Entry_Value_FromBool( True ) );
+ Dictionary_Add( dictionary, "allowPartitionOnNode", Dictionary_Entry_Value_FromBool( True ) );
+ Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 0 ) );
+ IO_Handler_ReadAllFromFile(io_handler, "data/surface.xml", dictionary);
+
+ rmt = (MeshTopology *)HexaMeshTopology_New(dictionary);
+ rmg = (MeshGeometry *)HexaMeshGeometry_New(dictionary);
+ rmd = (MeshDecomp *)HexaMeshDecomp_New(dictionary, MPI_COMM_WORLD, (HexaMeshTopology *)rmt);
+ rml = MeshLayout_New(dictionary, rmt, rmg, rmd);
+
+ imt = (MeshTopology *)TriSurfTopology_New(dictionary, "imElements");
+ img = (MeshGeometry *)TriSurfGeometry_New(dictionary, "imNodes");
+ imd = (MeshDecomp *)IrregularMeshDecomp_New1(dictionary, MPI_COMM_WORLD, imt, img, rml);
+ isl = MeshLayout_New(dictionary, imt, img, imd);
+
+ extensionMgr_Register = ExtensionManager_Register_New( );
+ mesh = Mesh_New( isl, sizeof(Node), sizeof(Element), extensionMgr_Register, dictionary );
+ Mesh_Build( mesh );
+ Mesh_Initialise(mesh);
+
+ surface = EmbeddedSurface_New(mesh);
+
+ if (procToWatch == rank)
+ {
+ intersect = Memory_Alloc_Array( Element_GlobalIndex, isl->decomp->elementGlobalCount(isl->decomp), "intersect" );
+ intersectCnt = EmbeddedSurface_BuildIntersection(surface, intersect);
+
+ printf("Intersects: %u\n", intersectCnt);
+ for (i = 0; i < intersectCnt; i++)
+ printf("\tinstersect[%u]: %u\n", i, intersect[i]);
+ printf("\n");
+
+ if (intersect) Memory_Free(intersect);
+
+ for (i = 0; i < isl->decomp->nodeGlobalCount(isl->decomp); i++)
+ {
+ Coord point;
+
+ point[0] = ((TriSurfGeometry *)img)->node[i][0] + 1.0;
+ point[1] = ((TriSurfGeometry *)img)->node[i][1];
+ point[2] = ((TriSurfGeometry *)img)->node[i][2];
+
+ printf("Distance to point {%.3f, %.3f, %.3f}: ", point[0], point[1], point[2]);
+ printf("%.3f\n", EmbeddedSurface_DistanceToPoint(surface, point));
+ }
+ }
+
+ Stg_Class_Delete(surface);
+ Stg_Class_Delete(isl);
+ Stg_Class_Delete(imd);
+ Stg_Class_Delete(img);
+ Stg_Class_Delete(imt);
+ Stg_Class_Delete(rml);
+ Stg_Class_Delete(rmd);
+ Stg_Class_Delete(rmg);
+ Stg_Class_Delete(rmt);
+
+ StgDomainUtils_Finalise();
+ StgDomainMesh_Finalise();
+ StgDomainShape_Finalise();
+ StgDomainGeometry_Finalise();
+
+ StGermain_Finalise();
+
+ /* Close off MPI */
+ MPI_Finalize();
+
+ return 0;
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/tests/testMeshCoarsener_Hexa..c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/tests/testMeshCoarsener_Hexa..c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,154 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: testMesh.c 2498 2005-01-07 03:57:00Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+#include <StgDomain/Mesh/Mesh.h>
+#include <StgDomain/Utils/Utils.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mpi.h>
+
+struct _Node
+{
+ double temp;
+};
+
+struct _Element
+{
+ double temp;
+};
+
+
+int main(int argc, char *argv[])
+{
+ MPI_Comm CommWorld;
+ int rank;
+ int procCount;
+ int procToWatch;
+ Dictionary* dictionary;
+ ExtensionManager_Register* extensionMgr_Register;
+ Topology* nTopology;
+ ElementLayout* eLayout;
+ NodeLayout* nLayout;
+ MeshDecomp* decomp;
+ MeshLayout* ml;
+ Mesh* mesh;
+ MeshCoarsener_Hexa* coarsener;
+ Stream* stream;
+
+ /* Initialise MPI, get world info */
+ MPI_Init(&argc, &argv);
+ MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
+ MPI_Comm_size(CommWorld, &procCount);
+ MPI_Comm_rank(CommWorld, &rank);
+
+ StGermain_Init( &argc, &argv );
+
+ StgDomainGeometry_Init( &argc, &argv );
+ StgDomainShape_Init( &argc, &argv );
+ StgDomainMesh_Init( &argc, &argv );
+
+ MPI_Barrier( CommWorld );
+
+ stream = Journal_Register (Info_Type, "myStream");
+ procToWatch = argc >= 2 ? atoi(argv[1]) : 0;
+
+ dictionary = Dictionary_New();
+ Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
+ Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( procCount ) );
+ Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 21 ) );
+ Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 21 ) );
+ Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 21 ) );
+ Dictionary_Add( dictionary, "allowUnusedCPUs", Dictionary_Entry_Value_FromBool( True ) );
+ Dictionary_Add( dictionary, "allowPartitionOnElement", Dictionary_Entry_Value_FromBool( True ) );
+ Dictionary_Add( dictionary, "allowPartitionOnNode", Dictionary_Entry_Value_FromBool( True ) );
+ Dictionary_Add( dictionary, "allowUnbalancing", Dictionary_Entry_Value_FromBool( False ) );
+ Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 0 ) );
+
+ nTopology = (Topology*)IJK6Topology_New( "IJK6Topology", dictionary );
+ eLayout = (ElementLayout*)ParallelPipedHexaEL_New( "PPHexaEL", 3, dictionary );
+ nLayout = (NodeLayout*)CornerNL_New( "CornerNL", dictionary, eLayout, nTopology );
+ decomp = (MeshDecomp*)HexaMD_New( "HexaMD", dictionary, MPI_COMM_WORLD, eLayout, nLayout );
+ ml = MeshLayout_New( "MeshLayout", eLayout, nLayout, decomp );
+
+ extensionMgr_Register = ExtensionManager_Register_New();
+ mesh = Mesh_New( "Mesh", ml, sizeof(Node), sizeof(Element), extensionMgr_Register, dictionary );
+
+ mesh->buildNodeLocalToGlobalMap = True;
+ mesh->buildNodeDomainToGlobalMap = True;
+ mesh->buildNodeGlobalToLocalMap = True;
+ mesh->buildNodeGlobalToDomainMap = True;
+ mesh->buildNodeNeighbourTbl = True;
+ mesh->buildNodeElementTbl = True;
+ mesh->buildElementLocalToGlobalMap = True;
+ mesh->buildElementDomainToGlobalMap = True;
+ mesh->buildElementGlobalToDomainMap = True;
+ mesh->buildElementGlobalToLocalMap = True;
+ mesh->buildElementNeighbourTbl = True;
+ mesh->buildElementNodeTbl = True;
+
+ /* Coarsen by one level */
+ coarsener = MeshCoarsener_Hexa_New("meshCoarsener");
+ MeshCoarsener_Hexa_Coarsen( coarsener, mesh, 1, NULL, NULL );
+ Stg_Class_Delete( coarsener );
+
+ Build( mesh, 0, False );
+ Initialise(mesh, 0, False );
+
+ if (rank == procToWatch)
+ {
+ Print(mesh, stream);
+ }
+
+ Stg_Class_Delete(mesh);
+ Stg_Class_Delete(ml);
+ Stg_Class_Delete(decomp);
+ Stg_Class_Delete(nLayout);
+ Stg_Class_Delete(eLayout);
+ Stg_Class_Delete( nTopology );
+ Stg_Class_Delete(dictionary);
+
+ StgDomainMesh_Finalise();
+ StgDomainShape_Finalise();
+ StgDomainGeometry_Finalise();
+
+ StGermain_Finalise();
+
+ /* Close off MPI */
+ MPI_Finalize();
+
+ return 0; /* success */
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/tests/testMeshCoarsener_Hexa.c
--- a/Utils/tests/testMeshCoarsener_Hexa.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: testMesh.c 2498 2005-01-07 03:57:00Z PatrickSunter $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <mpi.h>
-#include <StGermain/StGermain.h>
-
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-#include <StgDomain/Mesh/Mesh.h>
-#include <StgDomain/Utils/Utils.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <mpi.h>
-
-struct _Node
-{
- double temp;
-};
-
-struct _Element
-{
- double temp;
-};
-
-
-int main(int argc, char *argv[])
-{
- MPI_Comm CommWorld;
- int rank;
- int procCount;
- int procToWatch;
- Dictionary* dictionary;
- ExtensionManager_Register* extensionMgr_Register;
- Topology* nTopology;
- ElementLayout* eLayout;
- NodeLayout* nLayout;
- MeshDecomp* decomp;
- MeshLayout* ml;
- Mesh* mesh;
- MeshCoarsener_Hexa* coarsener;
- Stream* stream;
-
- /* Initialise MPI, get world info */
- MPI_Init(&argc, &argv);
- MPI_Comm_dup( MPI_COMM_WORLD, &CommWorld );
- MPI_Comm_size(CommWorld, &procCount);
- MPI_Comm_rank(CommWorld, &rank);
-
- StGermain_Init( &argc, &argv );
-
- StgDomainGeometry_Init( &argc, &argv );
- StgDomainShape_Init( &argc, &argv );
- StgDomainMesh_Init( &argc, &argv );
-
- MPI_Barrier( CommWorld );
-
- stream = Journal_Register (Info_Type, "myStream");
- procToWatch = argc >= 2 ? atoi(argv[1]) : 0;
-
- dictionary = Dictionary_New();
- Dictionary_Add( dictionary, "rank", Dictionary_Entry_Value_FromUnsignedInt( rank ) );
- Dictionary_Add( dictionary, "numProcessors", Dictionary_Entry_Value_FromUnsignedInt( procCount ) );
- Dictionary_Add( dictionary, "meshSizeI", Dictionary_Entry_Value_FromUnsignedInt( 21 ) );
- Dictionary_Add( dictionary, "meshSizeJ", Dictionary_Entry_Value_FromUnsignedInt( 21 ) );
- Dictionary_Add( dictionary, "meshSizeK", Dictionary_Entry_Value_FromUnsignedInt( 21 ) );
- Dictionary_Add( dictionary, "allowUnusedCPUs", Dictionary_Entry_Value_FromBool( True ) );
- Dictionary_Add( dictionary, "allowPartitionOnElement", Dictionary_Entry_Value_FromBool( True ) );
- Dictionary_Add( dictionary, "allowPartitionOnNode", Dictionary_Entry_Value_FromBool( True ) );
- Dictionary_Add( dictionary, "allowUnbalancing", Dictionary_Entry_Value_FromBool( False ) );
- Dictionary_Add( dictionary, "shadowDepth", Dictionary_Entry_Value_FromUnsignedInt( 0 ) );
-
- nTopology = (Topology*)IJK6Topology_New( "IJK6Topology", dictionary );
- eLayout = (ElementLayout*)ParallelPipedHexaEL_New( "PPHexaEL", 3, dictionary );
- nLayout = (NodeLayout*)CornerNL_New( "CornerNL", dictionary, eLayout, nTopology );
- decomp = (MeshDecomp*)HexaMD_New( "HexaMD", dictionary, MPI_COMM_WORLD, eLayout, nLayout );
- ml = MeshLayout_New( "MeshLayout", eLayout, nLayout, decomp );
-
- extensionMgr_Register = ExtensionManager_Register_New();
- mesh = Mesh_New( "Mesh", ml, sizeof(Node), sizeof(Element), extensionMgr_Register, dictionary );
-
- mesh->buildNodeLocalToGlobalMap = True;
- mesh->buildNodeDomainToGlobalMap = True;
- mesh->buildNodeGlobalToLocalMap = True;
- mesh->buildNodeGlobalToDomainMap = True;
- mesh->buildNodeNeighbourTbl = True;
- mesh->buildNodeElementTbl = True;
- mesh->buildElementLocalToGlobalMap = True;
- mesh->buildElementDomainToGlobalMap = True;
- mesh->buildElementGlobalToDomainMap = True;
- mesh->buildElementGlobalToLocalMap = True;
- mesh->buildElementNeighbourTbl = True;
- mesh->buildElementNodeTbl = True;
-
- /* Coarsen by one level */
- coarsener = MeshCoarsener_Hexa_New("meshCoarsener");
- MeshCoarsener_Hexa_Coarsen( coarsener, mesh, 1, NULL, NULL );
- Stg_Class_Delete( coarsener );
-
- Build( mesh, 0, False );
- Initialise(mesh, 0, False );
-
- if (rank == procToWatch)
- {
- Print(mesh, stream);
- }
-
- Stg_Class_Delete(mesh);
- Stg_Class_Delete(ml);
- Stg_Class_Delete(decomp);
- Stg_Class_Delete(nLayout);
- Stg_Class_Delete(eLayout);
- Stg_Class_Delete( nTopology );
- Stg_Class_Delete(dictionary);
-
- StgDomainMesh_Finalise();
- StgDomainShape_Finalise();
- StgDomainGeometry_Finalise();
-
- StGermain_Finalise();
-
- /* Close off MPI */
- MPI_Finalize();
-
- return 0; /* success */
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/tests/testSemiRegDeform.c
--- a/Utils/tests/testSemiRegDeform.c Fri Jan 25 03:44:23 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-**
-** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
-**
-** Authors:
-** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
-** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
-** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
-** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
-** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
-** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
-**
-** This library is free software; you can redistribute it and/or
-** modify it under the terms of the GNU Lesser General Public
-** License as published by the Free Software Foundation; either
-** version 2.1 of the License, or (at your option) any later version.
-**
-** This library is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-** Lesser General Public License for more details.
-**
-** You should have received a copy of the GNU Lesser General Public
-** License along with this library; if not, write to the Free Software
-** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-**
-** $Id: testSemiRegDeform.c 3124 2005-07-25 04:52:06Z RobertTurnbull $
-**
-**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <mpi.h>
-
-#include <StGermain/StGermain.h>
-#include <StgDomain/Geometry/Geometry.h>
-#include <StgDomain/Shape/Shape.h>
-#include <StgDomain/Mesh/Mesh.h>
-
-#include "StgDomain/Utils/types.h"
-#include "StgDomain/Utils/SemiRegDeform.h"
-
-
-struct _Node {
- double tmp;
-};
-
-struct _Element {
- double tmp;
-};
-
-
-Mesh* buildMesh( unsigned nDims, unsigned* size,
- double* minCrds, double* maxCrds,
- ExtensionManager_Register* emReg )
-{
- CartesianGenerator* gen;
- Mesh* mesh;
-
- gen = CartesianGenerator_New( "" );
- CartesianGenerator_SetDimSize( gen, nDims );
- CartesianGenerator_SetTopologyParams( gen, size, 0, NULL, NULL );
- CartesianGenerator_SetGeometryParams( gen, minCrds, maxCrds );
-
- mesh = Mesh_New( "" );
- Mesh_SetExtensionManagerRegister( mesh, emReg );
- Mesh_SetGenerator( mesh, gen );
-
- Build( mesh, NULL, False );
- Initialise( mesh, NULL, False );
-
- KillObject( mesh->generator );
-
- return mesh;
-}
-
-
-int main( int argc, char* argv[] ) {
- MPI_Comm commWorld;
- int rank;
- int nProcs;
- int procToWatch;
- ExtensionManager_Register* extensionMgr_Register;
- Stream* stream;
- SemiRegDeform* srd;
-
- unsigned nDims = 3;
- unsigned meshSize[3] = {4, 4, 4};
- double minCrds[3] = {0.0, 0.0, 0.0};
- double maxCrds[3] = {1.0, 1.0, 1.0};
- Mesh* mesh;
- Grid* vertGrid;
-
- /*
- ** Initialise MPI, StGermain Base, get world info.
- */
-
- MPI_Init( &argc, &argv );
- MPI_Comm_dup( MPI_COMM_WORLD, &commWorld );
- MPI_Comm_size( commWorld, &nProcs );
- MPI_Comm_rank( commWorld, &rank );
-
- StGermain_Init( &argc, &argv );
- StgDomainGeometry_Init( &argc, &argv );
- StgDomainShape_Init( &argc, &argv );
- StgDomainMesh_Init( &argc, &argv );
- MPI_Barrier( commWorld ); /* Ensures copyright info always come first in output */
-
- stream = Journal_Register( Info_Type, "myStream" );
- procToWatch = argc >= 2 ? atoi(argv[1]) : 0;
-
- /*
- ** Create the mesh.
- */
-
- mesh = buildMesh( nDims, meshSize, minCrds, maxCrds, extensionMgr_Register );
- vertGrid = *(Grid**)ExtensionManager_Get( mesh->info, mesh,
- ExtensionManager_GetHandle( mesh->info, "vertexGrid" ) );
-
- /*
- ** Create the deformation.
- */
-
- {
- IJK ijk;
- unsigned lower, upper;
-
- srd = SemiRegDeform_New( "SemiRegDeform" );
- SemiRegDeform_SetMesh( srd, mesh );
-
- /* Set up strips to remesh in the y direction. */
- for( ijk[2] = 0; ijk[2] < meshSize[2]; ijk[2]++ ) {
- for( ijk[0] = 0; ijk[0] < meshSize[0]; ijk[0]++ ) {
- ijk[1] = 0;
- lower = Grid_Project( vertGrid, ijk );
-
- ijk[1] = meshSize[1] - 1;
- upper = Grid_Project( vertGrid, ijk );
-
- SemiRegDeform_AddStrip( srd, lower, upper );
- }
- }
-
- /* Build and initialise. */
- Build( srd, 0, False );
- Initialise( srd, 0, False );
-
- /* Execute the deformation. */
- SemiRegDeform_Deform( srd );
-
- /* Check the deformation. */
- if (rank == procToWatch) {
- }
-
- /* Kill it. */
- Stg_Class_Delete( srd );
- }
-
- {
- IJK ijk;
- unsigned lower, upper;
-
- srd = SemiRegDeform_New( "SemiRegDeform" );
- SemiRegDeform_SetMesh( srd, mesh );
-
- /* Set up strips to remesh in the y direction. */
- for( ijk[2] = 0; ijk[2] < meshSize[2]; ijk[2]++ ) {
- for( ijk[0] = 0; ijk[0] < meshSize[0]; ijk[0]++ ) {
- ijk[1] = 0;
- lower = Grid_Project( vertGrid, ijk );
- ijk[1] = meshSize[1] - 2;
- upper = Grid_Project( vertGrid, ijk );
- SemiRegDeform_AddStrip( srd, lower, upper );
-
- lower = upper;
- ijk[1] = meshSize[1] - 1;
- upper = Grid_Project( vertGrid, ijk );
- SemiRegDeform_AddStrip( srd, lower, upper );
- }
- }
-
- /* Build and initialise. */
- Build( srd, 0, False );
- Initialise( srd, 0, False );
-
- /* Check the deformation. */
- if (rank == procToWatch) {
- }
-
- /* Kill it. */
- Stg_Class_Delete( srd );
- }
-
-
- /*
- ** Cleanup.
- */
-
- Stg_Class_Delete( mesh );
-
- StgDomainMesh_Finalise();
- StgDomainShape_Finalise();
- StgDomainGeometry_Finalise();
- StGermain_Finalise();
-
- /* Close off MPI */
- MPI_Finalize();
-
- return EXIT_SUCCESS;
-}
diff -r 8e9e91298ee8 -r c8338a44bcc5 Utils/tests/testSemiRegDeform.c.disabled
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils/tests/testSemiRegDeform.c.disabled Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,212 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**
+** $Id: testSemiRegDeform.c 3124 2005-07-25 04:52:06Z RobertTurnbull $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include <StgDomain/Geometry/Geometry.h>
+#include <StgDomain/Shape/Shape.h>
+#include <StgDomain/Mesh/Mesh.h>
+
+#include "StgDomain/Utils/types.h"
+#include "StgDomain/Utils/SemiRegDeform.h"
+
+
+struct _Node {
+ double tmp;
+};
+
+struct _Element {
+ double tmp;
+};
+
+
+Mesh* buildMesh( unsigned nDims, unsigned* size,
+ double* minCrds, double* maxCrds,
+ ExtensionManager_Register* emReg )
+{
+ CartesianGenerator* gen;
+ Mesh* mesh;
+
+ gen = CartesianGenerator_New( "" );
+ CartesianGenerator_SetDimSize( gen, nDims );
+ CartesianGenerator_SetTopologyParams( gen, size, 0, NULL, NULL );
+ CartesianGenerator_SetGeometryParams( gen, minCrds, maxCrds );
+
+ mesh = Mesh_New( "" );
+ Mesh_SetExtensionManagerRegister( mesh, emReg );
+ Mesh_SetGenerator( mesh, gen );
+
+ Build( mesh, NULL, False );
+ Initialise( mesh, NULL, False );
+
+ KillObject( mesh->generator );
+
+ return mesh;
+}
+
+
+int main( int argc, char* argv[] ) {
+ MPI_Comm commWorld;
+ int rank;
+ int nProcs;
+ int procToWatch;
+ ExtensionManager_Register* extensionMgr_Register;
+ Stream* stream;
+ SemiRegDeform* srd;
+
+ unsigned nDims = 3;
+ unsigned meshSize[3] = {4, 4, 4};
+ double minCrds[3] = {0.0, 0.0, 0.0};
+ double maxCrds[3] = {1.0, 1.0, 1.0};
+ Mesh* mesh;
+ Grid* vertGrid;
+
+ /*
+ ** Initialise MPI, StGermain Base, get world info.
+ */
+
+ MPI_Init( &argc, &argv );
+ MPI_Comm_dup( MPI_COMM_WORLD, &commWorld );
+ MPI_Comm_size( commWorld, &nProcs );
+ MPI_Comm_rank( commWorld, &rank );
+
+ StGermain_Init( &argc, &argv );
+ StgDomainGeometry_Init( &argc, &argv );
+ StgDomainShape_Init( &argc, &argv );
+ StgDomainMesh_Init( &argc, &argv );
+ MPI_Barrier( commWorld ); /* Ensures copyright info always come first in output */
+
+ stream = Journal_Register( Info_Type, "myStream" );
+ procToWatch = argc >= 2 ? atoi(argv[1]) : 0;
+
+ /*
+ ** Create the mesh.
+ */
+
+ mesh = buildMesh( nDims, meshSize, minCrds, maxCrds, extensionMgr_Register );
+ vertGrid = *(Grid**)ExtensionManager_Get( mesh->info, mesh,
+ ExtensionManager_GetHandle( mesh->info, "vertexGrid" ) );
+
+ /*
+ ** Create the deformation.
+ */
+
+ {
+ IJK ijk;
+ unsigned lower, upper;
+
+ srd = SemiRegDeform_New( "SemiRegDeform" );
+ SemiRegDeform_SetMesh( srd, mesh );
+
+ /* Set up strips to remesh in the y direction. */
+ for( ijk[2] = 0; ijk[2] < meshSize[2]; ijk[2]++ ) {
+ for( ijk[0] = 0; ijk[0] < meshSize[0]; ijk[0]++ ) {
+ ijk[1] = 0;
+ lower = Grid_Project( vertGrid, ijk );
+
+ ijk[1] = meshSize[1] - 1;
+ upper = Grid_Project( vertGrid, ijk );
+
+ SemiRegDeform_AddStrip( srd, lower, upper );
+ }
+ }
+
+ /* Build and initialise. */
+ Build( srd, 0, False );
+ Initialise( srd, 0, False );
+
+ /* Execute the deformation. */
+ SemiRegDeform_Deform( srd );
+
+ /* Check the deformation. */
+ if (rank == procToWatch) {
+ }
+
+ /* Kill it. */
+ Stg_Class_Delete( srd );
+ }
+
+ {
+ IJK ijk;
+ unsigned lower, upper;
+
+ srd = SemiRegDeform_New( "SemiRegDeform" );
+ SemiRegDeform_SetMesh( srd, mesh );
+
+ /* Set up strips to remesh in the y direction. */
+ for( ijk[2] = 0; ijk[2] < meshSize[2]; ijk[2]++ ) {
+ for( ijk[0] = 0; ijk[0] < meshSize[0]; ijk[0]++ ) {
+ ijk[1] = 0;
+ lower = Grid_Project( vertGrid, ijk );
+ ijk[1] = meshSize[1] - 2;
+ upper = Grid_Project( vertGrid, ijk );
+ SemiRegDeform_AddStrip( srd, lower, upper );
+
+ lower = upper;
+ ijk[1] = meshSize[1] - 1;
+ upper = Grid_Project( vertGrid, ijk );
+ SemiRegDeform_AddStrip( srd, lower, upper );
+ }
+ }
+
+ /* Build and initialise. */
+ Build( srd, 0, False );
+ Initialise( srd, 0, False );
+
+ /* Check the deformation. */
+ if (rank == procToWatch) {
+ }
+
+ /* Kill it. */
+ Stg_Class_Delete( srd );
+ }
+
+
+ /*
+ ** Cleanup.
+ */
+
+ Stg_Class_Delete( mesh );
+
+ StgDomainMesh_Finalise();
+ StgDomainShape_Finalise();
+ StgDomainGeometry_Finalise();
+ StGermain_Finalise();
+
+ /* Close off MPI */
+ MPI_Finalize();
+
+ return EXIT_SUCCESS;
+}
diff -r 8e9e91298ee8 -r c8338a44bcc5 libStgDomain/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libStgDomain/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,18 @@
+import os
+Import('env objs')
+
+# Execute subdirectory SConscripts.
+objs += SConscript('src/SConscript', exports='env')
+
+# Build libraries.
+libs = env.Library('#build/lib/StgDomain', objs)
+libs += env.LoadableModule('#build/lib/StgDomain', objs)
+env.Install(os.path.join(env['prefix'], 'lib'), libs)
+
+# Build tests.
+SConscript('tests/SConscript', exports='env')
+
+# Build toolbox.
+SConscript('Toolbox/SConscript', exports='env')
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 libStgDomain/Toolbox/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libStgDomain/Toolbox/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,14 @@
+import os
+Import('env')
+
+# Build our source files.
+objs = env['helpers']['buildCSrcs'](env)
+
+# Build plugin module.
+curLIBPREFIXES = env['LIBPREFIXES'] if 'LIBPREFIXES' in env._dict else []
+if not isinstance(curLIBPREFIXES, list):
+ curLIBPREFIXES = [curLIBPREFIXES]
+mod = env.LoadableModule('#build/lib/StgDomain_Toolboxmodule', objs,
+ SHLIBPREFIX='',
+ LIBPREFIXES=curLIBPREFIXES + [''])
+env.Install(os.path.join(env['prefix'], 'lib'), mod)
diff -r 8e9e91298ee8 -r c8338a44bcc5 libStgDomain/src/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libStgDomain/src/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,11 @@
+import os
+Import('env')
+
+# These guys go somewhere different than their source location.
+hdrs = Split('Init.h Finalise.h StgDomain.h')
+env.Install('#build/include/StgDomain', hdrs)
+
+# Build our source files.
+objs = env['helpers']['buildCSrcs'](env)
+
+Return('objs')
diff -r 8e9e91298ee8 -r c8338a44bcc5 libStgDomain/tests/SConscript
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libStgDomain/tests/SConscript Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,5 @@
+import os
+Import('env')
+
+# Build test binaries.
+env['helpers']['buildTests'](env, libs=['StgDomain'])
diff -r 8e9e91298ee8 -r c8338a44bcc5 meta-template.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/meta-template.c Tue Jan 29 03:40:13 2008 +0000
@@ -0,0 +1,58 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, Victorian Partnership for Advanced Computing (VPAC) Ltd, 110 Victoria Street, Melbourne, 3053, Australia.
+**
+** Authors:
+** Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+** Patrick D. Sunter, Software Engineer, VPAC. (pds at vpac.org)
+** Luke J. Hodkinson, Computational Engineer, VPAC. (lhodkins at vpac.org)
+** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
+** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
+** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+**
+** This library is free software; you can redistribute it and/or
+** modify it under the terms of the GNU Lesser General Public
+** License as published by the Free Software Foundation; either
+** version 2.1 of the License, or (at your option) any later version.
+**
+** This library is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** Lesser General Public License for more details.
+**
+** You should have received a copy of the GNU Lesser General Public
+** License along with this library; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+/* !!! This is an automatically generated file
+ * !!! Do not make modifications here or they will be overwritten
+ */
+#define Stg_Component_Stringify( str ) #str
+
+/* Note: Two macros are used to resolve the the extra macro level */
+#define Stg_Component_Metadata_Create( name ) Stg_Component_Metadata_Create_Macro( name )
+#define Stg_Component_Metadata_Create_Macro( name ) \
+ const char* name ##_Meta = XML_METADATA; \
+ const char* name ##_Name = #name; \
+ const char* name ##_Version = VERSION; \
+ const char* name ##_Type_GetMetadata() { /* hack...won't be needed when hierarchy rollout is done */\
+ return name ##_Meta; \
+ } \
+ const char* name ##_GetMetadata() { \
+ return name ##_Meta; \
+ } \
+ const char* name ##_GetName() { \
+ return name ##_Name; \
+ } \
+ const char* name ##_GetVersion() { \
+ return name ##_Version; \
+ }
+
+
+#if defined(COMPONENT_NAME) && defined(VERSION) && defined(XML_METADATA)
+
+ Stg_Component_Metadata_Create( COMPONENT_NAME )
+
+#endif
+
More information about the CIG-COMMITS
mailing list