/[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 3206 - (show annotations)
Fri Sep 24 03:20:22 2010 UTC (8 years, 9 months ago) by jfenwick
File MIME type: text/plain
File size: 6419 byte(s)
Remove references to reducedShapeFunction

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
17 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
18
19 /**************************************************************/
20
21 #include "Assemble.h"
22 #include "Util.h"
23 #ifdef _OPENMP
24 #include <omp.h>
25 #endif
26
27 #include "ShapeTable.h"
28
29 /**************************************************************/
30
31
32 void Dudley_Assemble_interpolate(Dudley_NodeFile *nodes, Dudley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
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 // Dudley_ReferenceElement* reference_element=NULL;
38 // Dudley_ShapeFunction *basis=NULL;
39 dim_t numComps=getDataPointSize(data);
40 index_t *map=NULL;
41 const double* shapeFns=0;
42 type_t data_type=getFunctionSpaceType(data);
43 type_t type;
44 size_t numComps_size;
45 Dudley_resetError();
46 #define NODES 0
47 #define REDUCED_NODES 3
48 #define DOF 1
49 #define REDUCED_DOF 2
50 if (nodes==NULL || elements==NULL) return;
51 reduced_integration = Dudley_Assemble_reducedIntegrationOrder(interpolated_data);
52 // reference_element= Dudley_ReferenceElementSet_borrowReferenceElement(elements->referenceElementSet, reduced_integration);
53 NN=elements->numNodes;
54
55 /* set some parameter */
56
57 if (data_type==DUDLEY_NODES) {
58 type=NODES;
59 // basis=reference_element->BasisFunctions;
60 numNodes=Dudley_NodeFile_getNumNodes(nodes);
61 map=Dudley_NodeFile_borrowTargetNodes(nodes);
62 } else if (data_type==DUDLEY_REDUCED_NODES) {
63 type=REDUCED_NODES;
64 // basis=reference_element->BasisFunctions;
65 numNodes=Dudley_NodeFile_getNumReducedNodes(nodes);
66 map=Dudley_NodeFile_borrowTargetReducedNodes(nodes);
67 } else if (data_type==DUDLEY_DEGREES_OF_FREEDOM) {
68 if (elements->MPIInfo->size>1) {
69 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
70 return;
71 }
72 type=DOF;
73 // basis=reference_element->BasisFunctions;
74 numNodes=Dudley_NodeFile_getNumDegreesOfFreedom(nodes);
75 map=Dudley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
76 } else if (data_type==DUDLEY_REDUCED_DEGREES_OF_FREEDOM) {
77 if (elements->MPIInfo->size>1) {
78 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
79 return;
80 }
81 type=REDUCED_DOF;
82 // basis=reference_element->BasisFunctions;
83 numNodes=Dudley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
84 map=Dudley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
85 } else {
86 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: Cannot interpolate data");
87 return;
88 }
89
90 // numQuad=basis->numQuadNodes;
91 numQuad=reduced_integration?1:(elements->numDim+1);
92 // numShapesTotal2=basis->Type->numShapes;
93 // NS_DOF=basis->Type->numShapes;
94 NS_DOF=elements->numDim+1;
95
96 //fprintf(stderr,"\nnumQuad=%d,%d DOF=%d %d RI=%d\n",numQuad, reduced_integration?1:(elements->numDim+1), NS_DOF,elements->numDim+1 , reduced_integration);
97
98 /* check the dimensions of interpolated_data and data */
99
100 if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
101 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: illegal number of samples of output Data object");
102 } else if (! numSamplesEqual(data,1,numNodes)) {
103 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: illegal number of samples of input Data object");
104 } else if (numComps!=getDataPointSize(interpolated_data)) {
105 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
106 } else if (!isExpanded(interpolated_data)) {
107 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: expanded Data object is expected for output data.");
108 }
109
110 if (Dudley_noError() && !getQuadShape(elements->numDim, reduced_integration, &shapeFns))
111 {
112 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: unable to locate shape function.");
113 }
114
115
116 /* now we can start */
117
118
119 //fprintf(stderr,"\nrange=%d elements->numDim=%d %d %d\n",INDEX2(NS_DOF,numQuad,NS_DOF), elements->numDim, NS_DOF, numQuad) ;
120
121 /*
122 fprintf(stderr,"\nQQ %d", elements->numDim);
123 for (int j=0;j<numQuad;++j)
124 {
125 for (int s=0;s<NS_DOF;++s)
126 {
127 dim_t ind=INDEX2(s,j,NS_DOF);
128 fprintf(stderr," [%d]%f", ind,basis->S[ind]);
129 }
130
131 }
132 fprintf(stderr,"\n");
133 */
134
135 /*
136 bool_t f=0;
137 for (int j=0;j<numQuad;++j)
138 {
139 for (int s=0;s<NS_DOF;++s)
140 {
141 dim_t ind=INDEX2(s,j,NS_DOF);
142 dim_t ind2=ind%(numQuad*numQuad);
143 if (fabs(basis->S[ind]-shapeFns[ind2])>0.0001)
144 {
145 f=1;
146 break;
147 }
148
149 }
150
151 }
152
153 if (f)
154 {
155
156 for (int j=0;j<numQuad;++j)
157 {
158 for (int s=0;s<NS_DOF;++s)
159 {
160 dim_t ind=INDEX2(s,j,NS_DOF);
161 fprintf(stderr, "\nZZ %d %d %f %f\n",elements->numDim, ind, basis->S[ind],shapeFns[ind%(numQuad*numQuad)]);
162 }
163
164 }
165
166
167 }
168 */
169
170 if (Dudley_noError())
171 {
172 requireWrite(interpolated_data);
173 #pragma omp parallel private(local_data, numComps_size)
174 {
175 local_data=NULL;
176 /* allocation of work arrays */
177 local_data=THREAD_MEMALLOC(NS_DOF*numComps,double);
178 if (! Dudley_checkPtr(local_data))
179 {
180 numComps_size=(size_t)numComps*sizeof(double);
181 /* open the element loop */
182 #pragma omp for private(e,q,i,data_array) schedule(static)
183 for(e=0;e<elements->numElements;e++)
184 {
185 for (q=0;q<NS_DOF;q++)
186 {
187 i=elements->Nodes[INDEX2(q,e,NN)];
188 data_array=getSampleDataRO(data,map[i]);
189 memcpy(&(local_data[INDEX3(0,q,0, numComps,NS_DOF)]), data_array, numComps_size);
190 }
191 /* calculate interpolated_data=local_data*S */
192 Dudley_Util_SmallMatSetMult1(1, numComps, numQuad, getSampleDataRW(interpolated_data,e),
193 NS_DOF,local_data, /*basis->S*/ shapeFns);
194 } /* end of element loop */
195 }
196 THREAD_MEMFREE(local_data);
197 } /* end of parallel region */
198 }
199 #undef NODES
200 #undef REDUCED_NODES
201 #undef DOF
202 #undef REDUCED_DOF
203 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26