/[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 1276 - (show annotations)
Fri Aug 24 05:30:41 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/plain
File size: 14220 byte(s)
have added a few more tests for some new features. Unfortunately they have shown a problem but that is what tests are for.
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(out,n),
114 getSampleDataFast(in,nodes->reducedNodesMapping->map[n]),
115 numComps_size);
116 }
117 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
118 #pragma omp parallel for private(n) schedule(static)
119 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);n++) {
120 memcpy(getSampleDataFast(out,n),
121 getSampleDataFast(in,nodes->degreesOfFreedomMapping->map[n]),
122 numComps_size);
123 }
124
125 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
126 #pragma omp parallel for private(n,i) schedule(static)
127 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
128 memcpy(getSampleDataFast(out,n),
129 getSampleDataFast(in,nodes->reducedDegreesOfFreedomMapping->map[n]),
130 numComps_size);
131 }
132 }
133 /*********************** FINLEY_REDUCED_NODES **************************************************/
134 } else if (in_data_type == FINLEY_REDUCED_NODES) {
135
136 if (out_data_type == FINLEY_NODES) {
137 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to nodes.");
138
139 } else if (out_data_type == FINLEY_REDUCED_NODES) {
140 #pragma omp parallel for private(n) schedule(static)
141 for (n=0;n<nodes->reducedNodesMapping->numNodes;n++) {
142 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
143 }
144
145 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
146 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to degrees of freedom.");
147 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
148 #pragma omp parallel for private(n,k) schedule(static)
149 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
150 k=nodes->reducedDegreesOfFreedomMapping->map[n];
151 memcpy(getSampleDataFast(out,n),
152 getSampleDataFast(in,nodes->reducedNodesMapping->target[k]),
153 numComps_size);
154 }
155 }
156
157 /*********************** FINLEY_DEGREES_OF_FREEDOM **************************************************/
158 } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {
159
160 if (out_data_type == FINLEY_NODES) {
161 Paso_Coupler_allocBuffer(nodes->degreesOfFreedomCoupler,numComps);
162 if (Paso_noError()) {
163 Paso_Coupler_startCollect(nodes->degreesOfFreedomCoupler,getSampleDataFast(in,0));
164 recv_buffer=Paso_Coupler_finishCollect(nodes->degreesOfFreedomCoupler);
165 upperBound=Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
166 #pragma omp parallel for private(n,k) schedule(static)
167 for (n=0;n<nodes->numNodes;n++) {
168 k=nodes->degreesOfFreedomMapping->target[n];
169 if (k < upperBound) {
170 memcpy(getSampleDataFast(out,n),
171 getSampleDataFast(in,k),
172 numComps_size);
173 } else {
174 memcpy(getSampleDataFast(out,n),
175 &recv_buffer[(k-upperBound)*numComps],
176 numComps_size);
177 }
178 }
179 Paso_Coupler_freeBuffer(nodes->degreesOfFreedomCoupler);
180 }
181
182 } else if (out_data_type == FINLEY_REDUCED_NODES) {
183 Paso_Coupler_allocBuffer(nodes->degreesOfFreedomCoupler,numComps);
184 if (Paso_noError()) {
185 Paso_Coupler_startCollect(nodes->degreesOfFreedomCoupler,getSampleDataFast(in,0));
186 recv_buffer=Paso_Coupler_finishCollect(nodes->degreesOfFreedomCoupler);
187 upperBound=Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
188 #pragma omp parallel for private(n,k,l) schedule(static)
189 for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
190 l=nodes->reducedNodesMapping->map[n];
191 k=nodes->degreesOfFreedomMapping->target[l];
192 if (k < upperBound) {
193 memcpy(getSampleDataFast(out,n),
194 getSampleDataFast(in,k),
195 numComps_size);
196 } else {
197 memcpy(getSampleDataFast(out,n),
198 &recv_buffer[(k-upperBound)*numComps],
199 numComps_size);
200 }
201 }
202 Paso_Coupler_freeBuffer(nodes->degreesOfFreedomCoupler);
203 }
204 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
205 #pragma omp parallel for private(n) schedule(static)
206 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);n++) {
207 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
208 }
209
210 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
211 #pragma omp parallel for private(n,k) schedule(static)
212 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
213 k=nodes->reducedDegreesOfFreedomMapping->map[n];
214 memcpy(getSampleDataFast(out,n),
215 getSampleDataFast(in,nodes->degreesOfFreedomMapping->target[k]),
216 numComps_size);
217 }
218 }
219
220 } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
221
222 if (out_data_type == FINLEY_NODES) {
223 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced degrees of freedom to nodes.");
224
225 } else if (out_data_type == FINLEY_REDUCED_NODES) {
226 Paso_Coupler_allocBuffer(nodes->reducedDegreesOfFreedomCoupler,numComps);
227 if (Paso_noError()) {
228 Paso_Coupler_startCollect(nodes->reducedDegreesOfFreedomCoupler,getSampleDataFast(in,0));
229 recv_buffer=Paso_Coupler_finishCollect(nodes->reducedDegreesOfFreedomCoupler);
230 upperBound=Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);
231 #pragma omp parallel for private(n,k,l) schedule(static)
232 for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
233 l=nodes->reducedNodesMapping->map[n];
234 k=nodes->reducedDegreesOfFreedomMapping->target[l];
235 if (k < upperBound) {
236 memcpy(getSampleDataFast(out,n),
237 getSampleDataFast(in,k),
238 numComps_size);
239 } else {
240 memcpy(getSampleDataFast(out,n),
241 &recv_buffer[(k-upperBound)*numComps],
242 numComps_size);
243 }
244 }
245 Paso_Coupler_freeBuffer(nodes->reducedDegreesOfFreedomCoupler);
246 }
247
248 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
249 #pragma omp parallel for private(n) schedule(static)
250 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
251 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
252 }
253
254 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM ) {
255 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced degrees of freedom to degrees of freedom.");
256 }
257 }
258 }
259 return;
260 }
261

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26