/[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 1981 - (show annotations)
Thu Nov 6 05:27:33 2008 UTC (10 years, 7 months ago) by jfenwick
File MIME type: text/plain
File size: 6190 byte(s)
More warning removal.

1
2 /*******************************************************
3 *
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
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 double* local_data=NULL,*S=NULL,*data_array;
32 index_t dof_offset, NN, NS;
33 bool_t reduced_integration=FALSE;
34 dim_t q,i,NS_DOF,NN_DOF,numNodes=0,e, numQuad;
35 Finley_RefElement* reference_element=NULL;
36 dim_t numComps=getDataPointSize(data);
37 index_t id[MAX_numNodes], *resort_nodes=0, *map=0;
38 type_t data_type=getFunctionSpaceType(data);
39 type_t type;
40 size_t numComps_size;
41 Finley_resetError();
42 #define NODES 0
43 #define REDUCED_NODES 3
44 #define DOF 1
45 #define REDUCED_DOF 2
46 if (nodes==NULL || elements==NULL) return;
47
48 NN=elements->numNodes;
49 NS=elements->ReferenceElement->Type->numShapes;
50 reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
51 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 if (reduced_integration) {
59 reference_element=elements->ReferenceElementReducedOrder;
60 } else {
61 reference_element=elements->ReferenceElement;
62 }
63 numNodes=Finley_NodeFile_getNumNodes(nodes);
64 map=Finley_NodeFile_borrowTargetNodes(nodes);
65 } else if (data_type==FINLEY_REDUCED_NODES) {
66 type=REDUCED_NODES;
67 resort_nodes=elements->ReferenceElement->Type->linearNodes;
68 if (reduced_integration) {
69 reference_element=elements->LinearReferenceElementReducedOrder;
70 } else {
71 reference_element=elements->LinearReferenceElement;
72 }
73 numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
74 map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
75 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
76 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 type=DOF;
81 resort_nodes=id;
82 if (reduced_integration) {
83 reference_element=elements->ReferenceElementReducedOrder;
84 } else {
85 reference_element=elements->ReferenceElement;
86 }
87 numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
88 map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
89 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
90 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 type=REDUCED_DOF;
95 resort_nodes=elements->ReferenceElement->Type->linearNodes;
96 if (reduced_integration) {
97 reference_element=elements->LinearReferenceElementReducedOrder;
98 } else {
99 reference_element=elements->LinearReferenceElement;
100 }
101 numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
102 map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
103 } else {
104 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
105 }
106 NN_DOF=reference_element->Type->numNodes;
107 NS_DOF=reference_element->Type->numShapes;
108 S=reference_element->S;
109 numQuad=reference_element->numQuadNodes;
110 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 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
120 } else if (! numSamplesEqual(data,1,numNodes)) {
121 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
122 } else if (numComps!=getDataPointSize(interpolated_data)) {
123 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
124 } else if (!isExpanded(interpolated_data)) {
125 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
126 }
127
128 /* now we can start */
129
130 if (Finley_noError()) {
131 #pragma omp parallel private(local_data, numComps_size)
132 {
133 local_data=NULL;
134 /* allocation of work arrays */
135 local_data=THREAD_MEMALLOC(NS*numComps,double);
136 if (! Finley_checkPtr(local_data)) {
137
138 numComps_size=(size_t)numComps*sizeof(double);
139 /* 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 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 }
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 } /* end of parallel region */
157 }
158 #undef NODES
159 #undef REDUCED_NODES
160 #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