~vcs-imports/escript-finley/trunk

« back to all changes in this revision

Viewing changes to dudley/src/NodeFile_setTags.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: Mesh: NodeFile */
 
17
 
 
18
/*  set tags to newTag where mask>0 */
 
19
 
 
20
/**************************************************************/
 
21
 
 
22
#include "NodeFile.h"
 
23
#include "Util.h"
 
24
 
 
25
/**************************************************************/
 
26
 
 
27
void Dudley_NodeFile_setTags(Dudley_NodeFile * self, const int newTag, escriptDataC * mask)
 
28
{
 
29
    register dim_t n;
 
30
    dim_t numNodes;
 
31
    register __const double *mask_array;
 
32
    Dudley_resetError();
 
33
 
 
34
    if (self == NULL)
 
35
        return;
 
36
    numNodes = self->numNodes;
 
37
    if (1 != getDataPointSize(mask))
 
38
    {
 
39
        Dudley_setError(TYPE_ERROR, "Dudley_NodeFile_setTags: number of components of mask is 1.");
 
40
    }
 
41
    else if (!numSamplesEqual(mask, 1, numNodes))
 
42
    {
 
43
        Dudley_setError(TYPE_ERROR, "Dudley_NodeFile_setTags: illegal number of samples of mask Data object");
 
44
    }
 
45
 
 
46
    /* now we can start */
 
47
 
 
48
    if (Dudley_noError())
 
49
    {
 
50
#pragma omp parallel private(n,mask_array)
 
51
        {
 
52
#pragma omp for schedule(static)
 
53
            for (n = 0; n < numNodes; n++)
 
54
            {
 
55
                mask_array = getSampleDataRO(mask, n);
 
56
                if (mask_array[0] > 0)
 
57
                    self->Tag[n] = newTag;
 
58
            }
 
59
        }
 
60
        Dudley_NodeFile_setTagsInUse(self);
 
61
    }
 
62
}
 
63
 
 
64
/*
 
65
* $Log$
 
66
*
 
67
*/