/[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 82 by jgs, Tue Oct 26 06:53:54 2004 UTC trunk/finley/src/Assemble_CopyElementData.c revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
 /* $Id$ */  
1    
2  /**************************************************************/  /* $Id$ */
3    
4  /*    assemblage routines: copies data between elements       */  /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
18  /*   Copyrights by ACcESS Australia, 2003,2004 */  /*    assemblage routines: copies data between elements       */
 /*   author: gross@access.edu.au */  
 /*   Version: $Id$ */  
19    
20  /**************************************************************/  /**************************************************************/
21    
 #include "escript/Data/DataC.h"  
 #include "Util.h"  
 #include "Finley.h"  
22  #include "Assemble.h"  #include "Assemble.h"
23  #include "ElementFile.h"  #include "Util.h"
24  #ifdef _OPENMP  #ifdef _OPENMP
25  #include <omp.h>  #include <omp.h>
26  #endif  #endif
# Line 24  Line 28 
28    
29    
30  void Finley_Assemble_CopyElementData(Finley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {  void Finley_Assemble_CopyElementData(Finley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {
31      if (elements==NULL) return;      dim_t n,q, numElements, numQuad;
     maybelong n,q;  
     int numElements=elements->numElements;  
     int numQuad=elements->ReferenceElement->numQuadNodes;  
     int numComps=getDataPointSize(out);  
32      double *in_array,*out_array;      double *in_array,*out_array;
33        dim_t numComps=getDataPointSize(out);
34        size_t len_size;
35    
36        Finley_resetError();
37        if( elements == NULL )
38        {
39           return;
40        }
41    
42        numElements=elements->numElements;
43        if (Finley_Assemble_reducedIntegrationOrder(in)) {
44           numQuad=elements->ReferenceElementReducedOrder->numQuadNodes;
45        } else {
46           numQuad=elements->ReferenceElement->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;         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: number of components of input and output Data do not match.");
52         sprintf(Finley_ErrorMsg,"number of components of input and output Data do not match.");      } else if (!numSamplesEqual(in,numQuad,numElements)) {
53      } else if (numSamplesEqual(out,numQuad,numElements)) {         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: illegal number of samples of input Data object");
54         Finley_ErrorCode=TYPE_ERROR;      } else if (!numSamplesEqual(out,numQuad,numElements)) {
55         sprintf(Finley_ErrorMsg,"illegal number of samples of output Data object");         Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: illegal number of samples of output Data object");
     } else if (numSamplesEqual(in,numQuad,numElements)) {  
        Finley_ErrorCode=TYPE_ERROR;  
        sprintf(Finley_ErrorMsg,"illegal number of samples of input Data object");  
56      } else if (!isExpanded(out)) {      } else if (!isExpanded(out)) {
57         Finley_ErrorCode=TYPE_ERROR;         Finley_setError(TYPE_ERROR,"Finley_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 (Finley_noError()) {
63           if (isExpanded(in)) {           if (isExpanded(in)) {
64                 len_size=numComps*numQuad*sizeof(double);
65               # pragma omp parallel for private(n) schedule(static)               # pragma omp parallel for private(n) schedule(static)
66               for (n=0;n<numElements;n++)               for (n=0;n<numElements;n++)
67                   Finley_copyDouble(numComps*numQuad,getSampleData(in,n),getSampleData(out,n));                   memcpy(getSampleData(out,n),getSampleData(in,n), len_size);
68           } else {           } else {
69                 len_size=numComps*sizeof(double);
70               # pragma omp parallel for private(q,n,out_array,in_array) schedule(static)               # pragma omp parallel for private(q,n,out_array,in_array) schedule(static)
71               for (n=0;n<numElements;n++) {               for (n=0;n<numElements;n++) {
72                   in_array=getSampleData(in,n);                   in_array=getSampleData(in,n);
73                   out_array=getSampleData(out,n);                   out_array=getSampleData(out,n);
74                   for (q=0;q<numQuad;q++) Finley_copyDouble(numComps,in_array,out_array+q*numComps);                   for (q=0;q<numQuad;q++) memcpy(out_array+q*numComps,in_array,len_size);
75               }               }
76           }           }
77      }      }
78      return;      return;
79  }  }
 /*  
  * $Log$  
  * Revision 1.1  2004/10/26 06:53:56  jgs  
  * Initial revision  
  *  
  * 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.82  
changed lines
  Added in v.1312

  ViewVC Help
Powered by ViewVC 1.1.26