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

Contents of /trunk/dudley/src/Assemble_interpolate.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3490 - (show annotations)
Wed Mar 30 02:24:33 2011 UTC (8 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 4932 byte(s)
More gcc-4.6 fixes (mostly initialized-but-unused-var warnings)

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: interpolates nodal data in a data array onto elements (=integration points) */
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 /**************************************************************/
29
30 void Dudley_Assemble_interpolate(Dudley_NodeFile * nodes, Dudley_ElementFile * elements, escriptDataC * data,
31 escriptDataC * interpolated_data)
32 {
33 __const double *data_array;
34 double *local_data = NULL;
35 bool_t reduced_integration = FALSE;
36 dim_t q, i, NS_DOF, NN, numNodes = 0, e, numQuad = 0;
37 dim_t numComps = getDataPointSize(data);
38 index_t *map = NULL;
39 const double *shapeFns = 0;
40 type_t data_type = getFunctionSpaceType(data);
41 size_t numComps_size;
42 Dudley_resetError();
43 if (nodes == NULL || elements == NULL)
44 return;
45 reduced_integration = Dudley_Assemble_reducedIntegrationOrder(interpolated_data);
46 NN = elements->numNodes;
47
48 /* set some parameter */
49
50 if (data_type == DUDLEY_NODES)
51 {
52 numNodes = Dudley_NodeFile_getNumNodes(nodes);
53 map = Dudley_NodeFile_borrowTargetNodes(nodes);
54 }
55 else if (data_type == DUDLEY_REDUCED_NODES)
56 {
57 numNodes = Dudley_NodeFile_getNumReducedNodes(nodes);
58 map = Dudley_NodeFile_borrowTargetReducedNodes(nodes);
59 }
60 else if (data_type == DUDLEY_DEGREES_OF_FREEDOM)
61 {
62 if (elements->MPIInfo->size > 1)
63 {
64 Dudley_setError(TYPE_ERROR,
65 "Dudley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
66 return;
67 }
68 numNodes = Dudley_NodeFile_getNumDegreesOfFreedom(nodes);
69 map = Dudley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
70 }
71 else if (data_type == DUDLEY_REDUCED_DEGREES_OF_FREEDOM)
72 {
73 if (elements->MPIInfo->size > 1)
74 {
75 Dudley_setError(TYPE_ERROR,
76 "Dudley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
77 return;
78 }
79 numNodes = Dudley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
80 map = Dudley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
81 }
82 else
83 {
84 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: Cannot interpolate data");
85 return;
86 }
87
88 numQuad = reduced_integration ? 1 : (elements->numDim + 1);
89 NS_DOF = elements->numDim + 1;
90
91 /* check the dimensions of interpolated_data and data */
92
93 if (!numSamplesEqual(interpolated_data, numQuad, elements->numElements))
94 {
95 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: illegal number of samples of output Data object");
96 }
97 else if (!numSamplesEqual(data, 1, numNodes))
98 {
99 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: illegal number of samples of input Data object");
100 }
101 else if (numComps != getDataPointSize(interpolated_data))
102 {
103 Dudley_setError(TYPE_ERROR,
104 "Dudley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
105 }
106 else if (!isExpanded(interpolated_data))
107 {
108 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: expanded Data object is expected for output data.");
109 }
110
111 if (Dudley_noError() && !getQuadShape(elements->numDim, reduced_integration, &shapeFns))
112 {
113 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: unable to locate shape function.");
114 }
115
116 /* now we can start */
117
118 if (Dudley_noError())
119 {
120 requireWrite(interpolated_data);
121 #pragma omp parallel private(local_data, numComps_size)
122 {
123 local_data = NULL;
124 /* allocation of work arrays */
125 local_data = THREAD_MEMALLOC(NS_DOF * numComps, double);
126 if (!Dudley_checkPtr(local_data))
127 {
128 numComps_size = (size_t) numComps *sizeof(double);
129 /* open the element loop */
130 #pragma omp for private(e,q,i,data_array) schedule(static)
131 for (e = 0; e < elements->numElements; e++)
132 {
133 for (q = 0; q < NS_DOF; q++)
134 {
135 i = elements->Nodes[INDEX2(q, e, NN)];
136 data_array = getSampleDataRO(data, map[i]);
137 memcpy(&(local_data[INDEX3(0, q, 0, numComps, NS_DOF)]), data_array, numComps_size);
138 }
139 /* calculate interpolated_data=local_data*S */
140 Dudley_Util_SmallMatSetMult1(1, numComps, numQuad, getSampleDataRW(interpolated_data, e),
141 NS_DOF, local_data, /*basis->S */ shapeFns);
142 } /* end of element loop */
143 }
144 THREAD_MEMFREE(local_data);
145 } /* end of parallel region */
146 }
147 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26