/[escript]/branches/domexper/dudley/src/Assemble_CopyElementData.c
ViewVC logotype

Diff of /branches/domexper/dudley/src/Assemble_CopyElementData.c

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

trunk/finley/src/Assemble_CopyElementData.c revision 2748 by gross, Tue Nov 17 07:32:59 2009 UTC branches/domexper/dudley/src/Assemble_CopyElementData.c revision 3152 by jfenwick, Fri Sep 3 05:48:31 2010 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*******************************************************
3  *  *
4  * Copyright (c) 2003-2009 by University of Queensland  * Copyright (c) 2003-2010 by University of Queensland
5  * Earth Systems Science Computational Center (ESSCC)  * Earth Systems Science Computational Center (ESSCC)
6  * http://www.uq.edu.au/esscc  * http://www.uq.edu.au/esscc
7  *  *
# Line 26  Line 26 
26  /******************************************************************************************************/  /******************************************************************************************************/
27    
28    
29  void Finley_Assemble_CopyElementData(Finley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {  void Dudley_Assemble_CopyElementData(Dudley_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;         numQuad=elements->referenceElementSet->referenceElementReducedQuadrature->BasisFunctions->numQuadNodes;
45      } else {      } else {
46         numQuad=elements->referenceElementSet->referenceElement->Parametrization->numQuadNodes;         numQuad=elements->referenceElementSet->referenceElement->BasisFunctions->numQuadNodes;
47      }      }
48    
49      /* check out and in */      /* check out and in */
50      if (numComps!=getDataPointSize(in)) {      if (numComps!=getDataPointSize(in)) {
51         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: number of components of input and output Data do not match.");         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: number of components of input and output Data do not match.");
52      } else if (!numSamplesEqual(in,numQuad,numElements)) {      } else if (!numSamplesEqual(in,numQuad,numElements)) {
53         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: illegal number of samples of input Data object");         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: illegal number of samples of input Data object");
54      } else if (!numSamplesEqual(out,numQuad,numElements)) {      } else if (!numSamplesEqual(out,numQuad,numElements)) {
55         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: illegal number of samples of output Data object");         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: illegal number of samples of output Data object");
56      } else if (!isExpanded(out)) {      } else if (!isExpanded(out)) {
57         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: expanded Data object is expected for output data.");         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: expanded Data object is expected for output data.");
58      }      }
59    
60      /* now we can start */      /* now we can start */
61    
62      if (Finley_noError()) {      if (Dudley_noError()) {
63           if (isExpanded(in)) {           if (isExpanded(in)) {
          void* buffer=allocSampleBuffer(in);  
64               len_size=numComps*numQuad*sizeof(double);               len_size=numComps*numQuad*sizeof(double);
65           requireWrite(out);           requireWrite(out);
66           #pragma omp parallel private(n)           #pragma omp parallel private(n)
67           {           {
68                 # pragma omp for schedule(static)                 # pragma omp for schedule(static)
69                 for (n=0;n<numElements;n++)                 for (n=0;n<numElements;n++)
70                   memcpy(getSampleDataRW(out,n),getSampleDataRO(in,n,buffer), len_size);                   memcpy(getSampleDataRW(out,n),getSampleDataRO(in,n), len_size);
71           }           }
          freeSampleBuffer(buffer);  
72           } else {           } else {
          void* buffer=allocSampleBuffer(in);  
73               len_size=numComps*sizeof(double);               len_size=numComps*sizeof(double);
74           requireWrite(out);           requireWrite(out);
75           #pragma omp parallel private(q,n,out_array,in_array)           #pragma omp parallel private(q,n,out_array,in_array)
76           {           {
77                 # pragma omp for schedule(static)                 # pragma omp for schedule(static)
78                 for (n=0;n<numElements;n++) {                 for (n=0;n<numElements;n++) {
79                   in_array=getSampleDataRO(in,n,buffer);                   in_array=getSampleDataRO(in,n);
80                   out_array=getSampleDataRW(out,n);                   out_array=getSampleDataRW(out,n);
81                   for (q=0;q<numQuad;q++) memcpy(out_array+q*numComps,in_array,len_size);                   for (q=0;q<numQuad;q++) memcpy(out_array+q*numComps,in_array,len_size);
82                 }                 }
83           }           }
          freeSampleBuffer(buffer);  
84           }           }
85      }      }
86      return;      return;

Legend:
Removed from v.2748  
changed lines
  Added in v.3152

  ViewVC Help
Powered by ViewVC 1.1.26