/[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/esys2/finley/src/finleyC/Assemble_CopyElementData.c revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC branches/domexper/dudley/src/Assemble_CopyElementData.c revision 3086 by jfenwick, Thu Aug 5 05:07:58 2010 UTC
# Line 1  Line 1 
 /* $Id$ */  
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    
 /*    assemblage routines: copies data between elements       */  
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /*   Copyrights by ACcESS Australia, 2003,2004 */  /*    assemblage routines: copies data between elements       */
 /*   author: gross@access.edu.au */  
 /*   Version: $Id$ */  
18    
19  /**************************************************************/  /**************************************************************/
20    
 #include "escript/Data/DataC.h"  
 #include "Util.h"  
 #include "Finley.h"  
21  #include "Assemble.h"  #include "Assemble.h"
22  #include "ElementFile.h"  #include "Util.h"
23  #ifdef _OPENMP  #ifdef _OPENMP
24  #include <omp.h>  #include <omp.h>
25  #endif  #endif
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      if (elements==NULL) return;      dim_t n,q, numElements, numQuad;
31      dim_t n,q;      __const double *in_array;
32      dim_t numElements=elements->numElements;      double *out_array;
     dim_t numQuad=elements->ReferenceElement->numQuadNodes;  
33      dim_t numComps=getDataPointSize(out);      dim_t numComps=getDataPointSize(out);
34      double *in_array,*out_array;      size_t len_size;
35    
36        Dudley_resetError();
37        if( elements == NULL )
38        {
39           return;
40        }
41    
42        numElements=elements->numElements;
43        if (Dudley_Assemble_reducedIntegrationOrder(in)) {
44           numQuad=elements->referenceElementSet->referenceElementReducedQuadrature->Parametrization->numQuadNodes;
45        } else {
46           numQuad=elements->referenceElementSet->referenceElement->Parametrization->numQuadNodes;
47        }
48    
49      /* check out and in */      /* check out and in */
50      if (numComps!=getDataPointSize(in)) {      if (numComps!=getDataPointSize(in)) {
51         Finley_ErrorCode=TYPE_ERROR;         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: number of components of input and output Data do not match.");
        sprintf(Finley_ErrorMsg,"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_ErrorCode=TYPE_ERROR;         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: illegal number of samples of input Data object");
        sprintf(Finley_ErrorMsg,"illegal number of samples of input Data object");  
54      } else if (!numSamplesEqual(out,numQuad,numElements)) {      } else if (!numSamplesEqual(out,numQuad,numElements)) {
55         Finley_ErrorCode=TYPE_ERROR;         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: illegal number of samples of output Data object");
        sprintf(Finley_ErrorMsg,"illegal number of samples of output Data object");  
56      } else if (!isExpanded(out)) {      } else if (!isExpanded(out)) {
57         Finley_ErrorCode=TYPE_ERROR;         Dudley_setError(TYPE_ERROR,"Dudley_Assemble_CopyElementData: expanded Data object is expected for output data.");
        sprintf(Finley_ErrorMsg,"expanded Data object is expected for output data.");  
58      }      }
59    
60      /* now we can start */      /* now we can start */
61    
62      if (Finley_ErrorCode==NO_ERROR) {      if (Dudley_noError()) {
63           if (isExpanded(in)) {           if (isExpanded(in)) {
64               # pragma omp parallel for private(n) schedule(static)               len_size=numComps*numQuad*sizeof(double);
65               for (n=0;n<numElements;n++)           requireWrite(out);
66                   Finley_copyDouble(numComps*numQuad,getSampleData(in,n),getSampleData(out,n));           #pragma omp parallel private(n)
67             {
68                   # pragma omp for schedule(static)
69                   for (n=0;n<numElements;n++)
70                     memcpy(getSampleDataRW(out,n),getSampleDataRO(in,n), len_size);
71             }
72           } else {           } else {
73               # pragma omp parallel for private(q,n,out_array,in_array) schedule(static)               len_size=numComps*sizeof(double);
74               for (n=0;n<numElements;n++) {           requireWrite(out);
75                   in_array=getSampleData(in,n);           #pragma omp parallel private(q,n,out_array,in_array)
76                   out_array=getSampleData(out,n);           {
77                   for (q=0;q<numQuad;q++) Finley_copyDouble(numComps,in_array,out_array+q*numComps);                 # pragma omp for schedule(static)
78               }                 for (n=0;n<numElements;n++) {
79                     in_array=getSampleDataRO(in,n);
80                     out_array=getSampleDataRW(out,n);
81                     for (q=0;q<numQuad;q++) memcpy(out_array+q*numComps,in_array,len_size);
82                   }
83             }
84           }           }
85      }      }
86      return;      return;
87  }  }
 /*  
  * $Log$  
  * Revision 1.3  2005/08/12 01:45:42  jgs  
  * erge of development branch dev-02 back to main trunk on 2005-08-12  
  *  
  * Revision 1.2.2.1  2005/08/02 05:29:11  gross  
  * bug in finley/src/Assemble_CopyElementData fixed  
  *  
  * Revision 1.2  2005/07/08 04:07:45  jgs  
  * Merge of development branch back to main trunk on 2005-07-08  
  *  
  * Revision 1.1.1.1.2.1  2005/06/29 02:34:46  gross  
  * some changes towards 64 integers in finley  
  *  
  * Revision 1.1.1.1  2004/10/26 06:53:56  jgs  
  * initial import of project esys2  
  *  
  * Revision 1.2  2004/07/21 05:00:54  gross  
  * name changes in DataC  
  *  
  * Revision 1.1  2004/07/02 04:21:13  gross  
  * Finley C code has been included  
  *  
  *  
  */  

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

  ViewVC Help
Powered by ViewVC 1.1.26