/[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 1223 - (show annotations)
Fri Aug 3 02:40:39 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/plain
File size: 6415 byte(s)
first attemt towards an improved MPI version.  

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 if (reduced_integration) {
71 reference_element=elements->LinearReferenceElementReducedOrder;
72 } else {
73 reference_element=elements->LinearReferenceElement;
74 }
75 numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
76 map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
77 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
78 if (elements->MPIInfo->size>1) {
79 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
80 return;
81 }
82 type=DOF;
83 resort_nodes=id;
84 if (reduced_integration) {
85 reference_element=elements->ReferenceElementReducedOrder;
86 } else {
87 reference_element=elements->ReferenceElement;
88 }
89 numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
90 map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
91 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
92 if (elements->MPIInfo->size>1) {
93 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
94 return;
95 }
96 type=REDUCED_DOF;
97 resort_nodes=elements->ReferenceElement->Type->linearNodes;
98 if (reduced_integration) {
99 reference_element=elements->LinearReferenceElementReducedOrder;
100 } else {
101 reference_element=elements->LinearReferenceElement;
102 }
103 numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
104 map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
105 } else {
106 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
107 }
108 NN_DOF=reference_element->Type->numNodes;
109 NS_DOF=reference_element->Type->numShapes;
110 S=reference_element->S;
111 numQuad=reference_element->numQuadNodes;
112 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
113 dof_offset=NN_DOF-NS_DOF;
114 } else {
115 dof_offset=0;
116 }
117
118 /* check the dimensions of interpolated_data and data */
119
120 if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
121 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
122 } else if (! numSamplesEqual(data,1,numNodes)) {
123 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
124 } else if (numComps!=getDataPointSize(interpolated_data)) {
125 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
126 } else if (!isExpanded(interpolated_data)) {
127 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
128 }
129
130 /* now we can start */
131
132 if (Finley_noError()) {
133 #pragma omp parallel private(local_data, numComps_size)
134 {
135 local_data=NULL;
136 /* allocation of work arrays */
137 local_data=THREAD_MEMALLOC(NS*numComps,double);
138 if (! Finley_checkPtr(local_data)) {
139
140 numComps_size=(size_t)numComps*sizeof(double);
141 /* open the element loop */
142
143 #pragma omp for private(e,q,i,data_array) schedule(static)
144 for(e=0;e<elements->numElements;e++) {
145 for (q=0;q<NS_DOF;q++) {
146 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
147 data_array=getSampleData(data,map[i]);
148 memcpy(local_data+q*numComps, data_array, numComps_size);
149 }
150 /* calculate interpolated_data=local_data*S */
151
152 Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
153
154 } /* end of element loop */
155
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