/[escript]/branches/doubleplusgood/paso/src/SharedComponents.cpp
ViewVC logotype

Annotation of /branches/doubleplusgood/paso/src/SharedComponents.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1562 - (hide annotations)
Wed May 21 13:04:40 2008 UTC (10 years, 10 months ago) by gross
Original Path: trunk/paso/src/SharedComponents.c
File MIME type: text/plain
File size: 3941 byte(s)
The algebraic upwinding with MPI. The case of boundary constraint needs still some attention. 


1 ksteube 1313
2     /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16     /**************************************************************/
17    
18     /* Paso: SharedComponents organizes the coupling with in a pattern/matrix */
19     /* across processors */
20    
21     /**************************************************************/
22    
23     /* Author: gross@access.edu.au */
24    
25     /**************************************************************/
26    
27     #include "SharedComponents.h"
28    
29     /**************************************************************/
30    
31     /* allocates a SharedComponents */
32    
33    
34     /**************************************************************/
35    
36 gross 1562 Paso_SharedComponents* Paso_SharedComponents_alloc(dim_t local_length,
37     dim_t numNeighbors,
38 ksteube 1313 Paso_MPI_rank* neighbor,
39     index_t* shared,
40     index_t* offsetInShared,
41     index_t m, index_t b,
42     Paso_MPIInfo *mpi_info)
43     {
44     dim_t i,j;
45     register index_t itmp;
46     Paso_SharedComponents* out=NULL;
47     Paso_resetError();
48     out=MEMALLOC(1,Paso_SharedComponents);
49     if (!Paso_checkPtr(out)) {
50 gross 1562 out->local_length=local_length*m;
51 ksteube 1313 out->mpi_info = Paso_MPIInfo_getReference(mpi_info);
52     out->numNeighbors=numNeighbors;
53     out->neighbor=MEMALLOC(out->numNeighbors,Paso_MPI_rank);
54     if (offsetInShared == NULL) {
55     out->numSharedComponents=0;
56     } else {
57     out->numSharedComponents=offsetInShared[numNeighbors]*m;
58     }
59     out->shared=MEMALLOC(out->numSharedComponents,index_t);
60     out->offsetInShared=MEMALLOC(out->numNeighbors+1,index_t);
61     out->reference_counter=1;
62     if (! (Paso_checkPtr(out->neighbor) ||
63     Paso_checkPtr(out->shared) ||
64     Paso_checkPtr(out->offsetInShared) ) ) {
65    
66    
67     if ((out->numNeighbors>0) && (offsetInShared!=NULL) ) {
68     #pragma omp parallel
69     {
70     #pragma omp for private(i)
71     for (i=0;i<out->numNeighbors;++i){
72     out->neighbor[i]=neighbor[i];
73     out->offsetInShared[i]=offsetInShared[i]*m;
74     }
75     out->offsetInShared[out->numNeighbors]=offsetInShared[numNeighbors]*m;
76     #pragma omp for private(i,j,itmp)
77     for (i=0;i<offsetInShared[numNeighbors];++i){
78     itmp=m*shared[i]+b;
79     for (j=0;j<m;++j) out->shared[m*i+j]=itmp+j;
80     }
81     }
82     } else {
83     out->offsetInShared[out->numNeighbors]=0;
84     }
85     }
86    
87     }
88     if (Paso_noError()) {
89     return out;
90     } else {
91     Paso_SharedComponents_free(out);
92     return NULL;
93     }
94     }
95    
96     /* returns a reference to in */
97    
98     Paso_SharedComponents* Paso_SharedComponents_getReference(Paso_SharedComponents* in) {
99     if (in!=NULL) {
100     ++(in->reference_counter);
101     }
102     return in;
103     }
104    
105     /* deallocates a SharedComponents: */
106    
107     void Paso_SharedComponents_free(Paso_SharedComponents* in) {
108     if (in!=NULL) {
109     in->reference_counter--;
110     if (in->reference_counter<=0) {
111     MEMFREE(in->neighbor);
112     MEMFREE(in->shared);
113     MEMFREE(in->offsetInShared);
114     Paso_MPIInfo_free(in->mpi_info);
115     MEMFREE(in);
116     #ifdef Paso_TRACE
117     printf("Paso_SharedComponents_dealloc: system matrix pattern as been deallocated.\n");
118     #endif
119     }
120     }
121     }

  ViewVC Help
Powered by ViewVC 1.1.26