/[escript]/trunk/finley/src/NodeDistribution.c
ViewVC logotype

Contents of /trunk/finley/src/NodeDistribution.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 782 - (show annotations)
Tue Jul 18 00:47:47 2006 UTC (12 years, 11 months ago) by bcumming
File MIME type: text/plain
File size: 3560 byte(s)
Large number of changes to Finley for meshing in MPI.

- optimisation and neatening up of rectcanglular mesh generation code
- first and second order 1D, 2D and 3D rectangular meshes are now
  available in finley and escript using MPI.
- reduced meshes now generated in MPI, and interpolation to and from 
  reduced data types now supported.  

1 /* created by Ben Cumming on 26/04/2006 */
2 #include "Distribution.h"
3
4 #ifdef PASO_MPI
5
6 Finley_NodeDistribution* Finley_NodeDistribution_alloc( Paso_MPIInfo *MPIInfo )
7 {
8 Finley_NodeDistribution *out=NULL;
9
10 out = MEMALLOC( 1, Finley_NodeDistribution );
11 if (Finley_checkPtr(out)) return NULL;
12
13 out->reference_counter = 0;
14
15 out->MPIInfo = Paso_MPIInfo_getReference(MPIInfo);
16
17 out->numLocal = 0;
18 out->numGlobal = 0;
19 out->numInternal = 0;
20 out->numBoundary = 0;
21 out->numExternal = 0;
22
23 out->numNeighbours = 0;
24 out->neighbours = NULL;
25 out->edges = NULL;
26 out->indexExternal = NULL;
27 out->vtxdist=NULL;
28
29 out->reference_counter++;
30
31 return out;
32 }
33
34 void Finley_NodeDistribution_dealloc( Finley_NodeDistribution *in )
35 {
36 index_t i;
37
38 if( in && !(--in->reference_counter) )
39 {
40 Paso_MPIInfo_dealloc( in->MPIInfo );
41
42 for( i=0; i<in->numNeighbours; i++ )
43 Finley_NodeGhostEdge_dealloc( in->edges[i] );
44 MEMFREE( in->edges );
45 MEMFREE( in->vtxdist );
46 MEMFREE( in->indexExternal );
47 MEMFREE( in->neighbours );
48
49 MEMFREE( in );
50 }
51 }
52
53 Finley_NodeDistribution* Finley_NodeDistribution_getReference( Finley_NodeDistribution *in )
54 {
55 if( in )
56 in->reference_counter++;
57
58 return in;
59 }
60
61 Finley_NodeGhostEdge* Finley_NodeGhostEdge_alloc( void )
62 {
63 Finley_NodeGhostEdge *out=NULL;
64
65 out = MEMALLOC( 1, Finley_NodeGhostEdge );
66 if (Finley_checkPtr(out)) return NULL;
67
68 out->reference_counter = 0;
69 out->numForward = out->numBackward = 0;
70 out->indexForward = out->indexBackward = NULL;
71
72 out->reference_counter++;
73
74 return out;
75 }
76
77 void Finley_NodeGhostEdge_dealloc( Finley_NodeGhostEdge *in )
78 {
79 if( in && !(--in->reference_counter) )
80 {
81 MEMFREE( in->indexForward );
82 MEMFREE( in->indexBackward );
83 MEMFREE( in );
84 }
85 }
86
87 Finley_NodeGhostEdge* Finley_NodeGhostEdge_getReference( Finley_NodeGhostEdge *in )
88 {
89 if( in )
90 in->reference_counter++;
91
92 return in;
93 }
94
95 /* print the local distribution data to fid */
96 void Finley_NodeDistribution_print( Finley_NodeDistribution *in, FILE *fid )
97 {
98 int n, i;
99
100 fprintf( fid, "=======================================================================================\nNode Distribution\n---------------------\n\nInternal %d\nBoundary %d\nLocal %d\nExternal %d\nGlobal %d\n", in->numInternal, in->numBoundary, in->numLocal, in->numExternal, in->numGlobal );
101 fprintf( fid, "vtxdist [ " );
102 for( i=0; i<in->MPIInfo->size+1; i++ )
103 fprintf( fid, "%d ", in->vtxdist[i] );
104 fprintf( fid, "]\n" );
105 fprintf( fid, "indexExternal [ " );
106 for( i=0; i<in->numExternal; i++ )
107 fprintf( fid, "%d ", in->indexExternal[i] );
108 fprintf( fid, "]\n" );
109 fprintf( fid, "NumNeighbours %d\n", in->numNeighbours );
110 /* list each neighbour */
111 for( n=0; n<in->numNeighbours; n++ )
112 {
113 if( in->neighbours[n]!=-1 ){
114 fprintf( fid, "\nNeighbour %d - Domain %d\n=====================\n\n", n, in->neighbours[n] );
115 fprintf( fid, "numForward = %d\tnumBackward = %d\n", in->edges[n]->numForward, in->edges[n]->numBackward );
116 fprintf( fid, "indexForward\n[ " );
117 for( i=0; i<in->edges[n]->numForward; i++ )
118 fprintf( fid, "%d ", in->edges[n]->indexForward[i] );
119 fprintf( fid, "]\n" );
120 fprintf( fid, "indexBackward\n[ " );
121 for( i=0; i<in->edges[n]->numBackward; i++ )
122 fprintf( fid, "%d ", in->edges[n]->indexBackward[i] );
123 fprintf( fid, "]\n=======================================================================================\n" );
124 }else
125 fprintf( fid, "\nNeighbour %d - Empty\n=====================\n\n", n );
126 }
127 }
128
129 #endif

  ViewVC Help
Powered by ViewVC 1.1.26