/[escript]/branches/domexper/dudley/src/Assemble_interpolate.c
ViewVC logotype

Contents of /branches/domexper/dudley/src/Assemble_interpolate.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3224 - (show annotations)
Wed Sep 29 05:19:37 2010 UTC (8 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 5161 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: 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 type_t type;
42 size_t numComps_size;
43 Dudley_resetError();
44 #define NODES 0
45 #define REDUCED_NODES 3
46 #define DOF 1
47 #define REDUCED_DOF 2
48 if (nodes == NULL || elements == NULL)
49 return;
50 reduced_integration = Dudley_Assemble_reducedIntegrationOrder(interpolated_data);
51 NN = elements->numNodes;
52
53 /* set some parameter */
54
55 if (data_type == DUDLEY_NODES)
56 {
57 type = NODES;
58 numNodes = Dudley_NodeFile_getNumNodes(nodes);
59 map = Dudley_NodeFile_borrowTargetNodes(nodes);
60 }
61 else if (data_type == DUDLEY_REDUCED_NODES)
62 {
63 type = REDUCED_NODES;
64 numNodes = Dudley_NodeFile_getNumReducedNodes(nodes);
65 map = Dudley_NodeFile_borrowTargetReducedNodes(nodes);
66 }
67 else if (data_type == DUDLEY_DEGREES_OF_FREEDOM)
68 {
69 if (elements->MPIInfo->size > 1)
70 {
71 Dudley_setError(TYPE_ERROR,
72 "Dudley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
73 return;
74 }
75 type = DOF;
76 numNodes = Dudley_NodeFile_getNumDegreesOfFreedom(nodes);
77 map = Dudley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
78 }
79 else if (data_type == DUDLEY_REDUCED_DEGREES_OF_FREEDOM)
80 {
81 if (elements->MPIInfo->size > 1)
82 {
83 Dudley_setError(TYPE_ERROR,
84 "Dudley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
85 return;
86 }
87 type = REDUCED_DOF;
88 numNodes = Dudley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
89 map = Dudley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
90 }
91 else
92 {
93 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: Cannot interpolate data");
94 return;
95 }
96
97 numQuad = reduced_integration ? 1 : (elements->numDim + 1);
98 NS_DOF = elements->numDim + 1;
99
100 /* check the dimensions of interpolated_data and data */
101
102 if (!numSamplesEqual(interpolated_data, numQuad, elements->numElements))
103 {
104 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: illegal number of samples of output Data object");
105 }
106 else if (!numSamplesEqual(data, 1, numNodes))
107 {
108 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: illegal number of samples of input Data object");
109 }
110 else if (numComps != getDataPointSize(interpolated_data))
111 {
112 Dudley_setError(TYPE_ERROR,
113 "Dudley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
114 }
115 else if (!isExpanded(interpolated_data))
116 {
117 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: expanded Data object is expected for output data.");
118 }
119
120 if (Dudley_noError() && !getQuadShape(elements->numDim, reduced_integration, &shapeFns))
121 {
122 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: unable to locate shape function.");
123 }
124
125 /* now we can start */
126
127 if (Dudley_noError())
128 {
129 requireWrite(interpolated_data);
130 #pragma omp parallel private(local_data, numComps_size)
131 {
132 local_data = NULL;
133 /* allocation of work arrays */
134 local_data = THREAD_MEMALLOC(NS_DOF * numComps, double);
135 if (!Dudley_checkPtr(local_data))
136 {
137 numComps_size = (size_t) numComps *sizeof(double);
138 /* open the element loop */
139 #pragma omp for private(e,q,i,data_array) schedule(static)
140 for (e = 0; e < elements->numElements; e++)
141 {
142 for (q = 0; q < NS_DOF; q++)
143 {
144 i = elements->Nodes[INDEX2(q, e, NN)];
145 data_array = getSampleDataRO(data, map[i]);
146 memcpy(&(local_data[INDEX3(0, q, 0, numComps, NS_DOF)]), data_array, numComps_size);
147 }
148 /* calculate interpolated_data=local_data*S */
149 Dudley_Util_SmallMatSetMult1(1, numComps, numQuad, getSampleDataRW(interpolated_data, e),
150 NS_DOF, local_data, /*basis->S */ shapeFns);
151 } /* end of element loop */
152 }
153 THREAD_MEMFREE(local_data);
154 } /* end of parallel region */
155 }
156 #undef NODES
157 #undef REDUCED_NODES
158 #undef DOF
159 #undef REDUCED_DOF
160 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26