/[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 3224 - (show annotations)
Wed Sep 29 05:19:37 2010 UTC (8 years, 11 months ago) by jfenwick
Original Path: branches/domexper/dudley/src/Assemble_CopyElementData.c
File MIME type: text/plain
File size: 2876 byte(s)
indent -linux -nce -i4 -bl -bli0 -l120

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
14 /**************************************************************/
15
16 /* assemblage routines: copies data between elements */
17
18 /**************************************************************/
19
20 #include "Assemble.h"
21 #include "Util.h"
22 #ifdef _OPENMP
23 #include <omp.h>
24 #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 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
51 }
52
53 /* check out and in */
54 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 }
59 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
73 /* now we can start */
74
75 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 }
105 return;
106 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26