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

Contents of /trunk/dudley/src/Assemble_CopyElementData.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2271 - (show annotations)
Mon Feb 16 05:08:29 2009 UTC (10 years, 7 months ago) by jfenwick
Original Path: trunk/finley/src/Assemble_CopyElementData.c
File MIME type: text/plain
File size: 3139 byte(s)
Merging version 2269 to trunk

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 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
17 /* assemblage routines: copies data between elements */
18
19 /**************************************************************/
20
21 #include "Assemble.h"
22 #include "Util.h"
23 #ifdef _OPENMP
24 #include <omp.h>
25 #endif
26 /******************************************************************************************************/
27
28
29 void Finley_Assemble_CopyElementData(Finley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {
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 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 */
50 if (numComps!=getDataPointSize(in)) {
51 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: number of components of input and output Data do not match.");
52 } else if (!numSamplesEqual(in,numQuad,numElements)) {
53 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: illegal number of samples of input Data object");
54 } else if (!numSamplesEqual(out,numQuad,numElements)) {
55 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: illegal number of samples of output Data object");
56 } else if (!isExpanded(out)) {
57 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyElementData: expanded Data object is expected for output data.");
58 }
59
60 /* now we can start */
61
62 if (Finley_noError()) {
63 if (isExpanded(in)) {
64 void* buffer=allocSampleBuffer(in);
65 len_size=numComps*numQuad*sizeof(double);
66 requireWrite(out);
67 #pragma omp parallel private(n)
68 {
69 # pragma omp for schedule(static)
70 for (n=0;n<numElements;n++)
71 memcpy(getSampleDataRW(out,n),getSampleDataRO(in,n,buffer), len_size);
72 }
73 freeSampleBuffer(buffer);
74 } else {
75 void* buffer=allocSampleBuffer(in);
76 len_size=numComps*sizeof(double);
77 requireWrite(out);
78 #pragma omp parallel private(q,n,out_array,in_array)
79 {
80 # pragma omp for schedule(static)
81 for (n=0;n<numElements;n++) {
82 in_array=getSampleDataRO(in,n,buffer);
83 out_array=getSampleDataRW(out,n);
84 for (q=0;q<numQuad;q++) memcpy(out_array+q*numComps,in_array,len_size);
85 }
86 }
87 freeSampleBuffer(buffer);
88 }
89 }
90 return;
91 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26