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

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

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

trunk/esys2/finley/src/finleyC/Assemble_CopyElementData.c revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC branches/domexper/dudley/src/Assemble_CopyElementData.c revision 3224 by jfenwick, Wed Sep 29 05:19:37 2010 UTC
# Line 1  Line 1 
 /* $Id$ */  
1    
2  /**************************************************************/  /*******************************************************
3    *
4  /*    assemblage routines: copies data between elements       */  * 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    
14  /**************************************************************/  /**************************************************************/
15    
16  /*   Copyrights by ACcESS Australia, 2003,2004 */  /*    assemblage routines: copies data between elements       */
 /*   author: gross@access.edu.au */  
 /*   Version: $Id$ */  
17    
18  /**************************************************************/  /**************************************************************/
19    
 #include "escript/Data/DataC.h"  
 #include "Util.h"  
 #include "Finley.h"  
20  #include "Assemble.h"  #include "Assemble.h"
21  #include "ElementFile.h"  #include "Util.h"
22  #ifdef _OPENMP  #ifdef _OPENMP
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    {
30        dim_t n, q, numElements, numQuad;
31        __const double *in_array;
32        double *out_array;
33        dim_t numComps = getDataPointSize(out);
34        size_t len_size;
35    
36        Dudley_resetError();
37        if (elements == NULL)
38        {
39        return;
40        }
41    
42  void Finley_Assemble_CopyElementData(Finley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {      numElements = elements->numElements;
43      if (elements==NULL) return;      if (Dudley_Assemble_reducedIntegrationOrder(in))
44      dim_t n,q;      {
45      dim_t numElements=elements->numElements;      numQuad = QuadNums[elements->numDim][0];
46      dim_t numQuad=elements->ReferenceElement->numQuadNodes;      }
47      dim_t numComps=getDataPointSize(out);      else
48      double *in_array,*out_array;      {
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_ErrorCode=TYPE_ERROR;      {
56         sprintf(Finley_ErrorMsg,"number of components of input and output Data do not match.");      Dudley_setError(TYPE_ERROR,
57      } else if (numSamplesEqual(out,numQuad,numElements)) {              "Dudley_Assemble_CopyElementData: number of components of input and output Data do not match.");
58         Finley_ErrorCode=TYPE_ERROR;      }
59         sprintf(Finley_ErrorMsg,"illegal number of samples of output Data object");      else if (!numSamplesEqual(in, numQuad, numElements))
60      } else if (numSamplesEqual(in,numQuad,numElements)) {      {
61         Finley_ErrorCode=TYPE_ERROR;      Dudley_setError(TYPE_ERROR, "Dudley_Assemble_CopyElementData: illegal number of samples of input Data object");
62         sprintf(Finley_ErrorMsg,"illegal number of samples of input Data object");      }
63      } else if (!isExpanded(out)) {      else if (!numSamplesEqual(out, numQuad, numElements))
64         Finley_ErrorCode=TYPE_ERROR;      {
65         sprintf(Finley_ErrorMsg,"expanded Data object is expected for output data.");      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_ErrorCode==NO_ERROR) {      if (Dudley_noError())
76           if (isExpanded(in)) {      {
77               # pragma omp parallel for private(n) schedule(static)      if (isExpanded(in))
78               for (n=0;n<numElements;n++)      {
79                   Finley_copyDouble(numComps*numQuad,getSampleData(in,n),getSampleData(out,n));          len_size = numComps * numQuad * sizeof(double);
80           } else {          requireWrite(out);
81               # pragma omp parallel for private(q,n,out_array,in_array) schedule(static)  #pragma omp parallel private(n)
82               for (n=0;n<numElements;n++) {          {
83                   in_array=getSampleData(in,n);  # pragma omp for schedule(static)
84                   out_array=getSampleData(out,n);          for (n = 0; n < numElements; n++)
85                   for (q=0;q<numQuad;q++) Finley_copyDouble(numComps,in_array,out_array+q*numComps);              memcpy(getSampleDataRW(out, n), getSampleDataRO(in, n), len_size);
86               }          }
87           }      }
88        else
89        {
90            len_size = numComps * sizeof(double);
91            requireWrite(out);
92    #pragma omp parallel private(q,n,out_array,in_array)
93            {
94    # 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  }  }
 /*  
  * $Log$  
  * 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.123  
changed lines
  Added in v.3224

  ViewVC Help
Powered by ViewVC 1.1.26