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

Annotation of /trunk-mpi-branch/finley/src/ElementFile_createColoring.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1226 - (hide annotations)
Fri Aug 3 08:00:07 2007 UTC (12 years, 11 months ago) by gross
File MIME type: text/plain
File size: 3434 byte(s)
hook for ParaMetis added. still needs some work
1 gross 1224 /*
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: ElementFile */
16     /* */
17     /* This routine tries to reduce the number of colors used to color elements in the Finley_ElementFile in */
18     /* */
19     /**************************************************************/
20    
21     /* Author: gross@access.edu.au */
22     /* Version: $Id: ElementFile_createColoring.c 1140 2007-05-15 03:23:17Z ksteube $ */
23    
24     /**************************************************************/
25    
26     #include "ElementFile.h"
27     #include "Util.h"
28    
29     /**************************************************************/
30    
31     void Finley_ElementFile_createColoring(Finley_ElementFile* in,dim_t numNodes, index_t* degreeOfFreedom) {
32     dim_t e,i,numUncoloredElements,n,len,NN;
33 gross 1226 index_t *maskDOF,color,min_id,max_id;
34 gross 1224 bool_t independent;
35    
36     if (in==NULL) return;
37     if (in->numElements<1) return;
38 gross 1226 NN=in->numNodes;
39 gross 1224
40     min_id=Finley_Util_getMinInt(1,numNodes,degreeOfFreedom);
41     max_id=Finley_Util_getMaxInt(1,numNodes,degreeOfFreedom);
42     len=max_id-min_id+1;
43     maskDOF=TMPMEMALLOC(len,index_t);
44 gross 1226 if (! Finley_checkPtr(maskDOF) ) {
45 gross 1224 #pragma omp parallel for private(e) schedule(static)
46 gross 1226 for (e=0;e<in->numElements;e++) in->Color[e]=-1;
47 gross 1224 numUncoloredElements=in->numElements;
48     while (numUncoloredElements>0) {
49     /* initialize the mask marking nodes used by a color */
50     #pragma omp parallel for private(n) schedule(static)
51     for (n=0;n<len;n++) maskDOF[n]=-1;
52     numUncoloredElements=0;
53 gross 1226 /* OMP ?*/
54     for (e=0;e<in->numElements;e++) {
55     if (in->Color[e]<0) {
56 gross 1224 /* find out if element e is independend from the elements already colored: */
57     independent=TRUE;
58     for (i=0;i<NN;i++) if (maskDOF[degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id]>0) independent=FALSE;
59     /* if e is independend a new color is assigned and the nodes are marked as being used */
60     if (independent) {
61     for (i=0;i<NN;i++) maskDOF[degreeOfFreedom[in->Nodes[INDEX2(i,e,NN)]]-min_id]=1;
62     in->Color[e]=in->maxColor+1;
63     } else {
64     numUncoloredElements++;
65     }
66     }
67     }
68     in->maxColor++;
69     } /* end of while loop */
70     }
71     /* all done : */
72     TMPMEMFREE(maskDOF);
73     }

  ViewVC Help
Powered by ViewVC 1.1.26