/[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 2881 - (show annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 2 months ago) by jfenwick
Original Path: trunk/finley/src/Assemble_interpolate.c
File MIME type: text/plain
File size: 6732 byte(s)
Don't panic.
Updating copyright stamps

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26