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

Annotation of /trunk/finley/src/Assemble_interpolate.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1981 - (hide annotations)
Thu Nov 6 05:27:33 2008 UTC (11 years ago) by jfenwick
File MIME type: text/plain
File size: 6190 byte(s)
More warning removal.

1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 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 jgs 82
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 ksteube 1312 /* 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     double* local_data=NULL,*S=NULL,*data_array;
32 phornby 1628 index_t dof_offset, NN, NS;
33 gross 1062 bool_t reduced_integration=FALSE;
34 jfenwick 1981 dim_t q,i,NS_DOF,NN_DOF,numNodes=0,e, numQuad;
35 gross 1062 Finley_RefElement* reference_element=NULL;
36 gross 1028 dim_t numComps=getDataPointSize(data);
37 jfenwick 1981 index_t id[MAX_numNodes], *resort_nodes=0, *map=0;
38 gross 1028 type_t data_type=getFunctionSpaceType(data);
39 jgs 123 type_t type;
40 ksteube 1312 size_t numComps_size;
41 gross 1028 Finley_resetError();
42 jgs 82 #define NODES 0
43 gross 1062 #define REDUCED_NODES 3
44 jgs 82 #define DOF 1
45     #define REDUCED_DOF 2
46     if (nodes==NULL || elements==NULL) return;
47 ksteube 1312
48     NN=elements->numNodes;
49 gross 1028 NS=elements->ReferenceElement->Type->numShapes;
50 gross 1062 reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
51 jgs 82 for (i=0;i<NN;i++) id[i]=i;
52    
53     /* set some parameter */
54    
55     if (data_type==FINLEY_NODES) {
56     type=NODES;
57     resort_nodes=id;
58 gross 1062 if (reduced_integration) {
59     reference_element=elements->ReferenceElementReducedOrder;
60     } else {
61     reference_element=elements->ReferenceElement;
62     }
63 ksteube 1312 numNodes=Finley_NodeFile_getNumNodes(nodes);
64     map=Finley_NodeFile_borrowTargetNodes(nodes);
65 gross 1062 } else if (data_type==FINLEY_REDUCED_NODES) {
66     type=REDUCED_NODES;
67 ksteube 1312 resort_nodes=elements->ReferenceElement->Type->linearNodes;
68 gross 1062 if (reduced_integration) {
69     reference_element=elements->LinearReferenceElementReducedOrder;
70     } else {
71     reference_element=elements->LinearReferenceElement;
72     }
73 ksteube 1312 numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
74     map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
75 jgs 82 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
76 ksteube 1312 if (elements->MPIInfo->size>1) {
77     Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
78     return;
79     }
80 jgs 82 type=DOF;
81     resort_nodes=id;
82 gross 1062 if (reduced_integration) {
83     reference_element=elements->ReferenceElementReducedOrder;
84     } else {
85     reference_element=elements->ReferenceElement;
86     }
87 ksteube 1312 numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
88     map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
89 jgs 82 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
90 ksteube 1312 if (elements->MPIInfo->size>1) {
91     Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
92     return;
93     }
94 jgs 82 type=REDUCED_DOF;
95     resort_nodes=elements->ReferenceElement->Type->linearNodes;
96 gross 1062 if (reduced_integration) {
97     reference_element=elements->LinearReferenceElementReducedOrder;
98     } else {
99     reference_element=elements->LinearReferenceElement;
100     }
101 ksteube 1312 numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
102     map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
103 jgs 82 } else {
104 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
105 jgs 82 }
106 gross 1062 NN_DOF=reference_element->Type->numNodes;
107     NS_DOF=reference_element->Type->numShapes;
108     S=reference_element->S;
109     numQuad=reference_element->numQuadNodes;
110 jgs 82 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
111     dof_offset=NN_DOF-NS_DOF;
112     } else {
113     dof_offset=0;
114     }
115    
116     /* check the dimensions of interpolated_data and data */
117    
118     if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
119 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
120 jgs 82 } else if (! numSamplesEqual(data,1,numNodes)) {
121 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
122 jgs 82 } else if (numComps!=getDataPointSize(interpolated_data)) {
123 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
124 jgs 82 } else if (!isExpanded(interpolated_data)) {
125 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
126 jgs 82 }
127    
128     /* now we can start */
129    
130 jgs 150 if (Finley_noError()) {
131 ksteube 1312 #pragma omp parallel private(local_data, numComps_size)
132 jgs 82 {
133     local_data=NULL;
134     /* allocation of work arrays */
135 jgs 102 local_data=THREAD_MEMALLOC(NS*numComps,double);
136 jgs 82 if (! Finley_checkPtr(local_data)) {
137    
138 ksteube 1312 numComps_size=(size_t)numComps*sizeof(double);
139 jgs 82 /* open the element loop */
140    
141     #pragma omp for private(e,q,i,data_array) schedule(static)
142     for(e=0;e<elements->numElements;e++) {
143 ksteube 1312 for (q=0;q<NS_DOF;q++) {
144     i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
145     data_array=getSampleData(data,map[i]);
146     memcpy(local_data+q*numComps, data_array, numComps_size);
147 jgs 82 }
148     /* calculate interpolated_data=local_data*S */
149    
150     Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
151    
152     } /* end of element loop */
153    
154     }
155     THREAD_MEMFREE(local_data);
156 jgs 102 } /* end of parallel region */
157 jgs 82 }
158     #undef NODES
159 gross 1062 #undef REDUCED_NODES
160 jgs 82 #undef DOF
161     #undef REDUCED_DOF
162     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26