21 MPI_Comm structuredCommunicator_,
22 const MInt noDomains_,
26 m_noBlocks(grid_->m_noBlocks),
27 m_blockId(grid_->m_blockId),
28 m_noDomains(noDomains_),
29 m_domainId(domainId_),
30 m_solverId(solverId_),
31 m_noGhostLayers(grid_->m_noGhostLayers),
32 m_StructuredComm(structuredCommunicator_) {}
41 constexpr MInt nDim = 2;
42 MInt countConnection = 0;
43 unique_ptr<StructuredWindowMap<nDim>> newWindow;
44 MBool found, notexisted, labell;
46 MInt numWindows[nDim] = {0, 0};
50 while(connectionset.size() != 0) {
51 auto element = connectionset.begin();
52 MInt order[2] = {-1, -1};
53 MInt step1[2] = {1, 1};
54 MInt step2[2] = {1, 1};
55 MInt pos1[3], pos2[3], b1, b2;
64 newWindow = make_unique<StructuredWindowMap<nDim>>();
65 mapCreate(b1, pos1, pos1, step1, b2, pos2, pos2, step2, order,
element->BC, newWindow);
66 newWindow->Nstar = -1;
68 for(
MInt i = 0; i < 2; ++i) {
70 pos1[0] = newWindow->start1[0];
71 pos1[1] = newWindow->start1[1];
73 if(newWindow->order[i] == -1) {
76 pos1[i] = newWindow->start1[i] + 1;
77 for(
MInt j = 0; j < 2; ++j) {
79 pos2[0] = newWindow->start2[0];
80 pos2[1] = newWindow->start2[1];
83 for(
MInt k = 0; k < 2; ++k) {
84 if(newWindow->order[k] == j) notexisted =
false;
88 pos2[j] = newWindow->start2[j] + 1;
90 temp1.
BC = newWindow->BC;
93 temp1.
pos1[0] = pos1[0];
94 temp1.
pos1[1] = pos1[1];
95 temp1.
pos2[0] = pos2[0];
96 temp1.
pos2[1] = pos2[1];
98 found = findConnection(temp1);
101 newWindow->step1[i] = 1;
102 newWindow->step2[j] = 1;
103 newWindow->order[i] = j;
108 pos2[j] = newWindow->start2[j] - 1;
109 temp1.
BC = newWindow->BC;
112 temp1.
pos1[0] = pos1[0];
113 temp1.
pos1[1] = pos1[1];
114 temp1.
pos2[0] = pos2[0];
115 temp1.
pos2[1] = pos2[1];
117 found = findConnection(temp1);
119 newWindow->step1[i] = 1;
120 newWindow->step2[j] = -1;
121 newWindow->order[i] = j;
132 pos1[i] = newWindow->start1[i] - 1;
133 for(
MInt j = 0; j < 2; ++j) {
135 pos2[0] = newWindow->start2[0];
136 pos2[1] = newWindow->start2[1];
138 for(
MInt k = 0; k < 2; ++k) {
139 if(newWindow->order[k] == j) {
145 pos2[j] = newWindow->start2[j] + 1;
146 temp1.
BC = newWindow->BC;
149 temp1.
pos1[0] = pos1[0];
150 temp1.
pos1[1] = pos1[1];
151 temp1.
pos2[0] = pos2[0];
152 temp1.
pos2[1] = pos2[1];
154 found = findConnection(temp1);
157 newWindow->step1[i] = -1;
158 newWindow->step2[j] = 1;
159 newWindow->order[i] = j;
164 pos2[j] = newWindow->start2[j] - 1;
165 temp1.
BC = newWindow->BC;
168 temp1.
pos1[0] = pos1[0];
169 temp1.
pos1[1] = pos1[1];
170 temp1.
pos2[0] = pos2[0];
171 temp1.
pos2[1] = pos2[1];
173 found = findConnection(temp1);
176 newWindow->step1[i] = -1;
177 newWindow->step2[j] = -1;
178 newWindow->order[i] = j;
190 MBool facewindow, directionInWindow[nDim];
191 for(
MInt i = 0; i < nDim; ++i) {
192 directionInWindow[i] =
false;
193 if(newWindow->order[i] != -1) {
195 directionInWindow[i] =
true;
200 cout <<
"Invalid volume mapping found! Are your blocks overlapping or is the grid epsilon too large?" << endl;
203 if(ordercount == 2) {
209 for(
MInt i = 0; i < 2; ++i) {
212 if(newWindow->order[i] == -1) {
213 for(j = 0; j < 2; ++j) {
215 for(
MInt k = 0; k < 2; ++k) {
216 if(newWindow->order[k] == j) {
222 newWindow->order[i] = j;
228 if(newWindow->start1[i] == 0) {
229 newWindow->dc1 = i + 1;
231 newWindow->dc1 = -i - 1;
234 if(newWindow->start2[j] == 0) {
235 newWindow->dc2 = j + 1;
237 newWindow->dc2 = -j - 1;
240 newWindow->dc1 = 999;
241 newWindow->dc2 = 999;
246 MInt start1[2], end1[2], start2[2], end2[2];
248 MInt countDim, countDim2;
252 for(countDim = 0; countDim < nDim; ++countDim) {
253 if(directionInWindow[countDim]) {
254 countDim2 = newWindow->order[countDim];
256 for(
MInt i = 0; i < 2; ++i) {
257 start1[i] = newWindow->start1[i];
258 end1[i] = newWindow->end1[i];
259 start2[i] = newWindow->start2[i];
260 end2[i] = newWindow->end2[i];
262 end1[countDim] = end1[countDim] + newWindow->step1[countDim];
263 end2[countDim2] = end2[countDim2] + newWindow->step2[countDim2];
264 start1[countDim] = end1[countDim];
265 start2[countDim2] = end2[countDim2];
268 pos2[newWindow->order[1]] = start2[newWindow->order[1]];
271 pos2[newWindow->order[0]] = start2[newWindow->order[0]];
276 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
282 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
283 found = findConnection(temp2);
285 if(!found && domainId() == 0 && newWindow->BC == 4401 && newWindow->Id1 == 2 && newWindow->Id2 != 2) {
287 connectionNode temp3(newWindow->BC, newWindow->Id2, pos2, newWindow->Id1, pos1, labell, nDim);
288 found = findConnection(temp3);
291 cout <<
"wooooo!! somthing is wrong and i do not know where and why!!!!!!" << endl;
297 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
298 ii = ii + newWindow->step1[0];
300 }
while(ii >= start1[0] && ii <= end1[0]);
301 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
302 jj = jj + newWindow->step1[1];
304 }
while(jj >= start1[1] && jj <= end1[1]);
309 for(
MInt m = 0; m < 2; ++m) {
310 newWindow->end1[m] = end1[m];
311 newWindow->end2[m] = end2[m];
316 for(
MInt i = 0; i < 2; ++i) {
317 start1[i] = newWindow->start1[i];
318 end1[i] = newWindow->end1[i];
319 start2[i] = newWindow->start2[i];
320 end2[i] = newWindow->end2[i];
322 start1[countDim] = start1[countDim] - newWindow->step1[countDim];
323 start2[countDim2] = start2[countDim2] - newWindow->step2[countDim2];
324 end1[countDim] = start1[countDim];
325 end2[countDim2] = start2[countDim2];
327 pos2[newWindow->order[1]] = start2[newWindow->order[1]];
330 pos2[newWindow->order[0]] = start2[newWindow->order[0]];
335 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
341 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
342 found = findConnection(temp2);
344 if(!found && domainId() == 0 && newWindow->BC == 4401 && newWindow->Id1 == 2 && newWindow->Id2 != 2) {
345 connectionNode temp3(newWindow->BC, newWindow->Id2, pos2, newWindow->Id1, pos1, labell, nDim);
346 found = findConnection(temp3);
348 cout <<
"wooooo!! somthing is wrong and i do not know where and why!!!!!!" << endl;
354 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
355 ii = ii + newWindow->step1[0];
357 }
while(ii >= start1[0] && ii <= end1[0]);
358 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
359 jj = jj + newWindow->step1[1];
361 }
while(jj >= start1[1] && jj <= end1[1]);
366 for(
MInt m = 0; m < 2; ++m) {
367 newWindow->start1[m] = start1[m];
368 newWindow->start2[m] = start2[m];
376 if(newWindow->BC >= 6000 && newWindow->BC < 6010
379 mapInvert1(newWindow);
381 mapNormalize3(newWindow);
384 pos2[newWindow->order[1]] = newWindow->start2[newWindow->order[1]];
385 for(
MInt j = newWindow->start1[1]; j <= newWindow->end1[1]; j = j + newWindow->step1[1]) {
386 pos2[newWindow->order[0]] = newWindow->start2[newWindow->order[0]];
387 for(
MInt i = newWindow->start1[0]; i <= newWindow->end1[0]; i = i + newWindow->step1[0]) {
391 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
397 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
398 found = findConnection(temp2);
401 cout <<
"error!! can not delete the element!!!" << endl;
402 cout <<
"BC: " << newWindow->BC <<
" id1:" << newWindow->Id1 <<
" id1:" << newWindow->Id2 << endl;
403 cout <<
"i: " << i <<
" iend:" << newWindow->end1[0] <<
" j: " << j <<
" jend:" << newWindow->end1[1] << endl;
407 removeConnection(temp2);
408 countConnection = countConnection + 1;
411 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
413 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
417 if(!mapCheck(newWindow)) {
418 cout <<
"invalid window!" << endl;
422 for(
MInt i = 0; i < nDim; ++i) {
423 if(newWindow->end1[i] - newWindow->start1[i] != 0) {
430 window1d.push_back(std::move(newWindow));
435 window0d.push_back(std::move(newWindow));
440 cout <<
"ERROR!!! face dim is wrong!!!" << endl;
444 m_log <<
"Connection Statistics: " << numWindows[1] <<
" 1D-, and " << numWindows[0] <<
" 0D-connections found"
456 MInt countConnection = 0, numConnections = 0, Nstar;
457 unique_ptr<StructuredWindowMap<nDim>> newWindow;
458 MBool found, notexisted, labell;
460 MInt numWindows[nDim]{};
461 numConnections = singularconnectionset.size();
465 while(singularconnectionset.size() != 0) {
466 auto element = singularconnectionset.begin();
467 MInt order[2] = {-1, -1};
468 MInt step1[2] = {1, 1};
469 MInt step2[2] = {1, 1};
470 MInt pos1[3], pos2[3], b1, b2;
480 newWindow = make_unique<StructuredWindowMap<nDim>>();
481 mapCreate(b1, pos1, pos1, step1, b2, pos2, pos2, step2, order,
element->BC, newWindow);
482 newWindow->Nstar = Nstar;
484 for(
MInt i = 0; i < nDim; ++i) {
486 pos1[0] = newWindow->start1[0];
487 pos1[1] = newWindow->start1[1];
489 if(newWindow->order[i] == -1) {
492 pos1[i] = newWindow->start1[i] + 1;
493 for(
MInt j = 0; j < nDim; ++j) {
495 pos2[0] = newWindow->start2[0];
496 pos2[1] = newWindow->start2[1];
499 for(
MInt k = 0; k < nDim; ++k) {
500 if(newWindow->order[k] == j) {
506 pos2[j] = newWindow->start2[j] + 1;
508 temp1.
BC = newWindow->BC;
511 temp1.
pos1[0] = pos1[0];
512 temp1.
pos1[1] = pos1[1];
513 temp1.
pos2[0] = pos2[0];
514 temp1.
pos2[1] = pos2[1];
516 found = findConnection(temp1, Nstar);
519 newWindow->step1[i] = 1;
520 newWindow->step2[j] = 1;
521 newWindow->order[i] = j;
526 pos2[j] = newWindow->start2[j] - 1;
528 temp1.
BC = newWindow->BC;
531 temp1.
pos1[0] = pos1[0];
532 temp1.
pos1[1] = pos1[1];
533 temp1.
pos2[0] = pos2[0];
534 temp1.
pos2[1] = pos2[1];
536 found = findConnection(temp1, Nstar);
539 newWindow->step1[i] = 1;
540 newWindow->step2[j] = -1;
541 newWindow->order[i] = j;
551 pos1[i] = newWindow->start1[i] - 1;
552 for(
MInt j = 0; j < nDim; ++j) {
554 pos2[0] = newWindow->start2[0];
555 pos2[1] = newWindow->start2[1];
558 for(
MInt k = 0; k < nDim; ++k) {
559 if(newWindow->order[k] == j) notexisted =
false;
563 pos2[j] = newWindow->start2[j] + 1;
564 temp1.
BC = newWindow->BC;
567 temp1.
pos1[0] = pos1[0];
568 temp1.
pos1[1] = pos1[1];
569 temp1.
pos2[0] = pos2[0];
570 temp1.
pos2[1] = pos2[1];
572 found = findConnection(temp1, Nstar);
575 newWindow->step1[i] = -1;
576 newWindow->step2[j] = 1;
577 newWindow->order[i] = j;
581 pos2[j] = newWindow->start2[j] - 1;
582 temp1.
BC = newWindow->BC;
585 temp1.
pos1[0] = pos1[0];
586 temp1.
pos1[1] = pos1[1];
587 temp1.
pos2[0] = pos2[0];
588 temp1.
pos2[1] = pos2[1];
590 found = findConnection(temp1, Nstar);
593 newWindow->step1[i] = -1;
594 newWindow->step2[j] = -1;
595 newWindow->order[i] = j;
607 MBool facewindow, directionInWindow[nDim];
609 for(
MInt i = 0; i < nDim; ++i) {
610 directionInWindow[i] =
false;
611 if(newWindow->order[i] != -1) {
613 directionInWindow[i] =
true;
617 ASSERT(ordercount == 0,
"In 2D only ordercount==0 makes sense!");
620 cout <<
"Invalid volume mapping found! "
621 <<
"Are your blockIds overlapping or is the grid epsilon too large?" << endl;
624 if(ordercount == 2) {
630 for(
MInt i = 0; i < nDim; ++i) {
632 if(newWindow->order[i] == -1) {
633 for(j = 0; j < nDim; ++j) {
635 for(
MInt k = 0; k < nDim; ++k) {
636 if(newWindow->order[k] == j) {
641 newWindow->order[i] = j;
647 if(newWindow->start1[i] == 0) {
648 newWindow->dc1 = i + 1;
650 newWindow->dc1 = -i - 1;
653 if(newWindow->start2[j] == 0) {
654 newWindow->dc2 = j + 1;
656 newWindow->dc2 = -j - 1;
659 newWindow->dc1 = 999;
660 newWindow->dc2 = 999;
665 MInt start1[2], end1[2], start2[2], end2[2];
667 MInt countDim, countDim2;
672 for(countDim = 0; countDim < nDim; ++countDim) {
673 if(directionInWindow[countDim]) {
674 countDim2 = newWindow->order[countDim];
675 for(
MInt i = 0; i < nDim; ++i) {
676 start1[i] = newWindow->start1[i];
677 end1[i] = newWindow->end1[i];
678 start2[i] = newWindow->start2[i];
679 end2[i] = newWindow->end2[i];
681 end1[countDim] = end1[countDim] + newWindow->step1[countDim];
682 end2[countDim2] = end2[countDim2] + newWindow->step2[countDim2];
683 start1[countDim] = end1[countDim];
684 start2[countDim2] = end2[countDim2];
686 pos2[newWindow->order[1]] = start2[newWindow->order[1]];
689 pos2[newWindow->order[0]] = start2[newWindow->order[0]];
694 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
700 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
702 found = findConnection(temp2, Nstar);
707 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
708 ii = ii + newWindow->step1[0];
710 }
while(ii >= start1[0] && ii <= end1[0]);
711 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
712 jj = jj + newWindow->step1[1];
714 }
while(jj >= start1[1] && jj <= end1[1]);
718 for(
MInt m = 0; m < nDim; ++m) {
719 newWindow->end1[m] = end1[m];
720 newWindow->end2[m] = end2[m];
725 for(
MInt i = 0; i < nDim; ++i) {
726 start1[i] = newWindow->start1[i];
727 end1[i] = newWindow->end1[i];
728 start2[i] = newWindow->start2[i];
729 end2[i] = newWindow->end2[i];
732 start1[countDim] = start1[countDim] - newWindow->step1[countDim];
733 start2[countDim2] = start2[countDim2] - newWindow->step2[countDim2];
734 end1[countDim] = start1[countDim];
735 end2[countDim2] = start2[countDim2];
737 pos2[newWindow->order[1]] = start2[newWindow->order[1]];
740 pos2[newWindow->order[0]] = start2[newWindow->order[0]];
746 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
752 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
754 found = findConnection(temp2, Nstar);
760 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
761 ii = ii + newWindow->step1[0];
763 }
while(ii >= start1[0] && ii <= end1[0]);
764 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
765 jj = jj + newWindow->step1[1];
767 }
while(jj >= start1[1] && jj <= end1[1]);
771 for(
MInt m = 0; m < nDim; ++m) {
772 newWindow->start1[m] = start1[m];
773 newWindow->start2[m] = start2[m];
782 if(newWindow->BC >= 6000 && newWindow->BC < 6010
785 mapInvert1(newWindow);
787 mapNormalize3(newWindow);
790 pos2[newWindow->order[1]] = newWindow->start2[newWindow->order[1]];
791 for(
MInt j = newWindow->start1[1]; j <= newWindow->end1[1]; j = j + newWindow->step1[1]) {
792 pos2[newWindow->order[0]] = newWindow->start2[newWindow->order[0]];
793 for(
MInt i = newWindow->start1[0]; i <= newWindow->end1[0]; i = i + newWindow->step1[0]) {
797 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
803 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
805 found = findConnection(temp2, Nstar);
808 cout <<
"singular error!! can not delete the element!!!" << endl;
811 removeConnection(temp2, Nstar);
813 countConnection = countConnection + 1;
815 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
817 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
821 newWindow->SingularId = numWindows[0];
822 singularwindow.push_back(std::move(newWindow));
825 if(domainId() == 0) {
826 cout << numWindows[0] <<
" singular connections found (" << countConnection * 100 / numConnections <<
"% done)"
836 MInt countConnection = 0;
837 unique_ptr<StructuredWindowMap<nDim>> newWindow;
838 MBool found, notexisted, labell;
840 MInt numWindows[3] = {0, 0, 0};
845 while(connectionset.size() != 0) {
846 auto element = connectionset.begin();
847 MInt order[3] = {-1, -1, -1};
848 MInt step1[3] = {1, 1, 1};
849 MInt step2[3] = {1, 1, 1};
850 MInt pos1[3], pos2[3], b1, b2;
861 newWindow = make_unique<StructuredWindowMap<nDim>>();
862 mapCreate(b1, pos1, pos1, step1, b2, pos2, pos2, step2, order,
element->BC, newWindow);
863 newWindow->Nstar = -1;
865 for(
MInt i = 0; i < nDim; ++i) {
867 pos1[0] = newWindow->start1[0];
868 pos1[1] = newWindow->start1[1];
869 pos1[2] = newWindow->start1[2];
871 if(newWindow->order[i] == -1) {
874 pos1[i] = newWindow->start1[i] + 1;
875 for(
MInt j = 0; j < nDim; ++j) {
877 pos2[0] = newWindow->start2[0];
878 pos2[1] = newWindow->start2[1];
879 pos2[2] = newWindow->start2[2];
882 for(
MInt k = 0; k < nDim; ++k) {
883 if(newWindow->order[k] == j) notexisted =
false;
887 pos2[j] = newWindow->start2[j] + 1;
889 temp1.
BC = newWindow->BC;
892 temp1.
pos1[0] = pos1[0];
893 temp1.
pos1[1] = pos1[1];
894 temp1.
pos1[2] = pos1[2];
895 temp1.
pos2[0] = pos2[0];
896 temp1.
pos2[1] = pos2[1];
897 temp1.
pos2[2] = pos2[2];
899 found = findConnection(temp1);
902 newWindow->step1[i] = 1;
903 newWindow->step2[j] = 1;
904 newWindow->order[i] = j;
909 pos2[j] = newWindow->start2[j] - 1;
910 temp1.
BC = newWindow->BC;
913 temp1.
pos1[0] = pos1[0];
914 temp1.
pos1[1] = pos1[1];
915 temp1.
pos1[2] = pos1[2];
916 temp1.
pos2[0] = pos2[0];
917 temp1.
pos2[1] = pos2[1];
918 temp1.
pos2[2] = pos2[2];
920 found = findConnection(temp1);
922 newWindow->step1[i] = 1;
923 newWindow->step2[j] = -1;
924 newWindow->order[i] = j;
935 pos1[i] = newWindow->start1[i] - 1;
936 for(
MInt j = 0; j < nDim; ++j) {
938 pos2[0] = newWindow->start2[0];
939 pos2[1] = newWindow->start2[1];
940 pos2[2] = newWindow->start2[2];
942 for(
MInt k = 0; k < nDim; ++k) {
943 if(newWindow->order[k] == j) {
949 pos2[j] = newWindow->start2[j] + 1;
950 temp1.
BC = newWindow->BC;
953 temp1.
pos1[0] = pos1[0];
954 temp1.
pos1[1] = pos1[1];
955 temp1.
pos1[2] = pos1[2];
956 temp1.
pos2[0] = pos2[0];
957 temp1.
pos2[1] = pos2[1];
958 temp1.
pos2[2] = pos2[2];
960 found = findConnection(temp1);
963 newWindow->step1[i] = -1;
964 newWindow->step2[j] = 1;
965 newWindow->order[i] = j;
970 pos2[j] = newWindow->start2[j] - 1;
971 temp1.
BC = newWindow->BC;
974 temp1.
pos1[0] = pos1[0];
975 temp1.
pos1[1] = pos1[1];
976 temp1.
pos1[2] = pos1[2];
977 temp1.
pos2[0] = pos2[0];
978 temp1.
pos2[1] = pos2[1];
979 temp1.
pos2[2] = pos2[2];
981 found = findConnection(temp1);
984 newWindow->step1[i] = -1;
985 newWindow->step2[j] = -1;
986 newWindow->order[i] = j;
998 MBool facewindow, directionInWindow[3];
999 for(
MInt i = 0; i < nDim; ++i) {
1000 directionInWindow[i] =
false;
1001 if(newWindow->order[i] != -1) {
1003 directionInWindow[i] =
true;
1007 if(ordercount > 2) {
1008 cout <<
"Invalid volume mapping found! Are your blockIds overlapping or is the grid epsilon too large?" << endl;
1011 if(ordercount == 2) {
1017 for(
MInt i = 0; i < nDim; ++i) {
1020 if(newWindow->order[i] == -1) {
1021 for(j = 0; j < nDim; ++j) {
1023 for(
MInt k = 0; k < nDim; ++k) {
1024 if(newWindow->order[k] == j) {
1029 if(labell ==
true) {
1030 newWindow->order[i] = j;
1036 if(newWindow->start1[i] == 0) {
1037 newWindow->dc1 = i + 1;
1039 newWindow->dc1 = -i - 1;
1042 if(newWindow->start2[j] == 0) {
1043 newWindow->dc2 = j + 1;
1045 newWindow->dc2 = -j - 1;
1048 newWindow->dc1 = 999;
1049 newWindow->dc2 = 999;
1054 MInt start1[3], end1[3], start2[3], end2[3];
1056 MInt countDim, countDim2;
1060 for(countDim = 0; countDim < nDim; ++countDim) {
1061 if(directionInWindow[countDim]) {
1062 countDim2 = newWindow->order[countDim];
1064 for(
MInt i = 0; i < nDim; ++i) {
1065 start1[i] = newWindow->start1[i];
1066 end1[i] = newWindow->end1[i];
1067 start2[i] = newWindow->start2[i];
1068 end2[i] = newWindow->end2[i];
1070 end1[countDim] = end1[countDim] + newWindow->step1[countDim];
1071 end2[countDim2] = end2[countDim2] + newWindow->step2[countDim2];
1072 start1[countDim] = end1[countDim];
1073 start2[countDim2] = end2[countDim2];
1075 pos2[newWindow->order[2]] = start2[newWindow->order[2]];
1078 pos2[newWindow->order[1]] = start2[newWindow->order[1]];
1081 pos2[newWindow->order[0]] = start2[newWindow->order[0]];
1087 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
1093 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
1094 found = findConnection(temp2);
1096 if(!found && domainId() == 0 && newWindow->BC == 4401 && newWindow->Id1 == 2 && newWindow->Id2 != 2) {
1098 connectionNode temp3(newWindow->BC, newWindow->Id2, pos2, newWindow->Id1, pos1, labell, nDim);
1099 found = findConnection(temp3);
1102 cout <<
"wooooo!! somthing is wrong and i do not know where and why!!!!!!" << endl;
1108 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
1109 ii = ii + newWindow->step1[0];
1111 }
while(ii >= start1[0] && ii <= end1[0]);
1112 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
1113 jj = jj + newWindow->step1[1];
1115 }
while(jj >= start1[1] && jj <= end1[1]);
1116 pos2[newWindow->order[2]] = pos2[newWindow->order[2]] + newWindow->step2[newWindow->order[2]];
1117 kk = kk + newWindow->step1[2];
1119 }
while(kk >= start1[2] && kk <= end1[2]);
1123 for(
MInt m = 0; m < nDim; ++m) {
1124 newWindow->end1[m] = end1[m];
1125 newWindow->end2[m] = end2[m];
1130 for(
MInt i = 0; i < nDim; ++i) {
1131 start1[i] = newWindow->start1[i];
1132 end1[i] = newWindow->end1[i];
1133 start2[i] = newWindow->start2[i];
1134 end2[i] = newWindow->end2[i];
1136 start1[countDim] = start1[countDim] - newWindow->step1[countDim];
1137 start2[countDim2] = start2[countDim2] - newWindow->step2[countDim2];
1138 end1[countDim] = start1[countDim];
1139 end2[countDim2] = start2[countDim2];
1141 pos2[newWindow->order[2]] = start2[newWindow->order[2]];
1144 pos2[newWindow->order[1]] = start2[newWindow->order[1]];
1147 pos2[newWindow->order[0]] = start2[newWindow->order[0]];
1153 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
1159 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
1160 found = findConnection(temp2);
1162 if(!found && domainId() == 0 && newWindow->BC == 4401 && newWindow->Id1 == 2 && newWindow->Id2 != 2) {
1163 connectionNode temp3(newWindow->BC, newWindow->Id2, pos2, newWindow->Id1, pos1, labell, nDim);
1164 found = findConnection(temp3);
1166 cout <<
"wooooo!! somthing is wrong and i do not know where and why!!!!!!" << endl;
1172 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
1173 ii = ii + newWindow->step1[0];
1175 }
while(ii >= start1[0] && ii <= end1[0]);
1176 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
1177 jj = jj + newWindow->step1[1];
1179 }
while(jj >= start1[1] && jj <= end1[1]);
1180 pos2[newWindow->order[2]] = pos2[newWindow->order[2]] + newWindow->step2[newWindow->order[2]];
1181 kk = kk + newWindow->step1[2];
1183 }
while(kk >= start1[2] && kk <= end1[2]);
1188 for(
MInt m = 0; m < nDim; ++m) {
1189 newWindow->start1[m] = start1[m];
1190 newWindow->start2[m] = start2[m];
1198 if(newWindow->BC >= 6000 && newWindow->BC < 6010
1201 mapInvert1(newWindow);
1203 mapNormalize3(newWindow);
1206 pos2[newWindow->order[2]] = newWindow->start2[newWindow->order[2]];
1207 for(
MInt k = newWindow->start1[2]; k <= newWindow->end1[2]; k = k + newWindow->step1[2]) {
1208 pos2[newWindow->order[1]] = newWindow->start2[newWindow->order[1]];
1209 for(
MInt j = newWindow->start1[1]; j <= newWindow->end1[1]; j = j + newWindow->step1[1]) {
1210 pos2[newWindow->order[0]] = newWindow->start2[newWindow->order[0]];
1211 for(
MInt i = newWindow->start1[0]; i <= newWindow->end1[0]; i = i + newWindow->step1[0]) {
1216 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
1222 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
1223 found = findConnection(temp2);
1226 cout <<
"error!! can not delete the element!!!" << endl;
1227 cout <<
"BC: " << newWindow->BC <<
" id1:" << newWindow->Id1 <<
" id1:" << newWindow->Id2 << endl;
1228 cout <<
"i: " << i <<
" iend:" << newWindow->end1[0] <<
" j: " << j <<
" jend:" << newWindow->end1[1]
1229 <<
" k: " << k <<
" kend:" << newWindow->end1[2] << endl;
1233 removeConnection(temp2);
1234 countConnection = countConnection + 1;
1237 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
1239 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
1241 pos2[newWindow->order[2]] = pos2[newWindow->order[2]] + newWindow->step2[newWindow->order[2]];
1245 if(!mapCheck(newWindow)) {
1246 cout <<
"invalid window!" << endl;
1250 for(
MInt i = 0; i < nDim; ++i) {
1251 if(newWindow->end1[i] - newWindow->start1[i] != 0) {
1258 window2d.push_back(std::move(newWindow));
1263 window1d.push_back(std::move(newWindow));
1268 window0d.push_back(std::move(newWindow));
1273 cout <<
"ERROR!!! face dim is wrong!!!" << endl;
1277 m_log <<
"Connection Statistics: " << numWindows[2] <<
" 2D-, " << numWindows[1] <<
" 1D-, and " << numWindows[0]
1278 <<
" 0D-connections found" << endl;
1283 const MInt nDim = 3;
1285 MInt countConnection = 0, numConnections = 0, Nstar;
1286 unique_ptr<StructuredWindowMap<nDim>> newWindow;
1287 MBool found, notexisted, labell;
1289 MInt numWindows[3] = {0, 0, 0};
1290 numConnections = singularconnectionset.size();
1294 while(singularconnectionset.size() != 0) {
1295 auto element = singularconnectionset.begin();
1296 MInt order[3] = {-1, -1, -1};
1297 MInt step1[3] = {1, 1, 1};
1298 MInt step2[3] = {1, 1, 1};
1299 MInt pos1[3], pos2[3], b1, b2;
1311 newWindow = make_unique<StructuredWindowMap<nDim>>();
1312 mapCreate(b1, pos1, pos1, step1, b2, pos2, pos2, step2, order,
element->BC, newWindow);
1313 newWindow->Nstar = Nstar;
1315 for(
MInt i = 0; i < nDim; ++i) {
1317 pos1[0] = newWindow->start1[0];
1318 pos1[1] = newWindow->start1[1];
1319 pos1[2] = newWindow->start1[2];
1321 if(newWindow->order[i] == -1) {
1324 pos1[i] = newWindow->start1[i] + 1;
1325 for(
MInt j = 0; j < nDim; ++j) {
1327 pos2[0] = newWindow->start2[0];
1328 pos2[1] = newWindow->start2[1];
1329 pos2[2] = newWindow->start2[2];
1332 for(
MInt k = 0; k < nDim; ++k) {
1333 if(newWindow->order[k] == j) {
1339 pos2[j] = newWindow->start2[j] + 1;
1341 temp1.
BC = newWindow->BC;
1344 temp1.
pos1[0] = pos1[0];
1345 temp1.
pos1[1] = pos1[1];
1346 temp1.
pos1[2] = pos1[2];
1347 temp1.
pos2[0] = pos2[0];
1348 temp1.
pos2[1] = pos2[1];
1349 temp1.
pos2[2] = pos2[2];
1350 temp1.
Nstar = Nstar;
1351 found = findConnection(temp1, Nstar);
1354 newWindow->step1[i] = 1;
1355 newWindow->step2[j] = 1;
1356 newWindow->order[i] = j;
1361 pos2[j] = newWindow->start2[j] - 1;
1363 temp1.
BC = newWindow->BC;
1366 temp1.
pos1[0] = pos1[0];
1367 temp1.
pos1[1] = pos1[1];
1368 temp1.
pos1[2] = pos1[2];
1369 temp1.
pos2[0] = pos2[0];
1370 temp1.
pos2[1] = pos2[1];
1371 temp1.
pos2[2] = pos2[2];
1372 temp1.
Nstar = Nstar;
1373 found = findConnection(temp1, Nstar);
1376 newWindow->step1[i] = 1;
1377 newWindow->step2[j] = -1;
1378 newWindow->order[i] = j;
1388 pos1[i] = newWindow->start1[i] - 1;
1389 for(
MInt j = 0; j < nDim; ++j) {
1391 pos2[0] = newWindow->start2[0];
1392 pos2[1] = newWindow->start2[1];
1393 pos2[2] = newWindow->start2[2];
1396 for(
MInt k = 0; k < nDim; ++k) {
1397 if(newWindow->order[k] == j) notexisted =
false;
1401 pos2[j] = newWindow->start2[j] + 1;
1402 temp1.
BC = newWindow->BC;
1405 temp1.
pos1[0] = pos1[0];
1406 temp1.
pos1[1] = pos1[1];
1407 temp1.
pos1[2] = pos1[2];
1408 temp1.
pos2[0] = pos2[0];
1409 temp1.
pos2[1] = pos2[1];
1410 temp1.
pos2[2] = pos2[2];
1411 temp1.
Nstar = Nstar;
1412 found = findConnection(temp1, Nstar);
1415 newWindow->step1[i] = -1;
1416 newWindow->step2[j] = 1;
1417 newWindow->order[i] = j;
1421 pos2[j] = newWindow->start2[j] - 1;
1422 temp1.
BC = newWindow->BC;
1425 temp1.
pos1[0] = pos1[0];
1426 temp1.
pos1[1] = pos1[1];
1427 temp1.
pos1[2] = pos1[2];
1428 temp1.
pos2[0] = pos2[0];
1429 temp1.
pos2[1] = pos2[1];
1430 temp1.
pos2[2] = pos2[2];
1431 temp1.
Nstar = Nstar;
1432 found = findConnection(temp1, Nstar);
1435 newWindow->step1[i] = -1;
1436 newWindow->step2[j] = -1;
1437 newWindow->order[i] = j;
1448 MInt ordercount = 0;
1449 MBool facewindow, directionInWindow[3];
1451 for(
MInt i = 0; i < nDim; ++i) {
1452 directionInWindow[i] =
false;
1453 if(newWindow->order[i] != -1) {
1455 directionInWindow[i] =
true;
1459 if(ordercount > 2) {
1460 cout <<
"Invalid volume mapping found! "
1461 <<
"Are your blockIds overlapping or is the grid epsilon too large?" << endl;
1464 if(ordercount == 2) {
1470 for(
MInt i = 0; i < nDim; ++i) {
1472 if(newWindow->order[i] == -1) {
1473 for(j = 0; j < nDim; ++j) {
1475 for(
MInt k = 0; k < nDim; ++k) {
1476 if(newWindow->order[k] == j) {
1480 if(labell ==
true) {
1481 newWindow->order[i] = j;
1487 if(newWindow->start1[i] == 0) {
1488 newWindow->dc1 = i + 1;
1490 newWindow->dc1 = -i - 1;
1493 if(newWindow->start2[j] == 0) {
1494 newWindow->dc2 = j + 1;
1496 newWindow->dc2 = -j - 1;
1499 newWindow->dc1 = 999;
1500 newWindow->dc2 = 999;
1505 MInt start1[3], end1[3], start2[3], end2[3];
1507 MInt countDim, countDim2;
1512 for(countDim = 0; countDim < nDim; ++countDim) {
1513 if(directionInWindow[countDim]) {
1514 countDim2 = newWindow->order[countDim];
1515 for(
MInt i = 0; i < nDim; ++i) {
1516 start1[i] = newWindow->start1[i];
1517 end1[i] = newWindow->end1[i];
1518 start2[i] = newWindow->start2[i];
1519 end2[i] = newWindow->end2[i];
1521 end1[countDim] = end1[countDim] + newWindow->step1[countDim];
1522 end2[countDim2] = end2[countDim2] + newWindow->step2[countDim2];
1523 start1[countDim] = end1[countDim];
1524 start2[countDim2] = end2[countDim2];
1526 pos2[newWindow->order[2]] = start2[newWindow->order[2]];
1530 pos2[newWindow->order[1]] = start2[newWindow->order[1]];
1533 pos2[newWindow->order[0]] = start2[newWindow->order[0]];
1539 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
1545 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
1546 temp2.
Nstar = Nstar;
1547 found = findConnection(temp2, Nstar);
1552 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
1553 ii = ii + newWindow->step1[0];
1555 }
while(ii >= start1[0] && ii <= end1[0]);
1556 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
1557 jj = jj + newWindow->step1[1];
1559 }
while(jj >= start1[1] && jj <= end1[1]);
1560 pos2[newWindow->order[2]] = pos2[newWindow->order[2]] + newWindow->step2[newWindow->order[2]];
1561 kk = kk + newWindow->step1[2];
1563 }
while(kk >= start1[2] && kk <= end1[2]);
1567 for(
MInt m = 0; m < nDim; ++m) {
1568 newWindow->end1[m] = end1[m];
1569 newWindow->end2[m] = end2[m];
1574 for(
MInt i = 0; i < nDim; ++i) {
1575 start1[i] = newWindow->start1[i];
1576 end1[i] = newWindow->end1[i];
1577 start2[i] = newWindow->start2[i];
1578 end2[i] = newWindow->end2[i];
1581 start1[countDim] = start1[countDim] - newWindow->step1[countDim];
1582 start2[countDim2] = start2[countDim2] - newWindow->step2[countDim2];
1583 end1[countDim] = start1[countDim];
1584 end2[countDim2] = start2[countDim2];
1586 pos2[newWindow->order[2]] = start2[newWindow->order[2]];
1590 pos2[newWindow->order[1]] = start2[newWindow->order[1]];
1593 pos2[newWindow->order[0]] = start2[newWindow->order[0]];
1600 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
1606 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
1607 temp2.
Nstar = Nstar;
1608 found = findConnection(temp2, Nstar);
1614 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
1615 ii = ii + newWindow->step1[0];
1617 }
while(ii >= start1[0] && ii <= end1[0]);
1618 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
1619 jj = jj + newWindow->step1[1];
1621 }
while(jj >= start1[1] && jj <= end1[1]);
1622 pos2[newWindow->order[2]] = pos2[newWindow->order[2]] + newWindow->step2[newWindow->order[2]];
1623 kk = kk + newWindow->step1[2];
1625 }
while(kk >= start1[2] && kk <= end1[2]);
1629 for(
MInt m = 0; m < nDim; ++m) {
1630 newWindow->start1[m] = start1[m];
1631 newWindow->start2[m] = start2[m];
1640 if(newWindow->BC >= 6000 && newWindow->BC < 6010
1643 mapInvert1(newWindow);
1645 mapNormalize3(newWindow);
1648 pos2[newWindow->order[2]] = newWindow->start2[newWindow->order[2]];
1649 for(
MInt k = newWindow->start1[2]; k <= newWindow->end1[2]; k = k + newWindow->step1[2]) {
1650 pos2[newWindow->order[1]] = newWindow->start2[newWindow->order[1]];
1651 for(
MInt j = newWindow->start1[1]; j <= newWindow->end1[1]; j = j + newWindow->step1[1]) {
1652 pos2[newWindow->order[0]] = newWindow->start2[newWindow->order[0]];
1653 for(
MInt i = newWindow->start1[0]; i <= newWindow->end1[0]; i = i + newWindow->step1[0]) {
1658 if(newWindow->BC >= 6000 && newWindow->BC < 6010) {
1664 connectionNode temp2(newWindow->BC, newWindow->Id1, pos1, newWindow->Id2, pos2, labell, nDim);
1665 temp2.
Nstar = Nstar;
1666 found = findConnection(temp2, Nstar);
1669 cout <<
"singular error!! can not delete the element!!!" << endl;
1672 removeConnection(temp2, Nstar);
1674 countConnection = countConnection + 1;
1676 pos2[newWindow->order[0]] = pos2[newWindow->order[0]] + newWindow->step2[newWindow->order[0]];
1678 pos2[newWindow->order[1]] = pos2[newWindow->order[1]] + newWindow->step2[newWindow->order[1]];
1680 pos2[newWindow->order[2]] = pos2[newWindow->order[2]] + newWindow->step2[newWindow->order[2]];
1684 newWindow->SingularId = numWindows[0];
1685 singularwindow.push_back(std::move(newWindow));
1688 if(domainId() == 0) {
1689 cout << numWindows[0] <<
" singular connections found (" << countConnection * 100 / numConnections <<
"% done)"
1697 constexpr MInt nDim = 3;
1699 MInt hasConnectionInfo = 0;
1703 if(attributeExists) {
1704 m_log <<
"Grid file has connection info!" << endl;
1705 pio.
getAttribute(&hasConnectionInfo,
"hasConnectionInfo",
"Connectivity");
1707 MPI_Bcast(&hasConnectionInfo, 1, MPI_INT, 0, m_StructuredComm, AT_,
"hasConnectionInfo");
1709 MPI_Bcast(&hasConnectionInfo, 1, MPI_INT, 0, m_StructuredComm, AT_,
"hasConnectionInfo");
1712 MBool readInConnectionInfo =
true;
1714 if(!hasConnectionInfo) {
1715 readInConnectionInfo =
false;
1718 readInConnectionInfo =
1719 Context::getSolverProperty<MBool>(
"readInConnectionInfo", solverId(), AT_, &readInConnectionInfo);
1723 if(readInConnectionInfo) {
1724 m_log <<
"Connection info available, reading connection information from grid file!" << endl;
1725 readConnectionWindowInformation3D(periodicDisplacements);
1727 if(domainId() == 0) {
1728 cout <<
"Starting grid connection info search..." << endl;
1730 m_log <<
" Starting grid connection info search..." << endl;
1731 MInt offset[3], size[3], count = 0;
1735 MInt totalGridCells = 0;
1736 MInt** totalGridBlockDim =
nullptr;
1737 MInt* totalGridBlockCells =
nullptr;
1739 mAlloc(totalGridBlockDim, m_noBlocks, 3,
"totalGridBlockDim", -1, AT_);
1740 mAlloc(totalGridBlockCells, m_noBlocks,
"totalGridBlockCells", -1, AT_);
1742 for(
MInt i = 0; i < m_noBlocks; ++i) {
1744 for(
MInt dim = 0; dim < 3; ++dim) {
1745 temp *= m_grid->getBlockNoCells(i, dim) + 1;
1746 totalGridBlockDim[i][dim] = m_grid->getBlockNoCells(i, dim) + 1;
1748 totalGridBlockCells[i] = temp;
1749 if(temp != 1) totalGridCells += temp;
1753 for(
MInt i = 0; i < m_noBlocks; i++) {
1754 countNode = countNode + 2 * totalGridBlockDim[i][1] * totalGridBlockDim[i][2]
1755 + 2 * totalGridBlockDim[i][2] * (totalGridBlockDim[i][0] - 2)
1756 + 2 * (totalGridBlockDim[i][0] - 2) * (totalGridBlockDim[i][1] - 2);
1760 coordinates.
fill(-1.01010101);
1761 std::vector<pointType<nDim>> nodeMap;
1762 nodeMap.resize(countNode);
1766 const MInt converter[] = {2, 1, 0};
1767 auto getCurrentWindow = [
this, converter](
const MInt blockId,
const MInt*
const offset_,
const MInt*
const size_) {
1768 std::vector<MInt> currentWindows;
1769 for(
MInt windowId = 0; windowId < noInputWindowInformation; ++windowId) {
1770 if(inputWindows[windowId]->blockId != blockId)
continue;
1771 if(inputWindows[windowId]->BC < 6000 || inputWindows[windowId]->BC >= 6010)
continue;
1773 MBool takeIt =
true;
1774 for(
MInt dim = 0; dim < nDim; ++dim) {
1775 if(inputWindows[windowId]->startindex[dim] >= offset_[converter[dim]] + size_[converter[dim]]
1776 || inputWindows[windowId]->endindex[dim] < offset_[converter[dim]]) {
1781 if(takeIt) currentWindows.push_back(windowId);
1783 return currentWindows;
1785 std::vector<MInt> pointsFoundPerWindow(noInputWindowInformation);
1786 auto getBCFromWindow = [
this, &pointsFoundPerWindow](
const MInt idx[nDim],
1787 const std::vector<MInt>& currentWindows) {
1788 std::vector<MInt> BCset;
1793 for(
auto windowId : currentWindows) {
1794 MBool takeIt =
true;
1795 for(
MInt dim = 0; dim < nDim; ++dim) {
1796 if(inputWindows[windowId]->startindex[dim] > idx[dim] || inputWindows[windowId]->endindex[dim] < idx[dim]) {
1802 ++pointsFoundPerWindow[windowId];
1803 BCset.push_back(inputWindows[windowId]->BC);
1812 if(BCset.size() > 3)
mTerm(1,
"");
1813 if(BCset.size() == 0) BCset.push_back(6000);
1814 MInt BC[3] = {0, 0, 0};
1816 for(
auto it = BCset.begin(); it != BCset.end(); ++it)
1818 return std::tuple<MInt, MInt, MInt>(BC[0], BC[1], BC[2]);
1823 if(domainId() == 0) {
1824 cout <<
"Reading in all coordinates of all block faces" << endl;
1829 for(
MInt i = 0; i < m_noBlocks; ++i) {
1831 stringstream number;
1833 bName += number.str();
1835 ParallelIo::size_type ioOffset[3] = {0, 0, 0};
1836 ParallelIo::size_type ioSize[3] = {0, 0, 0};
1843 if(m_domainId == 0) {
1847 ioSize[1] = m_grid->getBlockNoCells(i, 1) + 1;
1849 ioSize[0] = m_grid->getBlockNoCells(i, 0) + 1;
1851 pio.
readArray(&coordinates(0, memsize), bName,
"x", 3, ioOffset, ioSize);
1852 pio.
readArray(&coordinates(1, memsize), bName,
"y", 3, ioOffset, ioSize);
1853 pio.
readArray(&coordinates(2, memsize), bName,
"z", 3, ioOffset, ioSize);
1863 pio.
readArray(&empty, bName,
"x", 3, ioOffset, ioSize);
1864 pio.
readArray(&empty, bName,
"y", 3, ioOffset, ioSize);
1865 pio.
readArray(&empty, bName,
"z", 3, ioOffset, ioSize);
1867 for(
int dim = 0; dim < 3; ++dim) {
1868 offset[dim] = ioOffset[dim];
1869 size[dim] = ioSize[dim];
1872 std::vector<MInt> currentWindows = getCurrentWindow(i, offset, size);
1876 for(
MInt a = offset[2];
a < offset[2] + size[2]; ++
a) {
1877 for(
MInt c = offset[0]; c < offset[0] + size[0]; ++c) {
1878 for(
MInt b = offset[1];
b < offset[1] + size[1]; ++
b) {
1879 nodeMap[count].blockId = i;
1880 nodeMap[count].pos[0] =
a;
1881 nodeMap[count].pos[1] =
b;
1882 nodeMap[count].pos[2] = c;
1883 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1], nodeMap[count].BC[2]) =
1884 getBCFromWindow(nodeMap[count].pos, currentWindows);
1889 memsize += size[0] * size[1] * size[2];
1895 if(m_domainId == 0) {
1896 ioOffset[2] = m_grid->getBlockNoCells(i, 2);
1899 ioSize[1] = m_grid->getBlockNoCells(i, 1) + 1;
1901 ioSize[0] = m_grid->getBlockNoCells(i, 0) + 1;
1902 pio.
readArray(&coordinates(0, memsize), bName,
"x", 3, ioOffset, ioSize);
1903 pio.
readArray(&coordinates(1, memsize), bName,
"y", 3, ioOffset, ioSize);
1904 pio.
readArray(&coordinates(2, memsize), bName,
"z", 3, ioOffset, ioSize);
1913 pio.
readArray(&empty, bName,
"x", 3, ioOffset, ioSize);
1914 pio.
readArray(&empty, bName,
"y", 3, ioOffset, ioSize);
1915 pio.
readArray(&empty, bName,
"z", 3, ioOffset, ioSize);
1917 for(
int dim = 0; dim < 3; ++dim) {
1918 offset[dim] = ioOffset[dim];
1919 size[dim] = ioSize[dim];
1922 currentWindows = getCurrentWindow(i, offset, size);
1924 for(
MInt a = offset[2];
a < offset[2] + size[2]; ++
a) {
1925 for(
MInt c = offset[0]; c < offset[0] + size[0]; ++c) {
1926 for(
MInt b = offset[1];
b < offset[1] + size[1]; ++
b) {
1927 nodeMap[count].blockId = i;
1928 nodeMap[count].pos[0] =
a;
1929 nodeMap[count].pos[1] =
b;
1930 nodeMap[count].pos[2] = c;
1931 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1], nodeMap[count].BC[2]) =
1932 getBCFromWindow(nodeMap[count].pos, currentWindows);
1937 memsize += size[0] * size[1] * size[2];
1943 if(m_domainId == 0) {
1945 ioSize[2] = m_grid->getBlockNoCells(i, 2) - 1;
1949 ioSize[0] = m_grid->getBlockNoCells(i, 0) + 1;
1950 pio.
readArray(&coordinates(0, memsize), bName,
"x", 3, ioOffset, ioSize);
1951 pio.
readArray(&coordinates(1, memsize), bName,
"y", 3, ioOffset, ioSize);
1952 pio.
readArray(&coordinates(2, memsize), bName,
"z", 3, ioOffset, ioSize);
1961 pio.
readArray(&empty, bName,
"x", 3, ioOffset, ioSize);
1962 pio.
readArray(&empty, bName,
"y", 3, ioOffset, ioSize);
1963 pio.
readArray(&empty, bName,
"z", 3, ioOffset, ioSize);
1965 for(
int dim = 0; dim < 3; ++dim) {
1966 offset[dim] = ioOffset[dim];
1967 size[dim] = ioSize[dim];
1970 currentWindows = getCurrentWindow(i, offset, size);
1972 for(
MInt b = offset[1];
b < offset[1] + size[1]; ++
b) {
1973 for(
MInt c = offset[0]; c < offset[0] + size[0]; ++c) {
1974 for(
MInt a = offset[2];
a < offset[2] + size[2]; ++
a) {
1975 nodeMap[count].blockId = i;
1976 nodeMap[count].pos[0] =
a;
1977 nodeMap[count].pos[1] =
b;
1978 nodeMap[count].pos[2] = c;
1979 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1], nodeMap[count].BC[2]) =
1980 getBCFromWindow(nodeMap[count].pos, currentWindows);
1985 memsize += size[0] * size[1] * size[2];
1991 if(m_domainId == 0) {
1993 ioSize[2] = m_grid->getBlockNoCells(i, 2) - 1;
1994 ioOffset[1] = m_grid->getBlockNoCells(i, 1);
1997 ioSize[0] = m_grid->getBlockNoCells(i, 0) + 1;
1998 pio.
readArray(&coordinates(0, memsize), bName,
"x", 3, ioOffset, ioSize);
1999 pio.
readArray(&coordinates(1, memsize), bName,
"y", 3, ioOffset, ioSize);
2000 pio.
readArray(&coordinates(2, memsize), bName,
"z", 3, ioOffset, ioSize);
2009 pio.
readArray(&empty, bName,
"x", 3, ioOffset, ioSize);
2010 pio.
readArray(&empty, bName,
"y", 3, ioOffset, ioSize);
2011 pio.
readArray(&empty, bName,
"z", 3, ioOffset, ioSize);
2013 for(
int dim = 0; dim < 3; ++dim) {
2014 offset[dim] = ioOffset[dim];
2015 size[dim] = ioSize[dim];
2018 currentWindows = getCurrentWindow(i, offset, size);
2020 for(
MInt b = offset[1];
b < offset[1] + size[1]; ++
b) {
2021 for(
MInt c = offset[0]; c < offset[0] + size[0]; ++c) {
2022 for(
MInt a = offset[2];
a < offset[2] + size[2]; ++
a) {
2023 nodeMap[count].blockId = i;
2024 nodeMap[count].pos[0] =
a;
2025 nodeMap[count].pos[1] =
b;
2026 nodeMap[count].pos[2] = c;
2027 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1], nodeMap[count].BC[2]) =
2028 getBCFromWindow(nodeMap[count].pos, currentWindows);
2033 memsize += size[0] * size[1] * size[2];
2039 if(m_domainId == 0) {
2041 ioSize[2] = m_grid->getBlockNoCells(i, 2) - 1;
2043 ioSize[1] = m_grid->getBlockNoCells(i, 1) - 1;
2046 pio.
readArray(&coordinates(0, memsize), bName,
"x", 3, ioOffset, ioSize);
2047 pio.
readArray(&coordinates(1, memsize), bName,
"y", 3, ioOffset, ioSize);
2048 pio.
readArray(&coordinates(2, memsize), bName,
"z", 3, ioOffset, ioSize);
2057 pio.
readArray(&empty, bName,
"x", 3, ioOffset, ioSize);
2058 pio.
readArray(&empty, bName,
"y", 3, ioOffset, ioSize);
2059 pio.
readArray(&empty, bName,
"z", 3, ioOffset, ioSize);
2061 for(
int dim = 0; dim < 3; ++dim) {
2062 offset[dim] = ioOffset[dim];
2063 size[dim] = ioSize[dim];
2066 currentWindows = getCurrentWindow(i, offset, size);
2068 for(
MInt c = offset[0]; c < offset[0] + size[0]; ++c) {
2069 for(
MInt b = offset[1];
b < offset[1] + size[1]; ++
b) {
2070 for(
MInt a = offset[2];
a < offset[2] + size[2]; ++
a) {
2071 nodeMap[count].blockId = i;
2072 nodeMap[count].pos[0] =
a;
2073 nodeMap[count].pos[1] =
b;
2074 nodeMap[count].pos[2] = c;
2075 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1], nodeMap[count].BC[2]) =
2076 getBCFromWindow(nodeMap[count].pos, currentWindows);
2081 memsize += size[0] * size[1] * size[2];
2087 if(m_domainId == 0) {
2089 ioSize[2] = m_grid->getBlockNoCells(i, 2) - 1;
2091 ioSize[1] = m_grid->getBlockNoCells(i, 1) - 1;
2092 ioOffset[0] = m_grid->getBlockNoCells(i, 0);
2094 pio.
readArray(&coordinates(0, memsize), bName,
"x", 3, ioOffset, ioSize);
2095 pio.
readArray(&coordinates(1, memsize), bName,
"y", 3, ioOffset, ioSize);
2096 pio.
readArray(&coordinates(2, memsize), bName,
"z", 3, ioOffset, ioSize);
2105 pio.
readArray(&empty, bName,
"x", 3, ioOffset, ioSize);
2106 pio.
readArray(&empty, bName,
"y", 3, ioOffset, ioSize);
2107 pio.
readArray(&empty, bName,
"z", 3, ioOffset, ioSize);
2109 for(
int dim = 0; dim < 3; ++dim) {
2110 offset[dim] = ioOffset[dim];
2111 size[dim] = ioSize[dim];
2114 currentWindows = getCurrentWindow(i, offset, size);
2116 for(
MInt c = offset[0]; c < offset[0] + size[0]; ++c) {
2117 for(
MInt b = offset[1];
b < offset[1] + size[1]; ++
b) {
2118 for(
MInt a = offset[2];
a < offset[2] + size[2]; ++
a) {
2119 nodeMap[count].blockId = i;
2120 nodeMap[count].pos[0] =
a;
2121 nodeMap[count].pos[1] =
b;
2122 nodeMap[count].pos[2] = c;
2123 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1], nodeMap[count].BC[2]) =
2124 getBCFromWindow(nodeMap[count].pos, currentWindows);
2129 memsize += size[0] * size[1] * size[2];
2133 for(
MInt windowId = 0; windowId < noInputWindowInformation; ++windowId) {
2134 if(inputWindows[windowId]->BC < 6000 || inputWindows[windowId]->BC >= 6010)
continue;
2135 MInt noWindowPoints = 1;
2136 for(
MInt dim = 0; dim < nDim; ++dim) {
2137 noWindowPoints *= inputWindows[windowId]->endindex[dim] - inputWindows[windowId]->startindex[dim];
2140 if(noWindowPoints > pointsFoundPerWindow[windowId])
mTerm(1,
"noWindowPOints > pointsFoundPerWindow");
2144 MPI_Bcast(&count, 1, MPI_INT, 0, m_StructuredComm, AT_,
"count");
2145 MPI_Bcast(&memsize, 1, MPI_INT, 0, m_StructuredComm, AT_,
"memsize");
2146 MPI_Bcast(&coordinates(0, 0), memsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"coordinates(0");
2147 MPI_Bcast(&coordinates(1, 0), memsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"coordinates(1");
2148 MPI_Bcast(&coordinates(2, 0), memsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"coordinates(2");
2151 MPI_Datatype matrix;
2154 MPI_Bcast(nodeMap.data(), memsize, matrix, 0, m_StructuredComm, AT_,
"nodeMap");
2159 if(domainId() == 0) {
2160 cout <<
"Building up connections for multiblock connection search" << endl;
2162 vector<Point<3>> pts;
2163 for(
MInt j = 0; j < count; ++j) {
2164 Point<3> a(coordinates(0, j), coordinates(1, j), coordinates(2, j));
2166 nodeMap[j].found =
false;
2169 MFloat m_gridEps = 0.0000001;
2173 MInt numConnections = 0, numSingularConnections = 0, nfound, tempnum = 0, tempcount;
2175 for(
MInt i = 0; i < count; ++i) {
2176 if(!nodeMap[i].found) {
2177 Point<3> a(coordinates(0, i), coordinates(1, i), coordinates(2, i));
2178 nfound = tree.
locatenear(
a, m_gridEps, results, 10,
false);
2179 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
2180 for(
MInt countNode3 = countNode2 + 1; countNode3 < nfound; ++countNode3) {
2181 MBool check =
false;
2182 for(
MInt bc2 = 0; bc2 < nDim; ++bc2) {
2183 if(nodeMap[results[countNode2]].BC[bc2] == 0)
break;
2184 for(
MInt bc3 = 0; bc3 < nDim; ++bc3) {
2185 if(nodeMap[results[countNode2]].BC[bc2] == nodeMap[results[countNode3]].BC[bc3]) {
2189 nodeMap[results[countNode2]].BC[bc2],
2190 nodeMap[results[countNode2]].blockId,
2191 nodeMap[results[countNode2]].pos,
2192 nodeMap[results[countNode3]].blockId,
2193 nodeMap[results[countNode3]].pos)) {
2194 numConnections = numConnections + 1;
2200 cout <<
"DANGER: x|y|z=" << coordinates(0, i) <<
"|" << coordinates(1, i) <<
"|" << coordinates(2, i)
2201 <<
" nodeMap2: inpuBlockId=" << nodeMap[results[countNode2]].blockId <<
" BC =";
2202 for(
MInt d = 0; d < nDim; ++d)
2203 cout <<
" " << nodeMap[results[countNode2]].BC[d];
2204 cout <<
" nodeMap3: blockId=" << nodeMap[results[countNode3]].blockId <<
" BC =";
2205 for(
MInt d = 0; d < nDim; ++d)
2206 cout <<
" " << nodeMap[results[countNode3]].BC[d];
2225 nodeMap[results[countNode2]].found =
true;
2229 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
2230 for(
MInt d = 0; d < nDim; ++d) {
2231 if(nodeMap[results[countNode2]].BC[d] != 0) {
2232 BCs.insert(nodeMap[results[countNode2]].BC[d]);
2244 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
2245 for(
MInt j = 0; j < m_noBlocks; ++j) {
2246 if(nodeMap[results[countNode2]].blockId == j) {
2251 for(
MInt j = 0; j < 3; ++j) {
2253 if(nodeMap[results[countNode2]].pos[j] == 0
2254 || nodeMap[results[countNode2]].pos[j] == m_grid->getBlockNoCells(tempnum, 2 - j)) {
2260 if(tempcount == 9 || tempcount == 6) {
2265 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
2266 if(BCs.size() > 1) cout <<
"CAUTION: This singular point has more than one BC!" << endl;
2267 for(
const auto& BC : BCs) {
2269 if(addConnection(BC,
2270 nodeMap[results[countNode2]].blockId,
2271 nodeMap[results[countNode2]].pos,
2272 nodeMap[results[countNode2]].blockId,
2273 nodeMap[results[countNode2]].pos,
2275 numSingularConnections = numSingularConnections + 1;
2285 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
2286 if(BCs.size() > 1) cout <<
"CAUTION: This singular point has more than one BC!" << endl;
2287 for(
const auto& BC : BCs) {
2289 if(addConnection(BC,
2290 nodeMap[results[countNode2]].blockId,
2291 nodeMap[results[countNode2]].pos,
2292 nodeMap[results[countNode2]].blockId,
2293 nodeMap[results[countNode2]].pos,
2295 numSingularConnections = numSingularConnections + 1;
2302 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
2303 if(BCs.size() > 1) cout <<
"CAUTION: This singular point has more than one BC!" << endl;
2304 for(
const auto& BC : BCs) {
2306 if(addConnection(BC,
2307 nodeMap[results[countNode2]].blockId,
2308 nodeMap[results[countNode2]].pos,
2309 nodeMap[results[countNode2]].blockId,
2310 nodeMap[results[countNode2]].pos,
2312 numSingularConnections = numSingularConnections + 1;
2322 MInt pcount = 0, plocation = 0, numofpoints[3];
2324 for(
MInt i = 0; i < noInputWindowInformation; i++) {
2325 if(inputWindows[i]->BC > 4000 && inputWindows[i]->BC < 5000) {
2326 for(
MInt j = 0; j < 3; j++) {
2327 numofpoints[j] = inputWindows[i]->endindex[j] - inputWindows[i]->startindex[j] + 1;
2329 pcount += numofpoints[0] * numofpoints[1] * numofpoints[2];
2335 periodicCoordinates.
fill(-1.01010101);
2336 std::vector<pointType<nDim>> nodeMapP;
2337 nodeMapP.resize(pcount);
2339 if(domainId() == 0) {
2340 cout <<
"Loading periodic face coordinates" << endl;
2343 for(
MInt i = 0; i < noInputWindowInformation; i++) {
2344 if(inputWindows[i]->BC >= 4000 && inputWindows[i]->BC < 5000) {
2346 stringstream number;
2347 number << inputWindows[i]->blockId <<
"/";
2348 bName += number.str();
2350 ParallelIo::size_type ioOffset[3] = {0, 0, 0};
2351 ParallelIo::size_type ioSize[3] = {0, 0, 0};
2352 if(m_domainId == 0) {
2353 for(
MInt j = 0; j < 3; j++) {
2354 ioOffset[j] = inputWindows[i]->startindex[2 - j];
2355 ioSize[j] = inputWindows[i]->endindex[2 - j] - inputWindows[i]->startindex[2 - j] + 1;
2358 pio.
readArray(&periodicCoordinates(0, plocation), bName,
"x", 3, ioOffset, ioSize);
2359 pio.
readArray(&periodicCoordinates(1, plocation), bName,
"y", 3, ioOffset, ioSize);
2360 pio.
readArray(&periodicCoordinates(2, plocation), bName,
"z", 3, ioOffset, ioSize);
2369 pio.
readArray(&empty, bName,
"x", 3, ioOffset, ioSize);
2370 pio.
readArray(&empty, bName,
"y", 3, ioOffset, ioSize);
2371 pio.
readArray(&empty, bName,
"z", 3, ioOffset, ioSize);
2373 for(
int dim = 0; dim < 3; ++dim) {
2374 offset[dim] = ioOffset[dim];
2375 size[dim] = ioSize[dim];
2379 for(
MInt c = offset[0]; c < offset[0] + size[0]; ++c) {
2380 for(
MInt b = offset[1];
b < offset[1] + size[1]; ++
b) {
2381 for(
MInt a = offset[2];
a < offset[2] + size[2]; ++
a) {
2382 nodeMapP[plocation].BC[0] = inputWindows[i]->BC;
2383 nodeMapP[plocation].blockId = inputWindows[i]->blockId;
2384 nodeMapP[plocation].pos[0] =
a;
2385 nodeMapP[plocation].pos[1] =
b;
2386 nodeMapP[plocation].pos[2] = c;
2391 pmemsize += size[0] * size[1] * size[2];
2395 MPI_Bcast(&plocation, 1, MPI_INT, 0, m_StructuredComm, AT_,
"plocation");
2396 MPI_Bcast(&pmemsize, 1, MPI_INT, 0, m_StructuredComm, AT_,
"pmemsize");
2398 MPI_Bcast(&periodicCoordinates(0, 0), pmemsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"periodicCoordinates(0");
2399 MPI_Bcast(&periodicCoordinates(1, 0), pmemsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"periodicCoordinates(1");
2400 MPI_Bcast(&periodicCoordinates(2, 0), pmemsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"periodicCoordinates(2");
2402 MPI_Bcast(nodeMapP.data(), pmemsize, matrix, 0, m_StructuredComm, AT_,
"nodeMapP");
2404 if(domainId() == 0) {
2405 cout <<
"Computing periodic window displacements" << endl;
2407 m_log <<
"Computing periodic window displacements" << endl;
2411 MFloatScratchSpace periodicWindowCenter(m_noBlocks, nDim, 2 * nDim, AT_,
"periodicWindowCOGS");
2412 MIntScratchSpace periodicWindowNoNodes(m_noBlocks, 2 * nDim, AT_,
"periodicWindowNoNodes");
2414 periodicWindowCenter.
fill(F0);
2415 periodicWindowNoNodes.
fill(0);
2418 const MInt periodicOffset = 4401;
2419 for(
MInt i = 0; i < pcount; ++i) {
2420 if(nodeMapP[i].BC[0] < 4401 || nodeMapP[i].BC[0] > 4406) {
2425 for(
MInt dim = 0; dim < nDim; dim++) {
2426 periodicWindowCenter(nodeMapP[i].blockId, dim, nodeMapP[i].BC[0] - periodicOffset) +=
2427 periodicCoordinates(dim, i);
2430 periodicWindowNoNodes(nodeMapP[i].blockId, nodeMapP[i].BC[0] - periodicOffset) += 1;
2437 multimap<MInt, pair<vector<MFloat>,
MInt>> oddPeriodicSides;
2438 multimap<MInt, pair<vector<MFloat>,
MInt>> evenPeriodicSides;
2447 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
2448 for(
MInt periodicWindowId = 0; periodicWindowId < 2 * nDim; periodicWindowId++) {
2449 if(periodicWindowNoNodes(blockId, periodicWindowId) <= 0) {
2452 vector<MFloat> centerDimensions(nDim);
2453 for(
MInt dim = 0; dim < nDim; dim++) {
2454 periodicWindowCenter(blockId, dim, periodicWindowId) /=
2455 (
MFloat)periodicWindowNoNodes(blockId, periodicWindowId);
2456 centerDimensions[dim] =
2457 periodicWindowCenter(blockId, dim,
2459 cout <<
"periodic Window center " << periodicWindowCenter(blockId, dim, periodicWindowId) << endl;
2461 if(periodicWindowId % 2 == 0) {
2463 evenPeriodicSides.insert(pair<
MInt, pair<vector<MFloat>,
MInt>>(
2464 blockId, pair<vector<MFloat>,
MInt>(centerDimensions, periodicWindowId)));
2465 cout <<
"dimensions of centerDimensions (even)" << centerDimensions[0] <<
" " << centerDimensions[1] <<
" "
2466 << centerDimensions[2] << endl;
2469 oddPeriodicSides.insert(pair<
MInt, pair<vector<MFloat>,
MInt>>(
2470 blockId, pair<vector<MFloat>,
MInt>(centerDimensions, periodicWindowId)));
2471 cout <<
"dimensions of centerDimensions (odd)" << centerDimensions[0] <<
" " << centerDimensions[1] <<
" "
2472 << centerDimensions[2] << endl;
2481 pair<multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator, multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator>
2483 pair<multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator, multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator>
2488 "periodic Displacements per block");
2490 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
2491 MInt noEvenPerodicWindowsBlockIds = evenPeriodicSides.count(blockId);
2492 MInt noOddPeriodicWindowsBlockIds = oddPeriodicSides.count(blockId);
2493 cout <<
"we have evenSides " << noEvenPerodicWindowsBlockIds <<
" and we have oddSides "
2494 << noOddPeriodicWindowsBlockIds <<
" in BlockId " << blockId << endl;
2495 if(noEvenPerodicWindowsBlockIds == 0)
continue;
2496 if(noOddPeriodicWindowsBlockIds == 0)
2499 evenIt = evenPeriodicSides.equal_range(blockId);
2500 multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator eit = evenIt.first;
2501 while(eit != evenIt.second) {
2502 MBool tobeErased =
false;
2504 ceil(((
MFloat)((*eit).second.second + 1) / 2.0) - 1);
2505 MInt evenSide = (*eit).second.second;
2506 MInt oddSide = evenSide + 1;
2507 oddIt = oddPeriodicSides.equal_range(blockId);
2508 multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator oit = oddIt.first;
2510 while(oit != oddIt.second) {
2511 if((*oit).second.second == oddSide) {
2513 for(
MInt dim = 0; dim < nDim; dim++) {
2514 cout <<
"first element is " << (*oit).second.first[dim] <<
" and we subtract "
2515 << (*eit).second.first[dim] << endl;
2516 periodicDisplacementsBlockIds(blockId, evenSideDim + nDim * dim) =
2517 abs((*oit).second.first[dim] - (*eit).second.first[dim]);
2519 oit = oddPeriodicSides.erase(oit);
2527 eit = evenPeriodicSides.erase(eit);
2534 MFloat periodicEpsilon = 0.000001;
2537 if(evenPeriodicSides.size() != 0
2538 && oddPeriodicSides.size() != 0) {
2539 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
2540 MInt noEvenPerodicWindowsBlockId = evenPeriodicSides.count(blockId);
2541 if(noEvenPerodicWindowsBlockId == 0)
continue;
2542 evenIt = evenPeriodicSides.equal_range(blockId);
2543 multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator eit = evenIt.first;
2544 while(eit != evenIt.second) {
2545 MBool tobeErased =
false;
2547 ceil(((
MFloat)((*eit).second.second + 1) / 2.0) - 1);
2549 multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator oit = oddPeriodicSides.begin();
2550 while(oit != oddPeriodicSides.end()) {
2552 MInt equalConnectionDims = 0;
2553 for(
MInt d = 0; d < nDim; d++) {
2554 if(abs((*oit).second.first[d] - (*eit).second.first[d]) < periodicEpsilon) equalConnectionDims++;
2556 if(equalConnectionDims == 2) {
2557 for(
MInt dim = 0; dim < nDim; dim++) {
2558 periodicDisplacementsBlockIds(blockId, evenSideDim + nDim * dim) =
2559 abs((*oit).second.first[dim] - (*eit).second.first[dim]);
2561 periodicDisplacementsBlockIds((*oit).first, evenSideDim + nDim * dim) =
2562 periodicDisplacementsBlockIds(blockId, evenSideDim + nDim * dim);
2565 oit = oddPeriodicSides.erase(oit);
2571 eit = evenPeriodicSides.erase(eit);
2580 for(
MInt periodicWindowId = 0; periodicWindowId < 2 * nDim; periodicWindowId++) {
2581 if(periodicWindowId % 2 == 1) {
2582 for(
MInt dim = 0; dim < nDim; dim++) {
2583 const MInt displacementId = (
MFloat)(periodicWindowId + 1) / 2.0 - 1;
2584 periodicDisplacements[dim * nDim + displacementId] =
2585 periodicWindowCenter(m_blockId, dim, periodicWindowId)
2586 - periodicWindowCenter(m_blockId, dim, periodicWindowId - 1);
2587 m_log << m_blockId <<
" periodicWindowCenter for window: " << periodicWindowId + periodicOffset
2588 <<
" dim: " << dim <<
" displacementId: " << displacementId
2589 <<
" displacement: " << periodicDisplacements[dim * nDim + displacementId] << endl;
2594 cout <<
"old approach" << endl;
2595 for(
MInt periodicWindowId = 0; periodicWindowId < 2 * nDim; periodicWindowId++) {
2596 if(periodicWindowId % 2 == 1) {
2597 for(
MInt dim = 0; dim < nDim; dim++) {
2598 const MInt displacementId = (
MFloat)(periodicWindowId + 1) / 2.0 - 1;
2599 periodicDisplacements[dim * nDim + displacementId] =
2600 periodicWindowCenter(m_blockId, dim, periodicWindowId)
2601 - periodicWindowCenter(m_blockId, dim, periodicWindowId - 1);
2602 cout <<
"blockId = " << m_blockId
2603 <<
"periodicWindowCenter for window: " << periodicWindowId + periodicOffset <<
" dim: " << dim
2604 <<
" displacementId: " << displacementId
2605 <<
" displacement: " << periodicDisplacements[dim * nDim + displacementId] << endl;
2609 cout <<
"new approach " << endl;
2610 for(
MInt periodicWindowId = 0; periodicWindowId < 2 * nDim; periodicWindowId++) {
2611 if(periodicWindowId % 2 == 1) {
2612 const MInt displacementId = (
MFloat)(periodicWindowId + 1) / 2.0 - 1;
2613 for(
MInt dim = 0; dim < nDim; dim++) {
2614 cout <<
"blockId = " << m_blockId
2615 <<
"periodicWindowCenter for window: " << periodicWindowId + periodicOffset <<
" dim: " << dim
2616 <<
" displacementId: " << displacementId
2617 <<
" displacement: " << periodicDisplacementsBlockIds(m_blockId, dim * nDim + displacementId) << endl;
2622 if(domainId() == 0) {
2623 for(
MInt b = 0;
b < m_noBlocks;
b++) {
2624 cout <<
"BlockId " <<
b <<
": " << endl;
2626 for(
MInt i = 0; i < nDim * nDim; i++) {
2627 cout << periodicDisplacementsBlockIds(
b, i) <<
" ";
2633 for(
MInt b = 0;
b < m_noBlocks;
b++) {
2634 if(
b == m_blockId) {
2635 for(
MInt i = 0; i < nDim * nDim; i++) {
2636 periodicDisplacements[i] = periodicDisplacementsBlockIds(
b, i);
2647 for(
MInt i = 0; i < pcount; ++i) {
2648 tmppoint[0] = periodicCoordinates(0, i);
2649 tmppoint[1] = periodicCoordinates(1, i);
2650 tmppoint[2] = periodicCoordinates(2, i);
2651 periodicPointsChange(tmppoint, nodeMapP[i].BC[0], periodicDisplacements);
2652 Point<3> aaa(tmppoint[0], tmppoint[1], tmppoint[2]);
2653 nfound = tree.
locatenear(aaa, m_gridEps, results, 10,
false);
2654 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
2656 if(addConnection(nodeMapP[i].BC[0],
2657 nodeMapP[i].blockId,
2659 nodeMap[results[countNode2]].blockId,
2660 nodeMap[results[countNode2]].pos)) {
2661 numConnections = numConnections + 1;
2667 if(addConnection(nodeMapP[i].BC[0], nodeMapP[i].blockId, nodeMapP[i].pos, nodeMapP[i].blockId,
2668 nodeMapP[i].pos, 5)) {
2669 numSingularConnections = numSingularConnections + 1;
2675 if(addConnection(nodeMapP[i].BC[0], nodeMapP[i].blockId, nodeMapP[i].pos, nodeMapP[i].blockId,
2676 nodeMapP[i].pos, 6)) {
2677 numSingularConnections = numSingularConnections + 1;
2683 if(domainId() == 0) {
2684 cout <<
"Assemble multiblock connections" << endl;
2689 multiBlockAssembling();
2690 singularityAssembling();
2693 deleteDuplicateWindows(window0d, window0d);
2694 deleteDuplicateWindows(window1d, window1d);
2695 deleteDuplicateWindows(window2d, window2d);
2696 deleteDuplicateWindows(window0d, window1d);
2697 deleteDuplicateWindows(window0d, window2d);
2698 deleteDuplicateWindows(window1d, window2d);
2702 for(
auto it = singularwindow.cbegin(); it != singularwindow.cend();) {
2703 if(singularwindow.empty()) {
2707 if((*it)->BC >= 4400 && (*it)->BC < 4410)
continue;
2708 MInt noSameWindows = 0;
2709 (*it)->BCsingular[noSameWindows++] = (*it)->BC;
2711 for(
auto it2 = it + 1; it2 != singularwindow.cend();) {
2712 if(singularwindow.empty()) {
2715 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
2716 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
2717 const MBool test = mapCompare11(map1, map2);
2719 if((*it)->BCsingular[0] == (*it2)->BC || (*it)->Nstar != (*it2)->Nstar) {
2720 mTerm(1,
"There is no hope anymore!");
2723 if(noSameWindows >= (*it)->Nstar) {
2727 (*it)->BCsingular[noSameWindows++] = (*it2)->BC;
2728 singularwindow.erase(it2);
2773 for(
MInt i = 0; i < (
MInt)window2d.size(); ++i) {
2775 const MInt BC = (window2d[i]->BC >= 6000 && window2d[i]->BC < 6010) ? -window2d[i]->BC : window2d[i]->BC;
2777 unique_ptr<StructuredWindowMap<nDim>> windowMap1 = make_unique<StructuredWindowMap<nDim>>();
2778 mapCreate(window2d[i]->Id1, window2d[i]->start1, window2d[i]->end1, window2d[i]->step1, window2d[i]->Id2,
2779 window2d[i]->start2, window2d[i]->end2, window2d[i]->step2, window2d[i]->order, BC, windowMap1);
2780 windowMap1->Nstar = -1;
2781 windowMap1->SingularId = -1;
2782 windowMap1->dc1 = window2d[i]->dc1;
2783 windowMap1->dc2 = window2d[i]->dc2;
2786 if(windowMap1->dc1 * windowMap1->dc2 > 0) {
2787 MInt tempdim = abs(windowMap1->dc2) - 1;
2788 windowMap1->step2[tempdim] = -1;
2792 globalStructuredBndryCndMaps.push_back(std::move(windowMap1));
2795 if(window2d[i]->BC >= 6000 && window2d[i]->BC < 6010) {
2796 unique_ptr<StructuredWindowMap<nDim>> windowMap = make_unique<StructuredWindowMap<nDim>>();
2797 mapCreate(window2d[i]->Id1, window2d[i]->start1, window2d[i]->end1, window2d[i]->step1, window2d[i]->Id2,
2798 window2d[i]->start2, window2d[i]->end2, window2d[i]->step2, window2d[i]->order, BC, windowMap);
2799 windowMap->Nstar = -1;
2800 windowMap->SingularId = -1;
2801 windowMap->dc1 = window2d[i]->dc1;
2802 windowMap->dc2 = window2d[i]->dc2;
2804 if(windowMap->dc1 * windowMap->dc2 > 0) {
2805 MInt tempdim = abs(windowMap->dc2) - 1;
2806 windowMap->step2[tempdim] = -1;
2809 mapInvert1(windowMap);
2810 mapNormalize3(windowMap);
2811 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
2816 for(
MInt i = 0; i < (
MInt)window1d.size(); ++i) {
2818 const MInt BC = (window1d[i]->BC >= 6000 && window1d[i]->BC < 6010) ? -window1d[i]->BC : window1d[i]->BC;
2820 unique_ptr<StructuredWindowMap<nDim>> windowMap1 = make_unique<StructuredWindowMap<nDim>>();
2821 mapCreate(window1d[i]->Id1, window1d[i]->start1, window1d[i]->end1, window1d[i]->step1, window1d[i]->Id2,
2822 window1d[i]->start2, window1d[i]->end2, window1d[i]->step2, window1d[i]->order, BC, windowMap1);
2823 windowMap1->Nstar = -1;
2824 windowMap1->SingularId = -1;
2825 windowMap1->dc1 = window1d[i]->dc1;
2826 windowMap1->dc2 = window1d[i]->dc2;
2829 for(
MInt j = 0; j < 3; ++j) {
2830 if(windowMap1->start1[j] == windowMap1->end1[j]) {
2831 if(windowMap1->start1[j] == 0 && windowMap1->start2[windowMap1->order[j]] == 0) {
2832 windowMap1->step2[windowMap1->order[j]] = -1;
2834 if(windowMap1->start1[j] > 0 && windowMap1->start2[windowMap1->order[j]] > 0) {
2835 windowMap1->step2[windowMap1->order[j]] = -1;
2842 for(
MInt j = 0; j < (
MInt)singularwindow.size(); ++j) {
2843 const MInt test = mapCompare11(windowMap1, singularwindow[j]);
2845 windowMap1->Nstar = singularwindow[j]->Nstar;
2846 windowMap1->SingularId = singularwindow[j]->SingularId;
2851 globalStructuredBndryCndMaps.push_back(std::move(windowMap1));
2853 if(window1d[i]->BC >= 6000 && window1d[i]->BC < 6010) {
2854 unique_ptr<StructuredWindowMap<nDim>> windowMap = make_unique<StructuredWindowMap<nDim>>();
2855 mapCreate(window1d[i]->Id1, window1d[i]->start1, window1d[i]->end1, window1d[i]->step1, window1d[i]->Id2,
2856 window1d[i]->start2, window1d[i]->end2, window1d[i]->step2, window1d[i]->order, BC, windowMap);
2857 windowMap->Nstar = -1;
2858 windowMap->SingularId = -1;
2859 windowMap->dc1 = window1d[i]->dc1;
2860 windowMap->dc2 = window1d[i]->dc2;
2863 for(
MInt j = 0; j < 3; ++j) {
2864 if(windowMap->start1[j] == windowMap->end1[j]) {
2865 if(windowMap->start1[j] == 0 && windowMap->start2[windowMap->order[j]] == 0) {
2866 windowMap->step2[windowMap->order[j]] = -1;
2868 if(windowMap->start1[j] > 0 && windowMap->start2[windowMap->order[j]] > 0) {
2869 windowMap->step2[windowMap->order[j]] = -1;
2874 mapInvert1(windowMap);
2875 mapNormalize3(windowMap);
2879 for(
MInt j = 0; j < (
MInt)singularwindow.size(); ++j) {
2880 const MInt test = mapCompare11(windowMap, singularwindow[j]);
2882 windowMap->Nstar = singularwindow[j]->Nstar;
2883 windowMap->SingularId = singularwindow[j]->SingularId;
2887 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
2892 for(
MInt i = 0; i < (
MInt)window0d.size(); ++i) {
2894 const MInt BC = (window0d[i]->BC >= 6000 && window0d[i]->BC < 6010) ? -window0d[i]->BC : window0d[i]->BC;
2897 unique_ptr<StructuredWindowMap<nDim>> windowMap1 = make_unique<StructuredWindowMap<nDim>>();
2898 mapCreate(window0d[i]->Id1, window0d[i]->start1, window0d[i]->end1, window0d[i]->step1, window0d[i]->Id2,
2899 window0d[i]->start2, window0d[i]->end2, window0d[i]->step2, window0d[i]->order, BC, windowMap1);
2900 windowMap1->Nstar = -1;
2901 windowMap1->SingularId = -1;
2902 windowMap1->dc1 = window0d[i]->dc1;
2903 windowMap1->dc2 = window0d[i]->dc2;
2905 for(
MInt j = 0; j < 3; ++j) {
2906 if(windowMap1->start1[j] == windowMap1->end1[j]) {
2907 if(windowMap1->start1[j] == 0 && windowMap1->start2[windowMap1->order[j]] == 0) {
2908 windowMap1->step2[windowMap1->order[j]] = -1;
2910 if(windowMap1->start1[j] > 0 && windowMap1->start2[windowMap1->order[j]] > 0) {
2911 windowMap1->step2[windowMap1->order[j]] = -1;
2918 for(
MInt j = 0; j < (
MInt)singularwindow.size(); ++j) {
2919 const MInt test = mapCompare11(windowMap1, singularwindow[j]);
2921 windowMap1->Nstar = singularwindow[j]->Nstar;
2922 windowMap1->SingularId = singularwindow[j]->SingularId;
2927 globalStructuredBndryCndMaps.push_back(std::move(windowMap1));
2929 if(window0d[i]->BC >= 6000 && window0d[i]->BC < 6010) {
2930 unique_ptr<StructuredWindowMap<nDim>> windowMap = make_unique<StructuredWindowMap<nDim>>();
2931 mapCreate(window0d[i]->Id1, window0d[i]->start1, window0d[i]->end1, window0d[i]->step1, window0d[i]->Id2,
2932 window0d[i]->start2, window0d[i]->end2, window0d[i]->step2, window0d[i]->order, BC, windowMap);
2933 windowMap->Nstar = -1;
2934 windowMap->SingularId = -1;
2935 windowMap->dc1 = window0d[i]->dc1;
2936 windowMap->dc2 = window0d[i]->dc2;
2939 for(
MInt j = 0; j < 3; ++j) {
2940 if(windowMap->start1[j] == windowMap->end1[j]) {
2941 if(windowMap->start1[j] == 0 && windowMap->start2[windowMap->order[j]] == 0) {
2942 windowMap->step2[windowMap->order[j]] = -1;
2944 if(windowMap->start1[j] > 0 && windowMap->start2[windowMap->order[j]] > 0) {
2945 windowMap->step2[windowMap->order[j]] = -1;
2950 mapInvert1(windowMap);
2951 mapNormalize3(windowMap);
2955 for(
MInt j = 0; j < (
MInt)singularwindow.size(); ++j) {
2956 const MInt test = mapCompare11(windowMap, singularwindow[j]);
2958 windowMap->Nstar = singularwindow[j]->Nstar;
2959 windowMap->SingularId = singularwindow[j]->SingularId;
2962 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
2967 deleteDuplicateCommMaps();
2970 if(domainId() == 0) {
2971 cout <<
"======= GLOBALSTRUCTUREDBNDRYCNDMAPS ======" << endl;
2972 for(
MInt i = 0; i < (signed)globalStructuredBndryCndMaps.size(); ++i) {
2973 mapPrint(globalStructuredBndryCndMaps[i]);
2976 cout <<
" ======= SINGULARWINDOW =============" << endl;
2977 for(
MInt i = 0; i < (signed)singularwindow.size(); ++i) {
2978 mapPrint(singularwindow[i]);
2981 cout <<
" ======== window0d ==============" << endl;
2982 for(
MInt i = 0; i < (signed)window0d.size(); ++i) {
2983 mapPrint(window0d[i]);
2986 cout <<
" ======== window1d ==============" << endl;
2987 for(
MInt i = 0; i < (signed)window1d.size(); ++i) {
2988 mapPrint(window1d[i]);
2991 cout <<
" ======== window2d ==============" << endl;
2992 for(
MInt i = 0; i < (signed)window2d.size(); ++i) {
2993 mapPrint(window2d[i]);
2998 if(!hasConnectionInfo) {
2999 cout <<
"Writing connection info" << endl;
3000 writeConnectionWindowInformation3D(periodicDisplacements);
3002 if(domainId() == 0) {
3003 cout <<
"##########################################################################" << endl;
3004 cout <<
"WARNING: OLD CONNECTION INFO EXISTS, DELETE BEFORE NEW ONE CAN BE WRITTEN!" << endl;
3005 cout <<
"##########################################################################" << endl;
3009 if(domainId() == 0) {
3010 cout <<
"Connection identification and window creation finished! NUM_SINGULAR=" << numSingularConnections << endl;
3025 MFloat rotationMatrix[3][3]{};
3031 const MInt displacementId = (
MFloat)(type - 4400 + 1) / 2.0 - 1;
3032 for(
MInt dim = 0; dim < nDim; ++dim) {
3033 pt[dim] = pt[dim] + periodicDisplacements[dim * nDim + displacementId];
3041 const MInt displacementId = (
MFloat)(type - 4400) / 2.0 - 1;
3042 for(
MInt dim = 0; dim < nDim; ++dim) {
3043 pt[dim] = pt[dim] - periodicDisplacements[dim * nDim + displacementId];
3049 ASSERT(nDim == 3,
"");
3050 rotationMatrix[1][1] = cos(angle);
3051 rotationMatrix[1][2] = -sin(angle);
3052 rotationMatrix[2][1] = sin(angle);
3053 rotationMatrix[2][2] = cos(angle);
3057 for(
MInt i = 0; i < nDim; ++i) {
3058 pt[i] = rotationMatrix[i][0] * tmp[0] + rotationMatrix[i][1] * tmp[1] + rotationMatrix[i][2] * tmp[2];
3064 ASSERT(nDim == 3,
"");
3065 rotationMatrix[1][1] = cos(-angle);
3066 rotationMatrix[1][2] = -sin(-angle);
3067 rotationMatrix[2][1] = sin(-angle);
3068 rotationMatrix[2][2] = cos(-angle);
3072 for(
MInt i = 0; i < nDim; ++i) {
3073 pt[i] = rotationMatrix[i][0] * tmp[0] + rotationMatrix[i][1] * tmp[1] + rotationMatrix[i][2] * tmp[2];
3079 cout <<
"ERROR!!! periodic type is wrong!!! in windowinfoe" << endl;
3089 if(connectiontype >= 6000 && connectiontype < 6010) {
3091 connectionset.insert(
a);
3094 connectionset.insert(
a);
3111 if(connectiontype >= 6000 && connectiontype < 6010) {
3114 singularconnectionset.insert(
a);
3115 }
else if(connectiontype >= 4000 && connectiontype < 5000) {
3119 singularconnectionset.insert(
a);
3121 cout <<
"singular point on BC " << connectiontype <<
" is not supported!! check it!!!" << endl;
3136 multiset<connectionNode>::iterator it;
3137 it = connectionset.find(
a);
3139 if(it != connectionset.end()) {
3149 auto it = connectionset.find(
a);
3150 connectionset.erase(it);
3155 multiset<connectionNode>::iterator it;
3157 it = singularconnectionset.find(
a);
3159 if(it != singularconnectionset.end()) {
3170 auto it = singularconnectionset.find(
a);
3171 singularconnectionset.erase(it);
3177 constexpr MInt nDim = 2;
3179 MInt hasConnectionInfo = 0;
3183 if(attributeExists) {
3184 m_log <<
"Grid file has connection info!" << endl;
3185 pio.
getAttribute(&hasConnectionInfo,
"hasConnectionInfo",
"Connectivity");
3187 MPI_Bcast(&hasConnectionInfo, 1, MPI_INT, 0, m_StructuredComm, AT_,
"hasConnectionInfo");
3189 MPI_Bcast(&hasConnectionInfo, 1, MPI_INT, 0, m_StructuredComm, AT_,
"hasConnectionInfo");
3192 MBool readInConnectionInfo =
true;
3194 if(!hasConnectionInfo) {
3195 readInConnectionInfo =
false;
3198 readInConnectionInfo =
3199 Context::getSolverProperty<MBool>(
"readInConnectionInfo", solverId(), AT_, &readInConnectionInfo);
3203 if(readInConnectionInfo) {
3204 m_log <<
"Connection info available, reading connection information from grid file!" << endl;
3205 readConnectionWindowInformation2D(periodicDisplacements);
3207 if(domainId() == 0) {
3208 cout <<
"Starting grid connection info search..." << endl;
3212 m_log <<
" Starting grid connection info search..." << endl;
3213 MInt offset[2], size[2], count = 0;
3217 MInt totalGridCells = 0;
3218 MInt** totalGridBlockDim =
nullptr;
3219 MInt* totalGridBlockCells =
nullptr;
3221 mAlloc(totalGridBlockDim, m_noBlocks, 2,
"totalGridBlockDim", -1, AT_);
3222 mAlloc(totalGridBlockCells, m_noBlocks,
"totalGridBlockCells", -1, AT_);
3224 for(
MInt i = 0; i < m_noBlocks; ++i) {
3226 for(
MInt dim = 0; dim < nDim; ++dim) {
3227 temp *= m_grid->getBlockNoCells(i, dim) + 1;
3228 totalGridBlockDim[i][dim] = m_grid->getBlockNoCells(i, dim) + 1;
3230 totalGridBlockCells[i] = temp;
3231 if(temp != 1) totalGridCells += temp;
3235 for(
MInt i = 0; i < m_noBlocks; i++) {
3236 countNode = countNode + 2 * totalGridBlockDim[i][1] + 2 * totalGridBlockDim[i][0] - 2;
3240 coordinates.
fill(-1.01010101);
3244 const MInt converter[] = {1, 0};
3245 auto getCurrentWindow = [
this, converter](
const MInt blockId,
const MInt*
const offset_,
const MInt*
const size_) {
3246 std::vector<MInt> currentWindows;
3247 for(
MInt windowId = 0; windowId < noInputWindowInformation; ++windowId) {
3248 if(inputWindows[windowId]->blockId != blockId)
continue;
3249 if(inputWindows[windowId]->BC < 6000 || inputWindows[windowId]->BC >= 6010)
continue;
3251 MBool takeIt =
true;
3252 for(
MInt dim = 0; dim < nDim; ++dim) {
3253 if(inputWindows[windowId]->startindex[dim] >= offset_[converter[dim]] + size_[converter[dim]]
3254 || inputWindows[windowId]->endindex[dim] < offset_[converter[dim]]) {
3259 if(takeIt) currentWindows.push_back(std::move(windowId));
3261 return currentWindows;
3263 std::vector<MInt> pointsFoundPerWindow(noInputWindowInformation);
3264 auto getBCFromWindow = [
this, &pointsFoundPerWindow](
const MInt idx[nDim],
3265 const std::vector<MInt>& currentWindows) {
3266 std::vector<MInt> BCset;
3271 for(
auto windowId : currentWindows) {
3272 MBool takeIt =
true;
3273 for(
MInt dim = 0; dim < nDim; ++dim) {
3274 if(inputWindows[windowId]->startindex[dim] > idx[dim] || inputWindows[windowId]->endindex[dim] < idx[dim]) {
3280 ++pointsFoundPerWindow[windowId];
3282 BCset.push_back(inputWindows[windowId]->BC);
3290 if(BCset.size() > 2)
mTerm(1,
"");
3291 if(BCset.size() == 0) BCset.push_back(6000);
3292 MInt BC[2] = {0, 0};
3294 for(
auto it = BCset.begin(); it != BCset.end(); ++it)
3296 return std::tuple<MInt, MInt>(BC[0], BC[1]);
3301 if(domainId() == 0) {
3302 cout <<
"Reading in all coordinates of all block faces" << endl;
3304 for(
MInt i = 0; i < m_noBlocks; ++i) {
3306 stringstream number;
3308 bName += number.str();
3310 ParallelIo::size_type ioOffset[2] = {0, 0};
3311 ParallelIo::size_type ioSize[2] = {0, 0};
3317 if(m_domainId == 0) {
3321 ioSize[0] = m_grid->getBlockNoCells(i, 0) + 1;
3323 cout <<
"offset[1]=" << ioOffset[1] <<
" offset[0]=" << ioOffset[0] << endl;
3324 cout <<
"size[1]=" << ioSize[1] <<
" size[0]=" << ioSize[0] << endl;
3325 pio.
readArray(&coordinates(0, memsize), bName,
"x", 2, ioOffset, ioSize);
3326 pio.
readArray(&coordinates(1, memsize), bName,
"y", 2, ioOffset, ioSize);
3333 pio.
readArray(&empty, bName,
"x", 2, ioOffset, ioSize);
3334 pio.
readArray(&empty, bName,
"y", 2, ioOffset, ioSize);
3336 for(
int dim = 0; dim < nDim; ++dim) {
3337 offset[dim] = ioOffset[dim];
3338 size[dim] = ioSize[dim];
3341 std::vector<MInt> currentWindows = getCurrentWindow(i, offset, size);
3345 for(
MInt a = offset[1];
a < offset[1] + size[1]; ++
a) {
3346 for(
MInt b = offset[0];
b < offset[0] + size[0]; ++
b) {
3348 nodeMap[count].
pos[0] =
a;
3349 nodeMap[count].
pos[1] =
b;
3350 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1]) = getBCFromWindow(nodeMap[count].pos, currentWindows);
3354 memsize += size[0] * size[1];
3360 if(m_domainId == 0) {
3361 ioOffset[1] = m_grid->getBlockNoCells(i, 1);
3364 ioSize[0] = m_grid->getBlockNoCells(i, 0) + 1;
3366 cout <<
"offset[1]=" << ioOffset[1] <<
" offset[0]=" << ioOffset[0] << endl;
3367 cout <<
"size[1]=" << ioSize[1] <<
" size[0]=" << ioSize[0] << endl;
3368 pio.
readArray(&coordinates(0, memsize), bName,
"x", 2, ioOffset, ioSize);
3369 pio.
readArray(&coordinates(1, memsize), bName,
"y", 2, ioOffset, ioSize);
3376 pio.
readArray(&empty, bName,
"x", 2, ioOffset, ioSize);
3377 pio.
readArray(&empty, bName,
"y", 2, ioOffset, ioSize);
3379 for(
int dim = 0; dim < nDim; ++dim) {
3380 offset[dim] = ioOffset[dim];
3381 size[dim] = ioSize[dim];
3384 currentWindows = getCurrentWindow(i, offset, size);
3386 for(
MInt a = offset[1];
a < offset[1] + size[1]; ++
a) {
3387 for(
MInt b = offset[0];
b < offset[0] + size[0]; ++
b) {
3389 nodeMap[count].
pos[0] =
a;
3390 nodeMap[count].
pos[1] =
b;
3391 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1]) = getBCFromWindow(nodeMap[count].pos, currentWindows);
3395 memsize += size[0] * size[1];
3401 if(m_domainId == 0) {
3403 ioSize[1] = m_grid->getBlockNoCells(i, 1) - 1;
3406 pio.
readArray(&coordinates(0, memsize), bName,
"x", 2, ioOffset, ioSize);
3407 pio.
readArray(&coordinates(1, memsize), bName,
"y", 2, ioOffset, ioSize);
3414 pio.
readArray(&empty, bName,
"x", 2, ioOffset, ioSize);
3415 pio.
readArray(&empty, bName,
"y", 2, ioOffset, ioSize);
3417 for(
int dim = 0; dim < nDim; ++dim) {
3418 offset[dim] = ioOffset[dim];
3419 size[dim] = ioSize[dim];
3422 currentWindows = getCurrentWindow(i, offset, size);
3424 for(
MInt b = offset[0];
b < offset[0] + size[0]; ++
b) {
3425 for(
MInt a = offset[1];
a < offset[1] + size[1]; ++
a) {
3427 nodeMap[count].
pos[0] =
a;
3428 nodeMap[count].
pos[1] =
b;
3429 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1]) = getBCFromWindow(nodeMap[count].pos, currentWindows);
3433 memsize += size[0] * size[1];
3439 if(m_domainId == 0) {
3441 ioSize[1] = m_grid->getBlockNoCells(i, 1) - 1;
3442 ioOffset[0] = m_grid->getBlockNoCells(i, 0);
3444 pio.
readArray(&coordinates(0, memsize), bName,
"x", 2, ioOffset, ioSize);
3445 pio.
readArray(&coordinates(1, memsize), bName,
"y", 2, ioOffset, ioSize);
3452 pio.
readArray(&empty, bName,
"x", 2, ioOffset, ioSize);
3453 pio.
readArray(&empty, bName,
"y", 2, ioOffset, ioSize);
3455 for(
int dim = 0; dim < nDim; ++dim) {
3456 offset[dim] = ioOffset[dim];
3457 size[dim] = ioSize[dim];
3460 currentWindows = getCurrentWindow(i, offset, size);
3462 for(
MInt b = offset[0];
b < offset[0] + size[0]; ++
b) {
3463 for(
MInt a = offset[1];
a < offset[1] + size[1]; ++
a) {
3465 nodeMap[count].
pos[0] =
a;
3466 nodeMap[count].
pos[1] =
b;
3467 std::tie(nodeMap[count].BC[0], nodeMap[count].BC[1]) = getBCFromWindow(nodeMap[count].pos, currentWindows);
3471 memsize += size[0] * size[1];
3475 for(
MInt windowId = 0; windowId < noInputWindowInformation; ++windowId) {
3476 if(inputWindows[windowId]->BC < 6000 || inputWindows[windowId]->BC >= 6010)
continue;
3477 MInt noWindowPoints = 1;
3478 for(
MInt dim = 0; dim < nDim; ++dim) {
3479 noWindowPoints *= inputWindows[windowId]->endindex[dim] - inputWindows[windowId]->startindex[dim];
3482 if(noWindowPoints > pointsFoundPerWindow[windowId])
mTerm(1,
"noWindowPOints > pointFoundPerWindow");
3486 MPI_Bcast(&count, 1, MPI_INT, 0, m_StructuredComm, AT_,
"count");
3487 MPI_Bcast(&memsize, 1, MPI_INT, 0, m_StructuredComm, AT_,
"memsize");
3488 MPI_Bcast(&coordinates(0, 0), memsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"coordinates(0");
3489 MPI_Bcast(&coordinates(1, 0), memsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"coordinates(1");
3492 MPI_Datatype matrix;
3495 MPI_Bcast(nodeMap, memsize, matrix, 0, m_StructuredComm, AT_,
"nodeMap");
3500 MInt pcount = 0, plocation = 0, numofpoints[nDim];
3502 for(
MInt i = 0; i < noInputWindowInformation; i++) {
3503 if(inputWindows[i]->BC > 4000 && inputWindows[i]->BC < 5000) {
3504 for(
MInt j = 0; j < nDim; j++) {
3505 numofpoints[j] = inputWindows[i]->endindex[j] - inputWindows[i]->startindex[j] + 1;
3507 pcount += numofpoints[0] * numofpoints[1];
3512 MFloatScratchSpace periodicCoordinates(nDim, max(1, pcount), AT_,
"periodicCoordinates");
3513 periodicCoordinates.
fill(-1.01010101);
3516 if(domainId() == 0) {
3517 cout <<
"Loading periodic face coordinates" << endl;
3520 for(
MInt i = 0; i < noInputWindowInformation; i++) {
3521 if(inputWindows[i]->BC >= 4000 && inputWindows[i]->BC < 5000) {
3523 stringstream number;
3524 number << inputWindows[i]->
blockId <<
"/";
3525 bName += number.str();
3527 ParallelIo::size_type ioOffset[2] = {0, 0};
3528 ParallelIo::size_type ioSize[2] = {0, 0};
3529 if(domainId() == 0) {
3530 for(
MInt j = 0; j < nDim; j++) {
3531 ioOffset[j] = inputWindows[i]->startindex[1 - j];
3532 ioSize[j] = inputWindows[i]->endindex[1 - j] - inputWindows[i]->startindex[1 - j] + 1;
3535 pio.
readArray(&periodicCoordinates(0, plocation), bName,
"x", nDim, ioOffset, ioSize);
3536 pio.
readArray(&periodicCoordinates(1, plocation), bName,
"y", nDim, ioOffset, ioSize);
3543 pio.
readArray(&empty, bName,
"x", nDim, ioOffset, ioSize);
3544 pio.
readArray(&empty, bName,
"y", nDim, ioOffset, ioSize);
3547 for(
int dim = 0; dim < nDim; ++dim) {
3548 offset[dim] = ioOffset[dim];
3549 size[dim] = ioSize[dim];
3552 for(
MInt b = offset[0];
b < offset[0] + size[0]; ++
b) {
3553 for(
MInt a = offset[1];
a < offset[1] + size[1]; ++
a) {
3554 nodeMapP[plocation].
BC[0] = inputWindows[i]->BC;
3555 nodeMapP[plocation].
blockId = inputWindows[i]->blockId;
3556 nodeMapP[plocation].
pos[0] =
a;
3557 nodeMapP[plocation].
pos[1] =
b;
3561 pmemsize += size[0] * size[1];
3565 MPI_Bcast(&plocation, 1, MPI_INT, 0, m_StructuredComm, AT_,
"plocation");
3566 MPI_Bcast(&pmemsize, 1, MPI_INT, 0, m_StructuredComm, AT_,
"pmemsize");
3568 MPI_Bcast(&periodicCoordinates(0, 0), pmemsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"periodicCoordinates(0");
3569 MPI_Bcast(&periodicCoordinates(1, 0), pmemsize, MPI_DOUBLE, 0, m_StructuredComm, AT_,
"periodicCoordinates(1");
3571 MPI_Bcast(nodeMapP, pmemsize, matrix, 0, m_StructuredComm, AT_,
"nodeMapP");
3576 if(domainId() == 0) {
3577 cout <<
"Building up connections for multiblock connection search" << endl;
3579 vector<Point<2>> pts;
3580 for(
MInt j = 0; j < count; ++j) {
3581 Point<2> a(coordinates(0, j), coordinates(1, j));
3583 nodeMap[j].
found =
false;
3586 MFloat m_gridEps = 0.0000001;
3590 MInt numConnections = 0, numSingularConnections = 0, nfound, tempnum = 0, tempcount;
3593 for(
MInt i = 0; i < count; ++i) {
3594 if(!nodeMap[i].found) {
3595 Point<2> a(coordinates(0, i), coordinates(1, i));
3596 nfound = tree.
locatenear(
a, m_gridEps, results, 10,
false);
3597 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
3598 for(
MInt countNode3 = countNode2 + 1; countNode3 < nfound; ++countNode3) {
3599 MBool check =
false;
3600 for(
MInt bc2 = 0; bc2 < nDim; ++bc2) {
3601 if(nodeMap[results[countNode2]].BC[bc2] == 0)
break;
3602 for(
MInt bc3 = 0; bc3 < nDim; ++bc3) {
3603 if(nodeMap[results[countNode2]].BC[bc2] == nodeMap[results[countNode3]].BC[bc3]) {
3607 nodeMap[results[countNode2]].BC[bc2],
3608 nodeMap[results[countNode2]].blockId,
3609 nodeMap[results[countNode2]].pos,
3610 nodeMap[results[countNode3]].blockId,
3611 nodeMap[results[countNode3]].pos)) {
3612 numConnections = numConnections + 1;
3618 cout <<
"DANGER: x|y=" << coordinates(0, i) <<
"|" << coordinates(1, i)
3619 <<
" nodeMap2: blockId=" << nodeMap[results[countNode2]].
blockId <<
" BC =";
3620 for(
MInt d = 0; d < nDim; ++d)
3621 cout <<
" " << nodeMap[results[countNode2]].BC[d];
3622 cout <<
" nodeMap3: blockId=" << nodeMap[results[countNode3]].
blockId <<
" BC =";
3623 for(
MInt d = 0; d < nDim; ++d)
3624 cout <<
" " << nodeMap[results[countNode3]].BC[d];
3643 nodeMap[results[countNode2]].
found =
true;
3651 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
3652 for(
MInt bc2 = 0; bc2 < nDim; ++bc2) {
3653 const MInt BC = nodeMap[results[countNode2]].
BC[bc2];
3654 if(BC < 6000 || BC >= 6010) Nstar = 0;
3659 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
3660 for(
MInt j = 0; j < m_noBlocks; ++j) {
3661 if(nodeMap[results[countNode2]].blockId == j) {
3666 for(
MInt j = 0; j < nDim; ++j) {
3668 if(nodeMap[results[countNode2]].pos[j] == 0
3669 || nodeMap[results[countNode2]].pos[j] == m_grid->getBlockNoCells(tempnum, 1 - j)) {
3674 Nstar = nfound + 2 * nfound - tempcount;
3675 if(Nstar == 4) Nstar = 0;
3677 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
3678 for(
MInt d = 0; d < nDim; ++d) {
3679 if(nodeMap[results[countNode2]].BC[d] != 0) {
3680 BCs.insert(nodeMap[results[countNode2]].BC[d]);
3694 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
3695 for(
MInt j = 0; j < m_noBlocks; ++j) {
3696 if(nodeMap[results[countNode2]].blockId == j) {
3701 for(
MInt j = 0; j < nDim; ++j) {
3703 if(nodeMap[results[countNode2]].pos[j] == 0
3704 || nodeMap[results[countNode2]].pos[j] == m_grid->getBlockNoCells(tempnum, 1 - j)) {
3710 if(tempcount == 6) {
3715 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
3716 if(BCs.size() > 1) cout <<
"CAUTION: This singular point has more than one BC!" << endl;
3717 for(
const auto& BC : BCs) {
3719 if(addConnection(BC,
3720 nodeMap[results[countNode2]].blockId,
3721 nodeMap[results[countNode2]].pos,
3722 nodeMap[results[countNode2]].blockId,
3723 nodeMap[results[countNode2]].pos,
3725 ASSERT(Nstar == 3,
"");
3727 numSingularConnections = numSingularConnections + 1;
3737 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
3738 if(BCs.size() > 1) cout <<
"CAUTION: This singular point has more than one BC!" << endl;
3739 for(
const auto& BC : BCs) {
3741 if(addConnection(BC,
3742 nodeMap[results[countNode2]].blockId,
3743 nodeMap[results[countNode2]].pos,
3744 nodeMap[results[countNode2]].blockId,
3745 nodeMap[results[countNode2]].pos,
3747 ASSERT(Nstar == 5,
"");
3749 numSingularConnections = numSingularConnections + 1;
3756 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
3757 if(BCs.size() > 1) cout <<
"CAUTION: This singular point has more than one BC!" << endl;
3758 for(
const auto& BC : BCs) {
3760 if(addConnection(BC,
3761 nodeMap[results[countNode2]].blockId,
3762 nodeMap[results[countNode2]].pos,
3763 nodeMap[results[countNode2]].blockId,
3764 nodeMap[results[countNode2]].pos,
3766 ASSERT(Nstar == 6,
"");
3768 numSingularConnections = numSingularConnections + 1;
3774 cout <<
"ERROR: nfound=" << nfound <<
" Nstar=" << Nstar << endl;
3780 if(domainId() == 0) {
3781 cout <<
"Computing periodic window displacements" << endl;
3783 m_log <<
"Computing periodic window displacements" << endl;
3787 MFloatScratchSpace periodicWindowCenter(m_noBlocks, nDim, 2 * nDim, AT_,
"periodicWindowCOGS");
3788 MIntScratchSpace periodicWindowNoNodes(m_noBlocks, 2 * nDim, AT_,
"periodicWindowNoNodes");
3790 periodicWindowCenter.
fill(F0);
3791 periodicWindowNoNodes.
fill(0);
3794 const MInt periodicOffset = 4401;
3795 for(
MInt i = 0; i < pcount; ++i) {
3796 if(nodeMapP[i].BC[0] < 4401 || nodeMapP[i].BC[0] > 4406) {
3801 for(
MInt dim = 0; dim < nDim; dim++) {
3802 periodicWindowCenter(nodeMapP[i].blockId, dim, nodeMapP[i].BC[0] - periodicOffset) +=
3803 periodicCoordinates(dim, i);
3806 periodicWindowNoNodes(nodeMapP[i].blockId, nodeMapP[i].BC[0] - periodicOffset) += 1;
3813 multimap<MInt, pair<vector<MFloat>,
MInt>> oddPeriodicSides;
3814 multimap<MInt, pair<vector<MFloat>,
MInt>> evenPeriodicSides;
3823 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
3824 for(
MInt periodicWindowId = 0; periodicWindowId < 2 * nDim; periodicWindowId++) {
3825 if(periodicWindowNoNodes(blockId, periodicWindowId) <= 0) {
3828 vector<MFloat> centerDimensions(nDim);
3829 for(
MInt dim = 0; dim < nDim; dim++) {
3830 periodicWindowCenter(blockId, dim, periodicWindowId) /=
3831 (
MFloat)periodicWindowNoNodes(blockId, periodicWindowId);
3832 centerDimensions[dim] =
3833 periodicWindowCenter(blockId, dim,
3835 cout <<
"periodic Window center " << periodicWindowCenter(blockId, dim, periodicWindowId) << endl;
3837 if(periodicWindowId % 2 == 0) {
3839 evenPeriodicSides.insert(pair<
MInt, pair<vector<MFloat>,
MInt>>(
3840 blockId, pair<vector<MFloat>,
MInt>(centerDimensions, periodicWindowId)));
3841 cout <<
"dimensions of centerDimensions (even)" << centerDimensions[0] <<
" " << centerDimensions[1]
3845 oddPeriodicSides.insert(pair<
MInt, pair<vector<MFloat>,
MInt>>(
3846 blockId, pair<vector<MFloat>,
MInt>(centerDimensions, periodicWindowId)));
3847 cout <<
"dimensions of centerDimensions (odd)" << centerDimensions[0] <<
" " << centerDimensions[1]
3857 pair<multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator, multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator>
3859 pair<multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator, multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator>
3863 MFloatScratchSpace periodicDisplacementsBlockIds(m_noBlocks, nDim * nDim, AT_,
"periodic Displacements per block");
3865 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
3866 MInt noEvenPerodicWindowsBlockIds = evenPeriodicSides.count(blockId);
3867 MInt noOddPeriodicWindowsBlockIds = oddPeriodicSides.count(blockId);
3868 cout <<
"we have evenSides " << noEvenPerodicWindowsBlockIds <<
" and we have oddSides "
3869 << noOddPeriodicWindowsBlockIds <<
" in BlockId " << blockId << endl;
3870 if(noEvenPerodicWindowsBlockIds == 0)
continue;
3871 if(noOddPeriodicWindowsBlockIds == 0)
continue;
3873 evenIt = evenPeriodicSides.equal_range(blockId);
3874 multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator eit = evenIt.first;
3875 while(eit != evenIt.second) {
3876 MBool tobeErased =
false;
3878 ceil(((
MFloat)((*eit).second.second + 1) / 2.0) - 1);
3879 MInt evenSide = (*eit).second.second;
3880 MInt oddSide = evenSide + 1;
3881 oddIt = oddPeriodicSides.equal_range(blockId);
3882 multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator oit = oddIt.first;
3884 while(oit != oddIt.second) {
3885 if((*oit).second.second == oddSide) {
3887 for(
MInt dim = 0; dim < nDim; dim++) {
3888 cout <<
"first element is " << (*oit).second.first[dim] <<
" and we subtract " << (*eit).second.first[dim]
3890 periodicDisplacementsBlockIds(blockId, evenSideDim + nDim * dim) =
3891 abs((*oit).second.first[dim] - (*eit).second.first[dim]);
3893 oit = oddPeriodicSides.erase(oit);
3901 eit = evenPeriodicSides.erase(eit);
3908 MFloat periodicEpsilon = 0.000001;
3911 if(evenPeriodicSides.size() != 0
3912 && oddPeriodicSides.size() != 0) {
3913 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
3914 MInt noEvenPerodicWindowsBlockId = evenPeriodicSides.count(blockId);
3915 if(noEvenPerodicWindowsBlockId == 0)
continue;
3916 evenIt = evenPeriodicSides.equal_range(blockId);
3917 multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator eit = evenIt.first;
3918 while(eit != evenIt.second) {
3919 MBool tobeErased =
false;
3921 ceil(((
MFloat)((*eit).second.second + 1) / 2.0) - 1);
3923 multimap<MInt, pair<vector<MFloat>,
MInt>>::iterator oit = oddPeriodicSides.begin();
3924 while(oit != oddPeriodicSides.end()) {
3926 MInt equalConnectionDims = 0;
3927 for(
MInt d = 0; d < nDim; d++) {
3928 if(abs((*oit).second.first[d] - (*eit).second.first[d]) < periodicEpsilon) equalConnectionDims++;
3930 if(equalConnectionDims == 2) {
3931 for(
MInt dim = 0; dim < nDim; dim++) {
3932 periodicDisplacementsBlockIds(blockId, evenSideDim + nDim * dim) =
3933 abs((*oit).second.first[dim] - (*eit).second.first[dim]);
3935 periodicDisplacementsBlockIds((*oit).first, evenSideDim + nDim * dim) =
3936 periodicDisplacementsBlockIds(blockId, evenSideDim + nDim * dim);
3939 oit = oddPeriodicSides.erase(oit);
3945 eit = evenPeriodicSides.erase(eit);
3954 for(
MInt periodicWindowId = 0; periodicWindowId < 2 * nDim; periodicWindowId++) {
3955 if(periodicWindowId % 2 == 1) {
3956 for(
MInt dim = 0; dim < nDim; dim++) {
3957 const MInt displacementId = (
MFloat)(periodicWindowId + 1) / 2.0 - 1;
3958 periodicDisplacements[dim * nDim + displacementId] =
3959 periodicWindowCenter(m_blockId, dim, periodicWindowId)
3960 - periodicWindowCenter(m_blockId, dim, periodicWindowId - 1);
3961 m_log << m_blockId <<
" periodicWindowCenter for window: " << periodicWindowId + periodicOffset
3962 <<
" dim: " << dim <<
" displacementId: " << displacementId
3963 <<
" displacement: " << periodicDisplacements[dim * nDim + displacementId] << endl;
3968 cout <<
"old approach" << endl;
3969 for(
MInt periodicWindowId = 0; periodicWindowId < 2 * nDim; periodicWindowId++) {
3970 if(periodicWindowId % 2 == 1) {
3971 for(
MInt dim = 0; dim < nDim; dim++) {
3972 const MInt displacementId = (
MFloat)(periodicWindowId + 1) / 2.0 - 1;
3973 periodicDisplacements[dim * nDim + displacementId] =
3974 periodicWindowCenter(m_blockId, dim, periodicWindowId)
3975 - periodicWindowCenter(m_blockId, dim, periodicWindowId - 1);
3976 cout <<
"blockId = " << m_blockId <<
"periodicWindowCenter for window: " << periodicWindowId + periodicOffset
3977 <<
" dim: " << dim <<
" displacementId: " << displacementId
3978 <<
" displacement: " << periodicDisplacements[dim * nDim + displacementId] << endl;
3982 cout <<
"new approach " << endl;
3983 for(
MInt periodicWindowId = 0; periodicWindowId < 2 * nDim; periodicWindowId++) {
3984 if(periodicWindowId % 2 == 1) {
3985 const MInt displacementId = (
MFloat)(periodicWindowId + 1) / 2.0 - 1;
3986 for(
MInt dim = 0; dim < nDim; dim++) {
3987 cout <<
"blockId = " << m_blockId <<
"periodicWindowCenter for window: " << periodicWindowId + periodicOffset
3988 <<
" dim: " << dim <<
" displacementId: " << displacementId
3989 <<
" displacement: " << periodicDisplacementsBlockIds(m_blockId, dim * nDim + displacementId) << endl;
3994 if(domainId() == 0) {
3995 for(
MInt b = 0;
b < m_noBlocks;
b++) {
3996 cout <<
"BlockId " <<
b <<
": " << endl;
3998 for(
MInt i = 0; i < nDim * nDim; i++) {
3999 cout << periodicDisplacementsBlockIds(
b, i) <<
" ";
4005 for(
MInt b = 0;
b < m_noBlocks;
b++) {
4006 if(
b == m_blockId) {
4007 for(
MInt i = 0; i < nDim * nDim; i++) {
4008 periodicDisplacements[i] = periodicDisplacementsBlockIds(
b, i);
4019 for(
MInt i = 0; i < pcount; ++i) {
4020 tmppoint[0] = periodicCoordinates(0, i);
4021 tmppoint[1] = periodicCoordinates(1, i);
4022 periodicPointsChange(tmppoint, nodeMapP[i].BC[0], periodicDisplacements);
4023 Point<2> aaa(tmppoint[0], tmppoint[1]);
4024 nfound = tree.
locatenear(aaa, m_gridEps, results, 10,
false);
4025 for(
MInt countNode2 = 0; countNode2 < nfound; ++countNode2) {
4027 if(addConnection(nodeMapP[i].BC[0],
4028 nodeMapP[i].blockId,
4030 nodeMap[results[countNode2]].blockId,
4031 nodeMap[results[countNode2]].pos)) {
4032 numConnections = numConnections + 1;
4063 if(domainId() == 0) {
4064 cout <<
"Assemble multiblock connections" << endl;
4069 multiBlockAssembling();
4070 singularityAssembling();
4073 deleteDuplicateWindows(window0d, window0d);
4074 deleteDuplicateWindows(window1d, window1d);
4075 deleteDuplicateWindows(window0d, window1d);
4077 for(
auto it = singularwindow.cbegin(); it != singularwindow.cend(); ++it) {
4079 if((*it)->BC >= 4400 && (*it)->BC < 4410)
continue;
4080 MInt noSameWindows = 0;
4081 (*it)->BCsingular[noSameWindows++] = (*it)->BC;
4083 for(
auto it2 = it + 1; it2 != singularwindow.cend();) {
4084 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4085 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4086 const MBool test = mapCompare11(map1, map2);
4088 if((*it)->BCsingular[0] == (*it2)->BC || (*it)->Nstar != (*it2)->Nstar) {
4089 mTerm(1,
"There is no hope anymore!");
4092 if(noSameWindows >= (*it)->Nstar) {
4096 (*it)->BCsingular[noSameWindows++] = (*it2)->BC;
4097 singularwindow.erase(it2);
4140 unique_ptr<StructuredWindowMap<nDim>> windowMap;
4186 for(
MInt i = 0; i < (
MInt)window1d.size(); ++i) {
4188 const MInt BC = (window1d[i]->BC >= 6000 && window1d[i]->BC < 6010) ? -window1d[i]->BC : window1d[i]->BC;
4190 windowMap = make_unique<StructuredWindowMap<nDim>>();
4191 mapCreate(window1d[i]->Id1, window1d[i]->start1, window1d[i]->end1, window1d[i]->step1, window1d[i]->Id2,
4192 window1d[i]->start2, window1d[i]->end2, window1d[i]->step2, window1d[i]->order, BC, windowMap);
4193 windowMap->Nstar = -1;
4194 windowMap->SingularId = -1;
4195 windowMap->dc1 = window1d[i]->dc1;
4196 windowMap->dc2 = window1d[i]->dc2;
4199 for(
MInt j = 0; j < nDim; ++j) {
4200 if(windowMap->start1[j] == windowMap->end1[j]) {
4201 if(windowMap->start1[j] == 0 && windowMap->start2[windowMap->order[j]] == 0) {
4202 windowMap->step2[windowMap->order[j]] = -1;
4204 if(windowMap->start1[j] > 0 && windowMap->start2[windowMap->order[j]] > 0) {
4205 windowMap->step2[windowMap->order[j]] = -1;
4212 for(
MInt j = 0; j < (
MInt)singularwindow.size(); ++j) {
4213 const MBool test = mapCompare11(windowMap, singularwindow[j]);
4215 mTerm(1,
"Impossible behaviour!");
4216 windowMap->Nstar = singularwindow[j]->Nstar;
4217 windowMap->SingularId = singularwindow[j]->SingularId;
4222 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
4224 if(window1d[i]->BC >= 6000 && window1d[i]->BC < 6010) {
4225 windowMap = make_unique<StructuredWindowMap<nDim>>();
4226 mapCreate(window1d[i]->Id1, window1d[i]->start1, window1d[i]->end1, window1d[i]->step1, window1d[i]->Id2,
4227 window1d[i]->start2, window1d[i]->end2, window1d[i]->step2, window1d[i]->order, BC, windowMap);
4228 windowMap->Nstar = -1;
4229 windowMap->SingularId = -1;
4230 windowMap->dc1 = window1d[i]->dc1;
4231 windowMap->dc2 = window1d[i]->dc2;
4234 for(
MInt j = 0; j < nDim; ++j) {
4235 if(windowMap->start1[j] == windowMap->end1[j]) {
4236 if(windowMap->start1[j] == 0 && windowMap->start2[windowMap->order[j]] == 0) {
4237 windowMap->step2[windowMap->order[j]] = -1;
4239 if(windowMap->start1[j] > 0 && windowMap->start2[windowMap->order[j]] > 0) {
4240 windowMap->step2[windowMap->order[j]] = -1;
4245 mapInvert1(windowMap);
4246 mapNormalize3(windowMap);
4250 for(
MInt j = 0; j < (
MInt)singularwindow.size(); ++j) {
4251 const MBool test = mapCompare11(windowMap, singularwindow[j]);
4253 mTerm(1,
"Impossible behaviour!");
4254 windowMap->Nstar = singularwindow[j]->Nstar;
4255 windowMap->SingularId = singularwindow[j]->SingularId;
4259 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
4264 for(
MInt i = 0; i < (
MInt)window0d.size(); ++i) {
4266 const MInt BC = (window0d[i]->BC >= 6000 && window0d[i]->BC < 6010) ? -window0d[i]->BC : window0d[i]->BC;
4269 windowMap = make_unique<StructuredWindowMap<nDim>>();
4270 mapCreate(window0d[i]->Id1, window0d[i]->start1, window0d[i]->end1, window0d[i]->step1, window0d[i]->Id2,
4271 window0d[i]->start2, window0d[i]->end2, window0d[i]->step2, window0d[i]->order, BC, windowMap);
4272 windowMap->Nstar = -1;
4273 windowMap->SingularId = -1;
4274 windowMap->dc1 = window0d[i]->dc1;
4275 windowMap->dc2 = window0d[i]->dc2;
4277 for(
MInt j = 0; j < nDim; ++j) {
4278 if(windowMap->start1[j] == windowMap->end1[j]) {
4279 if(windowMap->start1[j] == 0 && windowMap->start2[windowMap->order[j]] == 0) {
4280 windowMap->step2[windowMap->order[j]] = -1;
4282 if(windowMap->start1[j] > 0 && windowMap->start2[windowMap->order[j]] > 0) {
4283 windowMap->step2[windowMap->order[j]] = -1;
4290 for(
MInt j = 0; j < (
MInt)singularwindow.size(); ++j) {
4291 const MBool test = mapCompare11(windowMap, singularwindow[j]);
4293 windowMap->Nstar = singularwindow[j]->Nstar;
4294 windowMap->SingularId = singularwindow[j]->SingularId;
4299 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
4301 if(window0d[i]->BC >= 6000 && window0d[i]->BC < 6010) {
4302 windowMap = make_unique<StructuredWindowMap<nDim>>();
4303 mapCreate(window0d[i]->Id1, window0d[i]->start1, window0d[i]->end1, window0d[i]->step1, window0d[i]->Id2,
4304 window0d[i]->start2, window0d[i]->end2, window0d[i]->step2, window0d[i]->order, BC, windowMap);
4305 windowMap->Nstar = -1;
4306 windowMap->SingularId = -1;
4307 windowMap->dc1 = window0d[i]->dc1;
4308 windowMap->dc2 = window0d[i]->dc2;
4311 for(
MInt j = 0; j < nDim; ++j) {
4312 if(windowMap->start1[j] == windowMap->end1[j]) {
4313 if(windowMap->start1[j] == 0 && windowMap->start2[windowMap->order[j]] == 0) {
4314 windowMap->step2[windowMap->order[j]] = -1;
4316 if(windowMap->start1[j] > 0 && windowMap->start2[windowMap->order[j]] > 0) {
4317 windowMap->step2[windowMap->order[j]] = -1;
4322 mapInvert1(windowMap);
4323 mapNormalize3(windowMap);
4327 for(
MInt j = 0; j < (
MInt)singularwindow.size(); ++j) {
4328 const MBool test = mapCompare11(windowMap, singularwindow[j]);
4330 windowMap->Nstar = singularwindow[j]->Nstar;
4331 windowMap->SingularId = singularwindow[j]->SingularId;
4334 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
4339 deleteDuplicateCommMaps();
4342 if(domainId() == 0) {
4343 cout <<
"======= GLOBALSTRUCTUREDBNDRYCNDMAPS ======" << endl;
4344 for(
MInt i = 0; i < (signed)globalStructuredBndryCndMaps.size(); ++i) {
4345 mapPrint(globalStructuredBndryCndMaps[i]);
4348 cout <<
" ======= SINGULARWINDOW =============" << endl;
4349 for(
MInt i = 0; i < (signed)singularwindow.size(); ++i) {
4350 mapPrint(singularwindow[i]);
4353 cout <<
" ======== window0d ==============" << endl;
4354 for(
MInt i = 0; i < (signed)window0d.size(); ++i) {
4355 mapPrint(window0d[i]);
4358 cout <<
" ======== window1d ==============" << endl;
4359 for(
MInt i = 0; i < (signed)window1d.size(); ++i) {
4360 mapPrint(window1d[i]);
4363 cout <<
" ======== window2d ==============" << endl;
4364 for(
MInt i = 0; i < (signed)window2d.size(); ++i) {
4365 mapPrint(window2d[i]);
4370 if(!hasConnectionInfo) {
4371 writeConnectionWindowInformation2D(periodicDisplacements);
4373 if(domainId() == 0) {
4374 cout <<
"##########################################################################" << endl;
4375 cout <<
"WARNING: OLD CONNECTION INFO EXISTS, DELETE BEFORE NEW ONE CAN BE WRITTEN!" << endl;
4376 cout <<
"##########################################################################" << endl;
4380 if(domainId() == 0) {
4381 cout <<
"Connection identification and window creation finished!" << endl;
4390 const MInt singularcount) {
4391 const MInt s_blockId = s_window->Id1;
4392 const MInt g_blockId = g_window->Id2;
4393 stringstream prop_name;
4394 prop_name <<
"BCMap_" << std::min(s_blockId, g_blockId) <<
"_" << std::max(s_blockId, g_blockId);
4395 const MInt BC_temp = Context::getSolverProperty<MInt>(prop_name.str(), solverId(), AT_);
4396 if(BC_temp < 6000 || BC_temp >= 6010)
mTerm(1,
"Your are an idiot!");
4397 s_window->BCsingular[singularcount + 2] = -BC_temp;
4398 g_window->BC = -BC_temp;
4407 const MBool isSame = (&window1 == &window2);
4410 for(
auto it = window1.cbegin(); it != window1.cend();) {
4411 if(window1.empty()) {
4414 MBool deleted1 =
false;
4415 if((*it)->BC >= 6000 && (*it)->BC < 6010) {
4416 for(
auto it2 = isSame ? it + 1 : window2.cbegin(); it2 != window2.cend();) {
4417 if(window2.empty()) {
4420 MBool deleted2 =
false;
4421 if((*it2)->BC >= 6000 && (*it2)->BC < 6010) {
4426 if((*it)->Id1 == (*it2)->Id1 && (*it)->Id2 == (*it2)->Id2) {
4430 MInt diffStart[nDim], diffEnd[nDim];
4431 for(
MInt dim = 0; dim < nDim; ++dim) {
4433 if((*it)->step1[dim] < 0 || (*it2)->step1[dim] < 0) {
4437 diffStart[dim] = (*it)->start1[dim] - (*it2)->start1[dim];
4438 diffEnd[dim] = (*it)->end1[dim] - (*it2)->end1[dim];
4441 const MInt minStart = *std::min_element(&diffStart[0], &diffStart[0] + nDim);
4442 const MInt maxStart = *std::max_element(&diffStart[0], &diffStart[0] + nDim);
4443 const MInt minEnd = *std::min_element(&diffEnd[0], &diffEnd[0] + nDim);
4444 const MInt maxEnd = *std::max_element(&diffEnd[0], &diffEnd[0] + nDim);
4445 if(minStart * maxStart >= 0 && minEnd * maxEnd >= 0
4446 && ((minStart >= 0 && maxEnd <= 0) || (maxStart <= 0 && minEnd >= 0))) {
4454 if(minStart == 0 && maxStart == 0 && minEnd == 0 && maxEnd == 0) {
4455 if((*it)->BC != 6000 || (*it2)->BC != 6000) {
4456 if(domainId() == 0) cout <<
"CAUTION: BC reset to 6000!" << endl;
4463 if(minStart >= 0 && maxEnd <= 0) {
4465 if(domainId() == 0) {
4466 cout <<
"!!! DELETE WINDOW: !!!" << endl;
4467 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4469 cout <<
"!!! BECAUSE OF: !!!" << endl;
4470 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4472 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4475 it = window1.erase(it);
4480 if(domainId() == 0) {
4481 cout <<
"!!! DELETE WINDOW2: !!!" << endl;
4482 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4484 cout <<
"!!! BECAUSE OF: !!!" << endl;
4485 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4487 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4490 it2 = window2.erase(it2);
4498 if(!deleted2) ++it2;
4507 for(
auto it = window1.cbegin(); it != window1.cend();) {
4508 if(window1.empty()) {
4511 MBool deleted1 =
false;
4512 if((*it)->BC >= 4401 && (*it)->BC <= 4406) {
4513 for(
auto it2 = isSame ? it + 1 : window2.cbegin(); it2 != window2.cend();) {
4514 if(window2.empty()) {
4517 MBool deleted2 =
false;
4518 if((*it2)->BC >= 4401 && (*it2)->BC <= 4406) {
4520 if((*it)->Id2 == (*it2)->Id2) {
4524 MInt diffStart[nDim], diffEnd[nDim];
4525 for(
MInt dim = 0; dim < nDim; ++dim) {
4526 auto it_start2 = (*it)->step2[dim] > 0 ? (*it)->start2[dim] : (*it)->end2[dim];
4527 auto it_end2 = (*it)->step2[dim] > 0 ? (*it)->end2[dim] : (*it)->start2[dim];
4528 auto it2_start2 = (*it2)->step2[dim] > 0 ? (*it2)->start2[dim] : (*it2)->end2[dim];
4529 auto it2_end2 = (*it2)->step2[dim] > 0 ? (*it2)->end2[dim] : (*it2)->start2[dim];
4530 diffStart[dim] = it_start2 - it2_start2;
4531 diffEnd[dim] = it_end2 - it2_end2;
4535 const MInt minStart = *std::min_element(&diffStart[0], &diffStart[0] + nDim);
4536 const MInt maxStart = *std::max_element(&diffStart[0], &diffStart[0] + nDim);
4537 const MInt minEnd = *std::min_element(&diffEnd[0], &diffEnd[0] + nDim);
4538 const MInt maxEnd = *std::max_element(&diffEnd[0], &diffEnd[0] + nDim);
4539 if(minStart * maxStart >= 0 && minEnd * maxEnd >= 0
4540 && ((minStart >= 0 && maxEnd <= 0) || (maxStart <= 0 && minEnd >= 0))) {
4544 if(!(minStart == 0 && maxStart == 0 && minEnd == 0 && maxEnd == 0)) {
4547 if(minStart >= 0 && maxEnd <= 0) {
4549 if(domainId() == 0) {
4550 cout <<
"!!! DELETE WINDOW: !!!" << endl;
4551 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4553 cout << minStart <<
"|" << maxStart <<
" " << minEnd <<
"|" << maxEnd << endl;
4554 cout <<
"!!! BECAUSE OF: !!!" << endl;
4555 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4557 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4560 it = window1.erase(it);
4565 if(domainId() == 0) {
4566 cout <<
"!!! DELETE WINDOW2: !!!" << endl;
4567 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4569 cout <<
"!!! BECAUSE OF: !!!" << endl;
4570 cout << minStart <<
"|" << maxStart <<
" " << minEnd <<
"|" << maxEnd << endl;
4571 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4573 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4576 it2 = window2.erase(it2);
4583 if(!deleted2) ++it2;
4596 for(
auto it = globalStructuredBndryCndMaps.cbegin(); it != globalStructuredBndryCndMaps.cend();) {
4597 if(globalStructuredBndryCndMaps.empty()) {
4601 MBool deleted1 =
false;
4602 if((*it)->BC <= -6000 && (*it)->BC > -6010) {
4603 for(
auto it2 = it + 1; it2 != globalStructuredBndryCndMaps.cend();) {
4604 if(globalStructuredBndryCndMaps.empty()) {
4608 MBool deleted2 =
false;
4609 if((*it2)->BC <= -6000 && (*it2)->BC > -6010) {
4610 if((*it)->Nstar != (*it2)->Nstar) {
4619 if((*it)->Id1 == (*it2)->Id1 && (*it)->Id2 == (*it2)->Id2) {
4623 MInt diffStart[nDim], diffEnd[nDim];
4624 for(
MInt dim = 0; dim < nDim; ++dim) {
4626 if((*it)->step1[dim] < 0 || (*it2)->step1[dim] < 0)
mTerm(1,
"");
4627 diffStart[dim] = (*it)->start1[dim] - (*it2)->start1[dim];
4628 diffEnd[dim] = (*it)->end1[dim] - (*it2)->end1[dim];
4630 const MInt minStart = *std::min_element(&diffStart[0], &diffStart[0] + nDim);
4631 const MInt maxStart = *std::max_element(&diffStart[0], &diffStart[0] + nDim);
4632 const MInt minEnd = *std::min_element(&diffEnd[0], &diffEnd[0] + nDim);
4633 const MInt maxEnd = *std::max_element(&diffEnd[0], &diffEnd[0] + nDim);
4634 if(minStart * maxStart >= 0 && minEnd * maxEnd >= 0
4635 && ((minStart >= 0 && maxEnd <= 0) || (maxStart <= 0 && minEnd >= 0))) {
4639 if(!(minStart == 0 && maxStart == 0 && minEnd == 0 && maxEnd == 0)) {
4640 mTerm(1,
"Duplicates are supposed to be deleted already in deleteDuplicateWindows!");
4644 if(minStart >= 0 && maxEnd <= 0) {
4646 if(domainId() == 0) {
4647 cout <<
"!!! DELETE MAP: !!!" << endl;
4648 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4650 cout <<
"!!! BECAUSE OF: !!!" << endl;
4651 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4653 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4656 it = globalStructuredBndryCndMaps.erase(it);
4661 if(domainId() == 0) {
4662 cout <<
"!!! DELETE MAP2: !!!" << endl;
4663 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4665 cout <<
"!!! BECAUSE OF: !!!" << endl;
4666 cout << minStart <<
"|" << maxStart <<
" " << minEnd <<
"|" << maxEnd << endl;
4667 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4669 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4672 it2 = globalStructuredBndryCndMaps.erase(it2);
4679 if(!deleted2) ++it2;
4688 for(
auto it = globalStructuredBndryCndMaps.cbegin(); it != globalStructuredBndryCndMaps.cend();) {
4689 if(globalStructuredBndryCndMaps.empty()) {
4693 MBool deleted1 =
false;
4694 if((*it)->BC >= 4401 && (*it)->BC <= 4406) {
4695 for(
auto it2 = it + 1; it2 != globalStructuredBndryCndMaps.cend();) {
4696 if(globalStructuredBndryCndMaps.empty()) {
4700 MBool deleted2 =
false;
4701 if((*it2)->BC >= 4401 && (*it2)->BC <= 4406) {
4703 if((*it)->Id2 == (*it2)->Id2) {
4707 MInt diffStart[nDim], diffEnd[nDim];
4708 for(
MInt dim = 0; dim < nDim; ++dim) {
4709 auto it_start2 = (*it)->step2[dim] > 0 ? (*it)->start2[dim] : (*it)->end2[dim];
4710 auto it_end2 = (*it)->step2[dim] > 0 ? (*it)->end2[dim] : (*it)->start2[dim];
4711 auto it2_start2 = (*it2)->step2[dim] > 0 ? (*it2)->start2[dim] : (*it2)->end2[dim];
4712 auto it2_end2 = (*it2)->step2[dim] > 0 ? (*it2)->end2[dim] : (*it2)->start2[dim];
4713 diffStart[dim] = it_start2 - it2_start2;
4714 diffEnd[dim] = it_end2 - it2_end2;
4718 const MInt minStart = *std::min_element(&diffStart[0], &diffStart[0] + nDim);
4719 const MInt maxStart = *std::max_element(&diffStart[0], &diffStart[0] + nDim);
4720 const MInt minEnd = *std::min_element(&diffEnd[0], &diffEnd[0] + nDim);
4721 const MInt maxEnd = *std::max_element(&diffEnd[0], &diffEnd[0] + nDim);
4722 if(minStart * maxStart >= 0 && minEnd * maxEnd >= 0
4723 && ((minStart >= 0 && maxEnd <= 0) || (maxStart <= 0 && minEnd >= 0))) {
4727 if(!(minStart == 0 && maxStart == 0 && minEnd == 0 && maxEnd == 0)) {
4728 mTerm(1,
"Duplicates are supposed to be deleted already in deleteDuplicateWindows!");
4732 if(minStart >= 0 && maxEnd <= 0) {
4734 if(domainId() == 0) {
4735 cout <<
"!!! DELETE MAP: !!!" << endl;
4736 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4738 cout << minStart <<
"|" << maxStart <<
" " << minEnd <<
"|" << maxEnd << endl;
4739 cout <<
"!!! BECAUSE OF: !!!" << endl;
4740 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4742 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4745 it = globalStructuredBndryCndMaps.erase(it);
4750 if(domainId() == 0) {
4751 cout <<
"!!! DELETE MAP2: !!!" << endl;
4752 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4754 cout <<
"!!! BECAUSE OF: !!!" << endl;
4755 cout << minStart <<
"|" << maxStart <<
" " << minEnd <<
"|" << maxEnd << endl;
4756 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4758 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4761 it2 = globalStructuredBndryCndMaps.erase(it2);
4768 if(!deleted2) ++it2;
4779 for(
auto it = BCMap.cbegin(); it != BCMap.cend();) {
4784 MBool deleted1 =
false;
4785 for(
auto it2 = it + 1; it2 != BCMap.cend();) {
4790 MBool deleted2 =
false;
4799 MInt diffStart[nDim], diffEnd[nDim];
4800 for(
MInt dim = 0; dim < nDim; ++dim) {
4801 diffStart[dim] = (*it)->start1[dim] - (*it2)->start1[dim];
4802 diffEnd[dim] = (*it)->end1[dim] - (*it2)->end1[dim];
4804 const MInt minStart = *std::min_element(&diffStart[0], &diffStart[0] + nDim);
4805 const MInt maxStart = *std::max_element(&diffStart[0], &diffStart[0] + nDim);
4806 const MInt minEnd = *std::min_element(&diffEnd[0], &diffEnd[0] + nDim);
4807 const MInt maxEnd = *std::max_element(&diffEnd[0], &diffEnd[0] + nDim);
4809 if(minStart * maxStart >= 0 && minEnd * maxEnd >= 0
4810 && ((minStart >= 0 && maxEnd <= 0) || (maxStart <= 0 && minEnd >= 0))) {
4812 if(!(minStart == 0 && maxStart == 0 && minEnd == 0 && maxEnd == 0)) {
4815 if(minStart >= 0 && maxEnd <= 0) {
4817 if(domainId() == 0) {
4818 cout <<
"!!! DELETE MAP: !!!" << endl;
4819 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4821 cout <<
"!!! BECAUSE OF: !!!" << endl;
4822 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4824 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4827 it = BCMap.erase(it);
4832 if(domainId() == 0) {
4833 cout <<
"!!! DELETE MAP2: !!!" << endl;
4834 const unique_ptr<StructuredWindowMap<nDim>>& map2 = (*it2);
4836 cout <<
"!!! BECAUSE OF: !!!" << endl;
4837 const unique_ptr<StructuredWindowMap<nDim>>& map1 = (*it);
4839 cout <<
"!!!!!!!!!!!!!!!!!!!" << endl;
4842 it2 = BCMap.erase(it2);
4847 if(!deleted2) ++it2;
4856 m_log <<
"-->reading windowInformation from file ...(serial->parallel approach)" << endl;
4859 stringstream dummy1;
4861 noInputWindowInformation = 0;
4862 pio.
getAttribute(&noInputWindowInformation,
"noWindows",
"/WindowInformation");
4864 noInputWindowConnections = 0;
4865 pio.
getAttribute(&noInputBndryCnds,
"noBndryCnds",
"/BC");
4867 MIntScratchSpace windowInfo(noInputWindowInformation * 7, AT_,
"widnow information");
4869 MInt indices[MAX_SPACE_DIMENSIONS][2];
4871 for(
MInt i = 0; i < noInputWindowInformation; i++) {
4872 stringstream windowdummy;
4873 windowdummy << (i + 1);
4874 MString window =
"window" + windowdummy.str();
4875 MString window1 =
"/WindowInformation/window" + windowdummy.str();
4876 pio.
getAttribute(&(windowInfo[i * 7]),
"block", window1);
4877 ParallelIo::size_type ioSize[2] = {nDim, 2};
4878 pio.
readArray(&(windowInfo[i * 7 + 1]),
"WindowInformation", window, 2, ioSize);
4882 MInt** BCInformation =
new MInt*[
mMax(noInputBndryCnds, 0)];
4884 MInt* noBcCndWindows =
new MInt[
mMax(noInputBndryCnds, 0)];
4886 for(
MInt i = 0; i < noInputBndryCnds; i++) {
4887 stringstream bcDummy;
4888 stringstream bcDummy1;
4889 bcDummy <<
"/BC/BC" << (i + 1);
4890 bcDummy1 <<
"BC" << (i + 1);
4891 char bcIdWindows[80];
4893 strcpy(bcIdWindows, &bcDummy.str()[0]);
4894 strcpy(bcId, &bcDummy.str()[0]);
4895 strcat(bcIdWindows,
"/noWindows");
4896 pio.
getAttribute(&noBcWindows,
"noWindows", bcDummy.str());
4897 noBcCndWindows[i] = noBcWindows;
4898 BCInformation[i] =
new MInt[
mMax((
MInt)noBcWindows, 0)];
4899 ParallelIo::size_type ioSize = noBcWindows;
4900 pio.
readArray(&BCInformation[i][0],
"BC", bcDummy1.str(), 1, &ioSize);
4901 strcat(bcId,
"/BC");
4906 for(
MInt i = 0; i < noInputBndryCnds; i++) {
4907 noWindows += noBcCndWindows[i];
4911 MIntScratchSpace bcInfo(noWindows + 3 * noInputBndryCnds, AT_,
"send bc info");
4912 for(
MInt i = 0; i < noInputBndryCnds; i++) {
4913 bcInfo[count] = bcCndId[i];
4915 bcInfo[count] = noBcCndWindows[i];
4917 memcpy(&(bcInfo[count]), &(BCInformation[i][0]), noBcCndWindows[i] *
sizeof(
MInt));
4918 count += noBcCndWindows[i];
4919 bcInfo[count] = bcCndId[i];
4923 MInt countInfo[3] = {noInputWindowInformation, noInputBndryCnds, noWindows};
4924 MPI_Bcast(countInfo, 3, MPI_INT, 0, m_StructuredComm, AT_,
"countInfo");
4927 MPI_Bcast(windowInfo.
getPointer(), noInputWindowInformation * 7, MPI_INT, 0, m_StructuredComm, AT_,
4928 "windowInfo.getPointer()");
4929 MPI_Bcast(bcInfo.
getPointer(), (noWindows + 3 * noInputBndryCnds), MPI_INT, 0, m_StructuredComm, AT_,
4930 "bcInfo.getPointer()");
4933 for(
MInt i = 0; i < noInputWindowInformation; i++) {
4934 std::unique_ptr<windowInformation<nDim>> temp = make_unique<windowInformation<nDim>>();
4938 temp->blockId = windowInfo[i * 7];
4939 memcpy(&indices[0][0], &(windowInfo[i * 7 + 1]), MAX_SPACE_DIMENSIONS * 2 *
sizeof(
MInt));
4940 for(
MInt dim = 0; dim < nDim; dim++) {
4941 temp->startindex[dim] = indices[dim][0] - 1;
4942 temp->endindex[dim] = indices[dim][1] - 1;
4945 inputWindows.push_back(std::move(temp));
4948 for(
MInt i = 0; i < noInputBndryCnds; ++i) {
4949 for(
MInt j = 0; j < noBcCndWindows[i]; ++j) {
4950 MInt windowId = BCInformation[i][j] - 1;
4951 inputWindows[windowId]->BC = bcCndId[i];
4956 delete[] noBcCndWindows;
4957 for(
MInt i = 0; i < noInputBndryCnds; i++) {
4958 delete[] BCInformation[i];
4960 delete[] BCInformation;
4963 MInt countInfo[3] = {0, 0, 0};
4964 MPI_Bcast(countInfo, 3, MPI_INT, 0, m_StructuredComm, AT_,
"countInfo");
4965 noInputWindowInformation = countInfo[0];
4966 noInputBndryCnds = countInfo[1];
4967 MInt noWindows = countInfo[2];
4968 MIntScratchSpace bcInfo(noWindows + 3 * noInputBndryCnds, AT_,
"send bc info");
4969 MIntScratchSpace windowInfo(noInputWindowInformation * 7, AT_,
"widnow information");
4971 MPI_Bcast(windowInfo.
getPointer(), noInputWindowInformation * 7, MPI_INT, 0, m_StructuredComm, AT_,
4972 "windowInfo.getPointer()");
4973 MPI_Bcast(bcInfo.
getPointer(), (noWindows + 3 * noInputBndryCnds), MPI_INT, 0, m_StructuredComm, AT_,
4974 "bcInfo.getPointer()");
4975 MInt indices[MAX_SPACE_DIMENSIONS][2];
4977 for(
MInt i = 0; i < noInputWindowInformation; i++) {
4978 std::unique_ptr<windowInformation<nDim>> temp = make_unique<windowInformation<nDim>>();
4982 temp->blockId = windowInfo[i * 7];
4983 memcpy(&indices[0][0], &(windowInfo[i * 7 + 1]), MAX_SPACE_DIMENSIONS * 2 *
sizeof(
MInt));
4984 for(
MInt dim = 0; dim < nDim; dim++) {
4985 temp->startindex[dim] = indices[dim][0] - 1;
4986 temp->endindex[dim] = indices[dim][1] - 1;
4989 inputWindows.push_back(std::move(temp));
4993 MInt** BCInformation =
new MInt*[
mMax(noInputBndryCnds, 0)];
4995 MInt* noBcCndWindows =
new MInt[
mMax(noInputBndryCnds, 0)];
4997 for(
MInt i = 0; i < noInputBndryCnds; i++) {
4998 bcCndId[i] = bcInfo[count];
5000 noBcCndWindows[i] = bcInfo[count];
5002 BCInformation[i] =
new MInt[
mMax(noBcCndWindows[i], 0)];
5003 memcpy(&(BCInformation[i][0]), &(bcInfo[count]), noBcCndWindows[i] *
sizeof(
MInt));
5004 count += noBcCndWindows[i];
5005 bcCndId[i] = bcInfo[count];
5010 for(
MInt i = 0; i < noInputBndryCnds; ++i) {
5011 for(
MInt j = 0; j < noBcCndWindows[i]; ++j) {
5012 MInt windowId = BCInformation[i][j] - 1;
5013 inputWindows[windowId]->BC = bcCndId[i];
5018 delete[] noBcCndWindows;
5019 for(
MInt i = 0; i < noInputBndryCnds; i++) {
5020 delete[] BCInformation[i];
5022 delete[] BCInformation;
5028 unique_ptr<StructuredWindowMap<nDim>> windowMap;
5035 MBool isPeriodicDirUsed[3] = {
false,
false,
false};
5036 MBool switchPeriodicBC[3] = {
true,
true,
true};
5041 for(
MInt windowId = 0; windowId < noInputWindowInformation; windowId++) {
5042 switch(inputWindows[windowId]->BC) {
5044 isPeriodicDirUsed[0] =
true;
5047 switchPeriodicBC[0] =
false;
5050 isPeriodicDirUsed[1] =
true;
5053 switchPeriodicBC[1] =
false;
5056 isPeriodicDirUsed[2] =
true;
5059 switchPeriodicBC[2] =
false;
5067 for(
MInt noWin = 0; noWin < noInputWindowInformation; noWin++) {
5068 windowMap = make_unique<StructuredWindowMap<nDim>>();
5069 MInt order[3] = {0, 1, 2};
5070 MInt step1[3] = {1, 1, 1};
5075 if(inputWindows[noWin]->BC != 6000
5076 && (inputWindows[noWin]->BC < 4000
5077 || inputWindows[noWin]->BC >= 5000) ) {
5078 mapCreate(inputWindows[noWin]->blockId, inputWindows[noWin]->startindex, inputWindows[noWin]->endindex, step1,
5079 (inputWindows[noWin]->windowId + 1),
nullptr,
nullptr,
nullptr, order, inputWindows[noWin]->BC,
5082 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
5095 if(inputWindows[noWin]->BC == 2221) {
5102 windowMap = make_unique<StructuredWindowMap<nDim>>();
5103 mapCreate(inputWindows[noWin]->blockId, inputWindows[noWin]->startindex, inputWindows[noWin]->endindex, step1,
5104 (inputWindows[noWin]->windowId + 1),
nullptr,
nullptr,
nullptr, order, 7909, windowMap);
5106 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
5110 if(inputWindows[noWin]->BC > 4000 && inputWindows[noWin]->BC < 5000) {
5117 if(inputWindows[noWin]->BC == 4011) {
5118 mapCreate(inputWindows[noWin]->blockId, inputWindows[noWin]->startindex, inputWindows[noWin]->endindex, step1,
5119 (inputWindows[noWin]->windowId + 1),
nullptr,
nullptr,
nullptr, order, 4001, windowMap);
5120 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
5123 if(inputWindows[noWin]->BC == 4012) {
5124 mapCreate(inputWindows[noWin]->blockId, inputWindows[noWin]->startindex, inputWindows[noWin]->endindex, step1,
5125 (inputWindows[noWin]->windowId + 1),
nullptr,
nullptr,
nullptr, order, 4002, windowMap);
5126 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
5129 if(inputWindows[noWin]->BC > 4400 && inputWindows[noWin]->BC < 4407) {
5132 MInt periodicDirection = -1;
5133 for(
MInt dim = 0; dim < nDim; dim++) {
5134 if(inputWindows[noWin]->startindex[dim] == inputWindows[noWin]->endindex[dim]) {
5135 periodicDirection = dim;
5140 MInt bigBlockId = inputWindows[noWin]->blockId;
5141 MInt bigBlockSize = m_grid->getBlockNoCells(bigBlockId, nDim - 1 - periodicDirection);
5142 MInt periodicId = inputWindows[noWin]->BC - 4401;
5143 MInt periodicIndex = periodicId / 2;
5145 if(switchPeriodicBC[periodicIndex] && bigBlockSize == inputWindows[noWin]->startindex[periodicDirection]
5146 && periodicId % 2 == 0) {
5147 m_log <<
"Changing BC from " << inputWindows[noWin]->BC <<
" to " << inputWindows[noWin]->BC + 1 << endl;
5148 inputWindows[noWin]->BC++;
5156 if(inputWindows[noWin]->BC == 4005 || inputWindows[noWin]->BC == 4006) {
5158 MInt freePeriodicBC = 4400;
5159 for(
MInt dir = 0; dir < nDim; dir++) {
5160 if(isPeriodicDirUsed[dir] ==
false) {
5161 freePeriodicBC += dir * 2 + 1;
5166 m_log <<
"Using Periodic BC " << freePeriodicBC <<
" / " << freePeriodicBC + 1 <<
" for the channel/pipe flow"
5169 if(inputWindows[noWin]->BC == 4005) {
5170 m_log <<
"Identified channel inflow bc 4005, creating periodic map BC " << freePeriodicBC
5171 <<
" and physicalMap BC " << 2401 << endl;
5172 inputWindows[noWin]->BC = freePeriodicBC;
5173 mapCreate(inputWindows[noWin]->blockId, inputWindows[noWin]->startindex, inputWindows[noWin]->endindex, step1,
5174 (inputWindows[noWin]->windowId + 1),
nullptr,
nullptr,
nullptr, order, 2401, windowMap);
5175 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
5178 if(inputWindows[noWin]->BC == 4006) {
5179 m_log <<
"Identified channel inflow bc 4006, creating periodic map BC " << freePeriodicBC + 1
5180 <<
" and physicalMap BC " << 2402 << endl;
5181 inputWindows[noWin]->BC = freePeriodicBC + 1;
5182 mapCreate(inputWindows[noWin]->blockId, inputWindows[noWin]->startindex, inputWindows[noWin]->endindex, step1,
5183 (inputWindows[noWin]->windowId + 1),
nullptr,
nullptr,
nullptr, order, 2402, windowMap);
5184 globalStructuredBndryCndMaps.push_back(std::move(windowMap));
5197 MInt noConnectionMaps = 0;
5199 for(
MInt mapId = 0; mapId < (
MInt)globalStructuredBndryCndMaps.size(); mapId++) {
5202 if((globalStructuredBndryCndMaps[mapId]->BC <= -6000 && globalStructuredBndryCndMaps[mapId]->BC > -6010)
5204 (globalStructuredBndryCndMaps[mapId]->BC > 4400 && globalStructuredBndryCndMaps[mapId]->BC < 4407)) {
5205 stringstream windowName;
5206 windowName <<
"map" << noConnectionMaps << endl;
5207 MString windowNameStr = windowName.str();
5208 ParallelIo::size_type noWindowInformation = 7 * nDim + 16;
5212 writeMapToArray(globalStructuredBndryCndMaps[mapId],
windowInformation.begin());
5215 ParallelIo::size_type offset = 0;
5219 ParallelIo::size_type zeroWindows = 0;
5220 pio.
writeArray(&empty,
"Connectivity", windowNameStr, 1, &offset, &zeroWindows);
5229 MInt noSingularityMaps = 0;
5230 for(
MInt mapId = 0; mapId < (
MInt)singularwindow.size(); mapId++) {
5231 stringstream windowName;
5232 windowName <<
"singularMap" << noSingularityMaps << endl;
5233 MString windowNameStr = windowName.str();
5234 ParallelIo::size_type noWindowInformation = 7 * nDim + 16;
5240 ParallelIo::size_type offset = 0;
5241 if(domainId() == 0) {
5244 ParallelIo::size_type zeroWindows = 0;
5245 pio.
writeArray(&empty,
"Connectivity", windowNameStr, 1, &offset, &zeroWindows);
5247 noSingularityMaps++;
5253 cout <<
"Starting write out " << endl;
5254 MInt noPeriodicDisplacementInfo = nDim * nDim;
5255 MFloatScratchSpace localPeriodicDisplacements(m_noBlocks * noPeriodicDisplacementInfo, AT_,
5256 "allPeriodicDisplacements");
5257 MFloatScratchSpace globalPeriodicDisplacements(m_noBlocks * noPeriodicDisplacementInfo, AT_,
5258 "allPeriodicDisplacements");
5259 localPeriodicDisplacements.
fill(-99999999.0);
5260 for(
MInt periodicId = 0; periodicId < noPeriodicDisplacementInfo; periodicId++) {
5261 localPeriodicDisplacements(m_blockId * noPeriodicDisplacementInfo + periodicId) = periodicDisplacements[periodicId];
5264 cout <<
"Allreduce noBlocks: " << m_noBlocks <<
" totalSize: " << m_noBlocks * noPeriodicDisplacementInfo << endl;
5265 MPI_Allreduce(&localPeriodicDisplacements(0), &globalPeriodicDisplacements(0),
5266 m_noBlocks * noPeriodicDisplacementInfo, MPI_DOUBLE, MPI_MAX, m_StructuredComm, AT_,
5267 "localPeriodicDisplacements(0)",
"globalPeriodicDisplacements(0)");
5269 cout <<
"Writing out periodic Window displacements" << endl;
5271 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
5273 path <<
"periodicDisplacements" << blockId;
5275 ParallelIo::size_type ioSize = noPeriodicDisplacementInfo;
5276 if(!pio.
hasDataset(pathStr,
"Connectivity")) {
5279 ParallelIo::size_type ioOffset = 0;
5280 if(domainId() == 0) {
5281 pio.
writeArray(&globalPeriodicDisplacements[blockId * noPeriodicDisplacementInfo],
"Connectivity", pathStr, 1,
5282 &ioOffset, &ioSize);
5284 ParallelIo::size_type zeroWindows = 0;
5286 pio.
writeArray(&emptyVar,
"Connectivity", pathStr, 1, &ioOffset, &zeroWindows);
5290 MInt hasConnectionInfo = 1;
5291 m_log <<
"Connection info written to grid file, normalConnections: " << noConnectionMaps
5292 <<
" noSingularityMaps: " << noSingularityMaps << endl;
5294 pio.
setAttribute(hasConnectionInfo,
"hasConnectionInfo",
"Connectivity");
5295 pio.
setAttribute(noConnectionMaps,
"noConnections",
"Connectivity");
5296 pio.
setAttribute(noSingularityMaps,
"noSingularConnections",
"Connectivity");
5301 MInt noConnectionMaps = 0;
5302 MInt noSingularityMaps = 0;
5303 MInt noPeriodicDisplacementInfo = nDim * nDim;
5304 MFloatScratchSpace globalPeriodicDisplacements(m_noBlocks * noPeriodicDisplacementInfo, AT_,
5305 "allPeriodicDisplacements");
5311 pio.
getAttribute(&noConnectionMaps,
"noConnections",
"Connectivity");
5312 pio.
getAttribute(&noSingularityMaps,
"noSingularConnections",
"Connectivity");
5313 MInt dummy[2] = {noConnectionMaps, noSingularityMaps};
5314 MPI_Bcast(dummy, 2, MPI_INT, 0, m_StructuredComm, AT_,
"dummy");
5316 MInt dummy[2] = {0, 0};
5317 MPI_Bcast(dummy, 2, MPI_INT, 0, m_StructuredComm, AT_,
"dummy");
5318 noConnectionMaps = dummy[0];
5319 noSingularityMaps = dummy[1];
5324 if(noConnectionMaps == 0 && noSingularityMaps == 0) {
5326 cout <<
"Connections were previously searched for, none found!" << endl
5327 <<
"---> hasConnectionInfo = 1" << endl
5328 <<
"---> noConnectionMaps = 0" << endl
5329 <<
"---> noSingularityMaps = 0" << endl;
5336 MInt noWindowInformation = 7 * nDim + 16;
5337 if(noConnectionMaps > 0) {
5339 for(
MInt mapId = 0; mapId < noConnectionMaps; mapId++) {
5340 stringstream windowName;
5341 windowName <<
"map" << mapId << endl;
5342 MString windowNameStr = windowName.str();
5343 ParallelIo::size_type ioSize = noWindowInformation;
5347 AT_,
"windowInformation.getPointer()");
5349 for(
MInt mapId = 0; mapId < noConnectionMaps; mapId++) {
5350 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5352 globalStructuredBndryCndMaps.push_back(std::move(temp));
5356 if(noSingularityMaps > 0) {
5357 MIntScratchSpace singularityInformation(noWindowInformation * noSingularityMaps, AT_,
"singularityInformation");
5358 for(
MInt mapId = 0; mapId < noSingularityMaps; mapId++) {
5359 stringstream windowName;
5360 windowName <<
"singularMap" << mapId << endl;
5361 MString windowNameStr = windowName.str();
5362 ParallelIo::size_type ioSize = noWindowInformation;
5363 pio.
readArray(&(singularityInformation[mapId * noWindowInformation]),
"Connectivity", windowNameStr, 1,
5366 MPI_Bcast(singularityInformation.
getPointer(), noWindowInformation * noSingularityMaps, MPI_INT, 0,
5367 m_StructuredComm, AT_,
"singularityInformation.getPointer()");
5368 for(
MInt mapId = 0; mapId < noSingularityMaps; mapId++) {
5369 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5370 readMapFromArray(temp, &(singularityInformation[mapId * noWindowInformation]));
5371 singularwindow.push_back(std::move(temp));
5375 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
5377 path <<
"periodicDisplacements" << blockId;
5379 ParallelIo::size_type ioSize = noPeriodicDisplacementInfo;
5380 if(pio.
hasDataset(pathStr,
"Connectivity")) {
5383 pio.
readArray(&globalPeriodicDisplacements[blockId * noPeriodicDisplacementInfo],
"Connectivity", pathStr, 1,
5386 pio.
readArray(&globalPeriodicDisplacements[blockId * noPeriodicDisplacementInfo],
"Connectivity",
5387 "periodicDisplacements", 1, &ioSize);
5391 MPI_Bcast(&globalPeriodicDisplacements(0), m_noBlocks * noPeriodicDisplacementInfo, MPI_DOUBLE, 0, m_StructuredComm,
5392 AT_,
"globalPeriodicDisplacements(0)");
5394 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
5395 for(
MInt i = 0; i < noPeriodicDisplacementInfo; i++) {
5396 cout <<
"globalPeriodicDisplacement: " << globalPeriodicDisplacements[blockId * noPeriodicDisplacementInfo + i]
5401 MInt noWindowInformation = 7 * nDim + 16;
5402 if(noConnectionMaps > 0) {
5405 AT_,
"windowInformation.getPointer()");
5406 for(
MInt mapId = 0; mapId < noConnectionMaps; mapId++) {
5407 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5409 globalStructuredBndryCndMaps.push_back(std::move(temp));
5412 if(noSingularityMaps > 0) {
5413 MIntScratchSpace singularityInformation(noWindowInformation * noSingularityMaps, AT_,
"singularityInformation");
5414 MPI_Bcast(singularityInformation.
getPointer(), noWindowInformation * noSingularityMaps, MPI_INT, 0,
5415 m_StructuredComm, AT_,
"singularityInformation.getPointer()");
5416 for(
MInt mapId = 0; mapId < noSingularityMaps; mapId++) {
5417 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5418 readMapFromArray(temp, &(singularityInformation[mapId * noWindowInformation]));
5419 singularwindow.push_back(std::move(temp));
5423 MPI_Bcast(&globalPeriodicDisplacements(0), m_noBlocks * noPeriodicDisplacementInfo, MPI_DOUBLE, 0, m_StructuredComm,
5424 AT_,
"globalPeriodicDisplacements(0)");
5427 for(
MInt periodicId = 0; periodicId < noPeriodicDisplacementInfo; periodicId++) {
5428 periodicDisplacements[periodicId] =
5429 globalPeriodicDisplacements(m_blockId * noPeriodicDisplacementInfo + periodicId);
5441 if(informationType) {
5442 for(
MUint bcId = 0; bcId < globalStructuredBndryCndMaps.size(); ++bcId) {
5443 for(
MInt i = 0; i < noSpongeInfo; ++i) {
5444 if(globalStructuredBndryCndMaps[bcId]->BC == bcInfo[i]) {
5445 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5446 mapCpy(globalStructuredBndryCndMaps[bcId], temp);
5447 temp->spongeThickness = thickness[i];
5448 temp->beta = beta[i];
5449 temp->sigma = sigma[i];
5450 m_spongeInfoMap.push_back(std::move(temp));
5455 for(
MUint bcId = 0; bcId < globalStructuredBndryCndMaps.size(); ++bcId) {
5456 for(
MInt i = 0; i < noSpongeInfo; ++i) {
5457 if(globalStructuredBndryCndMaps[bcId]->Id2 == bcInfo[i]) {
5458 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5459 mapCpy(globalStructuredBndryCndMaps[bcId], temp);
5460 temp->spongeThickness = thickness[i];
5461 temp->beta = beta[i];
5462 temp->sigma = sigma[i];
5463 m_spongeInfoMap.push_back(std::move(temp));
5473 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5474 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
5475 if(globalStructuredBndryCndMaps[i]->BC == 2221 || globalStructuredBndryCndMaps[i]->BC == 2222) {
5476 mapCpy(globalStructuredBndryCndMaps[i], temp);
5477 m_zonalBCMaps.push_back(std::move(temp));
5478 temp = make_unique<StructuredWindowMap<nDim>>();
5486 if(map1->BC == map2->BC && map1->Id1 == map2->Id1) {
5497 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5498 for(
MUint bcId = 0; bcId < globalStructuredBndryCndMaps.size(); ++bcId) {
5499 MInt firstDigit = (
MInt)(((
MFloat)globalStructuredBndryCndMaps[bcId]->BC) / 1000.0);
5500 if(firstDigit == 1 || globalStructuredBndryCndMaps[bcId]->BC == 2601) {
5501 mapCpy(globalStructuredBndryCndMaps[bcId], temp);
5502 m_wallDistInfoMap.push_back(std::move(temp));
5503 temp = make_unique<StructuredWindowMap<nDim>>();
5515 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
5516 for(
MUint bcId = 0; bcId < localStructuredBndryCndMaps.size(); ++bcId) {
5517 MInt firstDigit = (
MInt)(((
MFloat)localStructuredBndryCndMaps[bcId]->BC) / 1000.0);
5518 if(firstDigit == 1 || localStructuredBndryCndMaps[bcId]->BC == 2601) {
5519 mapCpy(localStructuredBndryCndMaps[bcId], temp);
5520 temp->face = localStructuredBndryCndMaps[bcId]->face;
5523 for(
MInt dim = 0; dim < nDim; ++dim) {
5524 if(dim != (
MInt)temp->face / 2) {
5525 if(temp->start1[dim] == m_myMapWithGC->start2[dim]) {
5526 temp->start1[dim] += m_noGhostLayers;
5527 temp->start2[dim] += m_noGhostLayers;
5529 if(temp->end1[dim] == m_myMapWithGC->end2[dim]) {
5530 temp->end1[dim] -= m_noGhostLayers;
5531 temp->end2[dim] -= m_noGhostLayers;
5534 const MInt face = temp->face;
5535 const MInt n = (face % 2) * 2 - 1;
5536 temp->start1[dim] += (
MInt)(0.5 - (1.5 * (
MFloat)n));
5537 temp->start2[dim] += (
MInt)(0.5 - (1.5 * (
MFloat)n));
5541 m_wallDistInfoMap.push_back(std::move(temp));
5542 temp = make_unique<StructuredWindowMap<nDim>>();
5551 const std::vector<MInt>& porousBlockIds,
5552 const std::vector<MInt>& auxDataWindowIds,
5553 const MBool force) {
5564 unique_ptr<StructuredWindowMap<nDim>> localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5566 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
5568 const MInt BC = globalStructuredBndryCndMaps[i]->BC;
5572 if(firstDigit != 1 && BC != 6002)
continue;
5575 MBool candidate =
false;
5577 if(auxDataType == 3) {
5578 for(
auto windowId : auxDataWindowIds) {
5579 if(globalStructuredBndryCndMaps[i]->Id2 == windowId) {
5584 }
else if(auxDataType == 0) {
5585 if(firstDigit == 1) candidate =
true;
5586 }
else if(auxDataType == 2) {
5587 if(BC == 6002 && porousBlockIds[globalStructuredBndryCndMaps[i]->Id1] == -1 )
5589 }
else if(firstDigit == 1
5591 && porousBlockIds[globalStructuredBndryCndMaps[i]->Id1]
5596 if(candidate) m_auxDataWindowIds.insert({i, globalStructuredBndryCndMaps[i]->Id2});
5598 if(candidate || force) {
5599 mapCombine11(m_myMapWithoutGC, globalStructuredBndryCndMaps[i], localMapDummy);
5601 test = mapCheck(localMapDummy);
5603 physicalAuxDataMap.push_back(std::move(localMapDummy));
5604 for(
MInt j = 0; j < nDim; ++j) {
5606 physicalAuxDataMap[counter]->start2[j] -= globalStructuredBndryCndMaps[i]->start2[j];
5607 physicalAuxDataMap[counter]->end2[j] -= globalStructuredBndryCndMaps[i]->start2[j];
5609 if(globalStructuredBndryCndMaps[i]->BC == 6002 && blockType ==
"porous")
5610 physicalAuxDataMap[counter]->isFluidPorousInterface =
true;
5612 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5617 deleteDuplicateBCMaps(physicalAuxDataMap);
5619 for(
MInt i = 0; i < (
MInt)physicalAuxDataMap.size(); i++) {
5620 for(
MInt dim = 0; dim < nDim; dim++) {
5623 if(physicalAuxDataMap[i]->start1[dim] == physicalAuxDataMap[i]->end1[dim]) {
5628 if(physicalAuxDataMap[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
5630 physicalAuxDataMap[i]->face = 0;
5632 physicalAuxDataMap[i]->face = 1;
5638 if(physicalAuxDataMap[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
5639 physicalAuxDataMap[i]->face = 2;
5641 physicalAuxDataMap[i]->face = 3;
5647 if(physicalAuxDataMap[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
5648 physicalAuxDataMap[i]->face = 4;
5650 physicalAuxDataMap[i]->face = 5;
5655 cerr <<
"error no side could be attributed" << endl;
5669 MPI_Comm* channelIn, MPI_Comm* channelOut, MPI_Comm* channelWorld,
MInt* channelRoots, MPI_Comm* commStg,
5670 MInt* commStgRoot,
MInt* commStgRootGlobal, MPI_Comm* commBC2600,
MInt* commBC2600Root,
MInt* commBC2600RootGlobal,
5671 MPI_Comm* rescalingCommGrComm,
MInt* rescalingCommGrRoot,
MInt* rescalingCommGrRootGlobal, MPI_Comm* commPerRotOne,
5672 MPI_Comm* commPerRotTwo, MPI_Comm* commPerRotWorld,
MInt* rotationRoots,
MInt& perRotGroup,
5679 MInt start1[3] = {0, 0, 0};
5680 MInt end1[3] = {0, 0, 0};
5681 MInt step1[3] = {1, 1, 1};
5682 MInt order[3] = {0, 1, 2};
5683 MInt start2[3] = {0, 0, 0};
5684 MInt end2[3] = {0, 0, 0};
5686 MInt blockId = m_grid->getBlockId(domainId());
5693 for(
MInt i = 0; i < nDim; i++) {
5694 start1[i] = m_grid->getMyOffset(nDim - 1 - i) + m_noGhostLayers;
5695 start2[i] = m_noGhostLayers;
5696 end1[i] = start1[i] + m_grid->getMyActivePoints(nDim - 1 - i) - 1;
5697 end2[i] = start2[i] + m_grid->getMyActivePoints(nDim - 1 - i) - 1;
5700 m_myMapWithoutGC = make_unique<StructuredWindowMap<nDim>>();
5701 mapCreate(blockId, start1, end1, step1, domainId(), start2, end2, step1, order, -1, m_myMapWithoutGC);
5704 for(
MInt i = 0; i < nDim; i++) {
5705 if(m_grid->getMyOffset(nDim - 1 - i) != 0) {
5706 start1[i] = m_grid->getMyOffset(nDim - 1 - i);
5707 end1[i] = start1[i] + m_grid->getMyActivePoints(nDim - 1 - i) - 1 + 2 * m_noGhostLayers;
5710 end1[i] = start1[i] + m_grid->getMyActivePoints(nDim - 1 - i) - 1 + 2 * m_noGhostLayers;
5713 end2[i] = m_grid->getMyActivePoints(nDim - 1 - i) - 1 + 2 * m_noGhostLayers;
5715 m_myMapWithGC = make_unique<StructuredWindowMap<nDim>>();
5716 mapCreate(blockId, start1, end1, step1, domainId(), start2, end2, step1, order, -1, m_myMapWithGC);
5720 unique_ptr<StructuredWindowMap<nDim>> localMapDummy =
nullptr;
5721 for(
MInt j = 0; j < noDomains(); j++) {
5722 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5724 blockId = m_grid->getBlockId(j);
5725 for(
MInt i = 0; i < nDim; i++) {
5726 start1[i] = m_grid->getOffset(j, nDim - 1 - i) + m_noGhostLayers;
5728 end1[i] = start1[i] + m_grid->getActivePoints(j, nDim - 1 - i) - 1;
5729 end2[i] = m_grid->getActivePoints(j, nDim - 1 - i) - 1;
5731 mapCreate(blockId, start1, end1, step1, j, start2, end2, step1, order, -6000, localMapDummy);
5732 m_partitionMapsWithoutGC.push_back(std::move(localMapDummy));
5736 for(
MInt j = 0; j < noDomains(); j++) {
5737 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5739 blockId = m_grid->getBlockId(j);
5741 for(
MInt i = 0; i < nDim; i++) {
5742 if(m_grid->getOffset(j, nDim - 1 - i) != 0) {
5743 start1[i] = m_grid->getOffset(j, nDim - 1 - i);
5744 end1[i] = start1[i] + m_grid->getActivePoints(j, nDim - 1 - i) - 1 + 2 * m_noGhostLayers;
5747 end1[i] = start1[i] + m_grid->getActivePoints(j, nDim - 1 - i) - 1 + 2 * m_noGhostLayers;
5751 end2[i] = m_grid->getActivePoints(j, nDim - 1 - i) - 1 + 4;
5753 mapCreate(blockId, start1, end1, step1, j, start2, end2, step1, order, -6000, localMapDummy);
5754 m_partitionMapsWithGC.push_back(std::move(localMapDummy));
5762 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5763 for(
MInt i = 0; i < noDomains(); i++) {
5765 if(domainId() == i) {
5768 mapCombine11(m_myMapWithoutGC, m_partitionMapsWithGC[i], localMapDummy);
5770 test = mapCheck(localMapDummy);
5772 localMapDummy->BC = -6000;
5773 sndMap.push_back(std::move(localMapDummy));
5774 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5779 for(
MInt i = 0; i < noDomains(); i++) {
5781 if(domainId() == i) {
5784 mapCombine11(m_myMapWithGC, m_partitionMapsWithoutGC[i], localMapDummy);
5786 test = mapCheck(localMapDummy);
5788 localMapDummy->BC = -6000;
5789 rcvMap.push_back(std::move(localMapDummy));
5790 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5795 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
5796 for(
MInt dim = 0; dim < nDim; dim++) {
5797 globalStructuredBndryCndMaps[i]->start1[dim] += m_noGhostLayers;
5798 globalStructuredBndryCndMaps[i]->end1[dim] += m_noGhostLayers;
5799 if((globalStructuredBndryCndMaps[i]->BC <= -6000 && globalStructuredBndryCndMaps[i]->BC > -6010)
5800 || (globalStructuredBndryCndMaps[i]->BC >= 4000 && globalStructuredBndryCndMaps[i]->BC < 5000)
5801 || globalStructuredBndryCndMaps[i]->BC == 6011) {
5806 globalStructuredBndryCndMaps[i]->start2[dim] += m_noGhostLayers;
5807 globalStructuredBndryCndMaps[i]->end2[dim] += m_noGhostLayers;
5817 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
5818 mapCombine11(m_myMapWithoutGC, globalStructuredBndryCndMaps[i], localMapDummy);
5820 test = mapCheck(localMapDummy);
5823 localMapDummy->BC = globalStructuredBndryCndMaps[i]->BC;
5824 localMapDummy->Nstar = globalStructuredBndryCndMaps[i]->Nstar;
5825 localMapDummy->SingularId = globalStructuredBndryCndMaps[i]->SingularId;
5826 localMapDummy->dc1 = globalStructuredBndryCndMaps[i]->dc1;
5827 localMapDummy->dc2 = globalStructuredBndryCndMaps[i]->dc2;
5828 localMapDummy->Id1 = globalStructuredBndryCndMaps[i]->Id1;
5829 localStructuredBndryCndMaps.push_back(std::move(localMapDummy));
5830 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5834 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
5835 for(
MInt i = 0; i < nDim; i++) {
5836 m_partitionMapsWithoutGC[j]->start2[i] += m_noGhostLayers;
5837 m_partitionMapsWithoutGC[j]->end2[i] += m_noGhostLayers;
5842 vector<unique_ptr<StructuredWindowMap<nDim>>> SndMapBC6000;
5844 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
5845 if(globalStructuredBndryCndMaps[i]->BC <= -6000
5846 && globalStructuredBndryCndMaps[i]->BC > -6010) {
5847 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
5849 if(globalStructuredBndryCndMaps[i]->Id1 != globalStructuredBndryCndMaps[i]->Id2) {
5850 if(domainId() == m_partitionMapsWithoutGC[j]->Id2) {
5855 MInt myBlockId = m_grid->getBlockId(domainId());
5856 if(globalStructuredBndryCndMaps[i]->Id2 == myBlockId) {
5857 mapCombine11(globalStructuredBndryCndMaps[i], m_partitionMapsWithoutGC[j], localMapDummy);
5859 test = mapCheck(localMapDummy);
5862 localMapDummy->BC = globalStructuredBndryCndMaps[i]->BC;
5863 localMapDummy->Nstar = globalStructuredBndryCndMaps[i]->Nstar;
5864 localMapDummy->SingularId = globalStructuredBndryCndMaps[i]->SingularId;
5865 localMapDummy->dc1 = globalStructuredBndryCndMaps[i]->dc1;
5866 localMapDummy->dc2 = globalStructuredBndryCndMaps[i]->dc2;
5868 SndMapBC6000.push_back(std::move(localMapDummy));
5869 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5878 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
5879 if(globalStructuredBndryCndMaps[i]->BC >= 4000 && globalStructuredBndryCndMaps[i]->BC < 5000) {
5880 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
5882 mapCombine11(globalStructuredBndryCndMaps[i], m_partitionMapsWithoutGC[j], localMapDummy);
5884 test = mapCheck(localMapDummy);
5887 localMapDummy->BC = globalStructuredBndryCndMaps[i]->BC;
5888 localMapDummy->Nstar = globalStructuredBndryCndMaps[i]->Nstar;
5889 localMapDummy->SingularId = globalStructuredBndryCndMaps[i]->SingularId;
5890 localMapDummy->dc1 = globalStructuredBndryCndMaps[i]->dc1;
5891 localMapDummy->dc2 = globalStructuredBndryCndMaps[i]->dc2;
5892 SndMapBC6000.push_back(std::move(localMapDummy));
5893 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5905 MInt singularPoint = (
MInt)singularwindow.size();
5906 for(
MInt i = 0; i < singularPoint; ++i) {
5907 for(
MInt dim = 0; dim < nDim; ++dim) {
5908 singularwindow[i]->start1[dim] += m_noGhostLayers;
5909 singularwindow[i]->end1[dim] += m_noGhostLayers;
5911 singularwindow[i]->start2[dim] += m_noGhostLayers;
5912 singularwindow[i]->end2[dim] += m_noGhostLayers;
5917 for(
MInt i = 0; i < singularPoint; ++i) {
5918 MInt singularcount = 0, limit = singularwindow[i]->Nstar - 3, cnt = 0;
5921 if(singularwindow[i]->BC < 4400 || singularwindow[i]->BC >= 4410) {
5923 singularwindow[i]->BC = -6000;
5924 for(
MInt t = 0; t < singularwindow[i]->Nstar; ++t) {
5925 if(singularwindow[i]->BCsingular[t] != 0) BCs.insert(-singularwindow[i]->BCsingular[t]);
5927 singularwindow[i]->BCsingular[0] = 0;
5928 singularwindow[i]->BCsingular[1] = 0;
5931 for(
MInt j = 0; j < (
MInt)globalStructuredBndryCndMaps.size(); j++) {
5932 if((globalStructuredBndryCndMaps[j]->Nstar == 5 || globalStructuredBndryCndMaps[j]->Nstar == 6)
5933 && (globalStructuredBndryCndMaps[j]->BC <= -6000 && globalStructuredBndryCndMaps[j]->BC > -6010)
5934 && globalStructuredBndryCndMaps[j]->Nstar == singularwindow[i]->Nstar) {
5939 if(singularwindow[i]->BC >= 4400 && singularwindow[i]->BC < 4410)
mTerm(1,
"ERROR 0");
5942 labell = mapCompare11(singularwindow[i], globalStructuredBndryCndMaps[j]);
5944 singularwindow[i]->SingularBlockId[singularcount] = globalStructuredBndryCndMaps[j]->Id2;
5945 if(BCs.size() == 1) {
5946 if(*BCs.cbegin() != globalStructuredBndryCndMaps[j]->BC)
mTerm(1,
"ERROR 1");
5947 singularwindow[i]->BCsingular[singularcount + 2] = *BCs.cbegin();
5949 setBCsingular(singularwindow[i], globalStructuredBndryCndMaps[j], singularcount);
5954 if(singularcount > limit)
5955 cout <<
"Important!! " << globalStructuredBndryCndMaps[j]->Nstar
5956 <<
" star check error!!!!!!!!!!!!!!!!!! check it !!!!!" << endl;
5959 if(globalStructuredBndryCndMaps[j]->Nstar == -1
5960 && (globalStructuredBndryCndMaps[j]->BC <= -6000 && globalStructuredBndryCndMaps[j]->BC > -6010)) {
5961 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
5962 mapCombine11(singularwindow[i], globalStructuredBndryCndMaps[j], localMapDummy);
5964 test = mapCheck(localMapDummy);
5966 singularwindow[i]->BCsingular[cnt++] = globalStructuredBndryCndMaps[j]->BC;
5971 if(cnt >= 3)
mTerm(1,
"");
5999 for(
MInt i = 0; i < singularPoint; ++i) {
6000 mapCombine11(m_myMapWithoutGC, singularwindow[i], localMapDummy);
6002 test = mapCheck(localMapDummy);
6003 localMapDummy->Nstar = singularwindow[i]->Nstar;
6004 localMapDummy->SingularId = singularwindow[i]->SingularId;
6005 for(
MInt n = 0; n < 6; ++n) {
6006 localMapDummy->BCsingular[n] = singularwindow[i]->BCsingular[n];
6012 localMapDummy->BC = singularwindow[i]->BC;
6014 localMapDummy->SingularBlockId[0] = singularwindow[i]->SingularBlockId[0];
6015 localMapDummy->SingularBlockId[1] = singularwindow[i]->SingularBlockId[1];
6016 localMapDummy->SingularBlockId[2] = singularwindow[i]->SingularBlockId[2];
6017 localMapDummy->SingularBlockId[3] = singularwindow[i]->SingularBlockId[3];
6020 localSingularMap.push_back(std::move(localMapDummy));
6021 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
6025 *hasSingularity = (
MInt)localSingularMap.size();
6026 singularPoint = (
MInt)localSingularMap.size();
6028 for(
MInt i = 0; i < (
MInt)localSingularMap.size(); ++i) {
6029 memcpy(singularity[i].start, localSingularMap[i]->start1, nDim *
sizeof(
MInt));
6030 memcpy(singularity[i].end, localSingularMap[i]->end1, nDim *
sizeof(
MInt));
6031 singularity[i].
Nstar = localSingularMap[i]->Nstar;
6032 singularity[i].
count = localSingularMap[i]->SingularId;
6033 singularity[i].
BC = localSingularMap[i]->BC;
6034 for(
MInt n = 0; n < 6; ++n) {
6035 singularity[i].
BCsingular[n] = localSingularMap[i]->BCsingular[n];
6037 singularity[i].
SingularBlockId[0] = localSingularMap[i]->SingularBlockId[0];
6038 singularity[i].
SingularBlockId[1] = localSingularMap[i]->SingularBlockId[1];
6039 singularity[i].
SingularBlockId[2] = localSingularMap[i]->SingularBlockId[2];
6040 singularity[i].
SingularBlockId[3] = localSingularMap[i]->SingularBlockId[3];
6046 if(localSingularMap[i]->BC >= 4400 && localSingularMap[i]->BC < 4410) {
6047 localSingularMap[i]->face = localSingularMap[i]->BC - 4401;
6049 for(
MInt k = 0; k < nDim; ++k) {
6050 if(localSingularMap[i]->start1[k] != localSingularMap[i]->end1[k]) {
6051 localSingularMap[i]->face = k * 2;
6056 MInt displace[nDim], dimcount = 0;
6059 for(
MInt k = 0; k < nDim; ++k) {
6060 if(singularity[i].start[k] == singularity[i].end[k]) {
6061 if(singularity[i].start[k] == 2) {
6073 IF_CONSTEXPR(nDim == 2) {
6074 ASSERT(dimcount == 2,
"Impossible!");
6079 if(localSingularMap[i]->face != -1) {
6080 dimN = localSingularMap[i]->face / 2;
6083 if(singularity[i].BC >= 6000
6084 && singularity[i].BC < 6010) {
6086 singularity[i].
BC = 6003;
6089 cout <<
"ERROR!!! point singular communication cannot decide the direction!! check the singularity!!!" << endl;
6094 if(dimN == 0 && nDim != 2) {
6097 }
else if(dimN == 1) {
6105 switch(singularity[i].Nstar) {
6109 singularity[i].
displacement[0][dimT1] = displace[dimT1];
6114 singularity[i].
displacement[1][dimT2] = displace[dimT2];
6122 singularity[i].
displacement[0][dimT1] = displace[dimT1];
6127 singularity[i].
displacement[1][dimT2] = displace[dimT2];
6130 singularity[i].
displacement[2][dimT1] = displace[dimT1];
6131 singularity[i].
displacement[2][dimT2] = displace[dimT2];
6134 singularity[i].
displacement[3][dimT1] = 2 * displace[dimT1];
6135 singularity[i].
displacement[3][dimT2] = 2 * displace[dimT2];
6139 singularity[i].
count = 2;
6147 singularity[i].
displacement[0][dimT1] = displace[dimT1];
6152 singularity[i].
displacement[1][dimT2] = displace[dimT2];
6155 singularity[i].
displacement[2][dimT1] = displace[dimT1];
6156 singularity[i].
displacement[2][dimT2] = displace[dimT2];
6159 singularity[i].
displacement[3][dimT1] = 2 * displace[dimT1];
6160 singularity[i].
displacement[3][dimT2] = 2 * displace[dimT2];
6163 singularity[i].
displacement[4][dimT1] = displace[dimT1];
6164 singularity[i].
displacement[4][dimT2] = 2 * displace[dimT2];
6168 singularity[i].
count = 2;
6179 for(
MInt i = 0; i < (
MInt)localSingularMap.size(); ++i) {
6180 if(localSingularMap[i]->BC <= -6000
6181 && localSingularMap[i]->BC > -6010)
6183 for(
MInt k = 0; k < nDim; ++k) {
6184 if(localSingularMap[i]->start1[k] != localSingularMap[i]->end1[k]) {
6187 localSingularMap[i]->start1[k] -= 2;
6188 localSingularMap[i]->start2[k] -= 2;
6192 localSingularMap[i]->end1[k] += 2;
6193 localSingularMap[i]->end2[k] += 2;
6214 vector<unique_ptr<StructuredWindowMap<nDim>>> periodicBC;
6215 vector<unique_ptr<StructuredWindowMap<nDim>>> addCommBC;
6219 for(
auto& localMap : localStructuredBndryCndMaps) {
6220 const MInt BC = (localMap->BC <= -6000 && localMap->BC > -6010) ? 6000 : localMap->BC;
6235 unique_ptr<StructuredWindowMap<nDim>> copy = make_unique<StructuredWindowMap<nDim>>();
6236 mapCpy(localMap, copy);
6237 addCommBC.push_back(std::move(copy));
6242 unique_ptr<StructuredWindowMap<nDim>> copy1 = make_unique<StructuredWindowMap<nDim>>();
6243 mapCpy(localMap, copy1);
6244 physicalBCMap.push_back(std::move(copy1));
6246 unique_ptr<StructuredWindowMap<nDim>> copy2 = make_unique<StructuredWindowMap<nDim>>();
6247 mapCpy(localMap, copy2);
6248 plenumInletSurfaceIndices.push_back(std::move(copy2));
6258 unique_ptr<StructuredWindowMap<nDim>> copy1 = make_unique<StructuredWindowMap<nDim>>();
6259 mapCpy(localMap, copy1);
6260 physicalBCMap.push_back(std::move(copy1));
6262 unique_ptr<StructuredWindowMap<nDim>> copy2 = make_unique<StructuredWindowMap<nDim>>();
6263 mapCpy(localMap, copy2);
6264 channelSurfaceIndices.push_back(std::move(copy2));
6270 unique_ptr<StructuredWindowMap<nDim>> copy = make_unique<StructuredWindowMap<nDim>>();
6271 mapCpy(localMap, copy);
6272 physicalBCMap.push_back(std::move(copy));
6282 for(
auto& localMap : localStructuredBndryCndMaps) {
6283 switch(localMap->BC) {
6293 unique_ptr<StructuredWindowMap<nDim>> copy = make_unique<StructuredWindowMap<nDim>>();
6294 mapCpy(localMap, copy);
6295 addCommBC.push_back(std::move(copy));
6308 vector<MInt> plenumPartitions;
6310 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
6311 if(globalStructuredBndryCndMaps[i]->BC == 2097) {
6315 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
6317 mapCombine11(globalStructuredBndryCndMaps[i], m_partitionMapsWithoutGC[j], localMapDummy);
6319 test = mapCheck(localMapDummy);
6321 plenumPartitions.push_back(m_partitionMapsWithoutGC[j]->Id2);
6328 vector<MInt> plenumInflow;
6329 if(plenumPartitions.size() != 0) {
6330 for(
auto& plenumPartition : plenumPartitions) {
6332 for(
MInt j = 0; j < noDomains(); j++) {
6333 if(plenumPartition == j) {
6334 plenumInflow.push_back(j);
6339 m_log <<
"Number of input partitions plenum Inlet " << plenumInflow.size() << endl;
6340 MPI_Group groupIn = MPI_GROUP_NULL;
6341 MPI_Group* newgroupIn =
new MPI_Group;
6343 MPI_Group_incl(groupIn, (
MInt)plenumInflow.size(), plenumInflow.data(), newgroupIn, AT_);
6344 MPI_Comm_create(m_StructuredComm, newgroupIn[0], plenumComm, AT_,
"plenumComm");
6346 if(domainId() == plenumInflow[0]) {
6347 MPI_Comm_rank(plenumComm[0], &plenumRoot[0]);
6349 MPI_Bcast(&plenumRoot[0], 1, MPI_INT, plenumInflow[0], m_StructuredComm, AT_,
"plenumRoots[0]");
6357 vector<MInt> channelface;
6358 vector<MInt> channelpartitions;
6361 MInt counterOut = 0;
6362 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
6363 if(globalStructuredBndryCndMaps[i]->BC == 2401 || globalStructuredBndryCndMaps[i]->BC == 2402) {
6368 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
6369 mapCombine11(globalStructuredBndryCndMaps[i], m_partitionMapsWithoutGC[j], localMapDummy);
6371 test = mapCheck(localMapDummy);
6373 channelpartitions.push_back(m_partitionMapsWithoutGC[j]->Id2);
6378 if(globalStructuredBndryCndMaps[i]->BC == 2401) {
6379 channelface.push_back(globalStructuredBndryCndMaps[i]->BC);
6382 channelface.push_back(globalStructuredBndryCndMaps[i]->BC);
6394 if(channelpartitions.size() != 0) {
6395 MInt counterI = 0, counterO = 0;
6396 for(
MInt i = 0; i < (
MInt)channelpartitions.size(); i++) {
6397 for(
MInt j = 0; j < noDomains(); j++) {
6398 if(channelpartitions[i] == j) {
6399 if(channelface[i] == 2401) {
6400 channelInflow[counterI] = j;
6403 if(channelface[i] == 2402) {
6404 channelOutflow[counterO] = j;
6412 m_log <<
"ChannelIn: " << counterI <<
" ChannelOut: " << counterOut << endl;
6416 MPI_Group groupIn = MPI_GROUP_NULL;
6417 MPI_Group newgroupIn = MPI_GROUP_NULL;
6418 MPI_Group groupOut = MPI_GROUP_NULL;
6419 MPI_Group newgroupOut = MPI_GROUP_NULL;
6425 MPI_Comm_create(m_StructuredComm, newgroupIn, channelIn, AT_,
"channelIn");
6428 MPI_Comm_create(m_StructuredComm, newgroupOut, channelOut, AT_,
"channelOut");
6435 MInt counterAll = 0;
6436 MInt* channelAll =
new MInt[counterOut + counterIn];
6437 for(
MInt i = 0; i < counterIn; i++) {
6438 channelAll[i] = channelInflow[i];
6441 for(
MInt i = 0; i < counterOut; i++) {
6442 MBool check =
false;
6443 for(
MInt j = 0; j < counterIn; ++j) {
6444 if(channelAll[j] == channelOutflow[i]) {
6446 cout <<
"ATTENTION: Skipping duplicate generation in channelAll" << endl;
6447 mTerm(1,
"In some cases this causes undefined behavior");
6453 channelAll[counterIn + i] = channelOutflow[i];
6457 MPI_Group groupAll = MPI_GROUP_NULL;
6458 MPI_Group newgroupAll = MPI_GROUP_NULL;
6462 MPI_Comm_create(m_StructuredComm, newgroupAll, channelWorld, AT_,
"channelWorld");
6465 if(domainId() == channelInflow[0]) {
6466 MPI_Comm_rank(*channelIn, &channelRoots[0]);
6467 MPI_Comm_rank(*channelWorld, &channelRoots[2]);
6470 MPI_Bcast(&channelRoots[0], 1, MPI_INT, channelInflow[0], m_StructuredComm, AT_,
"channelRoots[0]");
6471 MPI_Bcast(&channelRoots[2], 1, MPI_INT, channelInflow[0], m_StructuredComm, AT_,
"channelRoots[2]");
6473 if(domainId() == channelOutflow[0]) {
6474 MPI_Comm_rank(*channelOut, &channelRoots[1]);
6475 MPI_Comm_rank(*channelWorld, &channelRoots[3]);
6478 MPI_Bcast(&channelRoots[1], 1, MPI_INT, channelOutflow[0], m_StructuredComm, AT_,
"channelRoots[1]");
6479 MPI_Bcast(&channelRoots[3], 1, MPI_INT, channelOutflow[0], m_StructuredComm, AT_,
"channelRoots[3]");
6486 vector<MInt> rotatingface;
6487 vector<MInt> rotatingpartitions;
6489 MInt noRotPartitions = 0;
6493 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
6494 if(globalStructuredBndryCndMaps[i]->BC == 4001
6495 || globalStructuredBndryCndMaps[i]->BC == 4002) {
6498 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
6499 mapCombine11(globalStructuredBndryCndMaps[i], m_partitionMapsWithoutGC[j], localMapDummy);
6501 test = mapCheck(localMapDummy);
6503 rotatingpartitions.push_back(m_partitionMapsWithoutGC[j]->Id2);
6505 if(globalStructuredBndryCndMaps[i]->BC == 4001) {
6506 rotatingface.push_back(globalStructuredBndryCndMaps[i]->BC);
6509 rotatingface.push_back(globalStructuredBndryCndMaps[i]->BC);
6517 MInt* rotationOne =
nullptr;
6518 MInt* rotationTwo =
nullptr;
6519 if(rotatingpartitions.size() != 0) {
6520 MInt counterI = 0, counterO = 0;
6521 rotationOne =
new MInt[counterIn];
6522 rotationTwo =
new MInt[counterOut];
6523 for(
MInt i = 0; i < (
MInt)rotatingpartitions.size(); i++) {
6524 for(
MInt j = 0; j < noDomains(); j++) {
6525 if(rotatingpartitions[i] == j) {
6526 if(rotatingface[i] == 4001) {
6527 rotationOne[counterI] = j;
6530 rotationTwo[counterO] = j;
6538 for(
MInt i = 0; i < counterI; ++i) {
6539 if(domainId() == rotationOne[i]) {
6544 for(
MInt i = 0; i < counterO; ++i) {
6545 if(domainId() == rotationTwo[i]) {
6547 if(perRotGroup == 1)
6557 MPI_Group groupOne = MPI_GROUP_NULL;
6558 MPI_Group* newgroupOne =
new MPI_Group;
6559 MPI_Group groupTwo = MPI_GROUP_NULL;
6560 MPI_Group* newgroupTwo =
new MPI_Group;
6567 MPI_Comm_create(m_StructuredComm, *newgroupOne, commPerRotOne, AT_,
"commPerRotOne");
6571 MPI_Comm_create(m_StructuredComm, *newgroupTwo, commPerRotTwo, AT_,
"commPerRotTwo");
6576 MInt counterAll = 0;
6577 MInt* rotationAll =
new MInt[counterOut + counterIn];
6578 for(
MInt i = 0; i < counterIn; ++i) {
6579 rotationAll[i] = rotationOne[i];
6583 for(
MInt i = 0; i < counterOut; ++i) {
6585 MBool check =
false;
6586 for(
MInt j = 0; j < counterIn; ++j) {
6587 if(rotationAll[j] == rotationTwo[i]) {
6589 cout <<
"ATTENTION: Skipping duplicate generation in rotationAll" << endl;
6596 rotationAll[counterIn + i] = rotationTwo[i];
6601 MPI_Group groupAll = MPI_GROUP_NULL;
6602 MPI_Group* newgroupAll =
new MPI_Group;
6607 MPI_Comm_create(m_StructuredComm, *newgroupAll, commPerRotWorld, AT_,
"commPerRotWorld");
6610 if(domainId() == rotationOne[0]) {
6611 MPI_Comm_rank(commPerRotOne[0], &rotationRoots[0]);
6612 MPI_Comm_rank(commPerRotWorld[0], &rotationRoots[2]);
6615 MPI_Bcast(&rotationRoots[0], 1, MPI_INT, rotationOne[0], m_StructuredComm, AT_,
"rotationRoots[0]");
6616 MPI_Bcast(&rotationRoots[2], 1, MPI_INT, rotationOne[0], m_StructuredComm, AT_,
"rotationRoots[2]");
6618 if(domainId() == rotationTwo[0]) {
6619 MPI_Comm_rank(commPerRotTwo[0], &rotationRoots[1]);
6620 MPI_Comm_rank(commPerRotWorld[0], &rotationRoots[3]);
6623 MPI_Bcast(&rotationRoots[1], 1, MPI_INT, rotationTwo[0], m_StructuredComm, AT_,
"rotationRoots[1]");
6624 MPI_Bcast(&rotationRoots[3], 1, MPI_INT, rotationTwo[0], m_StructuredComm, AT_,
"rotationRoots[3]");
6637 vector<MInt> stgpartitions;
6639 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
6640 if(globalStructuredBndryCndMaps[i]->BC == 7909) {
6641 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
6642 mapCombine11(globalStructuredBndryCndMaps[i], m_partitionMapsWithoutGC[j], localMapDummy);
6644 test = mapCheck(localMapDummy);
6645 if(test ==
true) stgpartitions.push_back(m_partitionMapsWithoutGC[j]->Id2);
6652 if(stgpartitions.size() != 0) {
6653 m_log <<
"STG domains: ";
6654 MInt counterstg = 0;
6657 for(
MInt i = 0; i < (
MInt)stgpartitions.size(); i++) {
6658 for(
MInt j = 0; j < noDomains(); j++) {
6659 if(stgpartitions[i] == j) {
6660 stgranks[counterstg] = j;
6667 m_log <<
"Total number of STG domains: " << counterstg << endl;
6671 MPI_Group groupStg, newgroupStg;
6672 MInt stgcommsize = (
MInt)(stgpartitions.size());
6677 MPI_Comm_create(m_StructuredComm, newgroupStg, commStg, AT_,
"commStg");
6679 if(domainId() == stgranks[0]) {
6680 MPI_Comm_rank(*commStg, commStgRoot);
6681 MPI_Comm_rank(m_StructuredComm, commStgRootGlobal);
6685 MPI_Bcast(commStgRoot, 1, MPI_INT, stgranks[0], m_StructuredComm, AT_,
"commStgRoot");
6686 MPI_Bcast(commStgRootGlobal, 1, MPI_INT, stgranks[0], m_StructuredComm, AT_,
"commStgRootGlobal");
6693 vector<MInt> bc2600partitions;
6695 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
6696 if(globalStructuredBndryCndMaps[i]->BC == 2600) {
6697 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
6698 mapCombine11(globalStructuredBndryCndMaps[i], m_partitionMapsWithoutGC[j], localMapDummy);
6700 test = mapCheck(localMapDummy);
6701 if(test ==
true) bc2600partitions.push_back(m_partitionMapsWithoutGC[j]->Id2);
6709 if(bc2600partitions.size() != 0) {
6710 m_log <<
"bc2600 domains: ";
6711 MInt counterBC2600 = 0;
6712 bc2600ranks =
new MInt[
mMax(
MInt(bc2600partitions.size()), 0)];
6713 for(
MInt i = 0; i < (
MInt)bc2600partitions.size(); i++) {
6714 for(
MInt j = 0; j < noDomains(); j++) {
6715 if(bc2600partitions[i] == j) {
6716 bc2600ranks[counterBC2600] = j;
6723 m_log <<
"Total number of BC2600 domains: " << counterBC2600 << endl;
6727 MPI_Group groupBC2600, newgroupBC2600;
6728 MInt bc2600commsize = (
MInt)(bc2600partitions.size());
6730 MPI_Comm_group(m_StructuredComm, &groupBC2600, AT_,
"groupBC2600");
6731 MPI_Group_incl(groupBC2600, bc2600commsize, bc2600ranks, &newgroupBC2600, AT_);
6732 MPI_Comm_create(m_StructuredComm, newgroupBC2600, commBC2600, AT_,
"commBC2600");
6734 if(domainId() == bc2600ranks[0]) {
6735 MPI_Comm_rank(commBC2600[0], &commBC2600Root[0]);
6736 MPI_Comm_rank(m_StructuredComm, &commBC2600RootGlobal[0]);
6740 MPI_Bcast(commBC2600Root, 1, MPI_INT, bc2600ranks[0], m_StructuredComm, AT_,
"commBC2600Root");
6741 MPI_Bcast(commBC2600RootGlobal, 1, MPI_INT, bc2600ranks[0], m_StructuredComm, AT_,
"commBC2600RootGlobal");
6748 vector<MInt> rescalingCommGrPartitions;
6749 for(
MInt i = 0; i < (
MInt)globalStructuredBndryCndMaps.size(); i++) {
6750 if(globalStructuredBndryCndMaps[i]->BC == 2500 || globalStructuredBndryCndMaps[i]->BC == 2501) {
6751 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
6752 mapCombine11(globalStructuredBndryCndMaps[i], m_partitionMapsWithoutGC[j], localMapDummy);
6754 test = mapCheck(localMapDummy);
6756 rescalingCommGrPartitions.push_back(m_partitionMapsWithoutGC[j]->Id2);
6764 MInt* rescalingCommGrRanks;
6766 if(rescalingCommGrPartitions.size() != 0) {
6767 MInt counterCommGrRescaling = 0;
6768 rescalingCommGrRanks =
new MInt[
mMax(
MInt(rescalingCommGrPartitions.size()), 0)];
6769 for(
MInt i = 0; i < (
MInt)rescalingCommGrPartitions.size(); i++) {
6770 for(
MInt j = 0; j < noDomains(); j++) {
6771 if(rescalingCommGrPartitions[i] == j) {
6772 rescalingCommGrRanks[counterCommGrRescaling] = j;
6773 counterCommGrRescaling++;
6779 MPI_Group groupRescalingCommGr, newgroupRescalingCommGr;
6780 MInt rescalingCommGrCommsize = (
MInt)(rescalingCommGrPartitions.size());
6782 MPI_Comm_group(m_StructuredComm, &groupRescalingCommGr, AT_,
"groupRescalingCommGr");
6783 MPI_Group_incl(groupRescalingCommGr, rescalingCommGrCommsize, rescalingCommGrRanks, &newgroupRescalingCommGr, AT_);
6785 MPI_Comm_create(m_StructuredComm, newgroupRescalingCommGr, rescalingCommGrComm, AT_,
"rescalingCommGrComm");
6787 if(domainId() == rescalingCommGrRanks[0]) {
6788 MPI_Comm_rank(rescalingCommGrComm[0], &rescalingCommGrRoot[0]);
6789 MPI_Comm_rank(m_StructuredComm, &rescalingCommGrRootGlobal[0]);
6793 MPI_Bcast(rescalingCommGrRoot, 1, MPI_INT, rescalingCommGrRanks[0], m_StructuredComm, AT_,
"rescalingCommGrRoot");
6794 MPI_Bcast(rescalingCommGrRootGlobal, 1, MPI_INT, rescalingCommGrRanks[0], m_StructuredComm, AT_,
6795 "rescalingCommGrRootGlobal");
6804 vector<unique_ptr<StructuredWindowMap<nDim>>> addComm6000Recv;
6805 vector<unique_ptr<StructuredWindowMap<nDim>>> addComm6000Snd;
6806 vector<MInt> adjacentPartitionBC6000;
6811 for(
MInt i = 0; i < (
MInt)addCommBC.size(); i++) {
6812 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
6814 for(
MInt dim = 0; dim < nDim; dim++) {
6815 if(addCommBC[i]->start1[dim] != addCommBC[i]->end1[dim]
6816 && (addCommBC[i]->BC <= -6000 && addCommBC[i]->BC > -6010)) {
6817 if(addCommBC[i]->step2[addCommBC[i]->order[dim]] > 0) {
6821 if(addCommBC[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
6822 addCommBC[i]->start1[dim] -= m_noGhostLayers;
6823 addCommBC[i]->start2[addCommBC[i]->order[dim]] -= m_noGhostLayers;
6825 if(addCommBC[i]->end1[dim] == m_myMapWithoutGC->end2[dim]) {
6826 addCommBC[i]->end1[dim] += m_noGhostLayers;
6827 addCommBC[i]->end2[addCommBC[i]->order[dim]] += m_noGhostLayers;
6830 if(addCommBC[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
6831 addCommBC[i]->start1[dim] -= m_noGhostLayers;
6832 addCommBC[i]->start2[addCommBC[i]->order[dim]] += m_noGhostLayers;
6834 if(addCommBC[i]->end1[dim] == m_myMapWithoutGC->end2[dim]) {
6835 addCommBC[i]->end1[dim] += m_noGhostLayers;
6836 addCommBC[i]->end2[addCommBC[i]->order[dim]] -= m_noGhostLayers;
6840 if(addCommBC[i]->start1[dim] == addCommBC[i]->end1[dim]
6841 && (addCommBC[i]->BC <= -6000 && addCommBC[i]->BC > -6010))
6846 cout <<
"error!!!!!! 0d surface found!! check it .... " << endl;
6850 for(
MInt j = 0; j < (
MInt)m_partitionMapsWithoutGC.size(); j++) {
6851 mapCombine21(addCommBC[i], m_partitionMapsWithoutGC[j], temp);
6852 temp->BC = addCommBC[i]->BC;
6853 temp->Nstar = addCommBC[i]->Nstar;
6854 temp->SingularId = addCommBC[i]->SingularId;
6855 temp->dc1 = addCommBC[i]->dc1;
6856 temp->dc2 = addCommBC[i]->dc2;
6859 if(addCommBC[i]->BC <= -6000 && addCommBC[i]->BC > -6010)
6862 test = mapCheck2d(temp);
6863 else if(dimcount == 2)
6864 test = mapCheck1d(temp);
6865 else if(dimcount == 3)
6866 test = mapCheck0d(temp);
6868 test = mapCheck(temp);
6871 addComm6000Recv.push_back(std::move(temp));
6872 adjacentPartitionBC6000.push_back(j);
6873 temp = make_unique<StructuredWindowMap<nDim>>();
6880 for(
MInt i = 0; i < (
MInt)SndMapBC6000.size(); i++) {
6882 for(
MInt j = 0; j < noDomains(); ++j) {
6883 if(SndMapBC6000[i]->Id2 == j) {
6888 if(recvDom == -1)
mTerm(1,
"");
6891 for(
MInt dim = 0; dim < nDim; dim++) {
6892 if(SndMapBC6000[i]->start1[dim] != SndMapBC6000[i]->end1[dim]
6893 && (SndMapBC6000[i]->BC <= -6000 && SndMapBC6000[i]->BC > -6010)) {
6894 if(SndMapBC6000[i]->step2[SndMapBC6000[i]->order[dim]] > 0) {
6898 if(SndMapBC6000[i]->start2[SndMapBC6000[i]->order[dim]]
6899 == m_partitionMapsWithoutGC[recvDom]->start2[SndMapBC6000[i]->order[dim]]) {
6900 SndMapBC6000[i]->start1[dim] -= m_noGhostLayers;
6901 SndMapBC6000[i]->start2[SndMapBC6000[i]->order[dim]] -= m_noGhostLayers;
6903 if(SndMapBC6000[i]->end2[SndMapBC6000[i]->order[dim]]
6904 == m_partitionMapsWithoutGC[recvDom]->end2[SndMapBC6000[i]->order[dim]]) {
6905 SndMapBC6000[i]->end1[dim] += m_noGhostLayers;
6906 SndMapBC6000[i]->end2[SndMapBC6000[i]->order[dim]] += m_noGhostLayers;
6909 if(SndMapBC6000[i]->start2[SndMapBC6000[i]->order[dim]]
6910 == m_partitionMapsWithoutGC[recvDom]->end2[SndMapBC6000[i]->order[dim]]) {
6911 SndMapBC6000[i]->start1[dim] -= m_noGhostLayers;
6912 SndMapBC6000[i]->start2[SndMapBC6000[i]->order[dim]] += m_noGhostLayers;
6914 if(SndMapBC6000[i]->end2[SndMapBC6000[i]->order[dim]]
6915 == m_partitionMapsWithoutGC[recvDom]->start2[SndMapBC6000[i]->order[dim]]) {
6916 SndMapBC6000[i]->end1[dim] += m_noGhostLayers;
6917 SndMapBC6000[i]->end2[SndMapBC6000[i]->order[dim]] -= m_noGhostLayers;
6921 if(SndMapBC6000[i]->start1[dim] == SndMapBC6000[i]->end1[dim]
6922 && (SndMapBC6000[i]->BC <= -6000 && SndMapBC6000[i]->BC > -6010))
6927 cout <<
"error!!!!!! 0d surface found!! check it .... " << endl;
6932 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
6934 mapCombine11(m_myMapWithoutGC, SndMapBC6000[i], temp);
6935 temp->BC = SndMapBC6000[i]->BC;
6936 temp->Nstar = SndMapBC6000[i]->Nstar;
6937 temp->SingularId = SndMapBC6000[i]->SingularId;
6938 temp->dc1 = SndMapBC6000[i]->dc1;
6939 temp->dc2 = SndMapBC6000[i]->dc2;
6942 if(SndMapBC6000[i]->BC <= -6000 && SndMapBC6000[i]->BC > -6010)
6945 test = mapCheck2d(temp);
6946 else if(dimcount == 2)
6947 test = mapCheck1d(temp);
6948 else if(dimcount == 3)
6949 test = mapCheck0d(temp);
6951 test = mapCheck(temp);
6954 addComm6000Snd.push_back(std::move(temp));
6955 temp = make_unique<StructuredWindowMap<nDim>>();
6960 MInt count1[4] = {0, 0, 0, 0}, count2[4] = {0, 0, 0, 0};
6961 for(
MInt i = 0; i < (
MInt)addComm6000Snd.size(); ++i) {
6962 if((addComm6000Snd[i]->BC <= -6000 && addComm6000Snd[i]->BC > -6010)
6963 && addComm6000Snd[i]->Nstar == -1)
6965 else if((addComm6000Snd[i]->BC <= -6000 && addComm6000Snd[i]->BC > -6010)
6966 && addComm6000Snd[i]->Nstar != -1)
6968 else if(addComm6000Snd[i]->BC >= 4000 && addComm6000Snd[i]->BC < 5000 && addComm6000Snd[i]->Nstar == -1)
6970 else if(addComm6000Snd[i]->BC >= 4000 && addComm6000Snd[i]->BC < 5000 && addComm6000Snd[i]->Nstar != -1)
6973 for(
MInt i = 0; i < (
MInt)addComm6000Recv.size(); ++i) {
6974 if((addComm6000Recv[i]->BC <= -6000 && addComm6000Recv[i]->BC > -6010)
6975 && addComm6000Recv[i]->Nstar == -1)
6977 else if((addComm6000Recv[i]->BC <= -6000 && addComm6000Recv[i]->BC > -6010)
6978 && addComm6000Recv[i]->Nstar != -1)
6980 else if(addComm6000Recv[i]->BC >= 4000 && addComm6000Recv[i]->BC < 5000 && addComm6000Recv[i]->Nstar == -1)
6982 else if(addComm6000Recv[i]->BC >= 4000 && addComm6000Recv[i]->BC < 5000 && addComm6000Recv[i]->Nstar != -1)
6996 for(
MInt i = 0; i < (
MInt)addComm6000Recv.size(); ++i) {
6997 if(addComm6000Recv[i]->Nstar == -1
6998 && (addComm6000Recv[i]->BC <= -6000 && addComm6000Recv[i]->BC > -6010)) {
6999 unique_ptr<StructuredWindowMap<nDim>> tempRCV = make_unique<StructuredWindowMap<nDim>>();
7000 mapCpy(addComm6000Recv[i], tempRCV);
7004 for(
MInt dim = 0; dim < nDim; dim++) {
7005 if(addComm6000Recv[i]->step2[dim] < 0) {
7006 MInt haha = addComm6000Recv[i]->start2[dim];
7007 addComm6000Recv[i]->start2[dim] = addComm6000Recv[i]->end2[dim];
7008 addComm6000Recv[i]->end2[dim] = haha;
7013 for(
MInt part = 0; part < (
MInt)m_partitionMapsWithoutGC.size(); ++part) {
7014 if(addComm6000Recv[i]->Id2 == m_partitionMapsWithoutGC[part]->Id2) {
7015 for(
MInt dim = 0; dim < nDim; dim++) {
7016 if(addComm6000Recv[i]->start2[dim] == addComm6000Recv[i]->end2[dim]) {
7020 if(addComm6000Recv[i]->start2[dim] == m_partitionMapsWithoutGC[part]->start2[dim]) {
7030 if(addComm6000Recv[i]->start2[dim] == m_partitionMapsWithoutGC[part]->start2[dim]) {
7039 if(addComm6000Recv[i]->start2[dim] == m_partitionMapsWithoutGC[part]->start2[dim]) {
7047 cerr <<
"error no side could be attributed" << endl;
7075 for(
MInt dim = 0; dim < nDim; dim++) {
7076 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7079 if(addComm6000Recv[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7081 tempRCV->start1[dim] -= m_noGhostLayers;
7084 tempRCV->end1[dim] += m_noGhostLayers;
7088 tempRCV->BC = addComm6000Recv[i]->BC;
7089 rcvMap.push_back(std::move(tempRCV));
7097 for(
MInt i = 0; i < (
MInt)addComm6000Recv.size(); ++i) {
7098 if(addComm6000Recv[i]->Nstar != -1
7099 && (addComm6000Recv[i]->BC <= -6000 && addComm6000Recv[i]->BC > -6010)) {
7101 unique_ptr<StructuredWindowMap<nDim>> tempRCV = make_unique<StructuredWindowMap<nDim>>();
7102 mapCpy(addComm6000Recv[i], tempRCV);
7107 for(
MInt dim = 0; dim < nDim; dim++) {
7108 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7114 for(
MInt dim = 0; dim < nDim; dim++) {
7115 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7118 if(addComm6000Recv[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7121 tempRCV->end1[dim] += 1;
7124 tempRCV->start1[dim] -= 1;
7133 }
else if(dimcount == 3) {
7135 if(addComm6000Recv[i]->BC >= 4400 && addComm6000Recv[i]->BC < 4410) {
7136 addComm6000Recv[i]->face = addComm6000Recv[i]->BC - 4401;
7138 if(addComm6000Recv[i]->face != -1) {
7139 dimN = addComm6000Recv[i]->face / 2;
7141 cout <<
"ERROR!!! point singular communication cannot decide the direction!! check the singularity!!!"
7146 for(
MInt dim = 0; dim < nDim; dim++) {
7150 if(addComm6000Recv[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7153 tempRCV->end1[dim] += 1;
7157 tempRCV->start1[dim] -= 1;
7162 if(addComm6000Recv[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7164 tempRCV->start1[dim] -= 2;
7168 tempRCV->end1[dim] += 2;
7174 for(
MInt j = 0; j < singularPoint; ++j) {
7175 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
7181 if(localSingularMap[j]->BC == addComm6000Recv[i]->BC) {
7184 const MInt temporary = localSingularMap[j]->Id1;
7185 localSingularMap[j]->Id1 = m_grid->getBlockId(domainId());
7186 mapCombine11(localSingularMap[j], addComm6000Recv[i], temp);
7187 localSingularMap[j]->Id1 = temporary;
7190 test = mapCheck(temp);
7192 MInt Recvblock = m_grid->getBlockId(addComm6000Recv[i]->Id2);
7193 MInt singnumber = -1;
7194 for(
MInt k = 0; k < addComm6000Recv[i]->Nstar - 3; k++) {
7195 if(Recvblock == singularity[j].SingularBlockId[k]) {
7205 if(singnumber == -1) {
7206 cout <<
"ERROR!!!!!!!!can not find the correct the displacement!!!!!!" << endl;
7207 cout <<
"recvid2:" << addComm6000Recv[i]->Id2 <<
" recvblock:" << Recvblock
7212 for(
MInt dim = 0; dim < nDim; dim++) {
7213 tempRCV->start1[dim] += singularity[j].
displacement[singnumber + 2][dim];
7214 tempRCV->end1[dim] += singularity[j].
displacement[singnumber + 2][dim];
7216 tempRCV->BCsingular[0] = singularity[j].
BCsingular[singnumber + 2];
7218 tempRCV->SingularId = j;
7223 tempRCV->face = 100;
7225 if(addComm6000Recv[i]->BC >= 4000 && addComm6000Recv[i]->BC < 5000) {
7226 tempRCV->BC = addComm6000Recv[i]->BC;
7230 rcvMap.push_back(std::move(tempRCV));
7237 for(
MInt i = 0; i < (
MInt)addComm6000Snd.size(); i++) {
7238 if(addComm6000Snd[i]->Nstar == -1
7239 && (addComm6000Snd[i]->BC <= -6000 && addComm6000Snd[i]->BC > -6010)) {
7240 unique_ptr<StructuredWindowMap<nDim>> tempSND = make_unique<StructuredWindowMap<nDim>>();
7241 mapCpy(addComm6000Snd[i], tempSND);
7245 for(
MInt dim = 0; dim < nDim; dim++) {
7246 if(addComm6000Snd[i]->start1[dim] == addComm6000Snd[i]->end1[dim]) {
7250 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7260 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7269 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7277 cerr <<
"error no side could be attributed" << endl;
7284 for(
MInt dim = 0; dim < nDim; dim++) {
7285 if(addComm6000Snd[i]->start1[dim] == addComm6000Snd[i]->end1[dim]) {
7288 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7290 tempSND->end1[dim] += m_noGhostLayers;
7293 tempSND->start1[dim] -= m_noGhostLayers;
7298 tempSND->BC = addComm6000Snd[i]->BC;
7299 sndMap.push_back(std::move(tempSND));
7306 for(
MInt i = 0; i < (
MInt)addComm6000Snd.size(); i++) {
7307 if(addComm6000Snd[i]->Nstar != -1
7308 && (addComm6000Snd[i]->BC <= -6000 && addComm6000Snd[i]->BC > -6010)) {
7309 unique_ptr<StructuredWindowMap<nDim>> tempSND = make_unique<StructuredWindowMap<nDim>>();
7310 mapCpy(addComm6000Snd[i], tempSND);
7313 for(
MInt dim = 0; dim < nDim; dim++) {
7314 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7320 for(
MInt dim = 0; dim < nDim; dim++) {
7321 if(addComm6000Snd[i]->start1[dim] == addComm6000Snd[i]->end1[dim]) {
7325 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7327 tempSND->end1[dim] += 1;
7330 tempSND->start1[dim] -= 1;
7339 }
else if(dimcount == 3) {
7341 if(addComm6000Snd[i]->BC >= 4400 && addComm6000Snd[i]->BC < 4410) {
7342 addComm6000Snd[i]->face = addComm6000Snd[i]->BC - 4401;
7344 if(addComm6000Snd[i]->face != -1) {
7345 dimN = addComm6000Snd[i]->face / 2;
7347 cout <<
"erroor!!! point singular communication cannot decide the direction!! check the singylairy!!!!!!"
7352 for(
MInt dim = 0; dim < nDim; dim++) {
7357 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7359 tempSND->end1[dim] += 1;
7362 tempSND->start1[dim] -= 1;
7367 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7369 tempSND->end1[dim] += 2;
7373 tempSND->start1[dim] -= 2;
7379 for(
MInt j = 0; j < singularPoint; ++j) {
7380 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
7381 if(localSingularMap[j]->BC == addComm6000Snd[i]->BC) {
7383 const MInt temporary = localSingularMap[j]->Id1;
7384 localSingularMap[j]->Id1 = m_grid->getBlockId(domainId());
7385 mapCombine11(localSingularMap[j], addComm6000Snd[i], temp);
7386 localSingularMap[j]->Id1 = temporary;
7389 test = mapCheck(temp);
7391 MInt Recvblock = m_grid->getBlockId(addComm6000Snd[i]->Id2);
7392 MInt singnumber = -1;
7393 for(
MInt k = 0; k < addComm6000Snd[i]->Nstar - 3; k++) {
7394 if(Recvblock == singularity[j].SingularBlockId[k]) {
7404 if(singnumber == -1) {
7405 cout <<
"ERROR!!!!!!!!can not find the correct the displacement!!!!!!" << endl;
7406 cout <<
"recvid2:" << addComm6000Snd[i]->Id2 <<
" recvblock:" << Recvblock
7410 tempSND->BCsingular[0] = singularity[j].
BCsingular[singnumber + 2];
7412 tempSND->SingularId = j;
7417 tempSND->face = 100;
7419 if(addComm6000Snd[i]->BC >= 4000 && addComm6000Snd[i]->BC < 5000) {
7420 tempSND->BC = addComm6000Snd[i]->BC;
7425 sndMap.push_back(std::move(tempSND));
7436 for(
MInt i = 0; i < (
MInt)addComm6000Recv.size(); ++i) {
7437 if(addComm6000Recv[i]->Nstar == -1
7438 && (addComm6000Recv[i]->BC > -6000 || addComm6000Recv[i]->BC <= -6010)) {
7439 unique_ptr<StructuredWindowMap<nDim>> tempRCV = make_unique<StructuredWindowMap<nDim>>();
7440 mapCpy(addComm6000Recv[i], tempRCV);
7444 for(
MInt dim = 0; dim < nDim; dim++) {
7445 if(addComm6000Recv[i]->step2[dim] < 0) {
7446 MInt tmp = addComm6000Recv[i]->start2[dim];
7447 addComm6000Recv[i]->start2[dim] = addComm6000Recv[i]->end2[dim];
7448 addComm6000Recv[i]->end2[dim] = tmp;
7452 for(
MInt part = 0; part < (
MInt)m_partitionMapsWithoutGC.size(); ++part) {
7453 if(addComm6000Recv[i]->Id2 == m_partitionMapsWithoutGC[part]->Id2) {
7454 for(
MInt dim = 0; dim < nDim; dim++) {
7455 if(addComm6000Recv[i]->start2[dim] == addComm6000Recv[i]->end2[dim]) {
7459 if(addComm6000Recv[i]->start2[dim] == m_partitionMapsWithoutGC[part]->start2[dim]) {
7469 if(addComm6000Recv[i]->start2[dim] == m_partitionMapsWithoutGC[part]->start2[dim]) {
7478 if(addComm6000Recv[i]->start2[dim] == m_partitionMapsWithoutGC[part]->start2[dim]) {
7486 cerr <<
"error no side could be attributed" << endl;
7496 MInt mapDimension = 0;
7497 for(
MInt dim = 0; dim < nDim; dim++) {
7498 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7505 if(mapDimension == 1) {
7506 for(
MInt dim = 0; dim < nDim; dim++) {
7507 if(addComm6000Recv[i]->start1[dim] != addComm6000Recv[i]->end1[dim]) {
7508 tempRCV->start1[dim] -= m_noGhostLayers;
7509 tempRCV->end1[dim] += m_noGhostLayers;
7518 for(
MInt dim = 0; dim < nDim; dim++) {
7519 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7522 if(addComm6000Recv[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7525 tempRCV->start1[dim] -= m_noGhostLayers;
7529 tempRCV->end1[dim] += m_noGhostLayers;
7534 tempRCV->BC = addComm6000Recv[i]->BC;
7535 rcvMap.push_back(std::move(tempRCV));
7542 for(
MInt i = 0; i < (
MInt)addComm6000Recv.size(); ++i) {
7543 if(addComm6000Recv[i]->Nstar != -1
7544 && (addComm6000Recv[i]->BC > -6000 || addComm6000Recv[i]->BC <= -6010)) {
7545 unique_ptr<StructuredWindowMap<nDim>> tempRCV = make_unique<StructuredWindowMap<nDim>>();
7546 mapCpy(addComm6000Recv[i], tempRCV);
7551 for(
MInt dim = 0; dim < nDim; dim++) {
7552 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7558 for(
MInt dim = 0; dim < nDim; dim++) {
7559 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7563 if(addComm6000Recv[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7565 tempRCV->end1[dim] += 1;
7568 tempRCV->start1[dim] -= 1;
7573 tempRCV->start1[dim] -= m_noGhostLayers;
7574 tempRCV->end1[dim] += m_noGhostLayers;
7577 }
else if(dimcount == 3) {
7579 if(addComm6000Recv[i]->BC >= 4400 && addComm6000Recv[i]->BC < 4410) {
7580 addComm6000Recv[i]->face = addComm6000Recv[i]->BC - 4401;
7582 if(addComm6000Recv[i]->face != -1) {
7583 dimN = addComm6000Recv[i]->face / 2;
7585 cout <<
"erroor!!! point singular communication cannot decide the direction!! check the singylairy!!!!!!"
7590 for(
MInt dim = 0; dim < nDim; dim++) {
7595 if(addComm6000Recv[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7597 tempRCV->end1[dim] += 1;
7600 tempRCV->start1[dim] -= 1;
7605 if(addComm6000Recv[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7608 tempRCV->start1[dim] -= 2;
7611 tempRCV->end1[dim] += 2;
7617 for(
MInt j = 0; j < singularPoint; ++j) {
7618 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
7619 if(localSingularMap[j]->BC == addComm6000Recv[i]->BC)
7620 mapCombine11(localSingularMap[j], addComm6000Recv[i], temp);
7622 test = mapCheck(temp);
7627 for(
MInt dim = 0; dim < nDim; dim++) {
7628 tempRCV->start1[dim] += singularity[j].
displacement[singnumber][dim];
7629 tempRCV->end1[dim] += singularity[j].
displacement[singnumber][dim];
7631 singularity[j].
count++;
7632 tempRCV->SingularId = j;
7637 tempRCV->face = 100;
7639 if(addComm6000Recv[i]->BC >= 4000 && addComm6000Recv[i]->BC < 5000) {
7640 tempRCV->BC = addComm6000Recv[i]->BC;
7645 rcvMap.push_back(std::move(tempRCV));
7652 for(
MInt i = 0; i < (
MInt)addComm6000Snd.size(); i++) {
7653 if(addComm6000Snd[i]->Nstar == -1
7654 && (addComm6000Snd[i]->BC > -6000 || addComm6000Snd[i]->BC <= -6010)) {
7655 unique_ptr<StructuredWindowMap<nDim>> tempSND = make_unique<StructuredWindowMap<nDim>>();
7656 mapCpy(addComm6000Snd[i], tempSND);
7661 for(
MInt dim = 0; dim < nDim; dim++) {
7662 if(addComm6000Snd[i]->start1[dim] == addComm6000Snd[i]->end1[dim]) {
7666 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7676 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7685 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7693 cerr <<
"error no side could be attributed" << endl;
7701 MInt mapDimension = 0;
7702 for(
MInt dim = 0; dim < nDim; dim++) {
7703 if(addComm6000Snd[i]->start1[dim] == addComm6000Snd[i]->end1[dim]) {
7710 if(mapDimension == 1) {
7711 for(
MInt dim = 0; dim < nDim; dim++) {
7712 if(addComm6000Snd[i]->start1[dim] != addComm6000Snd[i]->end1[dim]) {
7714 tempSND->start1[dim] -= m_noGhostLayers;
7715 tempSND->end1[dim] += m_noGhostLayers;
7725 for(
MInt dim = 0; dim < nDim; dim++) {
7726 if(addComm6000Snd[i]->start1[dim] == addComm6000Snd[i]->end1[dim]) {
7729 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7732 tempSND->end1[dim] += m_noGhostLayers;
7736 tempSND->start1[dim] -= m_noGhostLayers;
7741 tempSND->BC = addComm6000Snd[i]->BC;
7742 sndMap.push_back(std::move(tempSND));
7749 for(
MInt i = 0; i < (
MInt)addComm6000Snd.size(); i++) {
7750 if(addComm6000Snd[i]->Nstar != -1
7751 && (addComm6000Snd[i]->BC > -6000 || addComm6000Snd[i]->BC <= -6010)) {
7752 unique_ptr<StructuredWindowMap<nDim>> tempSND = make_unique<StructuredWindowMap<nDim>>();
7753 mapCpy(addComm6000Snd[i], tempSND);
7756 for(
MInt dim = 0; dim < nDim; dim++) {
7757 if(addComm6000Recv[i]->start1[dim] == addComm6000Recv[i]->end1[dim]) {
7763 for(
MInt dim = 0; dim < nDim; dim++) {
7764 if(addComm6000Snd[i]->start1[dim] == addComm6000Snd[i]->end1[dim]) {
7768 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7770 tempSND->end1[dim] += 1;
7773 tempSND->start1[dim] -= 1;
7778 tempSND->start1[dim] -= m_noGhostLayers;
7779 tempSND->end1[dim] += m_noGhostLayers;
7782 }
else if(dimcount == 3) {
7784 if(addComm6000Snd[i]->BC >= 4400 && addComm6000Snd[i]->BC < 4410) {
7785 addComm6000Snd[i]->face = addComm6000Snd[i]->BC - 4401;
7787 if(addComm6000Snd[i]->face != -1) {
7788 dimN = addComm6000Snd[i]->face / 2;
7790 cout <<
"erroor!!! point singular communication cannot decide the direction!! check the singylairy!!!!!!"
7795 for(
MInt dim = 0; dim < nDim; dim++) {
7800 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7802 tempSND->end1[dim] += 1;
7805 tempSND->start1[dim] -= 1;
7810 if(addComm6000Snd[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7813 tempSND->end1[dim] += 2;
7816 tempSND->start1[dim] -= 2;
7822 tempSND->face = 100;
7824 if(addComm6000Snd[i]->BC >= 4000 && addComm6000Snd[i]->BC < 5000) {
7825 tempSND->BC = addComm6000Snd[i]->BC;
7830 sndMap.push_back(std::move(tempSND));
7838 for(
MInt i = 0; i < singularPoint; ++i) {
7839 for(
MInt dim = 0; dim < nDim; dim++) {
7840 singularity[i].
Viscous[dim] = 0;
7842 if(singularity[i].start[dim] == singularity[i].end[dim]) {
7844 if(singularity[i].start[dim] == m_myMapWithoutGC->start2[dim]) {
7846 singularity[i].
end[dim] += 1;
7847 singularity[i].
Viscous[dim] = -1;
7849 singularity[i].
start[dim] -= 1;
7852 singularity[i].
start[dim] -= m_noGhostLayers;
7853 singularity[i].
end[dim] += m_noGhostLayers;
7867 for(
MInt i = 0; i < (
MInt)physicalBCMap.size(); i++) {
7868 for(
MInt dim = 0; dim < nDim; dim++) {
7869 physicalBCMap[i]->start2[dim] += m_noGhostLayers;
7870 physicalBCMap[i]->end2[dim] += m_noGhostLayers;
7876 for(
MInt i = 0; i < (
MInt)physicalBCMap.size(); i++) {
7887 MInt addDimensionCount = 0;
7889 for(
MInt dim = 0; dim < nDim; dim++) {
7890 if(physicalBCMap[i]->start1[dim] == physicalBCMap[i]->end1[dim]) {
7896 if(physicalBCMap[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7897 physicalBCMap[i]->face = 0;
7898 physicalBCMap[i]->start1[dim] -= m_noGhostLayers;
7899 physicalBCMap[i]->start2[dim] -= m_noGhostLayers;
7901 physicalBCMap[i]->face = 1;
7902 physicalBCMap[i]->end1[dim] += m_noGhostLayers;
7903 physicalBCMap[i]->end2[dim] += m_noGhostLayers;
7908 if(physicalBCMap[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7910 physicalBCMap[i]->face = 2;
7911 physicalBCMap[i]->start1[dim] -= m_noGhostLayers;
7912 physicalBCMap[i]->start2[dim] -= m_noGhostLayers;
7914 physicalBCMap[i]->face = 3;
7915 physicalBCMap[i]->end1[dim] += m_noGhostLayers;
7916 physicalBCMap[i]->end2[dim] += m_noGhostLayers;
7921 if(physicalBCMap[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7923 physicalBCMap[i]->face = 4;
7924 physicalBCMap[i]->start1[dim] -= m_noGhostLayers;
7925 physicalBCMap[i]->start2[dim] -= m_noGhostLayers;
7927 physicalBCMap[i]->face = 5;
7928 physicalBCMap[i]->end1[dim] += m_noGhostLayers;
7929 physicalBCMap[i]->end2[dim] += m_noGhostLayers;
7934 cerr <<
"error no side could be attributed" << endl;
7939 addDimensionCount++;
7944 if(physicalBCMap[i]->start1[dim] == m_myMapWithoutGC->start2[dim]) {
7945 physicalBCMap[i]->start1[dim] -= m_noGhostLayers;
7946 physicalBCMap[i]->start2[dim] -= m_noGhostLayers;
7950 if(physicalBCMap[i]->end1[dim] == m_myMapWithoutGC->end2[dim]) {
7951 physicalBCMap[i]->end1[dim] += m_noGhostLayers;
7952 physicalBCMap[i]->end2[dim] += m_noGhostLayers;
7956 physicalBCMap[i]->originShape = addDimensionCount;
7960 deleteDuplicateBCMaps(physicalBCMap);
7973 for(
MInt i = 0; i < (
MInt)physicalBCMap.size(); i++) {
7975 if(physicalBCMap[i]->originShape == 2) {
7978 for(
MInt j = 0; j < (
MInt)physicalBCMap.size(); j++) {
7982 if(physicalBCMap[j]->originShape != 2) {
7986 if(physicalBCMap[i]->BC == physicalBCMap[j]->BC) {
7990 mapCombine11(physicalBCMap[i], physicalBCMap[j], localMapDummy);
7991 MBool is3dMap = mapCheck3d(localMapDummy);
7994 MInt faceDim = physicalBCMap[i]->face / 2;
7996 for(
MInt dim = 0; dim < nDim; dim++) {
7998 if(dim == faceDim) {
8003 if(physicalBCMap[j]->start1[dim] == physicalBCMap[i]->start1[dim]
8004 && physicalBCMap[j]->end1[dim] == m_myMapWithoutGC->start2[dim]) {
8005 physicalBCMap[i]->start1[dim] += m_noGhostLayers;
8006 cout <<
"DomainID: " << domainId()
8007 <<
" cutting extension at start of partition because of partition/bc conflict with BCs "
8008 << physicalBCMap[i]->BC <<
" and " << physicalBCMap[j]->BC << endl;
8012 if(physicalBCMap[j]->start1[dim] == m_myMapWithoutGC->end2[dim]
8013 && physicalBCMap[j]->end1[dim] == physicalBCMap[i]->end1[dim]) {
8014 physicalBCMap[i]->end1[dim] -= m_noGhostLayers;
8015 cout <<
"DomainID: " << domainId()
8016 <<
" cutting extension at end of partition because of partition/bc conflict with BCs "
8017 << physicalBCMap[i]->BC <<
" and " << physicalBCMap[j]->BC << endl;
8026 for(
MInt j = 0; j < (
MInt)rcvMap.size(); j++) {
8027 for(
MInt dim = 0; dim < nDim; dim++) {
8028 rcvMap[j]->start2[dim] = rcvMap[j]->start1[dim] + m_grid->getMyOffset(nDim - 1 - dim);
8029 rcvMap[j]->end2[dim] = rcvMap[j]->end1[dim] + m_grid->getMyOffset(nDim - 1 - dim);
8034 for(
MInt j = 0; j < (
MInt)rcvMap.size(); j++) {
8035 if(rcvMap[j]->Nstar > 3 && rcvMap[j]->BCsingular[0] < -6000 && rcvMap[j]->BCsingular[0] > -6010) {
8036 unique_ptr<StructuredWindowMap<nDim>> windowMap = make_unique<StructuredWindowMap<nDim>>();
8037 mapCreate(rcvMap[j]->Id1, rcvMap[j]->start1, rcvMap[j]->end1, rcvMap[j]->step1, -1, NULL, NULL, NULL,
8038 rcvMap[j]->order, -rcvMap[j]->BCsingular[0], windowMap);
8039 windowMap->Nstar = rcvMap[j]->Nstar;
8040 windowMap->SingularId = rcvMap[j]->SingularId;
8041 physicalBCMap.push_back(std::move(windowMap));
8048 for(
MInt i = 0; i < (
MInt)physicalBCMap.size(); i++) {
8049 if(physicalBCMap[i]->BC >= 6000 && physicalBCMap[i]->BC < 6010 && physicalBCMap[i]->Nstar == -1) {
8050 for(
MInt d = 0; d < nDim; ++d) {
8051 if(physicalBCMap[i]->step1[d] < 0)
mTerm(1,
"");
8053 const MInt faceDim = physicalBCMap[i]->face / 2;
8055 MInt start_begin[nDim], end_begin[nDim];
8056 MInt start_end[nDim], end_end[nDim];
8057 std::copy(&physicalBCMap[i]->start1[0], &physicalBCMap[i]->start1[0] + nDim, &start_begin[0]);
8058 std::copy(&physicalBCMap[i]->start1[0], &physicalBCMap[i]->start1[0] + nDim, &end_begin[0]);
8059 std::copy(&physicalBCMap[i]->end1[0], &physicalBCMap[i]->end1[0] + nDim, &end_end[0]);
8060 std::copy(&physicalBCMap[i]->end1[0], &physicalBCMap[i]->end1[0] + nDim, &start_end[0]);
8061 for(
MInt d = 0; d < nDim; ++d) {
8062 if(physicalBCMap[i]->start1[d] + m_noGhostLayers == m_myMapWithoutGC->start2[d] || d == faceDim)
8063 end_begin[d] += m_noGhostLayers;
8064 if(physicalBCMap[i]->end1[d] - m_noGhostLayers == m_myMapWithoutGC->end2[d] || d == faceDim)
8065 start_end[d] -= m_noGhostLayers;
8066 if(faceDim != -1 && d != faceDim && end_begin[d] > start_end[d]) {
8068 cout <<
"STOP " << d <<
"|" << faceDim <<
" " << start_end[d] <<
"|" << end_begin[d] << endl;
8069 mapPrint(physicalBCMap[i]);
8074 MBool overlap1 =
false;
8075 MBool overlap2 =
false;
8076 for(
MInt j = 0; j < (
MInt)rcvMap.size(); j++) {
8078 MBool overlap1_temp =
true;
8079 MBool overlap2_temp =
true;
8080 for(
MInt d = 0; d < nDim; ++d) {
8081 if(rcvMap[j]->step1[d] < 0)
mTerm(1,
"");
8085 for(
MInt d = 0; d < nDim; ++d) {
8086 if(rcvMap[j]->start1[d] > start_begin[d] || rcvMap[j]->end1[d] < end_begin[d]) overlap1_temp =
false;
8087 if(rcvMap[j]->start1[d] > start_end[d] || rcvMap[j]->end1[d] < end_end[d]) overlap2_temp =
false;
8090 if(overlap1_temp) overlap1 = overlap1_temp;
8091 if(overlap2_temp) overlap2 = overlap2_temp;
8095 cout <<
"DomainID: " << domainId() <<
" cutting extension at start of partition! " << endl;
8096 for(
MInt d = 0; d < nDim; ++d) {
8097 if(d == faceDim)
continue;
8099 physicalBCMap[i]->start1[d] += m_noGhostLayers;
8103 cout <<
"DomainID: " << domainId() <<
" cutting extension at end of partition! " << endl;
8104 for(
MInt d = 0; d < nDim; ++d) {
8105 if(d == faceDim)
continue;
8107 physicalBCMap[i]->end1[d] -= m_noGhostLayers;
8114 for(
MInt i = 0; i < (
MInt)physicalBCMap.size(); i++) {
8115 if(physicalBCMap[i]->BC == 2501) {
8118 for(
MInt j = 0; j < (
MInt)rcvMap.size(); j++) {
8119 mapCombine11(rcvMap[j], physicalBCMap[i], localMapDummy);
8120 MBool is3dMap = mapCheck3d(localMapDummy);
8121 if(is3dMap && ((rcvMap[j]->BC <= -6000 && rcvMap[j]->BC > -6010) || rcvMap[j]->BC == 6333)) {
8122 cout <<
"############ ATTENTION: BC MAP IS OVERLAPPING WITH 6000 RCV MAP!!! #############" << endl;
8123 cout <<
"receiveMap: " << endl;
8124 mapPrint(rcvMap[j]);
8125 cout <<
"physicalBCMap: " << endl;
8126 mapPrint(physicalBCMap[i]);
8127 cout <<
"combined21: " << endl;
8128 mapPrint(localMapDummy);
8167 if(nDim != 3)
return;
8171 MInt start1[3] = {0, 0, 0};
8172 MInt end1[3] = {0, 0, 0};
8173 MInt step1[3] = {1, 1, 1};
8174 MInt order[3] = {0, 1, 2};
8175 MInt start2[3] = {0, 0, 0};
8176 MInt end2[3] = {0, 0, 0};
8177 MInt offsetCells[3] = {0, 0, 0};
8178 MInt activeCells[3] = {0, 0, 0};
8180 MInt blockId = m_grid->getBlockId(domainId());
8187 for(
MInt i = 0; i < nDim; i++) {
8188 start1[i] = m_grid->getMyOffset(nDim - 1 - i);
8190 end1[i] = start1[i] + m_grid->getMyActivePoints(nDim - 1 - i) - 1;
8191 end2[i] = start2[i] + m_grid->getMyActivePoints(nDim - 1 - i) - 1;
8194 unique_ptr<StructuredWindowMap<nDim>> waveMyMap = make_unique<StructuredWindowMap<nDim>>();
8195 mapCreate(blockId, start1, end1, step1, domainId(), start2, end2, step1, order, -1, waveMyMap);
8197 MInt allCells[3] = {0, 0, 0};
8198 for(
MInt dim = 0; dim < nDim; dim++) {
8199 allCells[dim] = m_grid->getBlockNoCells(0, nDim - 1 - dim);
8202 vector<unique_ptr<StructuredWindowMap<nDim>>> waveSndPartitionMaps;
8203 unique_ptr<StructuredWindowMap<nDim>> localMapDummy =
nullptr;
8204 for(
MInt j = 0; j < noDomains(); j++) {
8205 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
8206 blockId = m_grid->getBlockId(j);
8208 for(
MInt dim = 0; dim < nDim; dim++) {
8209 offsetCells[dim] = m_grid->getOffset(j, nDim - 1 - dim);
8210 activeCells[dim] = m_grid->getActivePoints(j, nDim - 1 - dim) - 1;
8213 for(
MInt dim = 0; dim < nDim; dim++) {
8214 start1[dim] = offsetCells[dim];
8215 end1[dim] = start1[dim] + activeCells[dim];
8218 mapCreate(blockId, start1, end1, step1, j, start2, end2, step1, order, 0, localMapDummy);
8219 waveSndPartitionMaps.push_back(std::move(localMapDummy));
8222 vector<unique_ptr<StructuredWindowMap<nDim>>> wavePartitionMaps;
8224 for(
MInt j = 0; j < noDomains(); j++) {
8225 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
8228 MInt shiftedOffset[3] = {0, 0, 0};
8229 MInt croppedActiveCells[3] = {0, 0, 0};
8230 MInt overhangCells[3] = {0, 0, 0};
8231 MInt overhangOffset[3] = {0, 0, 0};
8232 blockId = m_grid->getBlockId(j);
8233 for(
MInt dim = 0; dim < nDim; dim++) {
8234 offsetCells[dim] = m_grid->getOffset(j, nDim - 1 - dim);
8235 activeCells[dim] = m_grid->getActivePoints(j, nDim - 1 - dim) - 1;
8240 for(
MInt dim = 0; dim < nDim; dim++) {
8241 shiftedOffset[dim] = offsetCells[dim];
8242 croppedActiveCells[dim] = activeCells[dim];
8243 overhangCells[dim] = activeCells[dim];
8244 overhangOffset[dim] = offsetCells[dim];
8247 if(offsetCells[2] + activeCells[2] <= waveZeroPos) {
8250 shiftedOffset[2] = allCells[2] - waveZeroPos + offsetCells[2];
8251 for(
MInt dim = 0; dim < nDim; dim++) {
8252 start1[dim] = shiftedOffset[dim];
8253 end1[dim] = start1[dim] + activeCells[dim];
8255 mapCreate(blockId, start1, end1, step1, j, start2, end2, step1, order, 0, localMapDummy);
8256 wavePartitionMaps.push_back(std::move(localMapDummy));
8257 }
else if(offsetCells[2] < waveZeroPos && offsetCells[2] + activeCells[2] > waveZeroPos) {
8259 croppedActiveCells[2] = waveZeroPos - offsetCells[2];
8260 shiftedOffset[2] = allCells[2] - croppedActiveCells[2];
8261 for(
MInt dim = 0; dim < nDim; dim++) {
8262 start1[dim] = shiftedOffset[dim];
8263 end1[dim] = start1[dim] + croppedActiveCells[dim];
8265 mapCreate(blockId, start1, end1, step1, j, start2, end2, step1, order, 0, localMapDummy);
8266 wavePartitionMaps.push_back(std::move(localMapDummy));
8267 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
8269 overhangCells[2] = activeCells[2] - croppedActiveCells[2];
8270 overhangOffset[2] = 0;
8271 for(
MInt dim = 0; dim < nDim; dim++) {
8272 start1[dim] = overhangOffset[dim];
8273 end1[dim] = start1[dim] + overhangCells[dim];
8275 mapCreate(blockId, start1, end1, step1, j, start2, end2, step1, order, 1, localMapDummy);
8276 wavePartitionMaps.push_back(std::move(localMapDummy));
8278 shiftedOffset[2] = offsetCells[2] - waveZeroPos;
8279 for(
MInt dim = 0; dim < nDim; dim++) {
8280 start1[dim] = shiftedOffset[dim];
8281 end1[dim] = start1[dim] + activeCells[dim];
8283 mapCreate(blockId, start1, end1, step1, j, start2, end2, step1, order, 1, localMapDummy);
8284 wavePartitionMaps.push_back(std::move(localMapDummy));
8293 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
8294 for(
MInt i = 0; i < (
MInt)wavePartitionMaps.size(); i++) {
8296 if(wavePartitionMaps[i]->Id2 != domainId()) {
8300 for(
MInt j = 0; j < (
MInt)waveSndPartitionMaps.size(); j++) {
8301 mapCombineWave(wavePartitionMaps[i], waveSndPartitionMaps[j], localMapDummy);
8303 test = mapCheckWave(localMapDummy);
8305 localMapDummy->BC = wavePartitionMaps[i]->BC;
8306 if(localMapDummy->start1[2] < allCells[2] - waveZeroPos) {
8307 const MInt translationK = allCells[2] - waveZeroPos - localMapDummy->start1[2];
8308 const MInt sizeK = localMapDummy->end1[2] - localMapDummy->start1[2];
8309 localMapDummy->start1[2] = allCells[2] - translationK;
8310 localMapDummy->end1[2] = localMapDummy->start1[2] + sizeK;
8312 const MInt translationK = allCells[2] - waveZeroPos;
8313 localMapDummy->start1[2] -= translationK;
8314 localMapDummy->end1[2] -= translationK;
8316 waveSndMap.push_back(std::move(localMapDummy));
8317 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
8323 for(
MInt i = 0; i < (
MInt)wavePartitionMaps.size(); i++) {
8324 mapCombineWave(waveMyMap, wavePartitionMaps[i], localMapDummy);
8326 test = mapCheckWave(localMapDummy);
8328 waveRcvMap.push_back(std::move(localMapDummy));
8329 localMapDummy = make_unique<StructuredWindowMap<nDim>>();
8333 for(
MInt i = 0; i < (
MInt)waveRcvMap.size(); i++) {
8334 for(
MInt dim = 0; dim < nDim; dim++) {
8335 const MInt offset = m_grid->getMyOffset(nDim - 1 - dim);
8336 waveRcvMap[i]->start1[dim] = waveRcvMap[i]->start1[dim] - offset + m_noGhostLayers;
8337 waveRcvMap[i]->end1[dim] = waveRcvMap[i]->end1[dim] - offset + m_noGhostLayers;
8341 for(
MInt i = 0; i < (
MInt)waveSndMap.size(); i++) {
8342 for(
MInt dim = 0; dim < nDim; dim++) {
8343 const MInt offset = m_grid->getMyOffset(nDim - 1 - dim);
8344 waveSndMap[i]->start1[dim] = waveSndMap[i]->start1[dim] - offset + m_noGhostLayers;
8345 waveSndMap[i]->end1[dim] = waveSndMap[i]->end1[dim] - offset + m_noGhostLayers;
8349 waveSndPartitionMaps.clear();
8350 wavePartitionMaps.clear();
8357 const MInt noVariables) {
8361 for(
MInt i = 0; i < (
MInt)waveSndMap.size(); i++) {
8363 MInt noCellsSnd = 1;
8364 for(
MInt j = 0; j < nDim; j++) {
8365 MInt cellSizes = (waveSndMap[i]->end1[j] - waveSndMap[i]->start1[j]);
8366 if(cellSizes != 0) {
8367 noCellsSnd *= (cellSizes);
8373 unique_ptr<StructuredComm<nDim>> snd =
8374 make_unique<StructuredComm<nDim>>(noVariables,
nullptr, noCellsSnd, 0, commType);
8376 snd->nghbrId = waveSndMap[i]->Id2;
8377 for(
MInt dim = 0; dim < nDim; ++dim) {
8378 snd->startInfoCells[dim] = waveSndMap[i]->start1[dim];
8379 snd->endInfoCells[dim] = waveSndMap[i]->end1[dim];
8381 snd->tagHelper = waveSndMap[i]->BC;
8383 sndComm.push_back(std::move(snd));
8387 for(
MInt i = 0; i < (
MInt)waveRcvMap.size(); i++) {
8389 MInt noCellsRcv = 1;
8390 for(
MInt j = 0; j < nDim; j++) {
8391 MInt cellSizes = (waveRcvMap[i]->end1[j] - waveRcvMap[i]->start1[j]);
8392 if(cellSizes != 0) {
8393 noCellsRcv *= (cellSizes);
8399 unique_ptr<StructuredComm<nDim>> rcv =
8400 make_unique<StructuredComm<nDim>>(noVariables,
nullptr, noCellsRcv, 0, commType);
8402 rcv->nghbrId = waveRcvMap[i]->Id2;
8403 for(
MInt dim = 0; dim < nDim; ++dim) {
8404 rcv->startInfoCells[dim] = waveRcvMap[i]->start1[dim];
8405 rcv->endInfoCells[dim] = waveRcvMap[i]->end1[dim];
8407 rcv->tagHelper = waveRcvMap[i]->BC;
8409 rcvComm.push_back(std::move(rcv));
8417 const MInt noVariables,
8418 MFloat*
const*
const variables) {
8419 if(rcvMap.size() != sndMap.size()) {
8420 MInt count1[4] = {0, 0, 0, 0}, count2[4] = {0, 0, 0, 0};
8421 for(
MInt i = 0; i < (
MInt)sndMap.size(); ++i) {
8422 if((sndMap[i]->BC <= -6000 && sndMap[i]->BC > -6010) && sndMap[i]->Nstar == -1)
8424 else if((sndMap[i]->BC <= -6000 && sndMap[i]->BC > -6010) && sndMap[i]->Nstar != -1)
8426 else if(sndMap[i]->BC >= 4000 && sndMap[i]->BC < 5000 && sndMap[i]->Nstar == -1)
8428 else if(sndMap[i]->BC >= 4000 && sndMap[i]->BC < 5000 && sndMap[i]->Nstar != -1)
8431 for(
MInt i = 0; i < (
MInt)rcvMap.size(); ++i) {
8432 if((rcvMap[i]->BC <= -6000 && rcvMap[i]->BC > -6010) && rcvMap[i]->Nstar == -1)
8434 else if((rcvMap[i]->BC <= -6000 && rcvMap[i]->BC > -6010) && rcvMap[i]->Nstar != -1)
8436 else if(rcvMap[i]->BC >= 4000 && rcvMap[i]->BC < 5000 && rcvMap[i]->Nstar == -1)
8438 else if(rcvMap[i]->BC >= 4000 && rcvMap[i]->BC < 5000 && rcvMap[i]->Nstar != -1)
8443 cout <<
"***********************************WARNING************************************** " << endl;
8444 cout <<
"this error may be caused by the partition when you have a Step in the grid, try to change number of "
8448 cout <<
"******************************************************************************** " << endl;
8449 mTerm(1, AT_,
"number of sending and receiving processes does not match");
8452 for(
MInt i = 0; i < (
MInt)rcvMap.size(); i++) {
8454 const MInt BC = (rcvMap[i]->BC <= -6000 && rcvMap[i]->BC > -6010) ? 6000 : rcvMap[i]->BC;
8456 MInt bcIdSnd = sndMap[i]->BC;
8457 MInt bcIdRcv = rcvMap[i]->BC;
8463 bcIdSnd = sndMap[i]->BCsingular[0];
8464 bcIdRcv = rcvMap[i]->BCsingular[0];
8475 if(rcvMap[i]->Nstar != -1) {
8496 MInt noCellsSnd = 1, noPointsSnd = 1;
8497 for(
MInt j = 0; j < nDim; j++) {
8498 MInt cellSizes = (sndMap[i]->end1[j] - sndMap[i]->start1[j]);
8499 if(cellSizes != 0) {
8500 noCellsSnd *= (cellSizes);
8501 noPointsSnd *= (cellSizes + 1);
8505 unique_ptr<StructuredComm<nDim>> snd =
8506 make_unique<StructuredComm<nDim>>(noVariables, variables, noCellsSnd, noPointsSnd, commType);
8508 snd->nghbrId = sndMap[i]->Id2;
8510 for(
MInt dim = 0; dim < nDim; ++dim) {
8511 snd->startInfoCells[dim] = sndMap[i]->start1[dim];
8512 snd->endInfoCells[dim] = sndMap[i]->end1[dim];
8513 snd->startInfoPoints[dim] = sndMap[i]->start1[dim];
8514 snd->endInfoPoints[dim] = sndMap[i]->end1[dim];
8517 snd->tagHelper = sndMap[i]->face;
8518 if(snd->tagHelper < 0) {
8522 snd->bcId = bcIdSnd;
8524 sndComm.push_back(std::move(snd));
8531 MInt noCellsRcv = 1, noPointsRcv = 1;
8532 for(
MInt j = 0; j < nDim; j++) {
8533 MInt cellSizes = (rcvMap[i]->end1[j] - rcvMap[i]->start1[j]);
8534 if(cellSizes != 0) {
8535 noCellsRcv *= (cellSizes);
8536 noPointsRcv *= (cellSizes + 1);
8540 unique_ptr<StructuredComm<nDim>> rcv =
8541 make_unique<StructuredComm<nDim>>(noVariables, variables, noCellsRcv, noPointsRcv, commType);
8543 rcv->nghbrId = rcvMap[i]->Id2;
8544 for(
MInt dim = 0; dim < nDim; ++dim) {
8545 rcv->startInfoCells[dim] = rcvMap[i]->start1[dim];
8546 rcv->endInfoCells[dim] = rcvMap[i]->end1[dim];
8547 rcv->startInfoPoints[dim] = rcvMap[i]->start1[dim];
8548 rcv->endInfoPoints[dim] = rcvMap[i]->end1[dim];
8549 rcv->orderInfo[dim] = rcvMap[i]->order[dim];
8550 rcv->stepInfo[dim] = rcvMap[i]->step2[dim];
8553 rcv->tagHelper = rcvMap[i]->face;
8554 if(rcv->tagHelper < 0) {
8558 rcv->bcId = bcIdRcv;
8560 rcvComm.push_back(std::move(rcv));
8567 if(map1->Id1 != map2->Id1)
return 0;
8568 if(map1->Id2 != map2->Id2)
return 0;
8569 for(
MInt i = 0; i < nDim; i++) {
8570 if(map1->start1[i] != map2->start1[i])
return 0;
8571 if(map1->end1[i] != map2->end1[i])
return 0;
8574 if(map1->step1[i] != map2->step1[i])
return 0;
8576 if(map1->order[i] != map2->order[i])
return 0;
8585 if(map1->Id1 != map2->Id1)
return 0;
8586 for(
MInt i = 0; i < nDim; i++) {
8587 if(map1->start1[i] != map2->start1[i])
return 0;
8588 if(map1->end1[i] != map2->end1[i])
return 0;
8602 output->SingularId = -1;
8610 memcpy(output->start1, start1, nDim *
sizeof(
MInt));
8611 if(start2 !=
nullptr) {
8612 memcpy(output->start2, start2, nDim *
sizeof(
MInt));
8614 memcpy(output->start2, start1, nDim *
sizeof(
MInt));
8617 memcpy(output->end1, end1, nDim *
sizeof(
MInt));
8618 if(end2 !=
nullptr) {
8619 memcpy(output->end2, end2, nDim *
sizeof(
MInt));
8621 memcpy(output->end2, end1, nDim *
sizeof(
MInt));
8624 if(step1 !=
nullptr) {
8625 memcpy(output->step1, step1, nDim *
sizeof(
MInt));
8627 for(
MInt i = 0; i < nDim; i++)
8628 output->step1[i] = 1;
8631 if(step2 !=
nullptr) {
8632 memcpy(output->step2, step2, nDim *
sizeof(
MInt));
8634 for(
MInt i = 0; i < nDim; i++)
8635 output->step2[i] = 1;
8638 if(order !=
nullptr) {
8639 memcpy(output->order, order, nDim *
sizeof(
MInt));
8641 for(
MInt i = 1; i < nDim; i++)
8642 output->order[i] = i;
8645 output->SingularId = -1;
8654 for(
MInt i = 0; i < nDim; i++) {
8656 if(input->step1[i] == 0)
break;
8657 if(input->step2[i] == 0)
break;
8658 if(input->step1[i] > 0) {
8659 if(input->end1[i] < input->start1[i])
break;
8661 if(input->start1[i] < input->end1[i])
break;
8663 if(input->step2[i] > 0) {
8664 if(input->end2[i] < input->start2[i])
break;
8666 if(input->start2[i] < input->end2[i])
break;
8669 if(((input->end1[i] - input->start1[i]) % (input->step1[i])) != 0)
break;
8670 if(((input->end2[i] - input->start2[i]) % (input->step2[i])) != 0)
break;
8672 if(input->order[i] < 0 || input->order[i] > (nDim - 1))
break;
8674 if(((input->end1[i] - input->start1[i]) / input->step1[i])
8675 != ((input->end2[input->order[i]] - input->start2[input->order[i]]) / input->step2[input->order[i]]))
8688 for(
MInt i = 0; i < nDim; i++) {
8690 if(input->step1[i] == 0)
break;
8691 if(input->step2[i] == 0)
break;
8692 if(input->step1[i] > 0) {
8693 if(input->end1[i] < input->start1[i])
break;
8695 if(input->start1[i] < input->end1[i])
break;
8697 if(input->step2[i] > 0) {
8698 if(input->end2[i] < input->start2[i])
break;
8700 if(input->start2[i] < input->end2[i])
break;
8703 if(((input->end1[i] - input->start1[i]) % (input->step1[i])) != 0)
break;
8704 if(((input->end2[i] - input->start2[i]) % (input->step2[i])) != 0)
break;
8706 if(input->order[i] < 0 || input->order[i] > (nDim - 1))
break;
8708 if(((input->end1[i] - input->start1[i]) / input->step1[i])
8709 != ((input->end2[input->order[i]] - input->start2[input->order[i]]) / input->step2[input->order[i]]))
8715 if(input->start1[i] == input->end1[i]) dummy++;
8723 if(dummy != 3) test =
false;
8733 for(
MInt i = 0; i < nDim; i++) {
8735 if(input->step1[i] == 0)
break;
8736 if(input->step2[i] == 0)
break;
8737 if(input->step1[i] > 0) {
8738 if(input->end1[i] < input->start1[i])
break;
8740 if(input->start1[i] < input->end1[i])
break;
8742 if(input->step2[i] > 0) {
8743 if(input->end2[i] < input->start2[i])
break;
8745 if(input->start2[i] < input->end2[i])
break;
8748 if(((input->end1[i] - input->start1[i]) % (input->step1[i])) != 0)
break;
8749 if(((input->end2[i] - input->start2[i]) % (input->step2[i])) != 0)
break;
8751 if(input->order[i] < 0 || input->order[i] > (nDim - 1))
break;
8753 if(((input->end1[i] - input->start1[i]) / input->step1[i])
8754 != ((input->end2[input->order[i]] - input->start2[input->order[i]]) / input->step2[input->order[i]]))
8760 if(input->start1[i] == input->end1[i]) dummy++;
8768 if(dummy != 2) test =
false;
8777 MBool result =
false;
8778 for(
MInt i = 0; i < nDim; i++) {
8780 if(input->step1[i] == 0)
break;
8781 if(input->step2[i] == 0)
break;
8782 if(input->step1[i] > 0) {
8783 if(input->end1[i] < input->start1[i])
break;
8785 if(input->start1[i] < input->end1[i])
break;
8787 if(input->step2[i] > 0) {
8788 if(input->end2[i] < input->start2[i])
break;
8790 if(input->start2[i] < input->end2[i])
break;
8793 if(((input->end1[i] - input->start1[i]) % (input->step1[i])) != 0)
break;
8794 if(((input->end2[i] - input->start2[i]) % (input->step2[i])) != 0)
break;
8796 if(input->order[i] < 0 || input->order[i] > (nDim - 1))
break;
8798 if(((input->end1[i] - input->start1[i]) / input->step1[i])
8799 != ((input->end2[input->order[i]] - input->start2[input->order[i]]) / input->step2[input->order[i]]))
8806 if(input->start1[i] == input->end1[i]) dummy++;
8811 if(dummy != 1 || result ==
false) {
8822 MBool result =
false;
8823 for(
MInt i = 0; i < nDim; i++) {
8825 if(input->step1[i] == 0)
break;
8826 if(input->step2[i] == 0)
break;
8827 if(input->step1[i] > 0) {
8828 if(input->end1[i] < input->start1[i])
break;
8830 if(input->start1[i] < input->end1[i])
break;
8832 if(input->step2[i] > 0) {
8833 if(input->end2[i] < input->start2[i])
break;
8835 if(input->start2[i] < input->end2[i])
break;
8838 if(((input->end1[i] - input->start1[i]) % (input->step1[i])) != 0)
break;
8839 if(((input->end2[i] - input->start2[i]) % (input->step2[i])) != 0)
break;
8841 if(input->order[i] < 0 || input->order[i] > (nDim - 1))
break;
8843 if(((input->end1[i] - input->start1[i]) / input->step1[i])
8844 != ((input->end2[input->order[i]] - input->start2[input->order[i]]) / input->step2[input->order[i]]))
8850 if(input->start1[i] == input->end1[i]) dummy++;
8855 if(dummy != 0 || result ==
false) {
8866 MBool result =
false;
8867 for(
MInt i = 0; i < nDim; i++) {
8869 if(input->step1[i] == 0)
break;
8870 if(input->step1[i] > 0) {
8871 if(input->end1[i] < input->start1[i])
break;
8873 if(input->start1[i] < input->end1[i])
break;
8876 if(((input->end1[i] - input->start1[i]) % (input->step1[i])) != 0)
break;
8881 if(input->start1[i] == input->end1[i]) dummy++;
8885 if(dummy != 0 || result ==
false) {
8894 cout <<
"======== MAP INFO =======" << endl;
8895 cout <<
"Id1: " << input->Id1 << endl;
8896 stringstream start1;
8897 start1 <<
"start1: ";
8898 stringstream start2;
8899 start2 <<
"start2: ";
8910 for(
MInt i = 0; i < nDim; i++) {
8911 start1 << input->start1[i] <<
" ";
8912 start2 << input->start2[i] <<
" ";
8913 end1 << input->end1[i] <<
" ";
8914 end2 << input->end2[i] <<
" ";
8915 step1 << input->step1[i] <<
" ";
8916 step2 << input->step2[i] <<
" ";
8917 order << input->order[i] <<
" ";
8919 cout << start1.str() << endl;
8920 cout << end1.str() << endl;
8921 cout << step1.str() << endl;
8922 cout << order.str() << endl;
8923 cout <<
"Id2: " << input->Id2 << endl;
8924 cout << start2.str() << endl;
8925 cout << end2.str() << endl;
8926 cout << step2.str() << endl;
8927 cout <<
"BC: " << input->BC << endl;
8928 if(input->Nstar != -1)
8929 cout <<
"BCsingular: " << input->BCsingular[0] <<
"|" << input->BCsingular[1] <<
"|" << input->BCsingular[2] <<
"|"
8930 << input->BCsingular[3] <<
"|" << input->BCsingular[4] <<
"|" << input->BCsingular[5] << endl;
8931 cout <<
"Face: " << input->face << endl;
8933 cout <<
"spongInfos:" << endl;
8934 cout <<
"hasSponge: " << input->hasSponge << endl;
8935 cout <<
"spongeThickness: " << input->spongeThickness << endl;
8936 cout <<
"beta: " << input->beta << endl;
8937 cout <<
"sigma: " << input->sigma << endl;
8939 cout <<
"Nstar: " << input->Nstar << endl;
8940 cout <<
"SingularId: " << input->SingularId << endl;
8941 cout <<
"DC1: " << input->dc1 <<
" DC2: " << input->dc2 << endl;
8942 cout <<
"======== MAP INFO END=======" << endl;
8947 stringstream start1;
8948 start1 <<
"start1: ";
8949 stringstream start2;
8950 start2 <<
"start2: ";
8956 for(
MInt i = 0; i < nDim; i++) {
8957 start1 << input->start1[i] <<
"-" << input->end1[i] <<
" ";
8958 start2 << input->start2[i] <<
"-" << input->end2[i] <<
" ";
8959 step2 << input->step2[i] <<
" ";
8960 order << input->order[i] <<
" ";
8962 cout <<
"Id1: " << input->Id1 <<
" Id2: " << input->Id2 <<
" BC: " << input->BC <<
" " << start1.str() <<
" "
8963 << start2.str() << step2.str() << order.str() <<
" BC:" << input->BC <<
" Nstar:" << input->Nstar << endl;
8971 for(
MInt i = 0; i < nDim; i++) {
8972 output->start1[i] = 0;
8973 output->end1[i] = -1;
8974 output->step1[i] = 1;
8975 output->start2[i] = 0;
8976 output->end2[i] = -1;
8977 output->step2[i] = 1;
8978 output->order[i] = 0;
8981 output->hasSponge =
false;
8982 output->spongeThickness = F0;
8991 output->Id1 = input->Id2;
8992 output->Id2 = input->Id1;
8994 memcpy(output->start2, input->start1, nDim *
sizeof(
MInt));
8996 memcpy(output->end2, input->end1, nDim *
sizeof(
MInt));
8997 memcpy(output->step2, input->step1, nDim *
sizeof(
MInt));
8998 memcpy(output->start1, input->start2, nDim *
sizeof(
MInt));
8999 memcpy(output->end1, input->end2, nDim *
sizeof(
MInt));
9000 memcpy(output->step1, input->step2, nDim *
sizeof(
MInt));
9002 for(
MInt i = 0; i < nDim; i++) {
9003 output->order[input->order[i]] = i;
9010 unique_ptr<StructuredWindowMap<nDim>> input;
9011 input = make_unique<StructuredWindowMap<nDim>>();
9012 mapCpy(output, input);
9013 output->Id1 = input->Id2;
9014 output->Id2 = input->Id1;
9016 output->dc1 = input->dc2;
9017 output->dc2 = input->dc1;
9019 memcpy(output->start2, input->start1, nDim *
sizeof(
MInt));
9021 memcpy(output->end2, input->end1, nDim *
sizeof(
MInt));
9022 memcpy(output->step2, input->step1, nDim *
sizeof(
MInt));
9023 memcpy(output->start1, input->start2, nDim *
sizeof(
MInt));
9024 memcpy(output->end1, input->end2, nDim *
sizeof(
MInt));
9025 memcpy(output->step1, input->step2, nDim *
sizeof(
MInt));
9027 for(
MInt i = 0; i < nDim; i++) {
9028 output->order[input->order[i]] = i;
9035 output->Id1 = input->Id1;
9036 output->Id2 = input->Id2;
9037 memcpy(output->start1, input->start1, nDim *
sizeof(
MInt));
9038 memcpy(output->start2, input->start2, nDim *
sizeof(
MInt));
9039 memcpy(output->end1, input->end1, nDim *
sizeof(
MInt));
9040 memcpy(output->end2, input->end2, nDim *
sizeof(
MInt));
9041 memcpy(output->step1, input->step1, nDim *
sizeof(
MInt));
9042 memcpy(output->step2, input->step2, nDim *
sizeof(
MInt));
9043 memcpy(output->order, input->order, nDim *
sizeof(
MInt));
9044 output->BC = input->BC;
9045 output->Nstar = input->Nstar;
9046 output->SingularId = input->SingularId;
9047 output->dc1 = input->dc1;
9048 output->dc2 = input->dc2;
9049 memcpy(output->SingularBlockId, input->SingularBlockId, 4 *
sizeof(
MInt));
9054 unique_ptr<StructuredWindowMap<nDim>> temp = make_unique<StructuredWindowMap<nDim>>();
9055 mapCpy(output, temp);
9056 for(
MInt i = 0; i < nDim; i++) {
9057 if(temp->step1[i] < 0) {
9058 output->step1[i] = -temp->step1[i];
9059 output->start1[i] = temp->end1[i];
9060 output->end1[i] = temp->start1[i];
9061 output->step2[output->order[i]] = -temp->step2[temp->order[i]];
9062 output->start2[output->order[i]] = temp->end2[temp->order[i]];
9063 output->end2[output->order[i]] = temp->start2[temp->order[i]];
9071 mapCpy(input, output);
9072 for(
MInt i = 0; i < nDim; i++) {
9073 if(input->step1[i] < 0) {
9074 output->step1[i] = -input->step1[i];
9075 output->start1[i] = input->end1[i];
9076 output->end1[i] = input->start1[i];
9077 output->step2[output->order[i]] = -input->step2[input->order[i]];
9078 output->start2[output->order[i]] = input->end2[input->order[i]];
9079 output->end2[output->order[i]] = input->start2[input->order[i]];
9087 unique_ptr<StructuredWindowMap<nDim>> out = make_unique<StructuredWindowMap<nDim>>();
9088 unique_ptr<StructuredWindowMap<nDim>> out1 = make_unique<StructuredWindowMap<nDim>>();
9089 mapInvert(input, out);
9090 mapNormalize1(out, out1);
9091 mapInvert(out1, output);
9098 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9100 if(input1->Id1 != input2->Id1) {
9103 mapNormalize1(input1, output);
9104 mapNormalize1(input2, tmp);
9105 for(
MInt i = 0; i < nDim; i++) {
9107 while(output->start1[i] + shift * output->step1[i] <= output->end1[i]) {
9108 if((output->start1[i] + shift * output->step1[i] >= tmp->start1[i])
9109 && (((output->start1[i] + shift * output->step1[i]) - (tmp->start1[i])) % (tmp->step1[i])) == 0)
9113 output->start1[i] = output->start1[i] + shift * output->step1[i];
9114 output->start2[output->order[i]] = output->start2[output->order[i]] + shift * output->step2[output->order[i]];
9118 while((output->end1[i] - shift * output->step1[i]) >= output->start1[i]) {
9119 if(((output->end1[i] - shift * output->step1[i]) <= tmp->end1[i])
9120 && ((output->end1[i] - shift * output->step1[i] - tmp->end1[i]) % tmp->step1[i]) == 0)
9125 output->end1[i] = output->end1[i] - shift * output->step1[i];
9126 output->end2[output->order[i]] = output->end2[output->order[i]] - shift * output->step2[output->order[i]];
9130 while(tmp->start1[i] + shift * tmp->step1[i] <= tmp->end1[i]) {
9131 if((tmp->start1[i] + shift * tmp->step1[i] >= output->start1[i])
9132 && ((tmp->start1[i] + (shift * tmp->step1[i]) - output->start1[i]) % output->step1[i]) == 0)
9137 tmp->start1[i] = tmp->start1[i] + shift * tmp->step1[i];
9138 tmp->start2[tmp->order[i]] = tmp->start2[tmp->order[i]] + shift * tmp->step2[tmp->order[i]];
9141 while(tmp->end1[i] - shift * tmp->step1[i] >= tmp->start1[i]) {
9142 if(((tmp->end1[i] - shift * tmp->step1[i]) <= output->end1[i])
9143 && ((tmp->end1[i] - shift * tmp->step1[i] - output->end1[i]) % output->step1[i]) == 0)
9147 tmp->end1[i] = tmp->end1[i] - shift * tmp->step1[i];
9148 tmp->end2[tmp->order[i]] = tmp->end2[tmp->order[i]] - shift * tmp->step2[tmp->order[i]];
9154 while(output->step1[i] * shift != tmp->step1[i] * shift2) {
9155 if(output->step1[i] * shift < tmp->step1[i] * shift2) {
9161 output->step1[i] = shift * output->step1[i];
9162 output->step2[output->order[i]] = shift * output->step2[output->order[i]];
9163 tmp->step1[i] = shift2 * tmp->step1[i];
9164 tmp->step2[tmp->order[i]] = shift2 * tmp->step2[tmp->order[i]];
9167 unique_ptr<StructuredWindowMap<nDim>> tmp1 = make_unique<StructuredWindowMap<nDim>>();
9168 mapCpy(output, tmp1);
9169 mapInvert(tmp1, output);
9170 for(
MInt i = 0; i < nDim; i++) {
9171 output->order[i] = tmp->order[output->order[i]];
9173 output->Id2 = tmp->Id2;
9174 memcpy(output->start2, tmp->start2, nDim *
sizeof(
MInt));
9175 memcpy(output->end2, tmp->end2, nDim *
sizeof(
MInt));
9176 memcpy(output->step2, tmp->step2, nDim *
sizeof(
MInt));
9178 mapCpy(output, tmp1);
9179 mapNormalize1(tmp1, output);
9180 if(input1->BC == -1 && input2->BC > 0) {
9181 output->BC = input2->BC;
9183 output->BC = input1->BC;
9192 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9193 mapInvert(input2, tmp);
9194 mapCombine11(input1, tmp, output);
9202 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9203 mapInvert(input1, tmp);
9204 mapCombine11(tmp, input2, output);
9211 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9212 unique_ptr<StructuredWindowMap<nDim>> tmp1 = make_unique<StructuredWindowMap<nDim>>();
9213 mapInvert(input1, tmp);
9214 mapInvert(input2, tmp1);
9215 mapCombine11(tmp, tmp1, output);
9222 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9224 if(input1->Id1 != input2->Id1) {
9227 mapNormalize1(input1, output);
9228 mapNormalize1(input2, tmp);
9229 for(
MInt i = 0; i < nDim; i++) {
9230 if(output->start1[i] == output->end1[i] || tmp->start1[i] == tmp->end1[i]) {
9232 while(output->start1[i] + shift * output->step1[i] <= output->end1[i]) {
9233 if((output->start1[i] + shift * output->step1[i] >= tmp->start1[i])
9234 && (((output->start1[i] + shift * output->step1[i]) - (tmp->start1[i])) % (tmp->step1[i])) == 0)
9238 output->start1[i] = output->start1[i] + shift * output->step1[i];
9239 output->start2[output->order[i]] = output->start2[output->order[i]] + shift * output->step2[output->order[i]];
9243 while((output->end1[i] - shift * output->step1[i]) >= output->start1[i]) {
9244 if(((output->end1[i] - shift * output->step1[i]) <= tmp->end1[i])
9245 && ((output->end1[i] - shift * output->step1[i] - tmp->end1[i]) % tmp->step1[i]) == 0)
9250 output->end1[i] = output->end1[i] - shift * output->step1[i];
9251 output->end2[output->order[i]] = output->end2[output->order[i]] - shift * output->step2[output->order[i]];
9255 while(tmp->start1[i] + shift * tmp->step1[i] <= tmp->end1[i]) {
9256 if((tmp->start1[i] + shift * tmp->step1[i] >= output->start1[i])
9257 && ((tmp->start1[i] + (shift * tmp->step1[i]) - output->start1[i]) % output->step1[i]) == 0)
9262 tmp->start1[i] = tmp->start1[i] + shift * tmp->step1[i];
9263 tmp->start2[tmp->order[i]] = tmp->start2[tmp->order[i]] + shift * tmp->step2[tmp->order[i]];
9266 while(tmp->end1[i] - shift * tmp->step1[i] >= tmp->start1[i]) {
9267 if(((tmp->end1[i] - shift * tmp->step1[i]) <= output->end1[i])
9268 && ((tmp->end1[i] - shift * tmp->step1[i] - output->end1[i]) % output->step1[i]) == 0)
9272 tmp->end1[i] = tmp->end1[i] - shift * tmp->step1[i];
9273 tmp->end2[tmp->order[i]] = tmp->end2[tmp->order[i]] - shift * tmp->step2[tmp->order[i]];
9279 output->end1[i] = output->end1[i] - shift * output->step1[i];
9280 output->end2[output->order[i]] = output->end2[output->order[i]] - shift * output->step2[output->order[i]];
9281 tmp->end1[i] = tmp->end1[i] - shift * tmp->step1[i];
9282 tmp->end2[tmp->order[i]] = tmp->end2[tmp->order[i]] - shift * tmp->step2[tmp->order[i]];
9286 while(output->start1[i] + shift * output->step1[i] <= output->end1[i]) {
9287 if((output->start1[i] + shift * output->step1[i] >= tmp->start1[i])
9288 && (((output->start1[i] + shift * output->step1[i]) - (tmp->start1[i])) % (tmp->step1[i])) == 0)
9292 output->start1[i] = output->start1[i] + shift * output->step1[i];
9293 output->start2[output->order[i]] = output->start2[output->order[i]] + shift * output->step2[output->order[i]];
9297 while((output->end1[i] - shift * output->step1[i]) >= output->start1[i]) {
9298 if(((output->end1[i] - shift * output->step1[i]) <= tmp->end1[i])
9299 && ((output->end1[i] - shift * output->step1[i] - tmp->end1[i]) % tmp->step1[i]) == 0)
9304 output->end1[i] = output->end1[i] - shift * output->step1[i];
9305 output->end2[output->order[i]] = output->end2[output->order[i]] - shift * output->step2[output->order[i]];
9310 while(tmp->start1[i] + shift * tmp->step1[i] <= tmp->end1[i]) {
9311 if((tmp->start1[i] + shift * tmp->step1[i] >= output->start1[i])
9312 && ((tmp->start1[i] + (shift * tmp->step1[i]) - output->start1[i]) % output->step1[i]) == 0)
9317 tmp->start1[i] = tmp->start1[i] + shift * tmp->step1[i];
9318 tmp->start2[tmp->order[i]] = tmp->start2[tmp->order[i]] + shift * tmp->step2[tmp->order[i]];
9321 while(tmp->end1[i] - shift * tmp->step1[i] >= tmp->start1[i]) {
9322 if(((tmp->end1[i] - shift * tmp->step1[i]) <= output->end1[i])
9323 && ((tmp->end1[i] - shift * tmp->step1[i] - output->end1[i]) % output->step1[i]) == 0)
9327 tmp->end1[i] = tmp->end1[i] - shift * tmp->step1[i];
9328 tmp->end2[tmp->order[i]] = tmp->end2[tmp->order[i]] - shift * tmp->step2[tmp->order[i]];
9331 if(output->start1[i] <= output->end1[i] && tmp->start1[i] <= tmp->end1[i]) {
9333 output->end1[i] = output->end1[i] - shift * output->step1[i];
9334 output->end2[output->order[i]] = output->end2[output->order[i]] - shift * output->step2[output->order[i]];
9335 tmp->end1[i] = tmp->end1[i] - shift * tmp->step1[i];
9336 tmp->end2[tmp->order[i]] = tmp->end2[tmp->order[i]] - shift * tmp->step2[tmp->order[i]];
9343 while(output->step1[i] * shift != tmp->step1[i] * shift2) {
9344 if(output->step1[i] * shift < tmp->step1[i] * shift2) {
9350 output->step1[i] = shift * output->step1[i];
9351 output->step2[output->order[i]] = shift * output->step2[output->order[i]];
9352 tmp->step1[i] = shift2 * tmp->step1[i];
9353 tmp->step2[tmp->order[i]] = shift2 * tmp->step2[tmp->order[i]];
9356 unique_ptr<StructuredWindowMap<nDim>> tmp1 = make_unique<StructuredWindowMap<nDim>>();
9357 mapCpy(output, tmp1);
9358 mapInvert(tmp1, output);
9359 for(
MInt i = 0; i < nDim; i++) {
9360 output->order[i] = tmp->order[output->order[i]];
9362 output->Id2 = tmp->Id2;
9363 memcpy(output->start2, tmp->start2, nDim *
sizeof(
MInt));
9364 memcpy(output->end2, tmp->end2, nDim *
sizeof(
MInt));
9365 memcpy(output->step2, tmp->step2, nDim *
sizeof(
MInt));
9367 mapCpy(output, tmp1);
9368 mapNormalize1(tmp1, output);
9369 if(input1->BC == -1 && input2->BC > 0) {
9370 output->BC = input2->BC;
9372 output->BC = input1->BC;
9381 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9383 if(input1->Id1 != input2->Id1) {
9386 mapNormalize1(input1, output);
9387 mapNormalize1(input2, tmp);
9388 for(
MInt i = 0; i < nDim; i++) {
9392 while(output->start1[i] + shift * output->step1[i] <= output->end1[i]) {
9395 if((output->start1[i] + shift * output->step1[i] >= tmp->start1[i])
9396 && (((output->start1[i] + shift * output->step1[i]) - (tmp->start1[i])) % (tmp->step1[i])) == 0)
9401 output->start1[i] = output->start1[i] + shift * output->step1[i];
9403 output->start2[output->order[i]] = output->start2[output->order[i]] + shift * output->step2[output->order[i]];
9409 while((output->end1[i] - shift * output->step1[i]) >= output->start1[i]) {
9411 if(((output->end1[i] - shift * output->step1[i]) <= tmp->end1[i])
9412 && ((output->end1[i] - shift * output->step1[i] - tmp->end1[i]) % tmp->step1[i]) == 0)
9417 output->end1[i] = output->end1[i] - shift * output->step1[i];
9419 output->end2[output->order[i]] = output->end2[output->order[i]] - shift * output->step2[output->order[i]];
9424 output->Id1 = output->Id2;
9425 output->Id2 = tmp->Id2;
9426 output->BC = tmp->BC;
9434 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9435 mapInvert(input2, tmp);
9436 mapCombineCell11(input1, tmp, output);
9444 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9445 mapInvert(input1, tmp);
9446 mapCombineCell11(tmp, input2, output);
9453 unique_ptr<StructuredWindowMap<nDim>> tmp = make_unique<StructuredWindowMap<nDim>>();
9454 unique_ptr<StructuredWindowMap<nDim>> tmp1 = make_unique<StructuredWindowMap<nDim>>();
9455 mapInvert(input1, tmp);
9456 mapInvert(input2, tmp1);
9457 mapCombineCell11(tmp, tmp1, output);
9462 for(
MInt dim = 0; dim < nDim; dim++) {
9463 map->start1[dim] = dataField[0 * nDim + dim];
9464 map->end1[dim] = dataField[1 * nDim + dim];
9465 map->step1[dim] = dataField[2 * nDim + dim];
9466 map->start2[dim] = dataField[3 * nDim + dim];
9467 map->end2[dim] = dataField[4 * nDim + dim];
9468 map->step2[dim] = dataField[5 * nDim + dim];
9469 map->order[dim] = dataField[6 * nDim + dim];
9472 map->Id1 = dataField[7 * nDim + 0];
9473 map->Id2 = dataField[7 * nDim + 1];
9475 map->BC = dataField[7 * nDim + 3];
9477 map->face = dataField[7 * nDim + 5];
9478 map->dir = dataField[7 * nDim + 6];
9479 map->dc1 = dataField[7 * nDim + 7];
9480 map->dc2 = dataField[7 * nDim + 8];
9481 map->originShape = dataField[7 * nDim + 9];
9482 map->hasSponge = dataField[7 * nDim + 10];
9483 map->spongeThickness = dataField[7 * nDim + 11];
9484 map->beta = dataField[7 * nDim + 12];
9485 map->sigma = dataField[7 * nDim + 13];
9486 map->Nstar = dataField[7 * nDim + 14];
9487 map->SingularId = dataField[7 * nDim + 15];
9492 for(
MInt dim = 0; dim < nDim; dim++) {
9493 dataField[0 * nDim + dim] = map->start1[dim];
9494 dataField[1 * nDim + dim] = map->end1[dim];
9495 dataField[2 * nDim + dim] = map->step1[dim];
9496 dataField[3 * nDim + dim] = map->start2[dim];
9497 dataField[4 * nDim + dim] = map->end2[dim];
9498 dataField[5 * nDim + dim] = map->step2[dim];
9499 dataField[6 * nDim + dim] = map->order[dim];
9502 dataField[7 * nDim + 0] = map->Id1;
9503 dataField[7 * nDim + 1] = map->Id2;
9505 dataField[7 * nDim + 3] = map->BC;
9507 dataField[7 * nDim + 5] = map->face;
9508 dataField[7 * nDim + 6] = map->dir;
9509 dataField[7 * nDim + 7] = map->dc1;
9510 dataField[7 * nDim + 8] = map->dc2;
9511 dataField[7 * nDim + 9] = map->originShape;
9512 dataField[7 * nDim + 10] = map->hasSponge;
9513 dataField[7 * nDim + 11] = map->spongeThickness;
9514 dataField[7 * nDim + 12] = map->beta;
9515 dataField[7 * nDim + 13] = map->sigma;
9516 dataField[7 * nDim + 14] = map->Nstar;
9517 dataField[7 * nDim + 15] = map->SingularId;
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
void mapPrintSimple(std::unique_ptr< StructuredWindowMap< nDim > > &input)
void writeConnectionWindowInformation3D(MFloat *periodicDisplacements)
void mapCombine12(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void removeConnection(connectionNode a)
void mapCombineCell22(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void createAuxDataMap(const MInt, const MString, const std::vector< MInt > &, const std::vector< MInt > &, const MBool)
void createWaveCommunicationExchangeFlags(std::vector< std::unique_ptr< StructuredComm< nDim > > > &, std::vector< std::unique_ptr< StructuredComm< nDim > > > &, const MInt noVariables)
void createWaveWindowMapping(MInt)
MBool mapCheck0d(std::unique_ptr< StructuredWindowMap< nDim > > &input)
void mapNormalize2(std::unique_ptr< StructuredWindowMap< nDim > > &input, std::unique_ptr< StructuredWindowMap< nDim > > &output)
MInt mapCompare11(const std::unique_ptr< StructuredWindowMap< nDim > > &map1, const std::unique_ptr< StructuredWindowMap< nDim > > &map2)
void setBCsingular(std::unique_ptr< StructuredWindowMap< nDim > > &, std::unique_ptr< StructuredWindowMap< nDim > > &, const MInt)
MBool mapCheckWave(std::unique_ptr< StructuredWindowMap< nDim > > &input)
void mapCombine22(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void deleteDuplicateWindows(std::vector< std::unique_ptr< StructuredWindowMap< nDim > > > &, std::vector< std::unique_ptr< StructuredWindowMap< nDim > > > &)
void mapCombine11(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void writeMapToArray(std::unique_ptr< StructuredWindowMap< nDim > > &map, MInt *array)
MBool mapCheck1d(std::unique_ptr< StructuredWindowMap< nDim > > &input)
void setWallInformation()
void readConnectionWindowInformation3D(MFloat *periodicDisplacments)
void mapCombineCell11(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void mapCreate(MInt Id1, MInt *start1, MInt *end1, MInt *step1, MInt Id2, MInt *start2, MInt *end2, MInt *step2, MInt *order, MInt BC, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void readMapFromArray(std::unique_ptr< StructuredWindowMap< nDim > > &map, MInt *array)
void mapPrint(const std::unique_ptr< StructuredWindowMap< nDim > > &input)
MBool mapCheck2d(std::unique_ptr< StructuredWindowMap< nDim > > &input)
void setSpongeInformation(MInt noSpongeInfo, MFloat *beta, MFloat *sigma, MFloat *thickness, MInt *bcInfo, MInt informationType)
void mapCombineCell12(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void deleteDuplicateBCMaps(std::vector< std::unique_ptr< StructuredWindowMap< nDim > > > &)
void mapZero(std::unique_ptr< StructuredWindowMap< nDim > > &output)
MBool checkZonalBCMaps(std::unique_ptr< StructuredWindowMap< nDim > > &, std::unique_ptr< StructuredWindowMap< nDim > > &)
void mapCombineWave(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void setLocalWallInformation()
void createCommunicationExchangeFlags(std::vector< std::unique_ptr< StructuredComm< nDim > > > &, std::vector< std::unique_ptr< StructuredComm< nDim > > > &, const MInt, MFloat *const *const)
void mapCpy(std::unique_ptr< StructuredWindowMap< nDim > > &input, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void mapNormalize3(std::unique_ptr< StructuredWindowMap< nDim > > &output)
void multiBlockAssembling()
void mapNormalize1(std::unique_ptr< StructuredWindowMap< nDim > > &input, std::unique_ptr< StructuredWindowMap< nDim > > &output)
MInt mapCompare(std::unique_ptr< StructuredWindowMap< nDim > > &map1, std::unique_ptr< StructuredWindowMap< nDim > > &map2)
void singularityAssembling()
void deleteDuplicateCommMaps()
FvStructuredSolverWindowInfo(StructuredGrid< nDim > *, MPI_Comm, const MInt, const MInt, const MInt)
~FvStructuredSolverWindowInfo()
MBool addConnection(MInt connectiontype, MInt b1, MInt *p1, MInt b2, MInt *p2)
void periodicPointsChange(MFloat *pt, MInt type, MFloat *periodicDisplacements)
void mapInvert(std::unique_ptr< StructuredWindowMap< nDim > > &input, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void mapCombine21(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void mapInvert1(std::unique_ptr< StructuredWindowMap< nDim > > &output)
void createWindowMapping(MPI_Comm *channelIn, MPI_Comm *channelOut, MPI_Comm *channelWorld, MInt *channelRoots, MPI_Comm *commStg, MInt *commStgRoot, MInt *commStgRootGlobal, MPI_Comm *commBC2600, MInt *commBC2600Root, MInt *commBC2600RootGlobal, MPI_Comm *rescalingCommGrComm, MInt *rescalingCommGrRoot, MInt *rescalingCommGrRootGlobal, MPI_Comm *commPerRotOne, MPI_Comm *commPerRotTwo, MPI_Comm *commPerRotWorld, MInt *rotationRoots, MInt &perRotGroup, SingularInformation *singularity, MInt *hasSingularity, MPI_Comm *plenumComm, MInt *plenumRoots)
void mapCombineCell21(std::unique_ptr< StructuredWindowMap< nDim > > &input1, std::unique_ptr< StructuredWindowMap< nDim > > &input2, std::unique_ptr< StructuredWindowMap< nDim > > &output)
void readWindowCoordinates(MFloat *periodicDisplacements)
MBool findConnection(connectionNode a)
void setZonalBCInformation()
MBool mapCheck(std::unique_ptr< StructuredWindowMap< nDim > > &input)
MBool mapCheck3d(std::unique_ptr< StructuredWindowMap< nDim > > &input)
void defineArray(maiabd_type type, const MString &name, size_type totalCount)
Create a new array in the file.
void writeArray(const T *array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1)
Write array data to file. [MPI]
MBool hasDataset(const MString &name, MInt dimension)
Check if the file contains an dataset with the given name and dimension.
void getAttribute(T *value, const MString &name, const MString &datasetName="")
Retrieve a file or dataset attribute.
MBool hasAttribute(const MString &name, const MString &path="")
Check if a given attribute exists in the file.
void setAttribute(const T &value, const MString &name, const MString &datasetName="")
Set a file or dataset attribute. [MPI]
void readArray(T *array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1)
Read array data from file. [MPI]
This class is a ScratchSpace.
T * getPointer() const
Deprecated: use begin() instead!
void fill(T val)
fill the scratch with a given value
void mTerm(const MInt errorCode, const MString &location, const MString &message)
constexpr T mMax(const T &x, const T &y)
MInt globalDomainId()
Return global domain id.
std::basic_string< char > MString
int MPI_Barrier(MPI_Comm comm, const MString &name)
same as MPI_Barrier
int MPI_Type_commit(MPI_Datatype *datatype, const MString &name)
same as MPI_Type_commit
int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm, const MString &name, const MString &varname)
same as MPI_Comm_create, but updates the number of MPI communicators
int MPI_Group_incl(MPI_Group group, int n, const int ranks[], MPI_Group *newgroup, const MString &name)
same as MPI_Group_incl
int MPI_Comm_group(MPI_Comm comm, MPI_Group *group, const MString &name, const MString &varname)
same as MPI_Comm_group
int MPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype *new_type_p, const MString &name)
same as MPI_Type_contiguous
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allreduce
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm, const MString &name, const MString &varname)
same as MPI_Bcast
MInt locatenear(Point< DIM > pt, MFloat r, MInt *list, MInt nmax, MBool returnCellId=true)