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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 102 - (show annotations)
Wed Dec 15 07:08:39 2004 UTC (15 years ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/IndexList.c
File MIME type: text/plain
File size: 3857 byte(s)
*** empty log message ***

1 /* $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, maybelong* row_Label,
26 int reduce_col_order, maybelong* col_Label) {
27 maybelong e,kr,kc,NN_row,NN_col,i,icol,irow,color;
28
29 if (elements!=NULL) {
30 maybelong NN=elements->ReferenceElement->Type->numNodes;
31 maybelong id[NN],*row_node,*col_node;
32 for (i=0;i<NN;i++) id[i]=i;
33 if (reduce_col_order) {
34 col_node=elements->ReferenceElement->Type->linearNodes;
35 NN_col=elements->LinearReferenceElement->Type->numNodes;
36 } else {
37 col_node=id;
38 NN_col=elements->ReferenceElement->Type->numNodes;
39 }
40 if (reduce_row_order) {
41 row_node=elements->ReferenceElement->Type->linearNodes;
42 NN_row=elements->LinearReferenceElement->Type->numNodes;
43 } else {
44 row_node=id;
45 NN_row=elements->ReferenceElement->Type->numNodes;
46 }
47 for (color=0;color<elements->numColors;color++) {
48 #pragma omp for private(e,irow,kr,kc,icol) schedule(static)
49 for (e=0;e<elements->numElements;e++) {
50 if (elements->Color[e]==color) {
51 for (kr=0;kr<NN_row;kr++) {
52 irow=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
53 for (kc=0;kc<NN_col;kc++) {
54 icol=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
55 Finley_IndexList_insertIndex(&(index_list[irow]),icol);
56 }
57 }
58 }
59 }
60 }
61 }
62 return;
63 }
64
65 /* inserts row index row into the Finley_IndexList in if it does not exist */
66
67 void Finley_IndexList_insertIndex(Finley_IndexList* in, maybelong index) {
68 int i;
69 /* is index in in? */
70 for (i=0;i<in->n;i++) {
71 if (in->index[i]==index) return;
72 }
73 /* index could not be found */
74 if (in->n==INDEXLIST_LENGTH) {
75 /* if in->index is full check the extension */
76 if (in->extension==NULL) {
77 in->extension=TMPMEMALLOC(1,Finley_IndexList);
78 if (Finley_checkPtr(in->extension)) return;
79 in->extension->n=0;
80 in->extension->extension=NULL;
81 }
82 Finley_IndexList_insertIndex(in->extension,index);
83 } else {
84 /* insert index into in->index*/
85 in->index[in->n]=index;
86 in->n++;
87 }
88 }
89
90 /* counts the number of row indices in the Finley_IndexList in */
91
92 int Finley_IndexList_count(Finley_IndexList* in) {
93 if (in==NULL) {
94 return 0;
95 } else {
96 return (in->n)+Finley_IndexList_count(in->extension);
97 }
98 }
99
100 /* count the number of row indices in the Finley_IndexList in */
101
102 void Finley_IndexList_toArray(Finley_IndexList* in, maybelong* array) {
103 int i;
104 if (in!=NULL) {
105 for (i=0;i<in->n;i++) array[i]=in->index[i]+INDEX_OFFSET;
106 Finley_IndexList_toArray(in->extension,&(array[in->n]));
107 }
108 }
109
110 /* deallocates the Finley_IndexList in by recursive calls */
111
112 void Finley_IndexList_free(Finley_IndexList* in) {
113 if (in!=NULL) {
114 Finley_IndexList_free(in->extension);
115 TMPMEMFREE(in);
116 }
117 }
118
119 /*
120 * $Log$
121 * Revision 1.4 2004/12/15 07:08:32 jgs
122 * *** empty log message ***
123 *
124 *
125 *
126 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26