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

Contents of /trunk-mpi-branch/finley/src/NodeDistribution.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1087 - (show annotations)
Thu Apr 12 10:01:47 2007 UTC (12 years, 2 months ago) by gross
File MIME type: text/plain
File size: 3565 byte(s)
the MPI version of PASO.PCG is running. 
There is a bug in the rectangular mesh generators but they need to be
revised in any case to clean up the code.


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
56 if( in )
57 (in->reference_counter)++;
58
59 return in;
60 }
61
62 Finley_NodeGhostEdge* Finley_NodeGhostEdge_alloc( void )
63 {
64 Finley_NodeGhostEdge *out=NULL;
65
66 out = MEMALLOC( 1, Finley_NodeGhostEdge );
67 if (Finley_checkPtr(out)) return NULL;
68
69 out->reference_counter = 0;
70 out->numForward = out->numBackward = 0;
71 out->indexForward = out->indexBackward = NULL;
72
73 out->reference_counter++;
74
75 return out;
76 }
77
78 void Finley_NodeGhostEdge_dealloc( Finley_NodeGhostEdge *in )
79 {
80 if( in && !(--in->reference_counter) )
81 {
82 MEMFREE( in->indexForward );
83 MEMFREE( in->indexBackward );
84 MEMFREE( in );
85 }
86 }
87
88 Finley_NodeGhostEdge* Finley_NodeGhostEdge_getReference( Finley_NodeGhostEdge *in )
89 {
90 if( in )
91 in->reference_counter++;
92
93 return in;
94 }
95
96 /* print the local distribution data to fid */
97 void Finley_NodeDistribution_print( Finley_NodeDistribution *in, FILE *fid )
98 {
99 int n, i;
100
101 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 );
102 fprintf( fid, "vtxdist [ " );
103 for( i=0; i<in->MPIInfo->size+1; i++ )
104 fprintf( fid, "%d ", in->vtxdist[i] );
105 fprintf( fid, "]\n" );
106 fprintf( fid, "indexExternal [ " );
107 for( i=0; i<in->numExternal; i++ )
108 fprintf( fid, "%d ", in->indexExternal[i] );
109 fprintf( fid, "]\n" );
110 fprintf( fid, "NumNeighbours %d\n", in->numNeighbours );
111 /* list each neighbour */
112 for( n=0; n<in->numNeighbours; n++ )
113 {
114 if( in->neighbours[n]!=-1 ){
115 fprintf( fid, "\nNeighbour %d - Domain %d\n=====================\n\n", n, in->neighbours[n] );
116 fprintf( fid, "numForward = %d\tnumBackward = %d\n", in->edges[n]->numForward, in->edges[n]->numBackward );
117 fprintf( fid, "indexForward\n[ " );
118 for( i=0; i<in->edges[n]->numForward; i++ )
119 fprintf( fid, "%d ", in->edges[n]->indexForward[i] );
120 fprintf( fid, "]\n" );
121 fprintf( fid, "indexBackward\n[ " );
122 for( i=0; i<in->edges[n]->numBackward; i++ )
123 fprintf( fid, "%d ", in->edges[n]->indexBackward[i] );
124 fprintf( fid, "]\n=======================================================================================\n" );
125 }else
126 fprintf( fid, "\nNeighbour %d - Empty\n=====================\n\n", n );
127 }
128 }
129
130 #endif

  ViewVC Help
Powered by ViewVC 1.1.26