~vcs-imports/escript-finley/trunk

« back to all changes in this revision

Viewing changes to dudley/src/ElementFile_gather.c

  • Committer: jfenwick
  • Date: 2010-10-11 01:48:14 UTC
  • Revision ID: svn-v4:77569008-7704-0410-b7a0-a92fef0b09fd:trunk:3259
Merging dudley and scons updates from branches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*******************************************************
 
3
*
 
4
* Copyright (c) 2003-2010 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
 
 
14
/**************************************************************/
 
15
 
 
16
/*   Dudley: ElementFile */
 
17
 
 
18
/*   gathers the ElementFile out from the  ElementFile in using index[0:out->numElements-1].  */
 
19
/*   index has to be between 0 and in->numElements-1. */
 
20
/*   a conservative assumtion on the coloring is made */
 
21
 
 
22
/**************************************************************/
 
23
 
 
24
#include "ElementFile.h"
 
25
 
 
26
/**************************************************************/
 
27
 
 
28
void Dudley_ElementFile_gather(index_t * index, Dudley_ElementFile * in, Dudley_ElementFile * out)
 
29
{
 
30
    index_t k;
 
31
    dim_t e, j;
 
32
    dim_t NN_in = in->numNodes;
 
33
    dim_t NN_out = out->numNodes;
 
34
    if (in != NULL)
 
35
    {
 
36
        /*OMP */
 
37
#pragma omp parallel for private(e,k,j) schedule(static)
 
38
        for (e = 0; e < out->numElements; e++)
 
39
        {
 
40
            k = index[e];
 
41
            out->Id[e] = in->Id[k];
 
42
            out->Tag[e] = in->Tag[k];
 
43
            out->Owner[e] = in->Owner[k];
 
44
            out->Color[e] = in->Color[k] + out->maxColor + 1;
 
45
            for (j = 0; j < MIN(NN_out, NN_in); j++)
 
46
                out->Nodes[INDEX2(j, e, NN_out)] = in->Nodes[INDEX2(j, k, NN_in)];
 
47
        }
 
48
        out->minColor = MIN(out->minColor, in->minColor + out->maxColor + 1);
 
49
        out->maxColor = MAX(out->maxColor, in->maxColor + out->maxColor + 1);
 
50
    }
 
51
}