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

Contents of /trunk-mpi-branch/finley/src/Assemble_interpolate.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1277 - (show annotations)
Mon Aug 27 04:15:51 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/plain
File size: 6482 byte(s)
bug in interpolation from reduced nodes to elements.
1 /*
2 ************************************************************
3 * Copyright 2006 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 /**************************************************************/
14
15 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
16
17 /**************************************************************/
18
19 /* Author: gross@access.edu.au */
20 /* Version: $Id$ */
21
22 /**************************************************************/
23
24 #include "Assemble.h"
25 #include "Util.h"
26 #ifdef _OPENMP
27 #include <omp.h>
28 #endif
29
30 /**************************************************************/
31
32
33 void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
34 double* local_data=NULL,*S=NULL,*data_array;
35 index_t dof_offset,*resort_nodesi, NN, NS;
36 bool_t reduced_integration=FALSE;
37 dim_t q,i,NS_DOF,NN_DOF,numNodes,e, numQuad;
38 Finley_RefElement* reference_element=NULL;
39 dim_t numComps=getDataPointSize(data);
40 index_t id[MAX_numNodes], *resort_nodes, *map;
41 type_t data_type=getFunctionSpaceType(data);
42 type_t type;
43 size_t numComps_size;
44 Finley_resetError();
45 #define NODES 0
46 #define REDUCED_NODES 3
47 #define DOF 1
48 #define REDUCED_DOF 2
49 if (nodes==NULL || elements==NULL) return;
50
51 NN=elements->numNodes;
52 NS=elements->ReferenceElement->Type->numShapes;
53 reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
54 for (i=0;i<NN;i++) id[i]=i;
55
56 /* set some parameter */
57
58 if (data_type==FINLEY_NODES) {
59 type=NODES;
60 resort_nodes=id;
61 if (reduced_integration) {
62 reference_element=elements->ReferenceElementReducedOrder;
63 } else {
64 reference_element=elements->ReferenceElement;
65 }
66 numNodes=Finley_NodeFile_getNumNodes(nodes);
67 map=Finley_NodeFile_borrowTargetNodes(nodes);
68 } else if (data_type==FINLEY_REDUCED_NODES) {
69 type=REDUCED_NODES;
70 resort_nodes=elements->ReferenceElement->Type->linearNodes;
71 if (reduced_integration) {
72 reference_element=elements->LinearReferenceElementReducedOrder;
73 } else {
74 reference_element=elements->LinearReferenceElement;
75 }
76 numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
77 map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
78 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
79 if (elements->MPIInfo->size>1) {
80 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
81 return;
82 }
83 type=DOF;
84 resort_nodes=id;
85 if (reduced_integration) {
86 reference_element=elements->ReferenceElementReducedOrder;
87 } else {
88 reference_element=elements->ReferenceElement;
89 }
90 numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
91 map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
92 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
93 if (elements->MPIInfo->size>1) {
94 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
95 return;
96 }
97 type=REDUCED_DOF;
98 resort_nodes=elements->ReferenceElement->Type->linearNodes;
99 if (reduced_integration) {
100 reference_element=elements->LinearReferenceElementReducedOrder;
101 } else {
102 reference_element=elements->LinearReferenceElement;
103 }
104 numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
105 map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
106 } else {
107 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
108 }
109 NN_DOF=reference_element->Type->numNodes;
110 NS_DOF=reference_element->Type->numShapes;
111 S=reference_element->S;
112 numQuad=reference_element->numQuadNodes;
113 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
114 dof_offset=NN_DOF-NS_DOF;
115 } else {
116 dof_offset=0;
117 }
118
119 /* check the dimensions of interpolated_data and data */
120
121 if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
122 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
123 } else if (! numSamplesEqual(data,1,numNodes)) {
124 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
125 } else if (numComps!=getDataPointSize(interpolated_data)) {
126 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
127 } else if (!isExpanded(interpolated_data)) {
128 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
129 }
130
131 /* now we can start */
132
133 if (Finley_noError()) {
134 #pragma omp parallel private(local_data, numComps_size)
135 {
136 local_data=NULL;
137 /* allocation of work arrays */
138 local_data=THREAD_MEMALLOC(NS*numComps,double);
139 if (! Finley_checkPtr(local_data)) {
140
141 numComps_size=(size_t)numComps*sizeof(double);
142 /* open the element loop */
143
144 #pragma omp for private(e,q,i,data_array) schedule(static)
145 for(e=0;e<elements->numElements;e++) {
146 for (q=0;q<NS_DOF;q++) {
147 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
148 data_array=getSampleData(data,map[i]);
149 memcpy(local_data+q*numComps, data_array, numComps_size);
150 }
151 /* calculate interpolated_data=local_data*S */
152
153 Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
154
155 } /* end of element loop */
156
157 }
158 THREAD_MEMFREE(local_data);
159 } /* end of parallel region */
160 }
161 #undef NODES
162 #undef REDUCED_NODES
163 #undef DOF
164 #undef REDUCED_DOF
165 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26