/[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 1231 - (show annotations)
Fri Aug 10 06:34:21 2007 UTC (12 years, 9 months ago) by ksteube
File MIME type: text/plain
File size: 13465 byte(s)
New parallelization now compiles on Altix
Some boost_ variables in options files were mis-spelled
Added -DMPI_NO_CPPBIND so mpi.h doesn't include mpi++.h and cause extern "C" confusion
Removed blockpapi until I fix it

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;
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
40 /* check out and in */
41 if (numComps!=getDataPointSize(in)) {
42 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: number of components of input and output Data do not match.");
43 } else if (!isExpanded(out)) {
44 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: expanded Data object is expected for output data.");
45 }
46
47 /* more sophisticated test needed for overlapping node/DOF counts */
48 if (in_data_type == FINLEY_NODES) {
49 if (! numSamplesEqual(in,1,Finley_NodeFile_getNumNodes(nodes))) {
50 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
51 }
52 } else if (in_data_type == FINLEY_REDUCED_NODES) {
53 if (! numSamplesEqual(in,1,Finley_NodeFile_getNumReducedNodes(nodes))) {
54 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
55 }
56 } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {
57 if (! numSamplesEqual(in,1,Finley_NodeFile_getNumDegreesOfFreedom(nodes))) {
58 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
59 }
60 } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
61 if (! numSamplesEqual(in,1,Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes))) {
62 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of input Data object");
63 }
64 } else {
65 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal function space type for target object");
66 }
67
68 if (out_data_type == FINLEY_NODES) {
69 if (! numSamplesEqual(out,1,Finley_NodeFile_getNumNodes(nodes))) {
70 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
71 }
72 } else if (out_data_type == FINLEY_REDUCED_NODES) {
73 if (! numSamplesEqual(out,1,Finley_NodeFile_getNumReducedNodes(nodes))) {
74 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
75 }
76 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
77 if (! numSamplesEqual(out,1,Finley_NodeFile_getNumDegreesOfFreedom(nodes))) {
78 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
79 }
80 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
81 if (! numSamplesEqual(out,1,Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes))) {
82 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal number of samples of output Data object");
83 }
84 } else {
85 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: illegal function space type for source object");
86 }
87
88 /* now we can start */
89
90 if (Finley_noError()) {
91 /*********************** FINLEY_NODES **************************************************/
92 numComps_size=(size_t)numComps*sizeof(double);
93 if (in_data_type == FINLEY_NODES) {
94
95 if (out_data_type == FINLEY_NODES) {
96 #pragma omp parallel for private(n) schedule(static)
97 for (n=0;n<nodes->nodesMapping->numNodes;n++) {
98 memcpy(getSampleDataFast(out,n), getSampleDataFast(in,n), numComps_size);
99 }
100
101 } else if (in_data_type == FINLEY_REDUCED_NODES) {
102 #pragma omp parallel for private(n,i) schedule(static)
103 for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
104 memcpy(getSampleDataFast(in,nodes->reducedNodesMapping->map[n]),
105 getSampleDataFast(out,n),numComps_size);
106 }
107 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
108 #pragma omp parallel for private(n) schedule(static)
109 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);n++) {
110 memcpy(getSampleDataFast(out,n),
111 getSampleDataFast(in,nodes->degreesOfFreedomMapping->map[n]),
112 numComps_size);
113 }
114
115 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
116 #pragma omp parallel for private(n,i) schedule(static)
117 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
118 memcpy(getSampleDataFast(out,n),
119 getSampleDataFast(in,nodes->reducedDegreesOfFreedomMapping->map[n]),
120 numComps_size);
121 }
122 }
123 /*********************** FINLEY_REDUCED_NODES **************************************************/
124 } else if (in_data_type == FINLEY_REDUCED_NODES) {
125
126 if (out_data_type == FINLEY_NODES) {
127 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to nodes.");
128
129 } else if (in_data_type == FINLEY_REDUCED_NODES) {
130 #pragma omp parallel for private(n) schedule(static)
131 for (n=0;n<nodes->reducedNodesMapping->numNodes;n++) {
132 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
133 }
134
135 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
136 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced nodes to degrees of freedom.");
137 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
138 #pragma omp parallel for private(n,k) schedule(static)
139 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
140 k=nodes->reducedDegreesOfFreedomMapping->map[n];
141 memcpy(getSampleDataFast(out,n),
142 getSampleDataFast(in,nodes->reducedNodesMapping->target[k]),
143 numComps_size);
144 }
145 }
146
147 /*********************** FINLEY_DEGREES_OF_FREEDOM **************************************************/
148 } else if (in_data_type == FINLEY_DEGREES_OF_FREEDOM) {
149
150 if (out_data_type == FINLEY_NODES) {
151 Paso_Coupler_allocBuffer(nodes->degreesOfFreedomCoupler,numComps);
152 if (Paso_noError()) {
153 Paso_Coupler_startCollect(nodes->degreesOfFreedomCoupler,getSampleDataFast(in,0));
154 recv_buffer=Paso_Coupler_finishCollect(nodes->degreesOfFreedomCoupler);
155 upperBound=Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
156 #pragma omp parallel for private(n,k) schedule(static)
157 for (n=0;n<nodes->numNodes;n++) {
158 k=nodes->degreesOfFreedomMapping->target[n];
159 if (k < upperBound) {
160 memcpy(getSampleDataFast(out,n),
161 getSampleDataFast(in,k),
162 numComps_size);
163 } else {
164 memcpy(getSampleDataFast(out,n),
165 &recv_buffer[k-upperBound],
166 numComps_size);
167 }
168 }
169 Paso_Coupler_freeBuffer(nodes->degreesOfFreedomCoupler);
170 }
171
172 } else if (out_data_type == FINLEY_REDUCED_NODES) {
173 Paso_Coupler_allocBuffer(nodes->degreesOfFreedomCoupler,numComps);
174 if (Paso_noError()) {
175 Paso_Coupler_startCollect(nodes->degreesOfFreedomCoupler,getSampleDataFast(in,0));
176 recv_buffer=Paso_Coupler_finishCollect(nodes->degreesOfFreedomCoupler);
177 upperBound=Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);
178 #pragma omp parallel for private(n,k,l) schedule(static)
179 for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
180 l=nodes->reducedNodesMapping->map[n];
181 k=nodes->degreesOfFreedomMapping->target[l];
182 if (k < upperBound) {
183 memcpy(getSampleDataFast(out,n),
184 getSampleDataFast(in,k),
185 numComps_size);
186 } else {
187 memcpy(getSampleDataFast(out,n),
188 &recv_buffer[k-upperBound],
189 numComps_size);
190 }
191 }
192 Paso_Coupler_freeBuffer(nodes->degreesOfFreedomCoupler);
193 }
194 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM) {
195 #pragma omp parallel for private(n) schedule(static)
196 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->degreesOfFreedomDistribution);n++) {
197 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
198 }
199
200 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
201 #pragma omp parallel for private(n,k) schedule(static)
202 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
203 k=nodes->reducedDegreesOfFreedomMapping->map[n];
204 memcpy(getSampleDataFast(out,n),
205 getSampleDataFast(in,nodes->degreesOfFreedomMapping->target[k]),
206 numComps_size);
207 }
208 }
209
210 } else if (in_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
211
212 if (out_data_type == FINLEY_NODES) {
213 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced degrees of freedom to nodes.");
214
215 } else if (in_data_type == FINLEY_REDUCED_NODES) {
216 Paso_Coupler_allocBuffer(nodes->reducedDegreesOfFreedomCoupler,numComps);
217 if (Paso_noError()) {
218 Paso_Coupler_startCollect(nodes->reducedDegreesOfFreedomCoupler,getSampleDataFast(in,0));
219 recv_buffer=Paso_Coupler_finishCollect(nodes->reducedDegreesOfFreedomCoupler);
220 upperBound=Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);
221 #pragma omp parallel for private(n,k,l) schedule(static)
222 for (n=0;n<nodes->reducedNodesMapping->numTargets;n++) {
223 l=nodes->reducedNodesMapping->map[n];
224 k=nodes->reducedDegreesOfFreedomMapping->target[l];
225 if (k < upperBound) {
226 memcpy(getSampleDataFast(out,n),
227 getSampleDataFast(in,k),
228 numComps_size);
229 } else {
230 memcpy(getSampleDataFast(out,n),
231 &recv_buffer[k-upperBound],
232 numComps_size);
233 }
234 }
235 Paso_Coupler_freeBuffer(nodes->reducedDegreesOfFreedomCoupler);
236 }
237
238 } else if (out_data_type == FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
239 #pragma omp parallel for private(n) schedule(static)
240 for (n=0;n<Paso_Distribution_getMyNumComponents(nodes->reducedDegreesOfFreedomDistribution);n++) {
241 memcpy(getSampleDataFast(out,n),getSampleDataFast(in,n),numComps_size);
242 }
243
244 } else if (out_data_type == FINLEY_DEGREES_OF_FREEDOM ) {
245 Finley_setError(TYPE_ERROR,"Finley_Assemble_CopyNodalData: cannot copy from reduced degrees of freedom to degrees of freedom.");
246 }
247 }
248 }
249 return;
250 }
251

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26