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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3080 - (hide annotations)
Tue Aug 3 04:28:03 2010 UTC (8 years, 8 months ago) by jfenwick
File MIME type: text/plain
File size: 6732 byte(s)
inital rename
1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 jgs 82
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 gross 2748 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
18 jgs 82
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 jfenwick 2271 __const double *data_array;
32 gross 2748 double* local_data=NULL;
33     index_t dof_offset;
34 gross 1062 bool_t reduced_integration=FALSE;
35 gross 2748 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 gross 1028 dim_t numComps=getDataPointSize(data);
39 gross 2748 index_t *resort_nodes=NULL, *map=NULL;
40 gross 1028 type_t data_type=getFunctionSpaceType(data);
41 jgs 123 type_t type;
42 ksteube 1312 size_t numComps_size;
43 gross 1028 Finley_resetError();
44 jgs 82 #define NODES 0
45 gross 1062 #define REDUCED_NODES 3
46 jgs 82 #define DOF 1
47     #define REDUCED_DOF 2
48     if (nodes==NULL || elements==NULL) return;
49 gross 2748 reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
50     reference_element= Finley_ReferenceElementSet_borrowReferenceElement(elements->referenceElementSet, reduced_integration);
51     NN=elements->numNodes;
52 ksteube 1312
53 jgs 82 /* set some parameter */
54    
55     if (data_type==FINLEY_NODES) {
56 gross 2748 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 gross 1062 } else if (data_type==FINLEY_REDUCED_NODES) {
68 gross 2748 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 jgs 82 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
80 gross 2748 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 jgs 82 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
96 gross 2748 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 jgs 82 } else {
112 gross 2748 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
113     return;
114 jgs 82 }
115    
116 gross 2748 numQuad=basis->numQuadNodes;
117     numShapesTotal2=basis->Type->numShapes * reference_element->Type->numSides;
118     NS_DOF=basis->Type->numShapes;
119    
120 jgs 82 /* check the dimensions of interpolated_data and data */
121    
122 gross 2748 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 jgs 82 } else if (! numSamplesEqual(data,1,numNodes)) {
125 gross 2748 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
126 jgs 82 } else if (numComps!=getDataPointSize(interpolated_data)) {
127 gross 2748 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 jgs 82 }
131    
132     /* now we can start */
133    
134 jgs 150 if (Finley_noError()) {
135 gross 2748 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 jfenwick 2770 data_array=getSampleDataRO(data,map[i]);
150 gross 2748 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 jgs 82 }
160     #undef NODES
161 gross 1062 #undef REDUCED_NODES
162 jgs 82 #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