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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1315 - (hide annotations)
Tue Sep 25 02:41:13 2007 UTC (11 years, 11 months ago) by ksteube
File MIME type: text/plain
File size: 3121 byte(s)
Copied more files from MPI branch to trunk

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

  ViewVC Help
Powered by ViewVC 1.1.26