/[escript]/trunk/dudley/src/ElementFile_setTags.cpp
ViewVC logotype

Diff of /trunk/dudley/src/ElementFile_setTags.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/domexper/dudley/src/ElementFile_setTags.c revision 3086 by jfenwick, Thu Aug 5 05:07:58 2010 UTC branches/doubleplusgood/dudley/src/ElementFile_setTags.c revision 4257 by jfenwick, Wed Feb 27 03:42:40 2013 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*****************************************************************************
3  *  *
4  * Copyright (c) 2003-2010 by University of Queensland  * Copyright (c) 2003-2013 by University of Queensland
5  * Earth Systems Science Computational Center (ESSCC)  * http://www.uq.edu.au
 * http://www.uq.edu.au/esscc  
6  *  *
7  * Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
8  * Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
9  * http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
10  *  *
11  *******************************************************/  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12    * Development since 2012 by School of Earth Sciences
13    *
14    *****************************************************************************/
15    
16  /**************************************************************/  /************************************************************************************/
17    
18  /*   Dudley: Mesh: ElementFile */  /*   Dudley: Mesh: ElementFile */
19    
20  /*  set tags to newTag where mask>0 */  /*  set tags to newTag where mask>0 */
21    
22  /**************************************************************/  /************************************************************************************/
23    
24  #include "ElementFile.h"  #include "ElementFile.h"
25  #include "Util.h"  #include "Util.h"
26  #include "Assemble.h"  #include "Assemble.h"
27    
28  /**************************************************************/  /************************************************************************************/
29    
30    void Dudley_ElementFile_setTags(Dudley_ElementFile * self, const int newTag, escriptDataC * mask)
31  void Dudley_ElementFile_setTags(Dudley_ElementFile* self,const int newTag, escriptDataC* mask) {  {
32      register dim_t n,q;      register dim_t n, q;
33      dim_t numElements, numQuad;      dim_t numElements, numQuad;
34      register __const double *mask_array;      register __const double *mask_array;
35      register bool_t check;      register bool_t check;
36      Dudley_resetError();      Dudley_resetError();
37      if (self==NULL) return;      if (self == NULL)
38      numElements=self->numElements;      return;
39        numElements = self->numElements;
40      numQuad= Dudley_ReferenceElementSet_borrowReferenceElement(self->referenceElementSet,Dudley_Assemble_reducedIntegrationOrder(mask))->Parametrization->numQuadNodes;  
41            numQuad = Dudley_Assemble_reducedIntegrationOrder(mask) ? 1 : (self->numDim + 1);
42      if (1!=getDataPointSize(mask)) {      if (1 != getDataPointSize(mask))
43         Dudley_setError(TYPE_ERROR,"Dudley_ElementFile_setTags: number of components of mask is 1.");      {
44      } else if (!numSamplesEqual(mask,numQuad,numElements)) {      Dudley_setError(TYPE_ERROR, "Dudley_ElementFile_setTags: number of components of mask is 1.");
45         Dudley_setError(TYPE_ERROR,"Dudley_ElementFile_setTags: illegal number of samples of mask Data object");      }
46        else if (!numSamplesEqual(mask, numQuad, numElements))
47        {
48        Dudley_setError(TYPE_ERROR, "Dudley_ElementFile_setTags: illegal number of samples of mask Data object");
49        }
50    
51        /* now we can start */
52    
53        if (Dudley_noError())
54        {
55        if (isExpanded(mask))
56        {
57    #pragma omp parallel private(n,check,mask_array)
58            {
59    #pragma omp for schedule(static)
60            for (n = 0; n < numElements; n++)
61            {
62                mask_array = getSampleDataRO(mask, n);
63                if (mask_array[0] > 0)
64                self->Tag[n] = newTag;
65            }
66            }
67      }      }
68        else
69      /* now we can start */      {
70    #pragma omp parallel private(q,n,check,mask_array)
71      if (Dudley_noError()) {          {
72          if (isExpanded(mask)) {  #pragma omp for schedule(static)
73              #pragma omp parallel private(n,check,mask_array)          for (n = 0; n < numElements; n++)
74              {          {
75                  #pragma omp for schedule(static)              mask_array = getSampleDataRO(mask, n);
76                  for (n=0;n<numElements;n++) {              check = FALSE;
77                      mask_array=getSampleDataRO(mask,n);              for (q = 0; q < numQuad; q++)
78                      if (mask_array[0]>0) self->Tag[n]=newTag;              check = check || mask_array[q];
79                  }              if (check)
80              }              self->Tag[n] = newTag;
         } else {  
             #pragma omp parallel private(q,n,check,mask_array)  
             {  
                 #pragma omp for schedule(static)  
                 for (n=0;n<numElements;n++) {  
                     mask_array=getSampleDataRO(mask,n);  
                     check=FALSE;  
                     for (q=0;q<numQuad;q++) check=check || mask_array[q];  
                     if (check) self->Tag[n]=newTag;  
                 }  
             }  
81          }          }
82          Dudley_ElementFile_setTagsInUse(self);          }
83      }      }
84        Dudley_ElementFile_setTagsInUse(self);
85        }
86  }  }
   

Legend:
Removed from v.3086  
changed lines
  Added in v.4257

  ViewVC Help
Powered by ViewVC 1.1.26