/[escript]/trunk/dudley/src/ElementFile_createColoring.c
ViewVC logotype

Annotation of /trunk/dudley/src/ElementFile_createColoring.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years, 4 months ago) by ksteube
Original Path: trunk/finley/src/ElementFile_createColoring.c
File MIME type: text/plain
File size: 3817 byte(s)
Copyright updated in all files

1 ksteube 1315
2     /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1315
14 ksteube 1811
15 ksteube 1315 /**************************************************************/
16     /* */
17     /* Finley: ElementFile */
18     /* */
19     /* This routine tries to reduce the number of colors used to color elements in the Finley_ElementFile in */
20     /* */
21     /**************************************************************/
22    
23     #include "ElementFile.h"
24     #include "Util.h"
25    
26     /**************************************************************/
27    
28     void Finley_ElementFile_createColoring(Finley_ElementFile* in,dim_t numNodes, index_t* degreeOfFreedom) {
29     dim_t e,i,numUncoloredElements,n,len,NN;
30 phornby 1628 index_t *maskDOF,min_id,max_id;
31 ksteube 1315 bool_t independent;
32    
33     if (in==NULL) return;
34     if (in->numElements<1) return;
35     NN=in->numNodes;
36    
37     min_id=Finley_Util_getMinInt(1,numNodes,degreeOfFreedom);
38     max_id=Finley_Util_getMaxInt(1,numNodes,degreeOfFreedom);
39     len=max_id-min_id+1;
40     maskDOF=TMPMEMALLOC(len,index_t);
41     if (! Finley_checkPtr(maskDOF) ) {
42     #pragma omp parallel for private(e) schedule(static)
43     for (e=0;e<in->numElements;e++) in->Color[e]=-1;
44     numUncoloredElements=in->numElements;
45 gross 1335 in->minColor=0;
46     in->maxColor=in->minColor-1;
47 ksteube 1315 while (numUncoloredElements>0) {
48     /* initialize the mask marking nodes used by a color */
49     #pragma omp parallel for private(n) schedule(static)
50     for (n=0;n<len;n++) maskDOF[n]=-1;
51     numUncoloredElements=0;
52     /* OMP ?*/
53     for (e=0;e<in->numElements;e++) {
54     if (in->Color[e]<0) {
55     /* find out if element e is independend from the elements already colored: */
56     independent=TRUE;
57 ksteube 1326 for (i=0;i<NN;i++) {
58     #ifdef BOUNDS_CHECK
59 ksteube 1340 if (in->Nodes[INDEX2(i,e,NN)] < 0 || in->Nodes[INDEX2(i,e,NN)] >= numNodes) { printf("BOUNDS_CHECK %s %d i=%d e=%d NN=%d min_id=%d in->Nodes[INDEX2...]=%d\n", __FILE__, __LINE__, i, e, NN, min_id, in->Nodes[INDEX2(i,e,NN)]); exit(1); }
60 ksteube 1326 if ((degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id) >= len || (degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id) < 0) { printf("BOUNDS_CHECK %s %d i=%d e=%d NN=%d min_id=%d dof=%d\n", __FILE__, __LINE__, i, e, NN, min_id, degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id); exit(1); }
61     #endif
62 gross 1335 if (maskDOF[degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id]>0) {
63     independent=FALSE;
64     break;
65     }
66 ksteube 1326 }
67 ksteube 1315 /* if e is independend a new color is assigned and the nodes are marked as being used */
68     if (independent) {
69 gross 1335 for (i=0;i<NN;i++) maskDOF[degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id]=1;
70     in->Color[e]=in->maxColor+1;
71     } else {
72     numUncoloredElements++;
73     }
74 ksteube 1315 }
75 gross 1358
76 ksteube 1315 }
77     in->maxColor++;
78     } /* end of while loop */
79     }
80     /* all done : */
81     TMPMEMFREE(maskDOF);
82     }

  ViewVC Help
Powered by ViewVC 1.1.26