/[escript]/temp_trunk_copy/finley/src/IndexList.c
ViewVC logotype

Annotation of /temp_trunk_copy/finley/src/IndexList.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (14 years, 11 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/IndexList.c
File MIME type: text/plain
File size: 8442 byte(s)
Initial revision

1 jgs 82 /* $Id$ */
2    
3     /**************************************************************/
4    
5     /* Finley: Converting an element list into a matrix shape */
6    
7     /**************************************************************/
8    
9     /* Copyrights by ACcESS Australia 2003,2004 */
10     /* Author: gross@access.edu.au */
11    
12     /**************************************************************/
13    
14     #include "Finley.h"
15     #include "ElementFile.h"
16     #include "System.h"
17     #include "IndexList.h"
18    
19     /**************************************************************/
20     /* inserts the contributions from the element matrices of elements
21     into the row index col. If symmetric is set, only the upper
22     triangle of the matrix is stored. */
23    
24     void Finley_IndexList_insertElements(Finley_IndexList* index_list, Finley_ElementFile* elements,
25     int reduce_row_order, int packed_row_block_size, maybelong* row_Label,
26     int reduce_col_order, int packed_col_block_size, maybelong* col_Label,
27     int symmetric, Finley_SystemMatrixType matType) {
28     maybelong e,kr,ir,kc,ic,NN_row,NN_col,i;
29     Finley_IndexList * tmp_list;
30     maybelong jr,jc,icol,irow,color;
31    
32    
33     if (elements!=NULL) {
34     maybelong NN=elements->ReferenceElement->Type->numNodes;
35     maybelong id[NN],*row_node,*col_node;
36     for (i=0;i<NN;i++) id[i]=i;
37     if (reduce_col_order) {
38     col_node=elements->ReferenceElement->Type->linearNodes;
39     NN_col=elements->LinearReferenceElement->Type->numNodes;
40     } else {
41     col_node=id;
42     NN_col=elements->ReferenceElement->Type->numNodes;
43     }
44     if (reduce_row_order) {
45     row_node=elements->ReferenceElement->Type->linearNodes;
46     NN_row=elements->LinearReferenceElement->Type->numNodes;
47     } else {
48     row_node=id;
49     NN_row=elements->ReferenceElement->Type->numNodes;
50     }
51    
52     #pragma omp parallel private(color)
53     {
54     switch(matType) {
55     case CSR:
56     if (symmetric) {
57     for (color=0;color<elements->numColors;color++) {
58     #pragma omp for private(e,kr,jr,kc,jc,ir,irow,ic,icol,tmp_list) schedule(static)
59     for (e=0;e<elements->numElements;e++) {
60     if (elements->Color[e]==color) {
61     for (kr=0;kr<NN_row;kr++) {
62     jr=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
63     for (ir=0;ir<packed_row_block_size;ir++) {
64     irow=ir+packed_row_block_size*jr;
65     tmp_list=&(index_list[irow]);
66     for (kc=0;kc<NN_col;kc++) {
67     jc=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
68     for (ic=0;ic<packed_col_block_size;ic++) {
69     icol=ic+packed_col_block_size*jc;
70     if (irow<=icol) Finley_IndexList_insertIndex(tmp_list,icol);
71     }
72     }
73     }
74     }
75     }
76     }
77     }
78     } else {
79     for (color=0;color<elements->numColors;color++) {
80     #pragma omp for private(e,kr,jr,kc,jc,ir,irow,ic,icol,tmp_list) schedule(static)
81     for (e=0;e<elements->numElements;e++) {
82     if (elements->Color[e]==color) {
83     for (kr=0;kr<NN_row;kr++) {
84     jr=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
85     for (ir=0;ir<packed_row_block_size;ir++) {
86     irow=ir+packed_row_block_size*jr;
87     tmp_list=&(index_list[irow]);
88     for (kc=0;kc<NN_col;kc++) {
89     jc=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
90     for (ic=0;ic<packed_col_block_size;ic++) { icol=ic+packed_col_block_size*jc;
91     Finley_IndexList_insertIndex(tmp_list,icol);
92     }
93     }
94     }
95     }
96     }
97     }
98     }
99     } /* if else */
100     break;
101     case CSC:
102     if (symmetric) {
103     for (color=0;color<elements->numColors;color++) {
104     #pragma omp for private (e,kr,jr,kc,jc,ir,irow,ic,icol,tmp_list) schedule(static)
105     for (e=0;e<elements->numElements;e++) {
106     if (elements->Color[e]==color) {
107     for (kc=0;kc<NN_col;kc++) {
108     jc=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
109     for (ic=0;ic<packed_col_block_size;ic++) {
110     icol=ic+packed_col_block_size*jc;
111     tmp_list=&(index_list[icol]);
112     for (kr=0;kr<NN_row;kr++) {
113     jr=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
114     for (ir=0;ir<packed_row_block_size;ir++) {
115     irow=ir+packed_row_block_size*jr;
116     if (irow<=icol) Finley_IndexList_insertIndex(tmp_list,irow);
117     }
118     }
119     }
120     }
121     }
122     }
123     }
124     } else {
125     for (color=0;color<elements->numColors;color++) {
126     #pragma omp for private (e,kr,jr,kc,jc,ir,irow,ic,icol,tmp_list) schedule(static)
127     for (e=0;e<elements->numElements;e++) {
128     if (elements->Color[e]==color) {
129     for (kc=0;kc<NN_col;kc++) {
130     jc=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
131     for (ic=0;ic<packed_col_block_size;ic++) {
132     icol=ic+packed_col_block_size*jc;
133     tmp_list=&(index_list[icol]);
134     for (kr=0;kr<NN_row;kr++) {
135     jr=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
136     for (ir=0;ir<packed_row_block_size;ir++) {
137     irow=ir+packed_row_block_size*jr;
138     Finley_IndexList_insertIndex(tmp_list,irow);
139     }
140     }
141     }
142     }
143     }
144     }
145     }
146     } /* if else */
147     } /* switch matType */
148     }
149     }
150     return;
151     }
152    
153     /* inserts row index row into the Finley_IndexList in if it does not exist */
154    
155     void Finley_IndexList_insertIndex(Finley_IndexList* in, maybelong index) {
156     int i;
157     /* is index in in? */
158     for (i=0;i<in->n;i++) {
159     if (in->index[i]==index) return;
160     }
161     /* index could not be found */
162     if (in->n==INDEXLIST_LENGTH) {
163     /* if in->index is full check the extension */
164     if (in->extension==NULL) {
165     in->extension=(Finley_IndexList*) TMPMEMALLOC(sizeof(Finley_IndexList));
166     if (Finley_checkPtr(in->extension)) return;
167     in->extension->n=0;
168     in->extension->extension=NULL;
169     }
170     Finley_IndexList_insertIndex(in->extension,index);
171     } else {
172     /* insert index into in->index*/
173     in->index[in->n]=index;
174     in->n++;
175     }
176     }
177    
178     /* counts the number of row indices in the Finley_IndexList in */
179    
180     int Finley_IndexList_count(Finley_IndexList* in) {
181     if (in==NULL) {
182     return 0;
183     } else {
184     return (in->n)+Finley_IndexList_count(in->extension);
185     }
186     }
187    
188     /* count the number of row indices in the Finley_IndexList in */
189    
190     void Finley_IndexList_toArray(Finley_IndexList* in, maybelong* array) {
191     int i;
192     if (in!=NULL) {
193     for (i=0;i<in->n;i++) array[i]=in->index[i]+INDEX_OFFSET;
194     Finley_IndexList_toArray(in->extension,&(array[in->n]));
195     }
196     }
197    
198     /* deallocates the Finley_IndexList in by recursive calls */
199    
200     void Finley_IndexList_free(Finley_IndexList* in) {
201     if (in!=NULL) {
202     Finley_IndexList_free(in->extension);
203     TMPMEMFREE(in);
204     }
205     }
206    
207     /*
208     * $Log$
209     * Revision 1.1 2004/10/26 06:53:57 jgs
210     * Initial revision
211     *
212     * Revision 1.1.2.2 2004/10/26 06:36:39 jgs
213     * committing Lutz's changes to branch jgs
214     *
215     * Revision 1.2 2004/10/13 01:53:42 gross
216     * bug in CSC assembling fixed
217     *
218     * Revision 1.1 2004/07/02 04:21:13 gross
219     * Finley C code has been included
220     *
221     *
222     */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26