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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 731 - (hide annotations)
Mon May 15 04:09:52 2006 UTC (15 years, 2 months ago) by bcumming
File MIME type: text/plain
File size: 1944 byte(s)


1 bcumming 731 /* 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     #endif

  ViewVC Help
Powered by ViewVC 1.1.26