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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1272 - (show annotations)
Fri Aug 24 00:40:43 2007 UTC (11 years, 8 months ago) by gross
File MIME type: text/plain
File size: 14193 byte(s)
some bugs in the node-node interpolation fixed
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 /* assemblage routines: copies data between different types nodal representation */
15
16 /**************************************************************/
17
18 /* author: gross@access.edu.au */
19 /* Version: $Id$ */
20
21 /**************************************************************/
22
23 #include "Util.h"
24 #include "Assemble.h"
25 #ifdef _OPENMP
26 #include <omp.h>
27 #endif
28
29 void Finley_Assemble_CopyNodalData(Finley_NodeFile* nodes,escriptDataC* out,escriptDataC* in) {
30 dim_t n,i,k,l, mpiSize;
31 dim_t numComps=getDataPointSize(out);
32 type_t in_data_type=getFunctionSpaceType(in);
33 type_t out_data_type=getFunctionSpaceType(out);
34 index_t upperBound;
35 double* recv_buffer;
36 size_t numComps_size=0;
37 Finley_resetError();
38 if (nodes==NULL) return;
39 mpiSize=nodes->MPIInfo->size;
40
41 /* check out and in */
42 if (numComps!=getDataPointSize(in)) {
43 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: number of components of input and output Data do not match.");
44 } else if (!isExpanded(out)) {
45 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: expanded Data object is expected for output data.");
46 }
47
48 /* more sophisticated test needed for overlapping node/DOF counts */
49 if (in_data_type == FINLEY_NODES) {
50 if (! numSamplesEqual(in,1,Finley_NodeFile_getNumNodes(nodes))) {
51 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
52 }
53 } else if (in_data_type == FINLEY_REDUCED_NODES) {
54 if (! numSamplesEqual(in,1,Finley_NodeFile_getNumReducedNodes(nodes))) {
55 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
56 }
57 } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {
58 if (! numSamplesEqual(in,1,Finley_NodeFile_getNumDegreesOfFreedom(nodes))) {
59 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
60 }
61 if ( (((out_data_type == FINLEY_NODES) || (out_data_type == FINLEY_DEGREES_OF_FREEDOM)) && !isExpanded(in) && (mpiSize>1))) {
62
63 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: FINLEY_DEGREES_OF_FREEDOM to FINLEY_NODES or FINLEY_DEGREES_OF_FREEDOM requires expanded input data on more than one processor.");
64 }
65 } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
66 if (! numSamplesEqual(in,1,Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes))) {
67 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
68 }
69 if ( (out_data_type == FINLEY_DEGREES_OF_FREEDOM) && !isExpanded(in) && (mpiSize>1)) {
70
71 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: FINLEY_REDUCED_DEGREES_OF_FREEDOM to FINLEY_DEGREES_OF_FREEDOM requires expanded input data on more than one processor.");
72 }
73 } else {
74 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal function space type for target object");
75 }
76
77 if (out_data_type == FINLEY_NODES) {
78 if (! numSamplesEqual(out,1,Finley_NodeFile_getNumNodes(nodes))) {
79 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
80 }
81 } else if (out_data_type == FINLEY_REDUCED_NODES) {
82 if (! numSamplesEqual(out,1,Finley_NodeFile_getNumReducedNodes(nodes))) {
83 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
84 }
85 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
86 if (! numSamplesEqual(out,1,Finley_NodeFile_getNumDegreesOfFreedom(nodes))) {
87 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
88 }
89 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
90 if (! numSamplesEqual(out,1,Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes))) {
91 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
92 }
93 } else {
94 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal function space type for source object");
95 }
96
97 /* now we can start */
98
99 if (Finley_noError()) {
100 /*********************** FINLEY_NODES **************************************************/
101 numComps_size=(size_t)numComps*sizeof(double);
102 if (in_data_type == FINLEY_NODES) {
103
104 if (out_data_type == FINLEY_NODES) {
105 #pragma omp parallel for private(n) schedule(static)
106 for (n=0;n<nodes->nodesMapping->numNodes;n++) {
107 memcpy(getSampleDataFast(out,n), getSampleDataFast(in,n), numComps_size);
108 }
109
110 } else if (out_data_type == FINLEY_REDUCED_NODES) {
111 #pragma omp parallel for private(n,i) schedule(static)
112 for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
113 memcpy(getSampleDataFast(in,nodes->reducedNodesMapping->map[n]),
114 getSampleDataFast(out,n),numComps_size);
115 }
116 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
117 #pragma omp parallel for private(n) schedule(static)
118 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);n++) {
119 memcpy(getSampleDataFast(out,n),
120 getSampleDataFast(in,nodes->degreesOfFreedomMapping->map[n]),
121 numComps_size);
122 }
123
124 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
125 #pragma omp parallel for private(n,i) schedule(static)
126 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
127 memcpy(getSampleDataFast(out,n),
128 getSampleDataFast(in,nodes->reducedDegreesOfFreedomMapping->map[n]),
129 numComps_size);
130 }
131 }
132 /*********************** FINLEY_REDUCED_NODES **************************************************/
133 } else if (in_data_type == FINLEY_REDUCED_NODES) {
134
135 if (out_data_type == FINLEY_NODES) {
136 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to nodes.");
137
138 } else if (out_data_type == FINLEY_REDUCED_NODES) {
139 #pragma omp parallel for private(n) schedule(static)
140 for (n=0;n<nodes->reducedNodesMapping->numNodes;n++) {
141 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
142 }
143
144 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
145 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to degrees of freedom.");
146 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
147 #pragma omp parallel for private(n,k) schedule(static)
148 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
149 k=nodes->reducedDegreesOfFreedomMapping->map[n];
150 memcpy(getSampleDataFast(out,n),
151 getSampleDataFast(in,nodes->reducedNodesMapping->target[k]),
152 numComps_size);
153 }
154 }
155
156 /*********************** FINLEY_DEGREES_OF_FREEDOM **************************************************/
157 } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {
158
159 if (out_data_type == FINLEY_NODES) {
160 Paso_Coupler_allocBuffer(nodes->degreesOfFreedomCoupler,numComps);
161 if (Paso_noError()) {
162 Paso_Coupler_startCollect(nodes->degreesOfFreedomCoupler,getSampleDataFast(in,0));
163 recv_buffer=Paso_Coupler_finishCollect(nodes->degreesOfFreedomCoupler);
164 upperBound=Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
165 #pragma omp parallel for private(n,k) schedule(static)
166 for (n=0;n<nodes->numNodes;n++) {
167 k=nodes->degreesOfFreedomMapping->target[n];
168 if (k < upperBound) {
169 memcpy(getSampleDataFast(out,n),
170 getSampleDataFast(in,k),
171 numComps_size);
172 } else {
173 memcpy(getSampleDataFast(out,n),
174 &recv_buffer[(k-upperBound)*numComps],
175 numComps_size);
176 }
177 }
178 Paso_Coupler_freeBuffer(nodes->degreesOfFreedomCoupler);
179 }
180
181 } else if (out_data_type == FINLEY_REDUCED_NODES) {
182 Paso_Coupler_allocBuffer(nodes->degreesOfFreedomCoupler,numComps);
183 if (Paso_noError()) {
184 Paso_Coupler_startCollect(nodes->degreesOfFreedomCoupler,getSampleDataFast(in,0));
185 recv_buffer=Paso_Coupler_finishCollect(nodes->degreesOfFreedomCoupler);
186 upperBound=Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
187 #pragma omp parallel for private(n,k,l) schedule(static)
188 for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
189 l=nodes->reducedNodesMapping->map[n];
190 k=nodes->degreesOfFreedomMapping->target[l];
191 if (k < upperBound) {
192 memcpy(getSampleDataFast(out,n),
193 getSampleDataFast(in,k),
194 numComps_size);
195 } else {
196 memcpy(getSampleDataFast(out,n),
197 &recv_buffer[(k-upperBound)*numComps],
198 numComps_size);
199 }
200 }
201 Paso_Coupler_freeBuffer(nodes->degreesOfFreedomCoupler);
202 }
203 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
204 #pragma omp parallel for private(n) schedule(static)
205 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);n++) {
206 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
207 }
208
209 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
210 #pragma omp parallel for private(n,k) schedule(static)
211 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
212 k=nodes->reducedDegreesOfFreedomMapping->map[n];
213 memcpy(getSampleDataFast(out,n),
214 getSampleDataFast(in,nodes->degreesOfFreedomMapping->target[k]),
215 numComps_size);
216 }
217 }
218
219 } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
220
221 if (out_data_type == FINLEY_NODES) {
222 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced degrees of freedom to nodes.");
223
224 } else if (out_data_type == FINLEY_REDUCED_NODES) {
225 Paso_Coupler_allocBuffer(nodes->reducedDegreesOfFreedomCoupler,numComps);
226 if (Paso_noError()) {
227 Paso_Coupler_startCollect(nodes->reducedDegreesOfFreedomCoupler,getSampleDataFast(in,0));
228 recv_buffer=Paso_Coupler_finishCollect(nodes->reducedDegreesOfFreedomCoupler);
229 upperBound=Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);
230 #pragma omp parallel for private(n,k,l) schedule(static)
231 for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
232 l=nodes->reducedNodesMapping->map[n];
233 k=nodes->reducedDegreesOfFreedomMapping->target[l];
234 if (k < upperBound) {
235 memcpy(getSampleDataFast(out,n),
236 getSampleDataFast(in,k),
237 numComps_size);
238 } else {
239 memcpy(getSampleDataFast(out,n),
240 &recv_buffer[(k-upperBound)*numComps],
241 numComps_size);
242 }
243 }
244 Paso_Coupler_freeBuffer(nodes->reducedDegreesOfFreedomCoupler);
245 }
246
247 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
248 #pragma omp parallel for private(n) schedule(static)
249 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
250 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
251 }
252
253 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM ) {
254 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced degrees of freedom to degrees of freedom.");
255 }
256 }
257 }
258 return;
259 }
260

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26