~vcs-imports/escript-finley/trunk

« back to all changes in this revision

Viewing changes to dudley/src/ElementFile_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: ElementFile */
 
17
 
 
18
/*      set tags to newTag where mask>0 */
 
19
 
 
20
/**************************************************************/
 
21
 
 
22
#include "ElementFile.h"
 
23
#include "Util.h"
 
24
#include "Assemble.h"
 
25
 
 
26
/**************************************************************/
 
27
 
 
28
void Dudley_ElementFile_setTags(Dudley_ElementFile * self, const int newTag, escriptDataC * mask)
 
29
{
 
30
    register dim_t n, q;
 
31
    dim_t numElements, numQuad;
 
32
    register __const double *mask_array;
 
33
    register bool_t check;
 
34
    Dudley_resetError();
 
35
    if (self == NULL)
 
36
        return;
 
37
    numElements = self->numElements;
 
38
 
 
39
    numQuad = Dudley_Assemble_reducedIntegrationOrder(mask) ? 1 : (self->numDim + 1);
 
40
    if (1 != getDataPointSize(mask))
 
41
    {
 
42
        Dudley_setError(TYPE_ERROR, "Dudley_ElementFile_setTags: number of components of mask is 1.");
 
43
    }
 
44
    else if (!numSamplesEqual(mask, numQuad, numElements))
 
45
    {
 
46
        Dudley_setError(TYPE_ERROR, "Dudley_ElementFile_setTags: illegal number of samples of mask Data object");
 
47
    }
 
48
 
 
49
    /* now we can start */
 
50
 
 
51
    if (Dudley_noError())
 
52
    {
 
53
        if (isExpanded(mask))
 
54
        {
 
55
#pragma omp parallel private(n,check,mask_array)
 
56
            {
 
57
#pragma omp for schedule(static)
 
58
                for (n = 0; n < numElements; n++)
 
59
                {
 
60
                    mask_array = getSampleDataRO(mask, n);
 
61
                    if (mask_array[0] > 0)
 
62
                        self->Tag[n] = newTag;
 
63
                }
 
64
            }
 
65
        }
 
66
        else
 
67
        {
 
68
#pragma omp parallel private(q,n,check,mask_array)
 
69
            {
 
70
#pragma omp for schedule(static)
 
71
                for (n = 0; n < numElements; n++)
 
72
                {
 
73
                    mask_array = getSampleDataRO(mask, n);
 
74
                    check = FALSE;
 
75
                    for (q = 0; q < numQuad; q++)
 
76
                        check = check || mask_array[q];
 
77
                    if (check)
 
78
                        self->Tag[n] = newTag;
 
79
                }
 
80
            }
 
81
        }
 
82
        Dudley_ElementFile_setTagsInUse(self);
 
83
    }
 
84
}