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

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

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

branches/domexper/dudley/src/Assemble_CopyElementData.c revision 3086 by jfenwick, Thu Aug 5 05:07:58 2010 UTC trunk/dudley/src/Assemble_CopyElementData.cpp revision 4346 by jfenwick, Tue Apr 2 04:46:45 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  /*    assemblage routines: copies data between elements       */  /*    assemblage routines: copies data between elements       */
19    
20  /**************************************************************/  /************************************************************************************/
21    
22  #include "Assemble.h"  #include "Assemble.h"
23  #include "Util.h"  #include "Util.h"
24  #ifdef _OPENMP  #ifdef _OPENMP
25  #include <omp.h>  #include <omp.h>
26  #endif  #endif
27  /******************************************************************************************************/  /****************************************************************************************************************************/
28    #include "ShapeTable.h"
29    
30    void Dudley_Assemble_CopyElementData(Dudley_ElementFile * elements, escriptDataC * out, escriptDataC * in)
31  void Dudley_Assemble_CopyElementData(Dudley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {  {
32      dim_t n,q, numElements, numQuad;      dim_t n, q, numElements, numQuad;
33      __const double *in_array;      __const double *in_array;
34      double *out_array;      double *out_array;
35      dim_t numComps=getDataPointSize(out);      dim_t numComps = getDataPointSize(out);
36      size_t len_size;      size_t len_size;
37    
38      Dudley_resetError();      Dudley_resetError();
39      if( elements == NULL )      if (elements == NULL)
40        {
41        return;
42        }
43    
44        numElements = elements->numElements;
45        if (Dudley_Assemble_reducedIntegrationOrder(in))
46      {      {
47         return;      numQuad = QuadNums[elements->numDim][0];
48      }      }
49        else
50        {
51        numQuad = QuadNums[elements->numDim][1];
52    
     numElements=elements->numElements;  
     if (Dudley_Assemble_reducedIntegrationOrder(in)) {  
        numQuad=elements->referenceElementSet->referenceElementReducedQuadrature->Parametrization->numQuadNodes;  
     } else {  
        numQuad=elements->referenceElementSet->referenceElement->Parametrization->numQuadNodes;  
53      }      }
54    
55      /* check out and in */      /* check out and in */
56      if (numComps!=getDataPointSize(in)) {      if (numComps != getDataPointSize(in))
57         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: number of components of input and output Data do not match.");      {
58      } else if (!numSamplesEqual(in,numQuad,numElements)) {      Dudley_setError(TYPE_ERROR,
59         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: illegal number of samples of input Data object");              "Dudley_Assemble_CopyElementData: number of components of input and output Data do not match.");
60      } else if (!numSamplesEqual(out,numQuad,numElements)) {      }
61         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: illegal number of samples of output Data object");      else if (!numSamplesEqual(in, numQuad, numElements))
62      } else if (!isExpanded(out)) {      {
63         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: expanded Data object is expected for output data.");      Dudley_setError(TYPE_ERROR, "Dudley_Assemble_CopyElementData: illegal number of samples of input Data object");
64        }
65        else if (!numSamplesEqual(out, numQuad, numElements))
66        {
67        Dudley_setError(TYPE_ERROR, "Dudley_Assemble_CopyElementData: illegal number of samples of output Data object");
68        }
69        else if (!isExpanded(out))
70        {
71        Dudley_setError(TYPE_ERROR,
72                "Dudley_Assemble_CopyElementData: expanded Data object is expected for output data.");
73      }      }
74    
75      /* now we can start */      /* now we can start */
76    
77      if (Dudley_noError()) {      if (Dudley_noError())
78           if (isExpanded(in)) {      {
79               len_size=numComps*numQuad*sizeof(double);      if (isExpanded(in))
80           requireWrite(out);      {
81           #pragma omp parallel private(n)          len_size = numComps * numQuad * sizeof(double);
82           {          requireWrite(out);
83                 # pragma omp for schedule(static)  #pragma omp parallel private(n)
84                 for (n=0;n<numElements;n++)          {
85                   memcpy(getSampleDataRW(out,n),getSampleDataRO(in,n), len_size);  # pragma omp for schedule(static)
86           }          for (n = 0; n < numElements; n++)
87           } else {              memcpy(getSampleDataRW(out, n), getSampleDataRO(in, n), len_size);
88               len_size=numComps*sizeof(double);          }
89           requireWrite(out);      }
90           #pragma omp parallel private(q,n,out_array,in_array)      else
91           {      {
92                 # pragma omp for schedule(static)          len_size = numComps * sizeof(double);
93                 for (n=0;n<numElements;n++) {          requireWrite(out);
94                   in_array=getSampleDataRO(in,n);  #pragma omp parallel private(q,n,out_array,in_array)
95                   out_array=getSampleDataRW(out,n);          {
96                   for (q=0;q<numQuad;q++) memcpy(out_array+q*numComps,in_array,len_size);  # pragma omp for schedule(static)
97                 }          for (n = 0; n < numElements; n++)
98           }          {
99           }              in_array = getSampleDataRO(in, n);
100                out_array = getSampleDataRW(out, n);
101                for (q = 0; q < numQuad; q++)
102                memcpy(out_array + q * numComps, in_array, len_size);
103            }
104            }
105        }
106      }      }
107      return;      return;
108  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26