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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1028 - (show annotations)
Wed Mar 14 00:15:24 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/plain
File size: 5143 byte(s)
modifications to be compliant with _WIN32. The substitutes for asinh, acosh, atanh are still missing (erf will through an exception)
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, *id=NULL;
35 dim_t e,kr,kc,NN_row,NN_col,i,icol,irow, NN, *row_node=NULL,*col_node=NULL;
36
37 if (elements!=NULL) {
38 NN=elements->ReferenceElement->Type->numNodes;
39 id=TMPMEMALLOC(NN, index_t);
40 if (! Finley_checkPtr(id) ) {
41 for (i=0;i<NN;i++) id[i]=i;
42 if (reduce_col_order) {
43 col_node=elements->ReferenceElement->Type->linearNodes;
44 NN_col=elements->LinearReferenceElement->Type->numNodes;
45 } else {
46 col_node=id;
47 NN_col=elements->ReferenceElement->Type->numNodes;
48 }
49 if (reduce_row_order) {
50 row_node=elements->ReferenceElement->Type->linearNodes;
51 NN_row=elements->LinearReferenceElement->Type->numNodes;
52 } else {
53 row_node=id;
54 NN_row=elements->ReferenceElement->Type->numNodes;
55 }
56 for (color=elements->minColor;color<=elements->maxColor;color++) {
57 #pragma omp for private(e,irow,kr,kc,icol) schedule(static)
58 for (e=0;e<elements->numElements;e++) {
59 if (elements->Color[e]==color) {
60 for (kr=0;kr<NN_row;kr++) {
61 irow=row_Label[elements->Nodes[INDEX2(row_node[kr],e,NN)]];
62 for (kc=0;kc<NN_col;kc++) {
63 icol=col_Label[elements->Nodes[INDEX2(col_node[kc],e,NN)]];
64 Finley_IndexList_insertIndex(&(index_list[irow]),icol);
65 }
66 }
67 }
68 }
69 }
70 TMPMEMFREE(id);
71 }
72 }
73 return;
74 }
75
76 /* inserts row index row into the Finley_IndexList in if it does not exist */
77
78 void Finley_IndexList_insertIndex(Finley_IndexList* in, index_t index) {
79 dim_t i;
80 /* is index in in? */
81 for (i=0;i<in->n;i++) {
82 if (in->index[i]==index) return;
83 }
84 /* index could not be found */
85 if (in->n==INDEXLIST_LENGTH) {
86 /* if in->index is full check the extension */
87 if (in->extension==NULL) {
88 in->extension=TMPMEMALLOC(1,Finley_IndexList);
89 if (Finley_checkPtr(in->extension)) return;
90 in->extension->n=0;
91 in->extension->extension=NULL;
92 }
93 Finley_IndexList_insertIndex(in->extension,index);
94 } else {
95 /* insert index into in->index*/
96 in->index[in->n]=index;
97 in->n++;
98 }
99 }
100
101 /* counts the number of row indices in the Finley_IndexList in */
102
103 dim_t Finley_IndexList_count(Finley_IndexList* in) {
104 if (in==NULL) {
105 return 0;
106 } else {
107 return (in->n)+Finley_IndexList_count(in->extension);
108 }
109 }
110
111 /* count the number of row indices in the Finley_IndexList in */
112
113 void Finley_IndexList_toArray(Finley_IndexList* in, index_t* array) {
114 dim_t i;
115 if (in!=NULL) {
116 for (i=0;i<in->n;i++) array[i]=in->index[i];
117 Finley_IndexList_toArray(in->extension,&(array[in->n]));
118 }
119 }
120
121 /* deallocates the Finley_IndexList in by recursive calls */
122
123 void Finley_IndexList_free(Finley_IndexList* in) {
124 if (in!=NULL) {
125 Finley_IndexList_free(in->extension);
126 TMPMEMFREE(in);
127 }
128 }
129
130 /*
131 * $Log$
132 * Revision 1.6 2005/09/15 03:44:22 jgs
133 * Merge of development branch dev-02 back to main trunk on 2005-09-15
134 *
135 * Revision 1.5.2.1 2005/09/07 06:26:18 gross
136 * the solver from finley are put into the standalone package paso now
137 *
138 * Revision 1.5 2005/07/08 04:07:51 jgs
139 * Merge of development branch back to main trunk on 2005-07-08
140 *
141 * Revision 1.4 2004/12/15 07:08:32 jgs
142 * *** empty log message ***
143 * Revision 1.1.1.1.2.3 2005/06/29 02:34:50 gross
144 * some changes towards 64 integers in finley
145 *
146 * Revision 1.1.1.1.2.2 2004/11/24 01:37:13 gross
147 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
148 *
149 *
150 *
151 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26