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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3911 - (hide annotations)
Thu Jun 14 01:01:03 2012 UTC (7 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 2876 byte(s)
Copyright changes
1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 3911 * Copyright (c) 2003-2012 by University of Queensland
5 ksteube 1811 * 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 ksteube 1312
14 jgs 82 /**************************************************************/
15    
16 ksteube 1312 /* assemblage routines: copies data between elements */
17 jgs 82
18     /**************************************************************/
19    
20 jgs 150 #include "Assemble.h"
21 jgs 82 #include "Util.h"
22     #ifdef _OPENMP
23     #include <omp.h>
24     #endif
25     /******************************************************************************************************/
26 jfenwick 3199 #include "ShapeTable.h"
27 jgs 82
28 jfenwick 3224 void Dudley_Assemble_CopyElementData(Dudley_ElementFile * elements, escriptDataC * out, escriptDataC * in)
29     {
30     dim_t n, q, numElements, numQuad;
31 jfenwick 2271 __const double *in_array;
32     double *out_array;
33 jfenwick 3224 dim_t numComps = getDataPointSize(out);
34 ksteube 1312 size_t len_size;
35 phornby 1030
36 jfenwick 3086 Dudley_resetError();
37 jfenwick 3224 if (elements == NULL)
38 phornby 1030 {
39 jfenwick 3224 return;
40 phornby 1030 }
41    
42 jfenwick 3224 numElements = elements->numElements;
43     if (Dudley_Assemble_reducedIntegrationOrder(in))
44     {
45     numQuad = QuadNums[elements->numDim][0];
46     }
47     else
48     {
49     numQuad = QuadNums[elements->numDim][1];
50 jfenwick 3199
51 gross 1062 }
52 phornby 1030
53 jgs 82 /* check out and in */
54 jfenwick 3224 if (numComps != getDataPointSize(in))
55     {
56     Dudley_setError(TYPE_ERROR,
57     "Dudley_Assemble_CopyElementData: number of components of input and output Data do not match.");
58 jgs 82 }
59 jfenwick 3224 else if (!numSamplesEqual(in, numQuad, numElements))
60     {
61     Dudley_setError(TYPE_ERROR, "Dudley_Assemble_CopyElementData: illegal number of samples of input Data object");
62     }
63     else if (!numSamplesEqual(out, numQuad, numElements))
64     {
65     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 jgs 82
73     /* now we can start */
74    
75 jfenwick 3224 if (Dudley_noError())
76     {
77     if (isExpanded(in))
78     {
79     len_size = numComps * numQuad * sizeof(double);
80     requireWrite(out);
81     #pragma omp parallel private(n)
82     {
83     # pragma omp for schedule(static)
84     for (n = 0; n < numElements; n++)
85     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 jgs 82 }
105     return;
106     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26