/[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

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

Legend:
Removed from v.2881  
changed lines
  Added in v.3224

  ViewVC Help
Powered by ViewVC 1.1.26