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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 616 - (hide annotations)
Wed Mar 22 02:46:56 2006 UTC (13 years, 8 months ago) by elspeth
File MIME type: text/plain
File size: 4931 byte(s)
Copyright added to more source files.

1 jgs 150 /*
2 elspeth 616 ************************************************************
3     * Copyright 2006 by ACcESS MNRF *
4     * *
5     * http://www.access.edu.au *
6     * Primary Business: Queensland, Australia *
7     * Licensed under the Open Software License version 3.0 *
8     * http://www.opensource.org/licenses/osl-3.0.php *
9     * *
10     ************************************************************
11 jgs 150 */
12 jgs 82
13     /**************************************************************/
14    
15     /* Finley: Converting an element list into a matrix shape */
16    
17     /**************************************************************/
18    
19 jgs 150 /* Author: gross@access.edu.au */
20     /* Version: $Id$ */
21 jgs 82
22     /**************************************************************/
23    
24     #include "IndexList.h"
25    
26     /**************************************************************/
27     /* inserts the contributions from the element matrices of elements
28     into the row index col. If symmetric is set, only the upper
29     triangle of the matrix is stored. */
30    
31     void Finley_IndexList_insertElements(Finley_IndexList* index_list, Finley_ElementFile* elements,
32 jgs 123 bool_t reduce_row_order, index_t* row_Label,
33     bool_t reduce_col_order, index_t* col_Label) {
34     index_t color;
35     dim_t e,kr,kc,NN_row,NN_col,i,icol,irow;
36 jgs 82
37     if (elements!=NULL) {
38 jgs 123 dim_t NN=elements->ReferenceElement->Type->numNodes;
39     index_t id[NN],*row_node,*col_node;
40 jgs 82 for (i=0;i<NN;i++) id[i]=i;
41     if (reduce_col_order) {
42     col_node=elements->ReferenceElement->Type->linearNodes;
43     NN_col=elements->LinearReferenceElement->Type->numNodes;
44     } else {
45     col_node=id;
46     NN_col=elements->ReferenceElement->Type->numNodes;
47     }
48     if (reduce_row_order) {
49     row_node=elements->ReferenceElement->Type->linearNodes;
50     NN_row=elements->LinearReferenceElement->Type->numNodes;
51     } else {
52     row_node=id;
53     NN_row=elements->ReferenceElement->Type->numNodes;
54     }
55 jgs 123 for (color=elements->minColor;color<=elements->maxColor;color++) {
56 jgs 102 #pragma omp for private(e,irow,kr,kc,icol) schedule(static)
57     for (e=0;e<elements->numElements;e++) {
58     if (elements->Color[e]==color) {
59     for (kr=0;kr<NN_row;kr++) {
60     irow=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
61     for (kc=0;kc<NN_col;kc++) {
62     icol=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
63     Finley_IndexList_insertIndex(&(index_list[irow]),icol);
64 jgs 82 }
65 jgs 102 }
66 jgs 82 }
67 jgs 102 }
68     }
69 jgs 82 }
70     return;
71     }
72    
73     /* inserts row index row into the Finley_IndexList in if it does not exist */
74    
75 jgs 123 void Finley_IndexList_insertIndex(Finley_IndexList* in, index_t index) {
76     dim_t i;
77 jgs 82 /* is index in in? */
78     for (i=0;i<in->n;i++) {
79 jgs 102 if (in->index[i]==index) return;
80 jgs 82 }
81     /* index could not be found */
82     if (in->n==INDEXLIST_LENGTH) {
83     /* if in->index is full check the extension */
84     if (in->extension==NULL) {
85 jgs 102 in->extension=TMPMEMALLOC(1,Finley_IndexList);
86 jgs 82 if (Finley_checkPtr(in->extension)) return;
87     in->extension->n=0;
88     in->extension->extension=NULL;
89     }
90     Finley_IndexList_insertIndex(in->extension,index);
91     } else {
92     /* insert index into in->index*/
93     in->index[in->n]=index;
94     in->n++;
95     }
96     }
97    
98     /* counts the number of row indices in the Finley_IndexList in */
99    
100 jgs 123 dim_t Finley_IndexList_count(Finley_IndexList* in) {
101 jgs 82 if (in==NULL) {
102     return 0;
103     } else {
104     return (in->n)+Finley_IndexList_count(in->extension);
105     }
106     }
107    
108     /* count the number of row indices in the Finley_IndexList in */
109    
110 jgs 123 void Finley_IndexList_toArray(Finley_IndexList* in, index_t* array) {
111     dim_t i;
112 jgs 82 if (in!=NULL) {
113 gross 416 for (i=0;i<in->n;i++) array[i]=in->index[i];
114 jgs 82 Finley_IndexList_toArray(in->extension,&(array[in->n]));
115     }
116     }
117    
118     /* deallocates the Finley_IndexList in by recursive calls */
119    
120     void Finley_IndexList_free(Finley_IndexList* in) {
121     if (in!=NULL) {
122     Finley_IndexList_free(in->extension);
123     TMPMEMFREE(in);
124     }
125     }
126    
127     /*
128     * $Log$
129 jgs 150 * Revision 1.6 2005/09/15 03:44:22 jgs
130     * Merge of development branch dev-02 back to main trunk on 2005-09-15
131     *
132     * Revision 1.5.2.1 2005/09/07 06:26:18 gross
133     * the solver from finley are put into the standalone package paso now
134     *
135 jgs 123 * Revision 1.5 2005/07/08 04:07:51 jgs
136     * Merge of development branch back to main trunk on 2005-07-08
137     *
138 jgs 102 * Revision 1.4 2004/12/15 07:08:32 jgs
139 jgs 97 * *** empty log message ***
140 jgs 123 * Revision 1.1.1.1.2.3 2005/06/29 02:34:50 gross
141     * some changes towards 64 integers in finley
142 jgs 82 *
143 jgs 123 * Revision 1.1.1.1.2.2 2004/11/24 01:37:13 gross
144     * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
145 jgs 97 *
146 jgs 82 *
147 jgs 123 *
148 jgs 82 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26