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

Contents of /trunk/finley/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: 6481 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
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 /**************************************************************/
28
29
30 void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
31 __const double *data_array;
32 double* local_data=NULL;
33 index_t dof_offset;
34 bool_t reduced_integration=FALSE;
35 dim_t q, i, NS_DOF, NN, numNodes=0, e, numQuad=0, numSub=0, isub, numShapesTotal2;
36 Finley_ReferenceElement* reference_element=NULL;
37 Finley_ShapeFunction *basis=NULL;
38 dim_t numComps=getDataPointSize(data);
39 index_t *resort_nodes=NULL, *map=NULL;
40 type_t data_type=getFunctionSpaceType(data);
41 size_t numComps_size;
42 Finley_resetError();
43 if (nodes==NULL || elements==NULL) return;
44 reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
45 reference_element= Finley_ReferenceElementSet_borrowReferenceElement(elements->referenceElementSet, reduced_integration);
46 NN=elements->numNodes;
47
48 /* set some parameter */
49
50 if (data_type==FINLEY_NODES) {
51 resort_nodes=reference_element->Type->subElementNodes;
52 numSub=reference_element->Type->numSubElements;
53 basis=reference_element->BasisFunctions;
54 numNodes=Finley_NodeFile_getNumNodes(nodes);
55 map=Finley_NodeFile_borrowTargetNodes(nodes);
56 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
57 dof_offset=reference_element->Type->offsets[1];
58 } else {
59 dof_offset=reference_element->Type->offsets[0];
60 }
61 } else if (data_type==FINLEY_REDUCED_NODES) {
62 numSub=1;
63 resort_nodes=reference_element->Type->linearNodes;
64 basis=reference_element->LinearBasisFunctions;
65 numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
66 map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
67 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
68 dof_offset=reference_element->LinearType->offsets[1];
69 } else {
70 dof_offset=reference_element->LinearType->offsets[0];
71 }
72 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
73 if (elements->MPIInfo->size>1) {
74 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
75 return;
76 }
77 numSub=reference_element->Type->numSubElements;
78 resort_nodes=reference_element->Type->subElementNodes;
79 basis=reference_element->BasisFunctions;
80 numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
81 map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
82 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
83 dof_offset=reference_element->Type->offsets[1];
84 } else {
85 dof_offset=reference_element->Type->offsets[0];
86 }
87 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
88 if (elements->MPIInfo->size>1) {
89 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
90 return;
91 }
92 numSub=1;
93 resort_nodes=reference_element->Type->linearNodes;
94 basis=reference_element->LinearBasisFunctions;
95 numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
96 map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
97 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
98 dof_offset=reference_element->LinearType->offsets[1];
99 } else {
100 dof_offset=reference_element->LinearType->offsets[0];
101 }
102 } else {
103 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
104 return;
105 }
106
107 numQuad=basis->numQuadNodes;
108 numShapesTotal2=basis->Type->numShapes * reference_element->Type->numSides;
109 NS_DOF=basis->Type->numShapes;
110
111 /* check the dimensions of interpolated_data and data */
112
113 if (! numSamplesEqual(interpolated_data,numQuad*numSub,elements->numElements)) {
114 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
115 } else if (! numSamplesEqual(data,1,numNodes)) {
116 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
117 } else if (numComps!=getDataPointSize(interpolated_data)) {
118 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
119 } else if (!isExpanded(interpolated_data)) {
120 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
121 }
122
123 /* now we can start */
124
125 if (Finley_noError()) {
126 requireWrite(interpolated_data);
127 #pragma omp parallel private(local_data, numComps_size, isub)
128 {
129 local_data=NULL;
130 /* allocation of work arrays */
131 local_data=THREAD_MEMALLOC(NS_DOF*numComps*numSub,double);
132 if (! Finley_checkPtr(local_data)) {
133 numComps_size=(size_t)numComps*sizeof(double);
134 /* open the element loop */
135 #pragma omp for private(e,q,i,data_array,isub) schedule(static)
136 for(e=0;e<elements->numElements;e++) {
137 for (isub=0; isub<numSub; isub++) {
138 for (q=0;q<NS_DOF;q++) {
139 i=elements->Nodes[INDEX2(resort_nodes[INDEX2(dof_offset+q,isub,numShapesTotal2)],e,NN)];
140 data_array=getSampleDataRO(data,map[i]);
141 memcpy(&(local_data[INDEX3(0,q,isub, numComps,NS_DOF)]), data_array, numComps_size);
142 }
143 }
144 /* calculate interpolated_data=local_data*S */
145 Finley_Util_SmallMatSetMult1(numSub,numComps,numQuad,getSampleDataRW(interpolated_data,e),NS_DOF,local_data,basis->S);
146 } /* end of element loop */
147 }
148 THREAD_MEMFREE(local_data);
149 } /* end of parallel region */
150 }
151 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26