/[escript]/branches/domexper/dudley/src/IndexList.c
ViewVC logotype

Annotation of /branches/domexper/dudley/src/IndexList.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (hide annotations)
Fri Jul 8 04:08:13 2005 UTC (13 years, 11 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/IndexList.c
File MIME type: text/plain
File size: 4243 byte(s)
Merge of development branch back to main trunk on 2005-07-08

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 jgs 123 bool_t reduce_row_order, index_t* row_Label,
26     bool_t reduce_col_order, index_t* col_Label) {
27     index_t color;
28     dim_t e,kr,kc,NN_row,NN_col,i,icol,irow;
29 jgs 82
30     if (elements!=NULL) {
31 jgs 123 dim_t NN=elements->ReferenceElement->Type->numNodes;
32     index_t id[NN],*row_node,*col_node;
33 jgs 82 for (i=0;i<NN;i++) id[i]=i;
34     if (reduce_col_order) {
35     col_node=elements->ReferenceElement->Type->linearNodes;
36     NN_col=elements->LinearReferenceElement->Type->numNodes;
37     } else {
38     col_node=id;
39     NN_col=elements->ReferenceElement->Type->numNodes;
40     }
41     if (reduce_row_order) {
42     row_node=elements->ReferenceElement->Type->linearNodes;
43     NN_row=elements->LinearReferenceElement->Type->numNodes;
44     } else {
45     row_node=id;
46     NN_row=elements->ReferenceElement->Type->numNodes;
47     }
48 jgs 123 for (color=elements->minColor;color<=elements->maxColor;color++) {
49 jgs 102 #pragma omp for private(e,irow,kr,kc,icol) schedule(static)
50     for (e=0;e<elements->numElements;e++) {
51     if (elements->Color[e]==color) {
52     for (kr=0;kr<NN_row;kr++) {
53     irow=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
54     for (kc=0;kc<NN_col;kc++) {
55     icol=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
56     Finley_IndexList_insertIndex(&(index_list[irow]),icol);
57 jgs 82 }
58 jgs 102 }
59 jgs 82 }
60 jgs 102 }
61     }
62 jgs 82 }
63     return;
64     }
65    
66     /* inserts row index row into the Finley_IndexList in if it does not exist */
67    
68 jgs 123 void Finley_IndexList_insertIndex(Finley_IndexList* in, index_t index) {
69     dim_t i;
70 jgs 82 /* is index in in? */
71     for (i=0;i<in->n;i++) {
72 jgs 102 if (in->index[i]==index) return;
73 jgs 82 }
74     /* index could not be found */
75     if (in->n==INDEXLIST_LENGTH) {
76     /* if in->index is full check the extension */
77     if (in->extension==NULL) {
78 jgs 102 in->extension=TMPMEMALLOC(1,Finley_IndexList);
79 jgs 82 if (Finley_checkPtr(in->extension)) return;
80     in->extension->n=0;
81     in->extension->extension=NULL;
82     }
83     Finley_IndexList_insertIndex(in->extension,index);
84     } else {
85     /* insert index into in->index*/
86     in->index[in->n]=index;
87     in->n++;
88     }
89     }
90    
91     /* counts the number of row indices in the Finley_IndexList in */
92    
93 jgs 123 dim_t Finley_IndexList_count(Finley_IndexList* in) {
94 jgs 82 if (in==NULL) {
95     return 0;
96     } else {
97     return (in->n)+Finley_IndexList_count(in->extension);
98     }
99     }
100    
101     /* count the number of row indices in the Finley_IndexList in */
102    
103 jgs 123 void Finley_IndexList_toArray(Finley_IndexList* in, index_t* array) {
104     dim_t i;
105 jgs 82 if (in!=NULL) {
106     for (i=0;i<in->n;i++) array[i]=in->index[i]+INDEX_OFFSET;
107     Finley_IndexList_toArray(in->extension,&(array[in->n]));
108     }
109     }
110    
111     /* deallocates the Finley_IndexList in by recursive calls */
112    
113     void Finley_IndexList_free(Finley_IndexList* in) {
114     if (in!=NULL) {
115     Finley_IndexList_free(in->extension);
116     TMPMEMFREE(in);
117     }
118     }
119    
120     /*
121     * $Log$
122 jgs 123 * Revision 1.5 2005/07/08 04:07:51 jgs
123     * Merge of development branch back to main trunk on 2005-07-08
124     *
125 jgs 102 * Revision 1.4 2004/12/15 07:08:32 jgs
126 jgs 97 * *** empty log message ***
127 jgs 123 * Revision 1.1.1.1.2.3 2005/06/29 02:34:50 gross
128     * some changes towards 64 integers in finley
129 jgs 82 *
130 jgs 123 * Revision 1.1.1.1.2.2 2004/11/24 01:37:13 gross
131     * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
132 jgs 97 *
133 jgs 82 *
134 jgs 123 *
135 jgs 82 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26