Branch data Line data Source code
1 : : /*********************************************
2 : : June,10
3 : : Reactor Assembly Mesh Assembler
4 : : Argonne National Laboratory
5 : :
6 : : CCrgen class functions for cop/moving meshes
7 : : based on symmetry and geometry type
8 : : *********************************************/
9 : :
10 : : #include "meshkit/CoreGen.hpp"
11 : : using namespace MeshKit;
12 : 0 : int CoreGen::copymove(const int nrank, const int numprocs)
13 : : // ---------------------------------------------------------------------------
14 : : // Function: copy/move the assemblies based on the geometrytype and symmetry - Assume 1 meshfile in each instance
15 : : // Input: none
16 : : // Output: none
17 : : // ---------------------------------------------------------------------------
18 : : {
19 [ # # ]: 0 : if (nrank < ((int) core_alias.size() + ((int) files.size() - nassys))){
20 : 0 : err = set_copymove_coords();
21 : : // ERRORR("Failed to set cm coords.", err);
22 : :
23 : : // now copy/move
24 : 0 : err = copymove_all(nrank, numprocs);
25 : : // ERRORR("Failed to cm hexflat.", err);
26 : : }
27 : 0 : return iBase_SUCCESS;
28 : : }
29 : :
30 : 0 : int CoreGen::set_copymove_coords()
31 : : // ---------------------------------------------------------------------------
32 : : // Function:
33 : : // Input: none
34 : : // Output: none
35 : : // ---------------------------------------------------------------------------
36 : : {
37 [ # # ]: 0 : x_coord.resize(tot_assys);
38 [ # # ]: 0 : y_coord.resize(tot_assys);
39 : 0 : int i = 0;
40 : : int assm_index;
41 : 0 : double dx[3] = {0.0, 0.0, 0.0};
42 : : // move the assys based on the geometry type
43 [ # # ][ # # ]: 0 : if (!strcmp(geom_type.c_str(), "hexflat") && symm == 6) {
[ # # ]
44 [ # # ]: 0 : for (int n1 = 0; n1 < nrings; n1++) {
45 [ # # ]: 0 : for (int n2 = 0; n2 < n1 + 1; n2++) {
46 [ # # ]: 0 : err = find_assm(i, assm_index);
47 [ # # ]: 0 : y_coord[i] = n1 * pitch * sin(PII / 3.0) - n2 * pitch * sin(PII / 3.0);
48 [ # # ]: 0 : x_coord[i] = n1 * pitch * cos(PII / 3.0) + n2 * pitch * cos(PII / 3.0);
49 : 0 : i++;
50 : : }
51 : : }
52 : : }
53 [ # # ][ # # ]: 0 : if (!strcmp(geom_type.c_str(), "rectangular") && symm == 1) {
[ # # ]
54 : 0 : double dx = 0.0, dy = 0.0;
55 : 0 : int i = 0;
56 [ # # ]: 0 : for (int m = 1; m <= nringsy; m++) {
57 [ # # ]: 0 : for (int n = 1; n <= nringsx; n++) {
58 [ # # ]: 0 : if (n==1){
59 : 0 : dx = 0;
60 [ # # ]: 0 : if(m==1)
61 : 0 : dy = 0;
62 : : }
63 : : else{
64 : 0 : dx+= pitchx;
65 : : }
66 [ # # ][ # # ]: 0 : if (m > 1 && n==1){
67 : 0 : dy+= pitchy;
68 : : }
69 [ # # ]: 0 : y_coord[i] = -dy;
70 [ # # ]: 0 : x_coord[i] = dx;
71 : 0 : i++;
72 : : }
73 : : }
74 : : }
75 [ # # ][ # # ]: 0 : if (!strcmp(geom_type.c_str(), "hexflat") && symm == 1) {
[ # # ]
76 : 0 : int t, width = 2 * nrings - 1;
77 [ # # ]: 0 : for (int n1 = 1; n1 <= width; n1++) {
78 [ # # ]: 0 : if(n1 > nrings)
79 : 0 : t = 2 * nrings - n1;
80 : : else
81 : 0 : t = n1;
82 : :
83 [ # # ]: 0 : for (int n2 = 1; n2 <= (nrings + t - 1); n2++) {
84 [ # # ]: 0 : err = find_assm(i,assm_index);
85 : :
86 [ # # ]: 0 : if (n1 < nrings){
87 [ # # ]: 0 : x_coord[i] = (nrings - n2 + 1) * pitch / 2.0 + n2 * pitch / 2.0 +
88 : 0 : (n2 - 1) * pitch - (n1 - 1) * pitch / 2.0;
89 [ # # ]: 0 : y_coord[i] = -((n1 - 1) * (0.5 * pitch / sin(PII/3.0) + 0.5 * pitch * sin(PII/6.0) / sin(PII/3.0)));
90 : : }
91 : : else{
92 [ # # ]: 0 : x_coord[i] = (nrings - n2 + 1) * pitch / 2.0 + n2 * pitch / 2.0 + (n2 - 1) * pitch -
93 : 0 : (2 * nrings - n1 -1) * pitch / 2.0;
94 [ # # ]: 0 : y_coord[i] = -((n1 -1) * (0.5 * pitch / sin(PII/3.0) + 0.5 * pitch * sin(PII/6.0) / sin(PII/3.0)));
95 : : }
96 : 0 : i++;
97 : : }
98 : : }
99 : : }
100 : :
101 [ # # ][ # # ]: 0 : if (!strcmp(geom_type.c_str(), "hexflat") && symm == 12) {
[ # # ]
102 : 0 : int flag = 0;
103 [ # # ]: 0 : for (int n1 = 0; n1 < nrings; n1++) {
104 : 0 : int loc = (n1 + 2)/2;
105 : :
106 [ # # ]: 0 : if( flag == 0 ){
107 : 0 : dx[0] = (n1 + loc - 1) * pitch / 2.0;
108 : 0 : dx[1] = (n1 - loc + 1) * pitch * sin(PII/3.0);
109 : 0 : flag = 1;
110 : : }
111 : : else{
112 : 0 : dx[0] = (n1 + loc) * pitch / 2.0;
113 : 0 : dx[1] = (n1 - loc) * pitch * sin(PII/3.0);
114 : 0 : flag = 0;
115 : : }
116 : :
117 [ # # ]: 0 : for (int n2 = 0; n2 < loc; n2++) {
118 [ # # ]: 0 : err = find_assm(i,assm_index);
119 [ # # ]: 0 : y_coord[i] = dx[1] - n2 * pitch * sin(PII/3.0);
120 [ # # ]: 0 : x_coord[i] = dx[0] + n2 * pitch * cos(PII/3.0);
121 : 0 : i++;
122 : : }
123 : : }
124 : : }
125 : :
126 [ # # ][ # # ]: 0 : if (!strcmp(geom_type.c_str(), "hexvertex") && symm == 6) {
[ # # ]
127 : 0 : int bd = 0;
128 [ # # ]: 0 : for (int n1 = 0; n1 < nrings; n1++) {
129 [ # # ]: 0 : if(n1%2==0){//check if n1 is even
130 [ # # ]: 0 : for (int n2 = 0; n2 < n1+1; n2++) {
131 : :
132 [ # # ]: 0 : err = find_assm(i, assm_index);
133 [ # # ]: 0 : if (-1 == assm_index){
134 : 0 : i++;
135 [ # # ]: 0 : if(n2 > (n1+1)/2)
136 : 0 : ++bd; // index for assemblies below diagonal needs updatation
137 : 0 : continue;
138 : : }
139 [ # # ]: 0 : if(n2 <= n1/2){// before or equal to diagonal
140 : 0 : dx[0] = n2 * pitch;
141 : 0 : dx[1] = n1 * pitch * sin(PII/3.0);
142 : : }
143 : : else{//below the diagonal
144 : 0 : dx[0] = (n1 + 1 + bd) * pitch / 2.0;
145 : 0 : dx[1] = (n1 - 1 - bd) * pitch * sin(PII/3.0);
146 : 0 : ++bd;
147 : : }
148 [ # # ]: 0 : x_coord[i] = (dx[0] * cos(PII/6.0) + dx[1] * sin(PII/6.0));
149 [ # # ]: 0 : y_coord[i] = (dx[1] * cos(PII/6.0) - dx[0] * sin(PII/6.0));
150 : 0 : i++;
151 : : }
152 : : }
153 : : else{//n1 is odd
154 [ # # ]: 0 : for (int n2 = 0; n2 < n1; n2++) {
155 [ # # ]: 0 : err = find_assm(i, assm_index);
156 [ # # ]: 0 : if (-1 == assm_index){
157 : 0 : i++;
158 [ # # ]: 0 : if(n2 > (n1+1)/2)
159 : 0 : ++bd; // index for assemblies below diagonal needs updatation
160 : 0 : continue;
161 : :
162 : : }
163 [ # # ]: 0 : if(n2 <= (n1-1)/2){// before or equal to diagonal
164 : 0 : dx[0] = (2 * n2 + 1) * pitch / 2.0;
165 : 0 : dx[1] = n1 * pitch * sin(PII/3.0);
166 : :
167 : : }
168 : : else{//below the diagonal
169 : 0 : dx[0] = (n1 + 1 + bd) * pitch / 2.0;
170 [ # # ]: 0 : if (bd == 0) // first n2 = 1 assembly
171 : 0 : dx[1] = pitch * sin(PII/3.0);
172 : 0 : dx[1] = (n1 - 1 - bd) * pitch * sin(PII/3.0);
173 : 0 : ++bd;
174 : : }
175 : :
176 : :
177 : : // starting from x-axis
178 [ # # ]: 0 : x_coord[i] = (dx[0] * cos(PII/6.0) + dx[1] * sin(PII/6.0));
179 [ # # ]: 0 : y_coord[i] = (dx[1] * cos(PII/6.0) - dx[0] * sin(PII/6.0));
180 : 0 : i++;
181 : : }
182 : : }
183 : 0 : bd = 0;
184 : : }
185 : : }
186 : 0 : return iBase_SUCCESS;
187 : : }
188 : :
189 : 0 : int CoreGen::copymove_all(const int nrank, const int numprocs)
190 : : // ---------------------------------------------------------------------------
191 : : // Function:
192 : : // Input: none
193 : : // Output: none
194 : : // ---------------------------------------------------------------------------
195 : : {
196 [ # # ]: 0 : if(prob_type == "mesh"){
197 : : // get the copy/expand sets
198 : 0 : const char *ctag_names[] = { "GEOM_DIMENSION" };
199 : 0 : const char *ctag_vals[] = { (const char*) &set_DIM };
200 : :
201 : 0 : int flag = 1;
202 : 0 : int assm_index = -1;
203 : : double dx_orig[3], dx[3];
204 : :
205 [ # # ]: 0 : if(numprocs <= (int) files.size()){
206 : : // no distribution of task for copy/move; each file loaded only once
207 [ # # ][ # # ]: 0 : int *flags = new int[assys.size()];
208 : 0 : int move_index = -1;
209 [ # # ][ # # ]: 0 : int *run_count = new int[assys.size()];
210 : 0 : double dx[3] = { 0.0, 0.0, 0.0 };
211 : 0 : double dx_move[3] = { 0.0, 0.0, 0.0 };
212 [ # # ]: 0 : CMatrix<double> dx_orig(assys.size(), 3);
213 [ # # ]: 0 : dx_orig.Set(0.0);
214 : :
215 [ # # ]: 0 : for (unsigned int i = 0; i < assys.size(); i++) {
216 : 0 : flags[i]=0;
217 : 0 : run_count[i]=0;
218 [ # # ][ # # ]: 0 : cm[i]->expand_sets().add_tag("MATERIAL_SET");
[ # # ][ # # ]
219 [ # # ][ # # ]: 0 : cm[i]->expand_sets().add_tag("DIRICHLET_SET");
[ # # ][ # # ]
220 [ # # ][ # # ]: 0 : cm[i]->expand_sets().add_tag("NEUMANN_SET");
[ # # ][ # # ]
221 : :
222 [ # # ][ # # ]: 0 : cm[i]->copy_sets().add_tag("GEOM_DIMENSION");
[ # # ][ # # ]
223 : :
224 [ # # ][ # # ]: 0 : cm[i]->update_sets();
225 : : }
226 [ # # ]: 0 : for (int k=0; k< tot_assys; k++){
227 [ # # ]: 0 : err = find_assm(k, assm_index);
228 [ # # ]: 0 : if(assm_index >= 0){
229 : : // check if this file is with the proc
230 : 0 : int out = 0;
231 [ # # ]: 0 : for(int c=0; c < (int) assys.size(); c++){
232 [ # # ][ # # ]: 0 : if(assys_index[c] == assm_index){
233 : : //found assembly
234 : 0 : move_index=c;
235 : 0 : out = 0;
236 : 0 : break;
237 : : }
238 : : else{
239 : 0 : out = 1;
240 : : }
241 : : }
242 [ # # ]: 0 : if(out == 1){
243 : 0 : continue;
244 : : }
245 [ # # ]: 0 : if (-1 == assm_index) {
246 : 0 : continue;
247 : : }
248 : :
249 [ # # ]: 0 : if (flags[move_index] == 0) {
250 [ # # ]: 0 : dx_move[0] = x_coord[k];
251 [ # # ]: 0 : dx_move[1] = y_coord[k];
252 : 0 : dx_move[2] = 0;
253 [ # # ]: 0 : dx_orig(move_index + 1, 1) = dx_move[0];
254 [ # # ]: 0 : dx_orig(move_index + 1, 2) = dx_move[1];
255 [ # # ]: 0 : dx_orig(move_index + 1, 3) = dx_move[2];
256 : :
257 [ # # ][ # # ]: 0 : move_verts(assys[move_index], dx_move);
258 [ # # ][ # # ]: 0 : logfile << "Moved Assembly: " << assm_index << " dX = " << dx_move[0] << " dY = "
[ # # ][ # # ]
[ # # ]
259 [ # # ][ # # ]: 0 : << dx_move[1] << " in proc with rank " << nrank << std::endl;
[ # # ][ # # ]
260 [ # # ]: 0 : if(strcmp(info.c_str(),"on") == 0)
261 [ # # ][ # # ]: 0 : info_file << assm_index << " \t" << k << " \t" << dx_move[0] << " \t" << dx_move[1] << " \t" << dx_move[2] << " \t" << nrank << std::endl;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
262 : :
263 : 0 : flags[move_index]=1;
264 : : }
265 : : else{
266 : :
267 [ # # ][ # # ]: 0 : dx[0] = x_coord[k] - dx_orig(move_index+1, 1);
268 [ # # ][ # # ]: 0 : dx[1] = y_coord[k] - dx_orig(move_index+1, 2);
269 : 0 : dx[2] = 0.0;
270 [ # # ][ # # ]: 0 : cm[move_index]->set_transform(Copy::Translate(dx));
[ # # ][ # # ]
271 [ # # ][ # # ]: 0 : cm[move_index]->execute_this();
272 : 0 : ++run_count[move_index];
273 : :
274 [ # # ][ # # ]: 0 : logfile << "Copy/moved A: " << assm_index
275 [ # # ][ # # ]: 0 : <<" dX = " <<dx[0]<< " dY = " << dx[1] << " rank " << nrank << std::endl;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
276 [ # # ]: 0 : if(strcmp(info.c_str(),"on") == 0)
277 [ # # ][ # # ]: 0 : info_file << assm_index << " " << k << " " << dx[0] << " \t" << dx[1] << " \t" << dx[2] << " \t" << nrank << std::endl;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
278 [ # # ][ # # ]: 0 : cm[move_index]->tag_copied_sets(ctag_names, ctag_vals, 1);
279 : : }
280 : :
281 : : }
282 : : }
283 [ # # ]: 0 : delete[] flags;
284 [ # # ]: 0 : delete[] run_count;
285 : : }
286 : : else{
287 [ # # ][ # # ]: 0 : for(int i =0; i < (int) position_core[nrank].size(); i++){
288 [ # # ][ # # ]: 0 : assm_index = position_core[nrank][i];
289 [ # # ]: 0 : if(assm_index >= 0){
290 : : // some files are loaded in two or more processors, copy/move task distribution takes place
291 : 0 : int j = 0;
292 [ # # ][ # # ]: 0 : cm[j]->expand_sets().add_tag("MATERIAL_SET");
[ # # ][ # # ]
293 [ # # ][ # # ]: 0 : cm[j]->expand_sets().add_tag("DIRICHLET_SET");
[ # # ][ # # ]
294 [ # # ][ # # ]: 0 : cm[j]->expand_sets().add_tag("NEUMANN_SET");
[ # # ][ # # ]
295 : :
296 [ # # ][ # # ]: 0 : cm[j]->copy_sets().add_tag("GEOM_DIMENSION");
[ # # ][ # # ]
297 : :
298 [ # # ][ # # ]: 0 : cm[j]->update_sets();
299 : :
300 [ # # ]: 0 : if(flag == 0){
301 [ # # ]: 0 : dx[0] = x_coord[assm_index] - dx_orig[0];
302 [ # # ]: 0 : dx[1] = y_coord[assm_index] - dx_orig[1];
303 : 0 : dx[2] = 0.0;
304 : :
305 [ # # ][ # # ]: 0 : cm[0]->set_transform(Copy::Translate(dx));
[ # # ][ # # ]
306 [ # # ][ # # ]: 0 : cm[0]->execute_this();
307 [ # # ][ # # ]: 0 : logfile << "Copy/moved Assm: " << assm_index << " dX = " << dx[0] << " dY = "
[ # # ][ # # ]
[ # # ]
308 [ # # ][ # # ]: 0 : << dx[1] << " rank " << nrank << std::endl;
[ # # ][ # # ]
309 [ # # ]: 0 : if(strcmp(info.c_str(),"on") == 0)
310 [ # # ][ # # ]: 0 : info_file << assm_index << " \t" << i << " \t" << dx[0] << " \t" << dx[1] << " \t" << dx[2] << " \t" << nrank << std::endl;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
311 : : } else {
312 : 0 : flag = 0;
313 [ # # ]: 0 : dx_orig[0] = x_coord[assm_index];
314 [ # # ]: 0 : dx_orig[1] = y_coord[assm_index];
315 : 0 : dx_orig[2] = 0;
316 [ # # ][ # # ]: 0 : move_verts(assys[0], dx_orig);
317 [ # # ][ # # ]: 0 : logfile << "Moved Assm: " << assm_index << " dX = " << dx_orig[0] << " dY = "
[ # # ][ # # ]
[ # # ]
318 [ # # ][ # # ]: 0 : << dx_orig[1] << " rank " << nrank << std::endl;
[ # # ][ # # ]
319 [ # # ]: 0 : if(strcmp(info.c_str(),"on") == 0)
320 [ # # ][ # # ]: 0 : info_file << assm_index << " \t" << i << " \t" << dx_orig[0] << " \t" << dx_orig[1] << " \t" << dx_orig[2] << " \t" << nrank << std::endl;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
321 : :
322 : : }
323 : : }
324 : : }
325 : : }
326 : : }
327 : : else{ // prob type is geometry
328 : 0 : int assm_index = -1;
329 : : // no distribution of task for copy/move; each file loaded only once
330 [ # # ][ # # ]: 0 : int *flags = new int[assys.size()];
331 : 0 : int move_index = -1;
332 : 0 : double dx[3] = { 0.0, 0.0, 0.0 };
333 : 0 : double dx_move[3] = { 0.0, 0.0, 0.0 };
334 [ # # ]: 0 : CMatrix<double> dx_orig(assys.size(), 3);
335 [ # # ]: 0 : dx_orig.Set(0.0);
336 : :
337 [ # # ]: 0 : for (unsigned int i = 0; i < assys.size(); i++) {
338 : 0 : flags[i]=0;
339 : : }
340 : :
341 [ # # ]: 0 : for (int k=0; k< tot_assys; k++){
342 [ # # ]: 0 : err = find_assm(k, assm_index);
343 [ # # ]: 0 : if(assm_index >= 0){
344 : : // check if this file is with the proc
345 : 0 : int out = 0;
346 [ # # ]: 0 : for(int c=0; c < (int) assys.size(); c++){
347 [ # # ][ # # ]: 0 : if(assys_index[c] == assm_index){
348 : : //found assembly
349 : 0 : move_index=c;
350 : 0 : out = 0;
351 : 0 : break;
352 : : }
353 : : else{
354 : 0 : out = 1;
355 : : }
356 : : }
357 [ # # ]: 0 : if(out == 1){
358 : 0 : continue;
359 : : }
360 [ # # ]: 0 : if (-1 == assm_index) {
361 : 0 : continue;
362 : : }
363 : :
364 [ # # ]: 0 : if (flags[move_index] == 0) {
365 [ # # ]: 0 : dx_move[0] = x_coord[k];
366 [ # # ]: 0 : dx_move[1] = y_coord[k];
367 : 0 : dx_move[2] = 0;
368 [ # # ]: 0 : dx_orig(move_index + 1, 1) = dx_move[0];
369 [ # # ]: 0 : dx_orig(move_index + 1, 2) = dx_move[1];
370 [ # # ]: 0 : dx_orig(move_index + 1, 3) = dx_move[2];
371 : :
372 [ # # ][ # # ]: 0 : move_geoms(assys[move_index], dx_move);
373 [ # # ][ # # ]: 0 : logfile << "Moved Assembly: " << assm_index << " dX = " << dx_move[0] << " dY = "
[ # # ][ # # ]
[ # # ]
374 [ # # ][ # # ]: 0 : << dx_move[1] << " in proc with rank " << nrank << std::endl;
[ # # ][ # # ]
375 : 0 : flags[move_index]=1;
376 : : }
377 : : else{
378 : :
379 [ # # ][ # # ]: 0 : dx[0] = x_coord[k] - dx_orig(move_index+1, 1);
380 [ # # ][ # # ]: 0 : dx[1] = y_coord[k] - dx_orig(move_index+1, 2);
381 : 0 : dx[2] = 0.0;
382 : :
383 [ # # ][ # # ]: 0 : cg[move_index]->set_location(dx);
[ # # ]
384 [ # # ][ # # ]: 0 : cg[move_index]->execute_this();
385 [ # # ][ # # ]: 0 : logfile << "Copy/moved A: " << assm_index
386 [ # # ][ # # ]: 0 : <<" dX = " <<dx[0]<< " dY = " << dx[1] << " rank " << nrank << std::endl;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
387 : : }
388 : :
389 : : }
390 : : }
391 [ # # ]: 0 : delete [] flags;
392 : :
393 : : }
394 : 0 : return iBase_SUCCESS;
395 [ + - ][ + - ]: 156 : }
|