/[escript]/trunk/dudley/src/IndexList.cpp
ViewVC logotype

Contents of /trunk/dudley/src/IndexList.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 616 - (show annotations)
Wed Mar 22 02:46:56 2006 UTC (13 years, 5 months ago) by elspeth
Original Path: trunk/finley/src/IndexList.c
File MIME type: text/plain
File size: 4931 byte(s)
Copyright added to more source files.

1 /*
2 ************************************************************
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 */
12
13 /**************************************************************/
14
15 /* Finley: Converting an element list into a matrix shape */
16
17 /**************************************************************/
18
19 /* Author: gross@access.edu.au */
20 /* Version: $Id$ */
21
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 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
37 if (elements!=NULL) {
38 dim_t NN=elements->ReferenceElement->Type->numNodes;
39 index_t id[NN],*row_node,*col_node;
40 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 for (color=elements->minColor;color<=elements->maxColor;color++) {
56 #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 }
65 }
66 }
67 }
68 }
69 }
70 return;
71 }
72
73 /* inserts row index row into the Finley_IndexList in if it does not exist */
74
75 void Finley_IndexList_insertIndex(Finley_IndexList* in, index_t index) {
76 dim_t i;
77 /* is index in in? */
78 for (i=0;i<in->n;i++) {
79 if (in->index[i]==index) return;
80 }
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 in->extension=TMPMEMALLOC(1,Finley_IndexList);
86 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 dim_t Finley_IndexList_count(Finley_IndexList* in) {
101 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 void Finley_IndexList_toArray(Finley_IndexList* in, index_t* array) {
111 dim_t i;
112 if (in!=NULL) {
113 for (i=0;i<in->n;i++) array[i]=in->index[i];
114 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 * 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 * 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 * Revision 1.4 2004/12/15 07:08:32 jgs
139 * *** empty log message ***
140 * Revision 1.1.1.1.2.3 2005/06/29 02:34:50 gross
141 * some changes towards 64 integers in finley
142 *
143 * 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 *
146 *
147 *
148 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26