40 typedef vector<Class_Octant<2> > OctantsType;
41 typedef vector<Class_Intersection<2> > IntersectionsType;
42 typedef vector<uint32_t> u32vector;
43 typedef vector<uint64_t> u64vector;
44 typedef vector<vector<uint32_t> > u32vector2D;
45 typedef vector<vector<uint64_t> > u64vector2D;
54 IntersectionsType intersections;
55 u64vector globalidx_ghosts;
59 uint8_t local_max_depth;
60 uint8_t balance_codim;
62 u32vector last_ghost_bros;
66 u32vector2D connectivity;
68 u32vector2D ghostsnodes;
69 u32vector2D ghostsconnectivity;
104 uint32_t getSizeGhost()
const{
107 uint32_t getNumOctants()
const{
108 return octants.size();
110 uint8_t getLocalMaxDepth()
const{
111 return local_max_depth;
113 int8_t getMarker(int32_t idx){
116 uint8_t getLevel(int32_t idx){
117 return octants[idx].getLevel();
119 uint8_t getGhostLevel(int32_t idx){
120 return ghosts[idx].getLevel();
122 bool getBalance(int32_t idx){
123 return octants[idx].getNotBalance();
129 uint8_t getBalanceCodim()
const{
130 return balance_codim;
133 void setMarker(int32_t idx, int8_t marker){
134 octants[idx].setMarker(marker);
136 void setBalance(int32_t idx,
bool balance){
137 octants[idx].setBalance(balance);
143 void setBalanceCodim(uint8_t b21codim){
144 balance_codim = b21codim;
148 OctantsType::const_iterator firstOctant = octants.begin();
149 first_desc =
Class_Octant<2>(MAX_LEVEL_2D,firstOctant->x,firstOctant->y);
152 OctantsType::const_iterator lastOctant = octants.end() - 1;
154 delta = (uint32_t)pow(2.0,(
double)((uint8_t)MAX_LEVEL_2D - lastOctant->level)) - 1;
155 x = lastOctant->x + delta;
156 y = lastOctant->y + delta;
185 vector<uint32_t> last_child_index;
186 vector<Class_Octant<2> > children;
187 uint32_t idx, nocts, ilastch;
188 uint32_t offset = 0, blockidx;
189 uint8_t nchm1 = global2D.
nchildren-1, ich;
190 bool dorefine =
false;
192 nocts = octants.size();
193 for (idx=0; idx<nocts; idx++){
194 if(octants[idx].getMarker() > 0 && octants[idx].getLevel() < MAX_LEVEL_2D){
195 last_child_index.push_back(idx+nchm1+offset);
200 if (octants[idx].marker > 0){
201 octants[idx].marker = 0;
202 octants[idx].info[11] =
true;
207 octants.resize(octants.size()+offset);
208 blockidx = last_child_index[0]-nchm1;
209 idx = octants.size();
210 ilastch = last_child_index.size()-1;
211 while (idx>blockidx){
213 if(idx == last_child_index[ilastch]){
214 children = octants[idx-offset].buildChildren();
215 for (ich=0; ich<global2D.
nchildren; ich++){
216 octants[idx-ich] = (children[nchm1-ich]);
221 if (children[0].getLevel() > local_max_depth){
222 local_max_depth = children[0].getLevel();
224 if (children[0].getMarker() > 0){
233 octants[idx] = octants[idx-offset];
237 #if defined(__INTEL_COMPILER) || defined(__ICC)
239 octants.shrink_to_fit();
241 nocts = octants.size();
254 vector<uint32_t> first_child_index;
261 int8_t markerfather, marker;
262 uint8_t nbro, nstart, nend;
264 bool docoarse =
false;
270 nbro = nstart = nend = 0;
275 nocts = octants.size();
276 size_ghosts = ghosts.size();
286 while(idx2_gh < size_ghosts && ghosts[idx2_gh].computeMorton() <= last_desc.
computeMorton()){
289 idx2_gh = min((size_ghosts-1), idx2_gh);
293 for (idx=0; idx<nocts; idx++){
294 if(octants[idx].getMarker() < 0 && octants[idx].getLevel() > 0){
296 father = octants[idx].buildFather();
298 for (idx2=idx; idx2<idx+global2D.
nchildren; idx2++){
300 if(octants[idx2].getMarker() < 0 && octants[idx2].buildFather() == father){
307 first_child_index.push_back(idx);
321 uint32_t nblock = nocts;
322 uint32_t nfchild = first_child_index.size();
324 nblock = nocts - nidx*nchm1;
326 for (idx=0; idx<nblock; idx++){
328 if (idx+offset == first_child_index[nidx]){
329 markerfather = -MAX_LEVEL_2D;
330 father = octants[idx+offset].buildFather();
331 for (uint32_t iii=0; iii<12; iii++){
332 father.info[iii] =
false;
334 for(idx2=0; idx2<global2D.
nchildren; idx2++){
335 if (markerfather < octants[idx+offset+idx2].getMarker()+1){
336 markerfather = octants[idx+offset+idx2].getMarker()+1;
338 for (uint32_t iii=0; iii<12; iii++){
339 father.info[iii] = father.info[iii] || octants[idx+offset+idx2].info[iii];
342 father.info[9] =
true;
343 father.info[11] =
true;
344 if (markerfather < 0){
348 octants[idx] = father;
353 octants[idx] = octants[idx+offset];
357 octants[idx] = octants[idx+offset];
361 octants.resize(nblock);
362 #if defined(__INTEL_COMPILER) || defined(__ICC)
364 octants.shrink_to_fit();
366 nocts = octants.size();
369 if (ghosts.size() && nocts > 0){
371 if (ghosts[idx2_gh].buildFather() == octants[nocts-1].buildFather()){
372 father = ghosts[idx2_gh].buildFather();
373 for (uint32_t iii=0; iii<12; iii++){
374 father.info[iii] =
false;
376 markerfather = ghosts[idx2_gh].getMarker()+1;
379 marker = ghosts[idx].getMarker();
380 while(marker < 0 && ghosts[idx].buildFather() == father){
382 if (markerfather < ghosts[idx].getMarker()+1){
383 markerfather = ghosts[idx].getMarker()+1;
385 for (uint32_t iii=0; iii<global2D.
nfaces; iii++){
386 father.info[iii] = father.info[iii] || ghosts[idx].info[iii];
388 father.info[10] = father.info[10] || ghosts[idx].info[10];
390 if(idx == size_ghosts){
393 marker = ghosts[idx].getMarker();
400 marker = octants[idx].getMarker();
401 while(marker < 0 && octants[idx].buildFather() == father && idx >= 0){
404 if (markerfather < octants[idx].getMarker()+1){
405 markerfather = octants[idx].getMarker()+1;
408 marker = octants[idx].getMarker();
429 for (idx=0; idx < nend; idx++){
430 for (uint32_t iii=0; iii<12; iii++){
431 father.info[iii] = father.info[iii] || octants[nocts-idx-1].info[iii];
434 father.info[9] =
true;
435 father.info[11] =
true;
436 if (markerfather < 0){
440 octants.resize(nocts-offset);
441 octants.push_back(father);
442 #if defined(__INTEL_COMPILER) || defined(__ICC)
444 octants.shrink_to_fit();
446 nocts = octants.size();
461 bool refine(u32vector & mapidx){
464 vector<uint32_t> last_child_index;
465 vector<Class_Octant<2> > children;
466 uint32_t idx, nocts, ilastch;
467 uint32_t offset = 0, blockidx;
468 uint8_t nchm1 = global2D.
nchildren-1, ich;
469 bool dorefine =
false;
471 nocts = octants.size();
472 for (idx=0; idx<nocts; idx++){
473 if(octants[idx].getMarker() > 0 && octants[idx].getLevel() < MAX_LEVEL_2D){
474 last_child_index.push_back(idx+nchm1+offset);
479 if (octants[idx].marker > 0){
480 octants[idx].marker = 0;
481 octants[idx].info[11] =
true;
486 mapidx.resize(octants.size()+offset);
487 #if defined(__INTEL_COMPILER) || defined(__ICC)
489 mapidx.shrink_to_fit();
491 octants.resize(octants.size()+offset);
492 blockidx = last_child_index[0]-nchm1;
493 idx = octants.size();
494 ilastch = last_child_index.size()-1;
495 while (idx>blockidx){
498 if(idx == last_child_index[ilastch]){
499 children = octants[idx-offset].buildChildren();
500 for (ich=0; ich<global2D.
nchildren; ich++){
501 octants[idx-ich] = (children[nchm1-ich]);
502 mapidx[idx-ich] = mapidx[idx-offset];
507 if (children[0].getLevel() > local_max_depth){
508 local_max_depth = children[0].getLevel();
510 if (children[0].getMarker() > 0){
519 octants[idx] = octants[idx-offset];
520 mapidx[idx] = mapidx[idx-offset];
524 #if defined(__INTEL_COMPILER) || defined(__ICC)
526 octants.shrink_to_fit();
528 nocts = octants.size();
539 bool coarse(u32vector & mapidx){
543 vector<uint32_t> first_child_index;
545 uint32_t nocts, nocts0;
550 int8_t markerfather, marker;
553 bool docoarse =
false;
564 nocts = nocts0 = octants.size();
565 size_ghosts = ghosts.size();
576 while(idx2_gh < size_ghosts && ghosts[idx2_gh].computeMorton() < last_desc.
computeMorton()){
579 idx2_gh = min((size_ghosts-1), idx2_gh);
583 for (idx=0; idx<nocts; idx++){
584 if(octants[idx].getMarker() < 0 && octants[idx].getLevel() > 0){
586 father = octants[idx].buildFather();
588 for (idx2=idx; idx2<idx+global2D.
nchildren; idx2++){
590 if(octants[idx2].getMarker() < 0 && octants[idx2].buildFather() == father){
597 first_child_index.push_back(idx);
611 uint32_t nblock = nocts;
612 uint32_t nfchild = first_child_index.size();
614 nblock = nocts - nidx*nchm1;
616 for (idx=0; idx<nblock; idx++){
618 if (idx+offset == first_child_index[nidx]){
619 markerfather = -MAX_LEVEL_2D;
620 father = octants[idx+offset].buildFather();
621 for (uint32_t iii=0; iii<12; iii++){
622 father.info[iii] =
false;
624 for(idx2=0; idx2<global2D.
nchildren; idx2++){
625 if (markerfather < octants[idx+offset+idx2].getMarker()+1){
626 markerfather = octants[idx+offset+idx2].getMarker()+1;
628 for (uint32_t iii=0; iii<12; iii++){
629 father.info[iii] = father.info[iii] || octants[idx+offset+idx2].info[iii];
632 father.info[9] =
true;
633 father.info[11] =
true;
634 if (markerfather < 0){
638 octants[idx] = father;
639 mapidx[idx] = mapidx[idx+offset];
644 octants[idx] = octants[idx+offset];
645 mapidx[idx] = mapidx[idx+offset];
649 octants[idx] = octants[idx+offset];
650 mapidx[idx] = mapidx[idx+offset];
654 octants.resize(nblock);
655 #if defined(__INTEL_COMPILER) || defined(__ICC)
657 octants.shrink_to_fit();
659 nocts = octants.size();
660 mapidx.resize(nblock);
661 #if defined(__INTEL_COMPILER) || defined(__ICC)
663 mapidx.shrink_to_fit();
667 if (ghosts.size() && nocts > 0){
669 if (ghosts[idx2_gh].buildFather() == octants[nocts-1].buildFather()){
670 father = ghosts[idx2_gh].buildFather();
671 for (uint32_t iii=0; iii<12; iii++){
672 father.info[iii] =
false;
674 markerfather = ghosts[idx2_gh].getMarker()+1;
677 marker = ghosts[idx].getMarker();
678 while(marker < 0 && ghosts[idx].buildFather() == father){
680 if (markerfather < ghosts[idx].getMarker()+1){
681 markerfather = ghosts[idx].getMarker()+1;
683 for (uint32_t iii=0; iii<global2D.
nfaces; iii++){
684 father.info[iii] = father.info[iii] || ghosts[idx].info[iii];
686 father.info[10] = father.info[10] || ghosts[idx].info[10];
688 if(idx == size_ghosts){
691 marker = ghosts[idx].getMarker();
698 marker = octants[idx].getMarker();
699 while(marker < 0 && octants[idx].buildFather() == father && idx >= 0){
702 if (markerfather < octants[idx].getMarker()+1){
703 markerfather = octants[idx].getMarker()+1;
706 marker = octants[idx].getMarker();
727 for (idx=0; idx < nend; idx++){
728 for (uint32_t iii=0; iii<12; iii++){
729 father.info[iii] = father.info[iii] || octants[nocts-idx-1].info[iii];
732 father.info[9] =
true;
733 father.info[11] =
true;
734 if (markerfather < 0){
738 octants.resize(nocts-offset);
739 octants.push_back(father);
740 #if defined(__INTEL_COMPILER) || defined(__ICC)
742 octants.shrink_to_fit();
744 nocts = octants.size();
746 mapidx.resize(nocts);
747 #if defined(__INTEL_COMPILER) || defined(__ICC)
749 mapidx.shrink_to_fit();
770 vector<uint32_t> last_child_index;
771 vector<Class_Octant<2> > children;
772 uint32_t idx, nocts, ilastch;
773 uint32_t offset = 0, blockidx;
774 uint8_t nchm1 = global2D.
nchildren-1, ich;
775 bool dorefine =
false;
777 nocts = octants.size();
778 for (idx=0; idx<nocts; idx++){
779 octants[idx].setMarker(1);
780 if(octants[idx].getMarker() > 0 && octants[idx].getLevel() < MAX_LEVEL_2D){
781 last_child_index.push_back(idx+nchm1+offset);
786 if (octants[idx].marker > 0){
787 octants[idx].marker = 0;
788 octants[idx].info[11] =
true;
793 octants.resize(octants.size()+offset);
794 blockidx = last_child_index[0]-nchm1;
795 idx = octants.size();
796 ilastch = last_child_index.size()-1;
797 while (idx>blockidx){
799 if(idx == last_child_index[ilastch]){
800 children = octants[idx-offset].buildChildren();
801 for (ich=0; ich<global2D.
nchildren; ich++){
802 octants[idx-ich] = (children[nchm1-ich]);
807 if (children[0].getLevel() > local_max_depth){
808 local_max_depth = children[0].getLevel();
810 if (children[0].getMarker() > 0){
819 octants[idx] = octants[idx-offset];
823 #if defined(__INTEL_COMPILER) || defined(__ICC)
825 octants.shrink_to_fit();
827 nocts = octants.size();
840 vector<uint32_t> first_child_index;
847 int8_t markerfather, marker;
850 bool docoarse =
false;
861 nocts = octants.size();
862 size_ghosts = ghosts.size();
872 while(idx2_gh < size_ghosts && ghosts[idx2_gh].computeMorton() <= last_desc.
computeMorton()){
875 idx2_gh = min((size_ghosts-1), idx2_gh);
879 for (idx=0; idx<nocts; idx++){
880 octants[idx].setMarker(-1);
881 if(octants[idx].getMarker() < 0 && octants[idx].getLevel() > 0){
883 father = octants[idx].buildFather();
885 for (idx2=idx; idx2<idx+global2D.
nchildren; idx2++){
888 if(octants[idx2].getMarker() < 0 && octants[idx2].buildFather() == father){
895 first_child_index.push_back(idx);
900 octants[idx].setMarker(0);
901 octants[idx].info[11] =
true;
909 uint32_t nblock = nocts;
911 nblock = nocts - nidx*nchm1;
913 uint32_t nfchild = first_child_index.size();
914 for (idx=0; idx<nblock; idx++){
916 if (idx+offset == first_child_index[nidx]){
917 markerfather = -MAX_LEVEL_2D;
918 father = octants[idx+offset].buildFather();
919 for (uint32_t iii=0; iii<12; iii++){
920 father.info[iii] =
false;
922 for(idx2=0; idx2<global2D.
nchildren; idx2++){
923 if (markerfather < octants[idx+offset+idx2].getMarker()+1){
924 markerfather = octants[idx+offset+idx2].getMarker()+1;
926 for (uint32_t iii=0; iii<12; iii++){
927 father.info[iii] = father.info[iii] || octants[idx+offset+idx2].info[iii];
930 father.info[9] =
true;
931 if (markerfather < 0){
935 octants[idx] = father;
940 octants[idx] = octants[idx+offset];
944 octants[idx] = octants[idx+offset];
948 octants.resize(nblock);
949 #if defined(__INTEL_COMPILER) || defined(__ICC)
951 octants.shrink_to_fit();
953 nocts = octants.size();
956 if (ghosts.size() && nocts > 0){
958 if ((ghosts[idx2_gh].getMarker() < 0) && (octants[nocts-1].getMarker() < 0)){
959 father = ghosts[idx2_gh].buildFather();
960 for (uint32_t iii=0; iii<12; iii++){
961 father.info[iii] =
false;
963 markerfather = ghosts[idx2_gh].getMarker()+1;
966 ghosts[idx].setMarker(-1);
967 marker = ghosts[idx].getMarker();
968 while(marker < 0 && ghosts[idx].buildFather() == father){
970 if (markerfather < ghosts[idx].getMarker()+1){
971 markerfather = ghosts[idx].getMarker()+1;
974 if(idx == size_ghosts){
977 ghosts[idx].setMarker(-1);
978 marker = ghosts[idx].getMarker();
979 for (uint32_t iii=0; iii<12; iii++){
980 father.info[iii] = father.info[iii] || ghosts[idx].info[iii];
985 octants[idx].setMarker(-1);
986 marker = octants[idx].getMarker();
987 while(marker < 0 && octants[idx].buildFather() == father && idx >= 0){
990 if (markerfather < octants[idx].getMarker()+1){
991 markerfather = octants[idx].getMarker()+1;
994 octants[idx].setMarker(-1);
995 marker = octants[idx].getMarker();
1008 for(uint32_t ii=nocts-global2D.
nchildren; ii<nocts; ii++){
1009 octants[ii].setMarker(0);
1010 octants[ii].info[11] =
true;
1016 for (idx=0; idx < nend; idx++){
1017 for (uint32_t iii=0; iii<12; iii++){
1018 father.info[iii] = father.info[iii] || octants[nocts-idx-1].info[iii];
1021 father.info[9] =
true;
1022 if (markerfather < 0){
1026 octants.resize(nocts-offset);
1027 octants.push_back(father);
1028 #if defined(__INTEL_COMPILER) || defined(__ICC)
1030 octants.shrink_to_fit();
1032 nocts = octants.size();
1048 bool globalRefine(u32vector & mapidx){
1051 vector<uint32_t> last_child_index;
1052 vector<Class_Octant<2> > children;
1053 uint32_t idx, nocts, ilastch;
1054 uint32_t offset = 0, blockidx;
1055 uint8_t nchm1 = global2D.
nchildren-1, ich;
1056 bool dorefine =
false;
1058 nocts = octants.size();
1059 for (idx=0; idx<nocts; idx++){
1060 octants[idx].setMarker(1);
1061 if(octants[idx].getMarker() > 0 && octants[idx].getLevel() < MAX_LEVEL_2D){
1062 last_child_index.push_back(idx+nchm1+offset);
1067 if (octants[idx].marker > 0){
1068 octants[idx].marker = 0;
1069 octants[idx].info[11] =
true;
1074 mapidx.resize(octants.size()+offset);
1075 #if defined(__INTEL_COMPILER) || defined(__ICC)
1077 mapidx.shrink_to_fit();
1079 octants.resize(octants.size()+offset);
1080 blockidx = last_child_index[0]-nchm1;
1081 idx = octants.size();
1082 ilastch = last_child_index.size()-1;
1083 while (idx>blockidx){
1086 if(idx == last_child_index[ilastch]){
1087 children = octants[idx-offset].buildChildren();
1088 for (ich=0; ich<global2D.
nchildren; ich++){
1089 octants[idx-ich] = (children[nchm1-ich]);
1090 mapidx[idx-ich] = mapidx[idx-offset];
1095 if (children[0].getLevel() > local_max_depth){
1096 local_max_depth = children[0].getLevel();
1098 if (children[0].getMarker() > 0){
1107 octants[idx] = octants[idx-offset];
1108 mapidx[idx] = mapidx[idx-offset];
1112 #if defined(__INTEL_COMPILER) || defined(__ICC)
1114 octants.shrink_to_fit();
1116 nocts = octants.size();
1128 bool globalCoarse(u32vector & mapidx){
1131 vector<uint32_t> first_child_index;
1133 uint32_t nocts, nocts0;
1138 int8_t markerfather, marker;
1139 uint8_t nbro, nstart, nend;
1141 bool docoarse =
false;
1147 nbro = nstart = nend = 0;
1152 nocts = nocts0 = octants.size();
1153 size_ghosts = ghosts.size();
1164 while(idx2_gh < size_ghosts && ghosts[idx2_gh].computeMorton() < last_desc.
computeMorton()){
1167 idx2_gh = min((size_ghosts-1), idx2_gh);
1171 for (idx=0; idx<nocts; idx++){
1172 octants[idx].setMarker(-1);
1173 if(octants[idx].getMarker() < 0 && octants[idx].getLevel() > 0){
1175 father = octants[idx].buildFather();
1177 for (idx2=idx; idx2<idx+global2D.
nchildren; idx2++){
1180 if(octants[idx2].getMarker() < 0 && octants[idx2].buildFather() == father){
1187 first_child_index.push_back(idx);
1192 octants[idx].setMarker(0);
1193 octants[idx].info[11] =
true;
1202 uint32_t nblock = nocts - nidx*nchm1 - nstart;
1204 uint32_t nfchild = first_child_index.size();
1206 for (idx=0; idx<nocts-offset; idx++){
1207 if (nidx < nfchild){
1208 if (idx+offset == first_child_index[nidx]){
1209 markerfather = -MAX_LEVEL_2D;
1210 father = octants[idx+offset].buildFather();
1211 for (uint32_t iii=0; iii<12; iii++){
1212 father.info[iii] =
false;
1214 for(idx2=0; idx2<global2D.
nchildren; idx2++){
1215 if (markerfather < octants[idx+offset+idx2].getMarker()+1){
1216 markerfather = octants[idx+offset+idx2].getMarker()+1;
1218 for (uint32_t iii=0; iii<12; iii++){
1219 father.info[iii] = father.info[iii] || octants[idx+offset+idx2].info[iii];
1222 father.info[9] =
true;
1223 if (markerfather < 0){
1227 octants[idx] = father;
1228 mapidx[idx] = mapidx[idx+offset];
1233 octants[idx] = octants[idx+offset];
1234 mapidx[idx] = mapidx[idx+offset];
1238 octants[idx] = octants[idx+offset];
1239 mapidx[idx] = mapidx[idx+offset];
1243 octants.resize(nocts-offset);
1244 #if defined(__INTEL_COMPILER) || defined(__ICC)
1246 octants.shrink_to_fit();
1248 nocts = octants.size();
1249 mapidx.resize(nocts);
1250 #if defined(__INTEL_COMPILER) || defined(__ICC)
1252 mapidx.shrink_to_fit();
1256 if (ghosts.size() && nocts > 0){
1258 if ((ghosts[idx2_gh].getMarker() < 0) && (octants[nocts-1].getMarker() < 0)){
1259 father = ghosts[idx2_gh].buildFather();
1260 markerfather = ghosts[idx2_gh].
getMarker()+1;
1263 ghosts[idx].setMarker(-1);
1264 marker = ghosts[idx].getMarker();
1265 while(marker < 0 && ghosts[idx].buildFather() == father){
1267 if (markerfather < ghosts[idx].getMarker()+1){
1268 markerfather = ghosts[idx].getMarker()+1;
1271 if(idx == size_ghosts){
1274 ghosts[idx].setMarker(-1);
1275 marker = ghosts[idx].getMarker();
1279 octants[idx].setMarker(-1);
1280 marker = octants[idx].getMarker();
1281 while(marker < 0 && octants[idx].buildFather() == father && idx >= 0){
1284 if (markerfather < octants[idx].getMarker()+1){
1285 markerfather = octants[idx].getMarker()+1;
1288 octants[idx].setMarker(-1);
1289 marker = octants[idx].getMarker();
1302 for(uint32_t ii=nocts-global2D.
nchildren; ii<nocts; ii++){
1303 octants[ii].setMarker(0);
1304 octants[ii].info[11] =
true;
1310 for (uint32_t iii=0; iii<12; iii++){
1311 father.info[iii] =
false;
1313 for (idx=0; idx < nend; idx++){
1314 for (uint32_t iii=0; iii<12; iii++){
1315 father.info[iii] = father.info[iii] || octants[nocts-idx-1].info[iii];
1318 father.info[9] =
true;
1319 if (markerfather < 0){
1323 octants.resize(nocts-offset);
1324 octants.push_back(father);
1325 #if defined(__INTEL_COMPILER) || defined(__ICC)
1327 octants.shrink_to_fit();
1329 nocts = octants.size();
1330 mapidx.resize(nocts-offset);
1331 mapidx.push_back(nocts0-nend);
1332 #if defined(__INTEL_COMPILER) || defined(__ICC)
1334 mapidx.shrink_to_fit();
1351 void checkCoarse(uint64_t lastDescPre,
1352 uint64_t firstDescPost){
1356 uint8_t toDelete = 0;
1358 nocts = getNumOctants();
1360 Morton = octants[idx].computeMorton();
1361 while(Morton <= lastDescPre && idx < nocts && Morton != 0){
1365 Morton = octants[idx].computeMorton();
1367 for(idx=0; idx<nocts-toDelete; idx++){
1368 octants[idx] = octants[idx+toDelete];
1370 octants.resize(nocts-toDelete);
1371 #if defined(__INTEL_COMPILER) || defined(__ICC)
1373 octants.shrink_to_fit();
1375 nocts = getNumOctants();
1384 void checkCoarse(uint64_t lastDescPre,
1385 uint64_t firstDescPost,
1386 u32vector & mapidx){
1390 uint8_t toDelete = 0;
1392 nocts = getNumOctants();
1394 Morton = octants[idx].computeMorton();
1395 while(Morton <= lastDescPre && idx < nocts && Morton != 0){
1399 Morton = octants[idx].computeMorton();
1401 for(idx=0; idx<nocts-toDelete; idx++){
1402 octants[idx] = octants[idx+toDelete];
1403 mapidx[idx] = mapidx[idx+toDelete];
1405 octants.resize(nocts-toDelete);
1406 #if defined(__INTEL_COMPILER) || defined(__ICC)
1408 octants.shrink_to_fit();
1410 mapidx.resize(nocts-toDelete);
1411 #if defined(__INTEL_COMPILER) || defined(__ICC)
1413 mapidx.shrink_to_fit();
1415 nocts = getNumOctants();
1424 void updateLocalMaxDepth(){
1425 uint32_t noctants = getNumOctants();
1428 local_max_depth = 0;
1429 for(i = 0; i < noctants; i++){
1430 if(octants[i].getLevel() > local_max_depth){
1431 local_max_depth = octants[i].getLevel();
1439 void findNeighbours(uint32_t idx,
1441 u32vector & neighbours,
1442 vector<bool> & isghost){
1444 uint64_t Morton, Mortontry;
1445 uint32_t noctants = getNumOctants();
1448 uint32_t size = oct->
getSize();
1453 int8_t cx = int8_t((iface<2)*(int8_t(2*iface-1)));
1454 int8_t cy = int8_t((int8_t(iface/2))*(int8_t(2*iface-5)));
1460 if (iface < 0 || iface > global2D.
nfaces){
1465 if (oct->info[global2D.
nfaces+iface] ==
false){
1468 if (oct->info[iface] ==
false){
1471 Class_Octant<2> samesizeoct(oct->level, int32_t(oct->x)+int32_t(cx*size), int32_t(oct->y)+int32_t(cy*size));
1476 int32_t jump = (oct->
computeMorton() > Morton) ? int32_t(idx/2+1) : int32_t((noctants -idx)/2+1);
1478 if (idxtry > noctants-1) idxtry = noctants-1;
1480 while(abs(jump) > 0){
1481 Mortontry = octants[idxtry].computeMorton();
1482 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
1484 if (idxtry > noctants-1){
1486 idxtry = noctants - 1;
1495 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
1497 isghost.push_back(
false);
1498 neighbours.push_back(idxtry);
1504 while(octants[idxtry].computeMorton() < Morton){
1506 if(idxtry > noctants-1){
1507 idxtry = noctants-1;
1511 while(octants[idxtry].computeMorton() > Morton){
1513 if(idxtry > noctants-1){
1519 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
1521 isghost.push_back(
false);
1522 neighbours.push_back(idxtry);
1528 Mortontry = octants[idxtry].computeMorton();
1530 int32_t Dxstar, Dystar;
1531 while(Mortontry < Mortonlast && idxtry < noctants){
1532 Dx = int32_t(abs(cx))*(-int32_t(oct->x) + int32_t(octants[idxtry].x));
1533 Dy = int32_t(abs(cy))*(-int32_t(oct->y) + int32_t(octants[idxtry].y));
1534 Dxstar = int32_t((cx-1)/2)*(octants[idxtry].getSize()) + int32_t((cx+1)/2)*size;
1535 Dystar = int32_t((cy-1)/2)*(octants[idxtry].getSize()) + int32_t((cy+1)/2)*size;
1537 uint32_t x0 = oct->x;
1538 uint32_t x1 = x0 + size;
1539 uint32_t y0 = oct->y;
1540 uint32_t y1 = y0 + size;
1541 uint32_t x0try = octants[idxtry].x;
1542 uint32_t x1try = x0try + octants[idxtry].getSize();
1543 uint32_t y0try = octants[idxtry].y;
1544 uint32_t y1try = y0try + octants[idxtry].getSize();
1545 uint8_t level = oct->level;
1546 uint8_t leveltry = octants[idxtry].getLevel();
1548 if (Dx == Dxstar && Dy == Dystar){
1549 if (leveltry > level){
1550 if((abs(cx)*((y0try>=y0)*(y0try<y1))) + (abs(cy)*((x0try>=x0)*(x0try<x1)))){
1551 neighbours.push_back(idxtry);
1552 isghost.push_back(
false);
1555 if (leveltry < level){
1556 if((abs(cx)*((y0>=y0try)*(y0<y1try))) + (abs(cy)*((x0>=x0try)*(x0<x1try)))){
1557 neighbours.push_back(idxtry);
1558 isghost.push_back(
false);
1564 if(idxtry>noctants-1){
1567 Mortontry = octants[idxtry].computeMorton();
1581 if (oct->info[iface] ==
false){
1584 if (ghosts.size()>0){
1587 uint32_t idxghost = uint32_t(size_ghosts/2);
1591 Class_Octant<2> samesizeoct(oct->level, oct->x+cx*size, oct->y+cy*size);
1596 int32_t jump = (octghost->
computeMorton() > Morton) ? int32_t(idxghost/2+1) : int32_t((size_ghosts -idxghost)/2+1);
1598 if (idxtry > ghosts.size()-1) idxtry = ghosts.size()-1;
1599 while(abs(jump) > 0){
1600 Mortontry = ghosts[idxtry].computeMorton();
1601 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
1603 if (idxtry > ghosts.size()-1){
1605 idxtry = ghosts.size() - 1;
1614 if(ghosts[idxtry].computeMorton() == Morton && ghosts[idxtry].level == oct->level){
1616 isghost.push_back(
true);
1617 neighbours.push_back(idxtry);
1623 while(ghosts[idxtry].computeMorton() < Morton){
1625 if(idxtry > ghosts.size()-1){
1626 idxtry = ghosts.size()-1;
1630 while(ghosts[idxtry].computeMorton() > Morton){
1632 if(idxtry > ghosts.size()-1){
1638 if(idxtry < size_ghosts){
1639 if(ghosts[idxtry].computeMorton() == Morton && ghosts[idxtry].level == oct->level){
1641 isghost.push_back(
true);
1642 neighbours.push_back(idxtry);
1648 Mortontry = ghosts[idxtry].computeMorton();
1650 int32_t Dxstar, Dystar;
1651 while(Mortontry < Mortonlast && idxtry < size_ghosts){
1652 Dx = int32_t(abs(cx))*(-int32_t(oct->x) + int32_t(ghosts[idxtry].x));
1653 Dy = int32_t(abs(cy))*(-int32_t(oct->y) + int32_t(ghosts[idxtry].y));
1654 Dxstar = int32_t((cx-1)/2)*(ghosts[idxtry].getSize()) + int32_t((cx+1)/2)*size;
1655 Dystar = int32_t((cy-1)/2)*(ghosts[idxtry].getSize()) + int32_t((cy+1)/2)*size;
1657 uint32_t x0 = oct->x;
1658 uint32_t x1 = x0 + size;
1659 uint32_t y0 = oct->y;
1660 uint32_t y1 = y0 + size;
1661 uint32_t x0try = ghosts[idxtry].x;
1662 uint32_t x1try = x0try + ghosts[idxtry].getSize();
1663 uint32_t y0try = ghosts[idxtry].y;
1664 uint32_t y1try = y0try + ghosts[idxtry].getSize();
1665 uint8_t level = oct->level;
1666 uint8_t leveltry = ghosts[idxtry].getLevel();
1668 if (Dx == Dxstar && Dy == Dystar){
1669 if (leveltry > level){
1670 if((abs(cx)*((y0try>=y0)*(y0try<y1))) + (abs(cy)*((x0try>=x0)*(x0try<x1)))){
1671 neighbours.push_back(idxtry);
1672 isghost.push_back(
true);
1675 if (leveltry < level){
1676 if((abs(cx)*((y0>=y0try)*(y0<y1try))) + (abs(cy)*((x0>=x0try)*(x0<x1try)))){
1677 neighbours.push_back(idxtry);
1678 isghost.push_back(
true);
1684 if(idxtry>size_ghosts-1){
1687 Mortontry = ghosts[idxtry].computeMorton();
1692 uint32_t lengthneigh = 0;
1693 uint32_t sizeneigh = neighbours.size();
1694 for (idxtry=0; idxtry<sizeneigh; idxtry++){
1695 lengthneigh += ghosts[neighbours[idxtry]].getSize();
1697 if (lengthneigh < oct->getSize()){
1701 if (oct->info[iface] ==
false){
1704 Class_Octant<2> samesizeoct(oct->level, oct->x+cx*size, oct->y+cy*size);
1709 int32_t jump = (oct->
computeMorton() > Morton) ? int32_t(idx/2+1) : int32_t((noctants -idx)/2+1);
1711 if (idxtry > noctants-1) idxtry = noctants-1;
1712 while(abs(jump) > 0){
1713 Mortontry = octants[idxtry].computeMorton();
1714 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
1716 if (idxtry > noctants-1){
1718 idxtry = noctants - 1;
1727 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
1729 isghost.push_back(
false);
1730 neighbours.push_back(idxtry);
1736 while(octants[idxtry].computeMorton() < Morton){
1738 if(idxtry > noctants-1){
1739 idxtry = noctants-1;
1743 while(octants[idxtry].computeMorton() > Morton){
1745 if(idxtry > noctants-1){
1751 if (idxtry < noctants){
1752 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
1754 isghost.push_back(
false);
1755 neighbours.push_back(idxtry);
1761 Mortontry = octants[idxtry].computeMorton();
1763 int32_t Dxstar, Dystar;
1764 while(Mortontry < Mortonlast && idxtry <= noctants-1){
1765 Dx = int32_t(abs(cx))*(-int32_t(oct->x) + int32_t(octants[idxtry].x));
1766 Dy = int32_t(abs(cy))*(-int32_t(oct->y) + int32_t(octants[idxtry].y));
1767 Dxstar = int32_t((cx-1)/2)*(octants[idxtry].getSize()) + int32_t((cx+1)/2)*size;
1768 Dystar = int32_t((cy-1)/2)*(octants[idxtry].getSize()) + int32_t((cy+1)/2)*size;
1770 uint32_t x0 = oct->x;
1771 uint32_t x1 = x0 + size;
1772 uint32_t y0 = oct->y;
1773 uint32_t y1 = y0 + size;
1774 uint32_t x0try = octants[idxtry].x;
1775 uint32_t x1try = x0try + octants[idxtry].getSize();
1776 uint32_t y0try = octants[idxtry].y;
1777 uint32_t y1try = y0try + octants[idxtry].getSize();
1778 uint8_t level = oct->level;
1779 uint8_t leveltry = octants[idxtry].getLevel();
1781 if (Dx == Dxstar && Dy == Dystar){
1782 if (leveltry > level){
1783 if((abs(cx)*((y0try>=y0)*(y0try<y1))) + (abs(cy)*((x0try>=x0)*(x0try<x1)))){
1784 neighbours.push_back(idxtry);
1785 isghost.push_back(
false);
1788 if (leveltry < level){
1789 if((abs(cx)*((y0>=y0try)*(y0<y1try))) + (abs(cy)*((x0>=x0try)*(x0<x1try)))){
1790 neighbours.push_back(idxtry);
1791 isghost.push_back(
false);
1797 if(idxtry>noctants-1){
1800 Mortontry = octants[idxtry].computeMorton();
1820 u32vector & neighbours,
1821 vector<bool> & isghost){
1823 uint64_t Morton, Mortontry;
1824 uint32_t noctants = getNumOctants();
1826 uint32_t size = oct->
getSize();
1830 int8_t cx = int8_t((iface<2)*(int8_t(2*iface-1)));
1831 int8_t cy = int8_t((int8_t(iface/2))*(int8_t(2*iface-5)));
1837 if (iface < 0 || iface > global2D.
nfaces){
1842 if (oct->info[global2D.
nfaces+iface] ==
false){
1845 if (oct->info[iface] ==
false){
1848 Class_Octant<2> samesizeoct(oct->level, int32_t(oct->x)+int32_t(cx*size), int32_t(oct->y)+int32_t(cy*size));
1853 int32_t jump = int32_t((noctants)/2+1);
1854 idxtry = uint32_t(jump);
1856 while(abs(jump) > 0){
1857 Mortontry = octants[idxtry].computeMorton();
1858 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
1860 if (idxtry > noctants-1){
1862 idxtry = noctants - 1;
1871 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
1873 isghost.push_back(
false);
1874 neighbours.push_back(idxtry);
1880 while(octants[idxtry].computeMorton() < Morton){
1882 if(idxtry > noctants-1){
1883 idxtry = noctants-1;
1887 while(octants[idxtry].computeMorton() > Morton){
1889 if(idxtry > noctants-1){
1895 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
1897 isghost.push_back(
false);
1898 neighbours.push_back(idxtry);
1904 Mortontry = octants[idxtry].computeMorton();
1906 int32_t Dxstar, Dystar;
1907 while(Mortontry < Mortonlast && idxtry < noctants){
1908 Dx = int32_t(abs(cx))*(-int32_t(oct->x) + int32_t(octants[idxtry].x));
1909 Dy = int32_t(abs(cy))*(-int32_t(oct->y) + int32_t(octants[idxtry].y));
1910 Dxstar = int32_t((cx-1)/2)*(octants[idxtry].getSize()) + int32_t((cx+1)/2)*size;
1911 Dystar = int32_t((cy-1)/2)*(octants[idxtry].getSize()) + int32_t((cy+1)/2)*size;
1913 uint32_t x0 = oct->x;
1914 uint32_t x1 = x0 + size;
1915 uint32_t y0 = oct->y;
1916 uint32_t y1 = y0 + size;
1917 uint32_t x0try = octants[idxtry].x;
1918 uint32_t x1try = x0try + octants[idxtry].getSize();
1919 uint32_t y0try = octants[idxtry].y;
1920 uint32_t y1try = y0try + octants[idxtry].getSize();
1921 uint8_t level = oct->level;
1922 uint8_t leveltry = octants[idxtry].getLevel();
1924 if (Dx == Dxstar && Dy == Dystar){
1925 if (leveltry > level){
1926 if((abs(cx)*((y0try>=y0)*(y0try<y1))) + (abs(cy)*((x0try>=x0)*(x0try<x1)))){
1927 neighbours.push_back(idxtry);
1928 isghost.push_back(
false);
1931 if (leveltry < level){
1932 if((abs(cx)*((y0>=y0try)*(y0<y1try))) + (abs(cy)*((x0>=x0try)*(x0<x1try)))){
1933 neighbours.push_back(idxtry);
1934 isghost.push_back(
false);
1940 if(idxtry>noctants-1){
1943 Mortontry = octants[idxtry].computeMorton();
1957 if (oct->info[iface] ==
false){
1960 if (ghosts.size()>0){
1963 uint32_t idxghost = uint32_t(size_ghosts/2);
1967 Class_Octant<2> samesizeoct(oct->level, oct->x+cx*size, oct->y+cy*size);
1972 int32_t jump = (octghost->
computeMorton() > Morton) ? int32_t(idxghost/2+1) : int32_t((size_ghosts -idxghost)/2+1);
1974 while(abs(jump) > 0){
1975 Mortontry = ghosts[idxtry].computeMorton();
1976 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
1978 if (idxtry > ghosts.size()-1){
1980 idxtry = ghosts.size() - 1;
1989 if(ghosts[idxtry].computeMorton() == Morton && ghosts[idxtry].level == oct->level){
1991 isghost.push_back(
true);
1992 neighbours.push_back(idxtry);
1998 while(ghosts[idxtry].computeMorton() < Morton){
2000 if(idxtry > ghosts.size()-1){
2001 idxtry = ghosts.size()-1;
2005 while(ghosts[idxtry].computeMorton() > Morton){
2007 if(idxtry > ghosts.size()-1){
2013 if(idxtry < size_ghosts){
2014 if(ghosts[idxtry].computeMorton() == Morton && ghosts[idxtry].level == oct->level){
2016 isghost.push_back(
true);
2017 neighbours.push_back(idxtry);
2023 Mortontry = ghosts[idxtry].computeMorton();
2025 int32_t Dxstar, Dystar;
2026 while(Mortontry < Mortonlast && idxtry < size_ghosts){
2027 Dx = int32_t(abs(cx))*(-int32_t(oct->x) + int32_t(ghosts[idxtry].x));
2028 Dy = int32_t(abs(cy))*(-int32_t(oct->y) + int32_t(ghosts[idxtry].y));
2029 Dxstar = int32_t((cx-1)/2)*(ghosts[idxtry].getSize()) + int32_t((cx+1)/2)*size;
2030 Dystar = int32_t((cy-1)/2)*(ghosts[idxtry].getSize()) + int32_t((cy+1)/2)*size;
2032 uint32_t x0 = oct->x;
2033 uint32_t x1 = x0 + size;
2034 uint32_t y0 = oct->y;
2035 uint32_t y1 = y0 + size;
2036 uint32_t x0try = ghosts[idxtry].x;
2037 uint32_t x1try = x0try + ghosts[idxtry].getSize();
2038 uint32_t y0try = ghosts[idxtry].y;
2039 uint32_t y1try = y0try + ghosts[idxtry].getSize();
2040 uint8_t level = oct->level;
2041 uint8_t leveltry = ghosts[idxtry].getLevel();
2043 if (Dx == Dxstar && Dy == Dystar){
2044 if (leveltry > level){
2045 if((abs(cx)*((y0try>=y0)*(y0try<y1))) + (abs(cy)*((x0try>=x0)*(x0try<x1)))){
2046 neighbours.push_back(idxtry);
2047 isghost.push_back(
true);
2050 if (leveltry < level){
2051 if((abs(cx)*((y0>=y0try)*(y0<y1try))) + (abs(cy)*((x0>=x0try)*(x0<x1try)))){
2052 neighbours.push_back(idxtry);
2053 isghost.push_back(
true);
2060 if(idxtry>size_ghosts-1){
2063 Mortontry = ghosts[idxtry].computeMorton();
2068 uint32_t lengthneigh = 0;
2069 uint32_t sizeneigh = neighbours.size();
2070 for (idxtry=0; idxtry<sizeneigh; idxtry++){
2071 lengthneigh += ghosts[neighbours[idxtry]].getSize();
2073 if (lengthneigh < oct->getSize()){
2077 if (oct->info[iface] ==
false){
2080 Class_Octant<2> samesizeoct(oct->level, oct->x+cx*size, oct->y+cy*size);
2085 int32_t jump = int32_t((noctants)/2+1);
2086 idxtry = uint32_t(jump);
2087 while(abs(jump) > 0){
2088 Mortontry = octants[idxtry].computeMorton();
2089 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
2091 if (idxtry > noctants-1){
2093 idxtry = noctants - 1;
2102 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
2104 isghost.push_back(
false);
2105 neighbours.push_back(idxtry);
2111 while(octants[idxtry].computeMorton() < Morton){
2113 if(idxtry > noctants-1){
2114 idxtry = noctants-1;
2118 while(octants[idxtry].computeMorton() > Morton){
2120 if(idxtry > noctants-1){
2126 if (idxtry < noctants){
2127 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
2129 isghost.push_back(
false);
2130 neighbours.push_back(idxtry);
2136 Mortontry = octants[idxtry].computeMorton();
2138 int32_t Dxstar, Dystar;
2139 while(Mortontry < Mortonlast && idxtry <= noctants-1){
2140 Dx = int32_t(abs(cx))*(-int32_t(oct->x) + int32_t(octants[idxtry].x));
2141 Dy = int32_t(abs(cy))*(-int32_t(oct->y) + int32_t(octants[idxtry].y));
2142 Dxstar = int32_t((cx-1)/2)*(octants[idxtry].getSize()) + int32_t((cx+1)/2)*size;
2143 Dystar = int32_t((cy-1)/2)*(octants[idxtry].getSize()) + int32_t((cy+1)/2)*size;
2145 uint32_t x0 = oct->x;
2146 uint32_t x1 = x0 + size;
2147 uint32_t y0 = oct->y;
2148 uint32_t y1 = y0 + size;
2149 uint32_t x0try = octants[idxtry].x;
2150 uint32_t x1try = x0try + octants[idxtry].getSize();
2151 uint32_t y0try = octants[idxtry].y;
2152 uint32_t y1try = y0try + octants[idxtry].getSize();
2153 uint8_t level = oct->level;
2154 uint8_t leveltry = octants[idxtry].getLevel();
2156 if (Dx == Dxstar && Dy == Dystar){
2157 if (leveltry > level){
2158 if((abs(cx)*((y0try>=y0)*(y0try<y1))) + (abs(cy)*((x0try>=x0)*(x0try<x1)))){
2159 neighbours.push_back(idxtry);
2160 isghost.push_back(
false);
2163 if (leveltry < level){
2164 if((abs(cx)*((y0>=y0try)*(y0<y1try))) + (abs(cy)*((x0>=x0try)*(x0<x1try)))){
2165 neighbours.push_back(idxtry);
2166 isghost.push_back(
false);
2172 Mortontry = octants[idxtry].computeMorton();
2190 void findGhostNeighbours(uint32_t
const idx,
2192 u32vector & neighbours){
2194 uint64_t Morton, Mortontry;
2195 uint32_t noctants = getNumOctants();
2198 uint32_t size = oct->
getSize();
2201 int8_t cx = int8_t((iface<2)*(int8_t(2*iface-1)));
2202 int8_t cy = int8_t((int8_t(iface/2))*(int8_t(2*iface-5)));
2207 if (iface < 0 || iface > global2D.
nfaces){
2212 if (oct->info[global2D.
nfaces+iface] ==
true){
2215 Class_Octant<2> samesizeoct(oct->level, int32_t(oct->x)+int32_t(cx*size), int32_t(oct->y)+int32_t(cy*size));
2220 int32_t jump = getNumOctants()/2;
2221 idxtry = uint32_t(getNumOctants()/2);
2222 Mortontry = octants[idxtry].computeMorton();
2223 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
2224 while(abs(jump) > 0){
2225 Mortontry = octants[idxtry].computeMorton();
2226 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
2228 if (idxtry > noctants-1){
2230 idxtry = noctants - 1;
2239 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
2241 neighbours.push_back(idxtry);
2247 while(octants[idxtry].computeMorton() < Morton){
2249 if(idxtry > noctants-1){
2250 idxtry = noctants-1;
2254 while(octants[idxtry].computeMorton() > Morton){
2256 if(idxtry > noctants-1){
2262 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
2264 neighbours.push_back(idxtry);
2270 Mortontry = octants[idxtry].computeMorton();
2272 int32_t Dxstar, Dystar;
2273 while(Mortontry < Mortonlast && idxtry < noctants){
2274 Dx = int32_t(abs(cx))*(-int32_t(oct->x) + int32_t(octants[idxtry].x));
2275 Dy = int32_t(abs(cy))*(-int32_t(oct->y) + int32_t(octants[idxtry].y));
2276 Dxstar = int32_t((cx-1)/2)*(octants[idxtry].getSize()) + int32_t((cx+1)/2)*size;
2277 Dystar = int32_t((cy-1)/2)*(octants[idxtry].getSize()) + int32_t((cy+1)/2)*size;
2279 uint32_t x0 = oct->x;
2280 uint32_t x1 = x0 + size;
2281 uint32_t y0 = oct->y;
2282 uint32_t y1 = y0 + size;
2283 uint32_t x0try = octants[idxtry].x;
2284 uint32_t x1try = x0try + octants[idxtry].getSize();
2285 uint32_t y0try = octants[idxtry].y;
2286 uint32_t y1try = y0try + octants[idxtry].getSize();
2287 uint8_t level = oct->level;
2288 uint8_t leveltry = octants[idxtry].getLevel();
2290 if (Dx == Dxstar && Dy == Dystar){
2291 if (leveltry > level){
2292 if((abs(cx)*((y0try>=y0)*(y0try<y1))) + (abs(cy)*((x0try>=x0)*(x0try<x1)))){
2293 neighbours.push_back(idxtry);
2296 if (leveltry < level){
2297 if((abs(cx)*((y0>=y0try)*(y0<y1try))) + (abs(cy)*((x0>=x0try)*(x0<x1try)))){
2298 neighbours.push_back(idxtry);
2304 if(idxtry>noctants-1){
2307 Mortontry = octants[idxtry].computeMorton();
2321 void preBalance21(
bool internal){
2326 uint32_t idx, idx2, idx0, last_idx;
2327 uint32_t idx1_gh, idx2_gh;
2328 int8_t markerfather, marker;
2341 nocts = octants.size();
2342 size_ghosts = ghosts.size();
2346 last_ghost_bros.clear();
2350 while(idx2_gh < size_ghosts && ghosts[idx2_gh].computeMorton() <= last_desc.
computeMorton()){
2353 idx2_gh = min((size_ghosts-1), idx2_gh);
2355 while(idx1_gh < size_ghosts && ghosts[idx1_gh].computeMorton() <= octants[0].computeMorton()){
2359 if (idx1_gh==-1) idx1_gh=0;
2363 if (ghosts.size() && nocts > 0){
2364 if (ghosts[idx1_gh].buildFather()==octants[0].buildFather()){
2365 father = ghosts[idx1_gh].buildFather();
2369 while(marker < 0 && ghosts[idx].buildFather() == father){
2374 marker = ghosts[idx].getMarker();
2379 while(octants[idx].buildFather() == father){
2380 if (octants[idx].getMarker()<0)
2386 if (nbro != global2D.
nchildren && idx!=nocts-1){
2387 for(uint32_t ii=0; ii<idx; ii++){
2388 if(octants[ii].getMarker()<0){
2389 octants[ii].setMarker(0);
2390 octants[ii].info[11]=
true;
2398 if (ghosts[idx2_gh].buildFather()==octants[nocts-1].buildFather()){
2399 father = ghosts[idx2_gh].buildFather();
2403 while(marker < 0 && ghosts[idx].buildFather() == father){
2406 last_ghost_bros.push_back(idx);
2410 if(idx == size_ghosts){
2413 marker = ghosts[idx].getMarker();
2419 while(octants[idx].buildFather() == father){
2420 if (octants[idx].getMarker()<0)
2427 if (nbro != global2D.
nchildren && idx!=nocts-1){
2428 for(uint32_t ii=idx+1; ii<nocts; ii++){
2429 if (octants[ii].getMarker()<0){
2430 octants[ii].setMarker(0);
2431 octants[ii].info[11]=
true;
2436 last_ghost_bros.clear();
2443 father = octants[0].buildFather();
2444 lastdesc = father.buildLastDesc();
2447 for (idx=0; idx<global2D.
nchildren; idx++){
2449 if (octants[idx].computeMorton() <= mortonld){
2457 for (idx=idx0; idx<nocts; idx++){
2458 if(octants[idx].getMarker() < 0 && octants[idx].getLevel() > 0){
2460 father = octants[idx].buildFather();
2462 for (idx2=idx; idx2<idx+global2D.
nchildren; idx2++){
2464 if(octants[idx2].getMarker() < 0 && octants[idx2].buildFather() == father){
2475 octants[idx].info[11]=
true;
2486 void preBalance21(u32vector& newmodified){
2491 uint32_t idx, idx2, idx0, last_idx;
2492 uint32_t idx1_gh, idx2_gh;
2493 int8_t markerfather, marker;
2505 nocts = octants.size();
2506 size_ghosts = ghosts.size();
2510 last_ghost_bros.clear();
2514 while(idx2_gh < size_ghosts && ghosts[idx2_gh].computeMorton() <= last_desc.
computeMorton()){
2517 idx2_gh = min((size_ghosts-1), idx2_gh);
2519 while(idx1_gh < size_ghosts && ghosts[idx1_gh].computeMorton() <= octants[0].computeMorton()){
2523 if (idx1_gh==-1) idx1_gh=0;
2527 if (ghosts.size() && nocts > 0){
2528 if (ghosts[idx1_gh].buildFather()==octants[0].buildFather()){
2529 father = ghosts[idx1_gh].buildFather();
2533 while(marker < 0 && ghosts[idx].buildFather() == father){
2536 last_ghost_bros.push_back(idx);
2542 marker = ghosts[idx].getMarker();
2547 while(idx<nocts && octants[idx].buildFather() == father){
2548 if (octants[idx].getMarker()<0)
2554 if (nbro != global2D.
nchildren && idx!=nocts-1){
2555 for(uint32_t ii=0; ii<idx; ii++){
2556 if (octants[ii].getMarker()<0){
2557 octants[ii].setMarker(0);
2558 octants[ii].info[11]=
true;
2560 newmodified.push_back(ii);
2564 last_ghost_bros.clear();
2569 if (ghosts[idx2_gh].buildFather()==octants[nocts-1].buildFather()){
2570 father = ghosts[idx2_gh].buildFather();
2574 while(marker < 0 && ghosts[idx].buildFather() == father){
2577 if(idx == size_ghosts){
2580 marker = ghosts[idx].getMarker();
2585 while(octants[idx].buildFather() == father){
2586 if (octants[idx].getMarker()<0)
2593 if (nbro != global2D.
nchildren && idx!=nocts-1){
2594 for(uint32_t ii=idx+1; ii<nocts; ii++){
2595 if (octants[ii].getMarker()<0){
2596 octants[ii].setMarker(0);
2597 octants[ii].info[11]=
true;
2599 newmodified.push_back(ii);
2607 father = octants[0].buildFather();
2608 lastdesc = father.buildLastDesc();
2611 for (idx=0; idx<global2D.
nchildren; idx++){
2613 if (octants[idx].computeMorton() <= mortonld){
2621 for (idx=idx0; idx<nocts; idx++){
2622 if(octants[idx].getMarker() < 0 && octants[idx].getLevel() > 0){
2624 father = octants[idx].buildFather();
2626 for (idx2=idx; idx2<idx+global2D.
nchildren; idx2++){
2628 if(octants[idx2].getMarker() < 0 && octants[idx2].buildFather() == father){
2639 octants[idx].info[11]=
true;
2641 newmodified.push_back(idx);
2650 bool localBalance(
bool doInterior){
2654 uint32_t sizeneigh, modsize;
2656 u32vector modified, newmodified;
2658 uint8_t iface, inode;
2659 int8_t targetmarker;
2660 vector<bool> isghost;
2663 OctantsType::iterator obegin, oend, it;
2664 u32vector::iterator ibegin, iend, iit;
2668 obegin = octants.begin();
2669 oend = octants.end();
2671 for (it=obegin; it!=oend; it++){
2672 if (!it->getNotBalance() && it->getMarker() != 0){
2673 targetmarker = min(MAX_LEVEL_2D,
int(octants[idx].getLevel()) +
int(octants[idx].getMarker()));
2676 for (iface=0; iface<global2D.
nfaces; iface++){
2677 if(!it->getBound(iface)){
2678 findNeighbours(idx, iface, neigh, isghost);
2679 sizeneigh = neigh.size();
2680 for(i=0; i<sizeneigh; i++){
2683 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1) ){
2684 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-1-octants[idx].getLevel());
2685 octants[idx].info[11] =
true;
2686 modified.push_back(idx);
2689 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2690 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2691 octants[neigh[i]].info[11] =
true;
2692 modified.push_back(neigh[i]);
2698 if((ghosts[neigh[i]].getLevel() + ghosts[neigh[i]].getMarker()) > (targetmarker + 1) ){
2699 octants[idx].setMarker(ghosts[neigh[i]].getLevel()+ghosts[neigh[i]].getMarker()-1-octants[idx].getLevel());
2700 octants[idx].info[11] =
true;
2701 modified.push_back(idx);
2709 if (balance_codim>1){
2711 for (inode=0; inode<global2D.
nnodes; inode++){
2712 if(!it->getBound(global2D.
nodeface[inode][0]) && !it->getBound(global2D.
nodeface[inode][1])){
2713 findNodeNeighbours(idx, inode, neigh, isghost);
2714 sizeneigh = neigh.size();
2715 for(i=0; i<sizeneigh; i++){
2718 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1) ){
2719 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-1-octants[idx].getLevel());
2720 octants[idx].info[11] =
true;
2721 modified.push_back(idx);
2724 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2725 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2726 octants[neigh[i]].info[11] =
true;
2727 modified.push_back(neigh[i]);
2733 if((ghosts[neigh[i]].getLevel() + ghosts[neigh[i]].getMarker()) > (targetmarker + 1) ){
2734 octants[idx].setMarker(ghosts[neigh[i]].getLevel()+ghosts[neigh[i]].getMarker()-1-octants[idx].getLevel());
2735 octants[idx].info[11] =
true;
2736 modified.push_back(idx);
2750 obegin = ghosts.begin();
2751 oend = ghosts.end();
2753 for (it=obegin; it!=oend; it++){
2754 if (!it->getNotBalance() && it->getMarker() != 0){
2755 targetmarker = min(MAX_LEVEL_2D, (it->getLevel()+it->getMarker()));
2758 for (iface=0; iface<global2D.
nfaces; iface++){
2759 if(it->getPbound(iface) ==
true){
2761 findGhostNeighbours(idx, iface, neigh);
2762 sizeneigh = neigh.size();
2763 for(i=0; i<sizeneigh; i++){
2764 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2765 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2766 octants[neigh[i]].info[11] =
true;
2767 modified.push_back(neigh[i]);
2774 if (balance_codim>1){
2776 for (inode=0; inode<global2D.
nnodes; inode++){
2777 if(it->getPbound(global2D.
nodeface[inode][0]) ==
true || it->getPbound(global2D.
nodeface[inode][1]) ==
true){
2779 findGhostNodeNeighbours(idx, inode, neigh);
2780 sizeneigh = neigh.size();
2781 for(i=0; i<sizeneigh; i++){
2782 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2783 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2784 octants[neigh[i]].info[11] =
true;
2785 modified.push_back(neigh[i]);
2798 u32vector().swap(newmodified);
2799 modsize = modified.size();
2801 ibegin = modified.begin();
2802 iend = modified.end();
2803 for (iit=ibegin; iit!=iend; iit++){
2805 if (!octants[idx].getNotBalance()){
2806 targetmarker = min(MAX_LEVEL_2D, (octants[idx].getLevel()+octants[idx].getMarker()));
2809 for (iface=0; iface<global2D.
nfaces; iface++){
2810 if(!octants[idx].getPbound(iface)){
2811 findNeighbours(idx, iface, neigh, isghost);
2812 sizeneigh = neigh.size();
2813 for(i=0; i<sizeneigh; i++){
2816 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1)){
2817 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-octants[idx].getLevel()-1);
2818 octants[idx].info[11] =
true;
2819 newmodified.push_back(idx);
2822 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2823 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2824 octants[neigh[i]].info[11] =
true;
2825 newmodified.push_back(neigh[i]);
2834 if (balance_codim>1){
2836 for (inode=0; inode<global2D.
nnodes; inode++){
2837 if(!octants[idx].getPbound(global2D.
nodeface[inode][0]) || !octants[idx].getPbound(global2D.
nodeface[inode][1])){
2838 findNodeNeighbours(idx, inode, neigh, isghost);
2839 sizeneigh = neigh.size();
2840 for(i=0; i<sizeneigh; i++){
2843 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1)){
2844 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-octants[idx].getLevel()-1);
2845 octants[idx].info[11] =
true;
2846 newmodified.push_back(idx);
2849 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2850 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2851 octants[neigh[i]].info[11] =
true;
2852 newmodified.push_back(neigh[i]);
2864 preBalance21(newmodified);
2865 u32vector().swap(modified);
2866 swap(modified,newmodified);
2867 modsize = modified.size();
2868 u32vector().swap(newmodified);
2874 obegin = ghosts.begin();
2875 oend = ghosts.end();
2877 for (it=obegin; it!=oend; it++){
2879 if (!it->getNotBalance() && (it->info[11])){
2880 targetmarker = min(MAX_LEVEL_2D, (it->getLevel()+it->getMarker()));
2883 for (iface=0; iface<global2D.
nfaces; iface++){
2884 if(it->getPbound(iface) ==
true){
2886 findGhostNeighbours(idx, iface, neigh);
2887 sizeneigh = neigh.size();
2888 for(i=0; i<sizeneigh; i++){
2889 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2890 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2891 octants[neigh[i]].info[11] =
true;
2892 modified.push_back(neigh[i]);
2899 if (balance_codim>1){
2901 for (inode=0; inode<global2D.
nnodes; inode++){
2902 if(it->getPbound(global2D.
nodeface[inode][0]) ==
true || it->getPbound(global2D.
nodeface[inode][1]) ==
true){
2904 findGhostNodeNeighbours(idx, inode, neigh);
2905 sizeneigh = neigh.size();
2906 for(i=0; i<sizeneigh; i++){
2907 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2908 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2909 octants[neigh[i]].info[11] =
true;
2910 modified.push_back(neigh[i]);
2923 u32vector().swap(newmodified);
2924 modsize = modified.size();
2926 ibegin = modified.begin();
2927 iend = modified.end();
2928 for (iit=ibegin; iit!=iend; iit++){
2930 if (!octants[idx].getNotBalance()){
2931 targetmarker = min(MAX_LEVEL_2D, (octants[idx].getLevel()+octants[idx].getMarker()));
2934 for (iface=0; iface<global2D.
nfaces; iface++){
2935 if(!octants[idx].getPbound(iface)){
2936 findNeighbours(idx, iface, neigh, isghost);
2937 sizeneigh = neigh.size();
2938 for(i=0; i<sizeneigh; i++){
2941 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1)){
2942 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-octants[idx].getLevel()-1);
2943 octants[idx].info[11] =
true;
2944 newmodified.push_back(idx);
2947 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2948 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2949 octants[neigh[i]].info[11] =
true;
2950 newmodified.push_back(neigh[i]);
2959 if (balance_codim>1){
2961 for (inode=0; inode<global2D.
nnodes; inode++){
2962 if(!octants[idx].getPbound(global2D.
nodeface[inode][0]) || !octants[idx].getPbound(global2D.
nodeface[inode][1])){
2963 findNodeNeighbours(idx, inode, neigh, isghost);
2964 sizeneigh = neigh.size();
2965 for(i=0; i<sizeneigh; i++){
2968 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1)){
2969 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-octants[idx].getLevel()-1);
2970 octants[idx].info[11] =
true;
2971 newmodified.push_back(idx);
2974 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
2975 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
2976 octants[neigh[i]].info[11] =
true;
2977 newmodified.push_back(neigh[i]);
2989 preBalance21(newmodified);
2990 u32vector().swap(modified);
2991 swap(modified,newmodified);
2992 modsize = modified.size();
2993 u32vector().swap(newmodified);
2995 obegin = oend = octants.end();
2996 ibegin = iend = modified.end();
3004 bool localBalanceAll(
bool doInterior){
3008 uint32_t sizeneigh, modsize;
3010 u32vector modified, newmodified;
3012 uint8_t iface, inode;
3013 int8_t targetmarker;
3014 vector<bool> isghost;
3017 OctantsType::iterator obegin, oend, it;
3018 u32vector::iterator ibegin, iend, iit;
3023 obegin = octants.begin();
3024 oend = octants.end();
3026 for (it=obegin; it!=oend; it++){
3027 if ((!it->getNotBalance()) && ((it->info[11]) || (it->getMarker()!=0) || ((it->getIsNewC()) || (it->getIsNewR())))){
3028 targetmarker = min(MAX_LEVEL_2D,
int(octants[idx].getLevel()) +
int(octants[idx].getMarker()));
3031 for (iface=0; iface<global2D.
nfaces; iface++){
3032 if(!it->getBound(iface)){
3033 findNeighbours(idx, iface, neigh, isghost);
3034 sizeneigh = neigh.size();
3035 for(i=0; i<sizeneigh; i++){
3038 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1) ){
3039 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-1-octants[idx].getLevel());
3040 octants[idx].info[11] =
true;
3041 modified.push_back(idx);
3044 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3045 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3046 octants[neigh[i]].info[11] =
true;
3047 modified.push_back(neigh[i]);
3054 if((ghosts[neigh[i]].getLevel() + ghosts[neigh[i]].getMarker()) > (targetmarker + 1) ){
3055 octants[idx].setMarker(ghosts[neigh[i]].getLevel()+ghosts[neigh[i]].getMarker()-1-octants[idx].getLevel());
3056 octants[idx].info[11] =
true;
3057 modified.push_back(idx);
3067 if (balance_codim>1){
3069 for (inode=0; inode<global2D.
nnodes; inode++){
3070 if(!it->getBound(global2D.
nodeface[inode][0]) && !it->getBound(global2D.
nodeface[inode][1])){
3071 findNodeNeighbours(idx, inode, neigh, isghost);
3072 sizeneigh = neigh.size();
3073 for(i=0; i<sizeneigh; i++){
3076 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1) ){
3077 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-1-octants[idx].getLevel());
3078 octants[idx].info[11] =
true;
3079 modified.push_back(idx);
3082 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3083 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3084 octants[neigh[i]].info[11] =
true;
3085 modified.push_back(neigh[i]);
3091 if((ghosts[neigh[i]].getLevel() + ghosts[neigh[i]].getMarker()) > (targetmarker + 1) ){
3092 octants[idx].setMarker(ghosts[neigh[i]].getLevel()+ghosts[neigh[i]].getMarker()-1-octants[idx].getLevel());
3093 octants[idx].info[11] =
true;
3094 modified.push_back(idx);
3107 obegin = ghosts.begin();
3108 oend = ghosts.end();
3110 for (it=obegin; it!=oend; it++){
3111 if (!it->getNotBalance() && (it->info[11] || (it->getIsNewC() || it->getIsNewR()))){
3112 targetmarker = min(MAX_LEVEL_2D, (it->getLevel()+it->getMarker()));
3115 for (iface=0; iface<global2D.
nfaces; iface++){
3116 if(it->getPbound(iface) ==
true){
3118 findGhostNeighbours(idx, iface, neigh);
3119 sizeneigh = neigh.size();
3120 for(i=0; i<sizeneigh; i++){
3121 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3122 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3123 octants[neigh[i]].info[11] =
true;
3124 modified.push_back(neigh[i]);
3131 if (balance_codim>1){
3133 for (inode=0; inode<global2D.
nnodes; inode++){
3134 if(it->getPbound(global2D.
nodeface[inode][0]) ==
true || it->getPbound(global2D.
nodeface[inode][1]) ==
true){
3136 findGhostNodeNeighbours(idx, inode, neigh);
3137 sizeneigh = neigh.size();
3138 for(i=0; i<sizeneigh; i++){
3139 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3140 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3141 octants[neigh[i]].info[11] =
true;
3142 modified.push_back(neigh[i]);
3155 u32vector().swap(newmodified);
3156 modsize = modified.size();
3158 ibegin = modified.begin();
3159 iend = modified.end();
3160 for (iit=ibegin; iit!=iend; iit++){
3162 if (!octants[idx].getNotBalance()){
3163 targetmarker = min(MAX_LEVEL_2D, (octants[idx].getLevel()+octants[idx].getMarker()));
3166 for (iface=0; iface<global2D.
nfaces; iface++){
3167 if(!octants[idx].getPbound(iface)){
3168 findNeighbours(idx, iface, neigh, isghost);
3169 sizeneigh = neigh.size();
3170 for(i=0; i<sizeneigh; i++){
3173 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1)){
3174 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-octants[idx].getLevel()-1);
3175 octants[idx].info[11] =
true;
3176 newmodified.push_back(idx);
3179 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3180 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3181 octants[neigh[i]].info[11] =
true;
3182 newmodified.push_back(neigh[i]);
3191 if (balance_codim>1){
3193 for (inode=0; inode<global2D.
nnodes; inode++){
3194 if(!octants[idx].getPbound(global2D.
nodeface[inode][0]) || !octants[idx].getPbound(global2D.
nodeface[inode][1])){
3195 findNodeNeighbours(idx, inode, neigh, isghost);
3196 sizeneigh = neigh.size();
3197 for(i=0; i<sizeneigh; i++){
3200 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1)){
3201 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-octants[idx].getLevel()-1);
3202 octants[idx].info[11] =
true;
3203 newmodified.push_back(idx);
3206 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3207 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3208 octants[neigh[i]].info[11] =
true;
3209 newmodified.push_back(neigh[i]);
3221 preBalance21(newmodified);
3222 u32vector().swap(modified);
3223 swap(modified,newmodified);
3224 modsize = modified.size();
3225 u32vector().swap(newmodified);
3232 obegin = ghosts.begin();
3233 oend = ghosts.end();
3235 for (it=obegin; it!=oend; it++){
3236 if (!it->getNotBalance() && (it->info[11] || (it->getIsNewC() || it->getIsNewR()))){
3237 targetmarker = min(MAX_LEVEL_2D, (it->getLevel()+it->getMarker()));
3240 for (iface=0; iface<global2D.
nfaces; iface++){
3241 if(it->getPbound(iface) ==
true){
3243 findGhostNeighbours(idx, iface, neigh);
3244 sizeneigh = neigh.size();
3245 for(i=0; i<sizeneigh; i++){
3246 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3247 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3248 octants[neigh[i]].info[11] =
true;
3249 modified.push_back(neigh[i]);
3256 if (balance_codim>1){
3258 for (inode=0; inode<global2D.
nnodes; inode++){
3259 if(it->getPbound(global2D.
nodeface[inode][0]) ==
true || it->getPbound(global2D.
nodeface[inode][0]) ==
true){
3261 findGhostNodeNeighbours(idx, inode, neigh);
3262 sizeneigh = neigh.size();
3263 for(i=0; i<sizeneigh; i++){
3264 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3265 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3266 octants[neigh[i]].info[11] =
true;
3267 modified.push_back(neigh[i]);
3280 u32vector().swap(newmodified);
3281 modsize = modified.size();
3283 ibegin = modified.begin();
3284 iend = modified.end();
3285 for (iit=ibegin; iit!=iend; iit++){
3287 if (!octants[idx].getNotBalance()){
3288 targetmarker = min(MAX_LEVEL_2D, (octants[idx].getLevel()+octants[idx].getMarker()));
3291 for (iface=0; iface<global2D.
nfaces; iface++){
3292 if(!octants[idx].getPbound(iface)){
3293 findNeighbours(idx, iface, neigh, isghost);
3294 sizeneigh = neigh.size();
3295 for(i=0; i<sizeneigh; i++){
3298 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1)){
3299 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-octants[idx].getLevel()-1);
3300 octants[idx].info[11] =
true;
3301 newmodified.push_back(idx);
3304 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3305 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3306 octants[neigh[i]].info[11] =
true;
3307 newmodified.push_back(neigh[i]);
3316 if (balance_codim>1){
3318 for (inode=0; inode<global2D.
nnodes; inode++){
3319 if(!octants[idx].getPbound(global2D.
nodeface[inode][0]) || !octants[idx].getPbound(global2D.
nodeface[inode][1])){
3320 findNodeNeighbours(idx, inode, neigh, isghost);
3321 sizeneigh = neigh.size();
3322 for(i=0; i<sizeneigh; i++){
3325 if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) > (targetmarker + 1)){
3326 octants[idx].setMarker(octants[neigh[i]].getLevel()+octants[neigh[i]].getMarker()-octants[idx].getLevel()-1);
3327 octants[idx].info[11] =
true;
3328 newmodified.push_back(idx);
3331 else if((octants[neigh[i]].getLevel() + octants[neigh[i]].getMarker()) < (targetmarker - 1)){
3332 octants[neigh[i]].setMarker(targetmarker-octants[neigh[i]].getLevel()-1);
3333 octants[neigh[i]].info[11] =
true;
3334 newmodified.push_back(neigh[i]);
3346 preBalance21(newmodified);
3347 u32vector().swap(modified);
3348 swap(modified,newmodified);
3349 modsize = modified.size();
3350 u32vector().swap(newmodified);
3352 obegin = oend = octants.end();
3353 ibegin = iend = modified.end();
3361 void findNodeNeighbours(uint32_t idx,
3363 u32vector & neighbours,
3364 vector<bool> & isghost){
3366 uint64_t Morton, Mortontry;
3367 uint32_t noctants = getNumOctants();
3370 uint32_t size = oct->
getSize();
3371 uint8_t iface1, iface2;
3373 int32_t Dhxref, Dhyref;
3376 int8_t Cx[4] = {-1,1,-1,1};
3377 int8_t Cy[4] = {-1,-1,1,1};
3378 int8_t cx = Cx[inode];
3379 int8_t cy = Cy[inode];
3385 if (inode < 0 || inode > global2D.
nnodes){
3390 iface1 = global2D.
nodeface[inode][0];
3391 iface2 = global2D.
nodeface[inode][1];
3394 if (oct->info[iface1] ==
false && oct->info[iface2] ==
false){
3397 Class_Octant<2> samesizeoct(oct->level, int32_t(oct->x)+int32_t(cx)*int32_t(size), int32_t(oct->y)+int32_t(cy)*int32_t(size));
3402 if (ghosts.size()>0){
3405 uint32_t idxghost = uint32_t(size_ghosts/2);
3412 if (inode==3 || inode ==0){
3413 jump = (octghost->
computeMorton() > Morton) ? int32_t(idxghost/2+1) : int32_t((size_ghosts -idxghost)/2+1);
3415 if (idxtry > size_ghosts-1)
3416 idxtry = size_ghosts-1;
3420 idxtry = uint32_t(jump);
3422 while(abs(jump) > 0){
3423 Mortontry = ghosts[idxtry].computeMorton();
3424 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
3426 if (idxtry > ghosts.size()-1){
3428 idxtry = ghosts.size() - 1;
3437 if(ghosts[idxtry].computeMorton() == Morton && ghosts[idxtry].level == oct->level){
3439 isghost.push_back(
true);
3440 neighbours.push_back(idxtry);
3446 while(ghosts[idxtry].computeMorton() < Morton){
3448 if(idxtry > ghosts.size()-1){
3449 idxtry = ghosts.size()-1;
3453 while(ghosts[idxtry].computeMorton() > Morton){
3455 if(idxtry > ghosts.size()-1){
3461 if(idxtry < size_ghosts){
3462 if(ghosts[idxtry].computeMorton() == Morton && ghosts[idxtry].level == oct->level){
3464 isghost.push_back(
true);
3465 neighbours.push_back(idxtry);
3471 Mortontry = ghosts[idxtry].computeMorton();
3472 while(Mortontry < Mortonlast && idxtry < size_ghosts){
3473 Dhx = (-int32_t(oct->x) + int32_t(ghosts[idxtry].x));
3474 Dhy = (-int32_t(oct->y) + int32_t(ghosts[idxtry].y));
3475 Dhxref = int32_t(cx<0)*(-int32_t(ghosts[idxtry].getSize())) + int32_t(cx>0)*size;
3476 Dhyref = int32_t(cy<0)*(-int32_t(ghosts[idxtry].getSize())) + int32_t(cy>0)*size;
3477 if ((Dhx == Dhxref) && (Dhy == Dhyref)){
3478 neighbours.push_back(idxtry);
3479 isghost.push_back(
true);
3483 if(idxtry>size_ghosts-1){
3486 Mortontry = ghosts[idxtry].computeMorton();
3498 if (inode==0 || inode==3){
3499 jump = (oct->
computeMorton() > Morton) ? int32_t(idx/2+1) : int32_t((noctants -idx)/2+1);
3501 if (idxtry > noctants-1)
3502 idxtry = noctants-1;
3508 while(abs(jump) > 0){
3509 Mortontry = octants[idxtry].computeMorton();
3510 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
3512 if (idxtry > octants.size()-1){
3514 idxtry = octants.size() - 1;
3523 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
3525 isghost.push_back(
false);
3526 neighbours.push_back(idxtry);
3532 while(octants[idxtry].computeMorton() < Morton){
3534 if(idxtry > noctants-1){
3535 idxtry = noctants-1;
3539 while(octants[idxtry].computeMorton() > Morton){
3541 if(idxtry > noctants-1){
3547 if (idxtry < noctants){
3548 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
3550 isghost.push_back(
false);
3551 neighbours.push_back(idxtry);
3557 Mortontry = octants[idxtry].computeMorton();
3558 while(Mortontry < Mortonlast && idxtry <= noctants-1){
3559 Dhx = (-int32_t(oct->x) + int32_t(octants[idxtry].x));
3560 Dhy = (-int32_t(oct->y) + int32_t(octants[idxtry].y));
3561 Dhxref = int32_t(cx<0)*(-int32_t(octants[idxtry].getSize())) + int32_t(cx>0)*size;
3562 Dhyref = int32_t(cy<0)*(-int32_t(octants[idxtry].getSize())) + int32_t(cy>0)*size;
3563 if ((Dhx == Dhxref) && (Dhy == Dhyref)){
3564 neighbours.push_back(idxtry);
3565 isghost.push_back(
false);
3569 if(idxtry>noctants-1){
3572 Mortontry = octants[idxtry].computeMorton();
3589 u32vector & neighbours,
3590 vector<bool> & isghost){
3592 uint64_t Morton, Mortontry;
3593 uint32_t noctants = getNumOctants();
3595 uint32_t size = oct->
getSize();
3596 uint8_t iface1, iface2;
3598 int32_t Dhxref, Dhyref;
3601 int8_t Cx[4] = {-1,1,-1,1};
3602 int8_t Cy[4] = {-1,-1,1,1};
3603 int8_t cx = Cx[inode];
3604 int8_t cy = Cy[inode];
3610 if (inode < 0 || inode > global2D.
nnodes){
3615 iface1 = global2D.
nodeface[inode][0];
3616 iface2 = global2D.
nodeface[inode][1];
3619 if (oct->info[iface1] ==
false && oct->info[iface2] ==
false){
3622 Class_Octant<2> samesizeoct(oct->level, int32_t(oct->x)+int32_t(cx)*int32_t(size), int32_t(oct->y)+int32_t(cy)*int32_t(size));
3627 if (ghosts.size()>0){
3630 uint32_t idxghost = uint32_t(size_ghosts/2);
3636 int32_t jump = (octghost->
computeMorton() > Morton) ? int32_t(idxghost/2+1) : int32_t((size_ghosts -idxghost)/2+1);
3638 if (idxtry > size_ghosts-1)
3639 idxtry = size_ghosts-1;
3640 while(abs(jump) > 0){
3641 Mortontry = ghosts[idxtry].computeMorton();
3642 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
3644 if (idxtry > ghosts.size()-1){
3646 idxtry = ghosts.size() - 1;
3655 if(ghosts[idxtry].computeMorton() == Morton && ghosts[idxtry].level == oct->level){
3657 isghost.push_back(
true);
3658 neighbours.push_back(idxtry);
3664 while(ghosts[idxtry].computeMorton() < Morton){
3666 if(idxtry > ghosts.size()-1){
3667 idxtry = ghosts.size()-1;
3671 while(ghosts[idxtry].computeMorton() > Morton){
3673 if(idxtry > ghosts.size()-1){
3679 if(idxtry < size_ghosts){
3680 if(ghosts[idxtry].computeMorton() == Morton && ghosts[idxtry].level == oct->level){
3682 isghost.push_back(
true);
3683 neighbours.push_back(idxtry);
3689 Mortontry = ghosts[idxtry].computeMorton();
3690 while(Mortontry < Mortonlast && idxtry < size_ghosts){
3691 Dhx = (-int32_t(oct->x) + int32_t(ghosts[idxtry].x));
3692 Dhy = (-int32_t(oct->y) + int32_t(ghosts[idxtry].y));
3693 Dhxref = int32_t(cx<0)*(-int32_t(ghosts[idxtry].getSize())) + int32_t(cx>0)*size;
3694 Dhyref = int32_t(cy<0)*(-int32_t(ghosts[idxtry].getSize())) + int32_t(cy>0)*size;
3695 if ((Dhx == Dhxref) && (Dhy == Dhyref)){
3696 neighbours.push_back(idxtry);
3697 isghost.push_back(
true);
3701 if(idxtry>size_ghosts-1){
3704 Mortontry = ghosts[idxtry].computeMorton();
3716 int32_t jump = int32_t((noctants)/2+1);
3717 idxtry = uint32_t(jump);
3718 if (idxtry > noctants-1)
3719 idxtry = noctants-1;
3720 while(abs(jump) > 0){
3721 Mortontry = octants[idxtry].computeMorton();
3722 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
3724 if (idxtry > octants.size()-1){
3726 idxtry = octants.size() - 1;
3735 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
3737 isghost.push_back(
false);
3738 neighbours.push_back(idxtry);
3744 while(octants[idxtry].computeMorton() < Morton){
3746 if(idxtry > noctants-1){
3747 idxtry = noctants-1;
3751 while(octants[idxtry].computeMorton() > Morton){
3753 if(idxtry > noctants-1){
3759 if (idxtry < noctants){
3760 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
3762 isghost.push_back(
false);
3763 neighbours.push_back(idxtry);
3769 Mortontry = octants[idxtry].computeMorton();
3770 while(Mortontry < Mortonlast && idxtry <= noctants-1){
3771 Dhx = (-int32_t(oct->x) + int32_t(octants[idxtry].x));
3772 Dhy = (-int32_t(oct->y) + int32_t(octants[idxtry].y));
3773 Dhxref = int32_t(cx<0)*(-int32_t(octants[idxtry].getSize())) + int32_t(cx>0)*size;
3774 Dhyref = int32_t(cy<0)*(-int32_t(octants[idxtry].getSize())) + int32_t(cy>0)*size;
3775 if ((Dhx == Dhxref) && (Dhy == Dhyref)){
3776 neighbours.push_back(idxtry);
3777 isghost.push_back(
false);
3781 Mortontry = octants[idxtry].computeMorton();
3796 void findGhostNodeNeighbours(uint32_t
const idx,
3798 u32vector & neighbours){
3800 uint64_t Morton, Mortontry;
3801 uint32_t noctants = getNumOctants();
3804 uint32_t size = oct->
getSize();
3805 uint8_t iface1, iface2;
3807 int32_t Dhxref, Dhyref;
3810 int8_t Cx[4] = {-1,1,-1,1};
3811 int8_t Cy[4] = {-1,-1,1,1};
3812 int8_t cx = Cx[inode];
3813 int8_t cy = Cy[inode];
3818 if (inode < 0 || inode > global2D.
nnodes){
3823 iface1 = global2D.
nodeface[inode][0];
3824 iface2 = global2D.
nodeface[inode][1];
3829 if (oct->info[iface1+global2D.
nfaces] ==
true || oct->info[iface2+global2D.
nfaces] ==
true){
3832 Class_Octant<2> samesizeoct(oct->level, int32_t(oct->x)+int32_t(cx)*int32_t(size), int32_t(oct->y)+int32_t(cy)*int32_t(size));
3840 int32_t jump = getNumOctants()/2;
3841 idxtry = uint32_t(getNumOctants()/2);
3842 while(abs(jump) > 0){
3843 Mortontry = octants[idxtry].computeMorton();
3844 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
3846 if (idxtry > octants.size()-1){
3848 idxtry = octants.size() - 1;
3857 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
3859 neighbours.push_back(idxtry);
3865 while(octants[idxtry].computeMorton() < Morton){
3867 if(idxtry > noctants-1){
3868 idxtry = noctants-1;
3872 while(octants[idxtry].computeMorton() > Morton){
3874 if(idxtry > noctants-1){
3880 if (idxtry < noctants){
3881 if(octants[idxtry].computeMorton() == Morton && octants[idxtry].level == oct->level){
3883 neighbours.push_back(idxtry);
3889 Mortontry = octants[idxtry].computeMorton();
3890 while(Mortontry < Mortonlast && idxtry <= noctants-1){
3891 Dhx = (-int32_t(oct->x) + int32_t(octants[idxtry].x));
3892 Dhy = (-int32_t(oct->y) + int32_t(octants[idxtry].y));
3893 Dhxref = int32_t(cx<0)*(-int32_t(octants[idxtry].getSize())) + int32_t(cx>0)*size;
3894 Dhyref = int32_t(cy<0)*(-int32_t(octants[idxtry].getSize())) + int32_t(cy>0)*size;
3895 if ((Dhx == Dhxref) && (Dhy == Dhyref)){
3896 neighbours.push_back(idxtry);
3899 if(idxtry>noctants-1){
3902 Mortontry = octants[idxtry].computeMorton();
3917 void computeIntersections() {
3919 OctantsType::iterator it, obegin, oend;
3921 u32vector neighbours;
3922 vector<bool> isghost;
3923 uint32_t counter, idx;
3925 uint8_t iface, iface2;
3928 intersections.clear();
3929 intersections.reserve(2*2*octants.size());
3933 obegin = ghosts.begin();
3934 oend = ghosts.end();
3935 for (it = obegin; it != oend; it++){
3936 for (iface = 0; iface < 2; iface++){
3938 findGhostNeighbours(idx, iface2, neighbours);
3939 nsize = neighbours.size();
3940 for (i = 0; i < nsize; i++){
3941 intersection.finer = getGhostLevel(idx) >= getLevel((
int)neighbours[i]);
3942 intersection.owners[0] = neighbours[i];
3943 intersection.owners[1] = idx;
3944 intersection.iface = global2D.
oppface[iface2] - (getGhostLevel(idx) >= getLevel((
int)neighbours[i]));
3945 intersection.isnew =
false;
3946 intersection.isghost =
true;
3947 intersection.bound =
false;
3948 intersection.pbound =
true;
3949 intersections.push_back(intersection);
3957 obegin = octants.begin();
3958 oend = octants.end();
3959 for (it = obegin; it != oend; it++){
3960 for (iface = 0; iface < 2; iface++){
3962 findNeighbours(idx, iface2, neighbours, isghost);
3963 nsize = neighbours.size();
3965 for (i = 0; i < nsize; i++){
3967 intersection.owners[0] = idx;
3968 intersection.owners[1] = neighbours[i];
3969 intersection.finer = (nsize>1);
3970 intersection.iface = iface2 + (nsize>1);
3971 intersection.isnew =
false;
3972 intersection.isghost =
true;
3973 intersection.bound =
false;
3974 intersection.pbound =
true;
3975 intersections.push_back(intersection);
3979 intersection.owners[0] = idx;
3980 intersection.owners[1] = neighbours[i];
3981 intersection.finer = (nsize>1);
3982 intersection.iface = iface2 + (nsize>1);
3983 intersection.isnew =
false;
3984 intersection.isghost =
false;
3985 intersection.bound =
false;
3986 intersection.pbound =
false;
3987 intersections.push_back(intersection);
3993 intersection.owners[0] = idx;
3994 intersection.owners[1] = idx;
3995 intersection.finer = 0;
3996 intersection.iface = iface2;
3997 intersection.isnew =
false;
3998 intersection.isghost =
false;
3999 intersection.bound =
true;
4000 intersection.pbound =
false;
4001 intersections.push_back(intersection);
4004 if (it->info[iface2+1]){
4005 intersection.owners[0] = idx;
4006 intersection.owners[1] = idx;
4007 intersection.finer = 0;
4008 intersection.iface = iface2+1;
4009 intersection.isnew =
false;
4010 intersection.isghost =
false;
4011 intersection.bound =
true;
4012 intersection.pbound =
false;
4013 intersections.push_back(intersection);
4019 #if defined(__INTEL_COMPILER) || defined(__ICC)
4021 intersections.shrink_to_fit();
4027 uint32_t findMorton(uint64_t Morton){
4028 uint32_t nocts = octants.size();
4029 uint32_t idx = nocts/2;
4030 uint64_t Mortontry = octants[idx].computeMorton();
4031 int32_t jump = nocts/2;
4033 if (Mortontry == Morton){
4036 Mortontry = octants[idx].computeMorton();
4037 jump = ((Mortontry<Morton)-(Mortontry>Morton))*abs(jump)/2;
4043 if (Mortontry<Morton){
4044 for (uint32_t idx2=idx; idx2<nocts; idx2++){
4045 Mortontry = octants[idx2].computeMorton();
4046 if (Mortontry == Morton){
4052 for(uint32_t idx2=0; idx2<idx+1; idx2++){
4053 Mortontry = octants[idx2].computeMorton();
4054 if (Mortontry == Morton){
4064 uint32_t findGhostMorton(uint64_t Morton){
4065 uint32_t nocts = ghosts.size();
4066 uint32_t idx = nocts/2;
4067 uint64_t Mortontry = ghosts[idx].computeMorton();
4068 int32_t jump = nocts/2;
4070 if (Mortontry == Morton){
4073 Mortontry = ghosts[idx].computeMorton();
4074 jump = (Mortontry<Morton)*jump/4;
4080 if (Mortontry<Morton){
4081 for (uint32_t idx2=idx; idx2<nocts; idx2++){
4082 Mortontry = ghosts[idx2].computeMorton();
4083 if (Mortontry == Morton){
4089 for(uint32_t idx2=0; idx2<idx; idx2++){
4090 Mortontry = ghosts[idx2].computeMorton();
4091 if (Mortontry == Morton){
4103 void computeConnectivity() {
4104 map<uint64_t, vector<uint32_t> > mapnodes;
4105 map<uint64_t, vector<uint32_t> >::iterator iter, iterend;
4106 uint32_t i, k, counter;
4108 uint32_t noctants = getNumOctants();
4109 u32vector2D octnodes;
4112 clearConnectivity();
4114 octnodes.reserve(global2D.
nnodes);
4115 if (nodes.size() == 0){
4116 connectivity.resize(noctants);
4117 for (i = 0; i < noctants; i++){
4118 octants[i].getNodes(octnodes);
4119 for (j = 0; j < global2D.
nnodes; j++){
4121 morton = keyXY(octnodes[j][0], octnodes[j][1]);
4122 if (mapnodes[morton].size()==0){
4123 mapnodes[morton].reserve(8);
4124 for (k = 0; k < 3; k++){
4125 mapnodes[morton].push_back(octnodes[j][k]);
4128 mapnodes[morton].push_back(i);
4130 u32vector2D().swap(octnodes);
4132 iter = mapnodes.begin();
4133 iterend = mapnodes.end();
4135 uint32_t numnodes = mapnodes.size();
4136 nodes.resize(numnodes);
4137 while (iter != iterend){
4138 vector<uint32_t> nodecasting(iter->second.begin(), iter->second.begin()+3);
4139 nodes[counter] = nodecasting;
4140 #if defined(__INTEL_COMPILER) || defined(__ICC)
4142 nodes[counter].shrink_to_fit();
4144 for(vector<uint32_t>::iterator iter2 = iter->second.begin()+3; iter2 != iter->second.end(); iter2++){
4145 if (connectivity[
int(*iter2)].size()==0){
4146 connectivity[int(*iter2)].reserve(4);
4148 connectivity[int(*iter2)].push_back(counter);
4150 mapnodes.erase(iter++);
4153 #if defined(__INTEL_COMPILER) || defined(__ICC)
4155 nodes.shrink_to_fit();
4158 for (uint32_t ii=0; ii<noctants; ii++){
4159 #if defined(__INTEL_COMPILER) || defined(__ICC)
4161 connectivity[ii].shrink_to_fit();
4170 #if defined(__INTEL_COMPILER) || defined(__ICC)
4172 connectivity.shrink_to_fit();
4175 map<uint64_t, vector<uint32_t> >().swap(mapnodes);
4176 iter = mapnodes.end();
4183 void clearConnectivity() {
4184 u32vector2D().swap(nodes);
4185 u32vector2D().swap(connectivity);
4192 void updateConnectivity() {
4193 clearConnectivity();
4194 computeConnectivity();
4201 void computeghostsConnectivity() {
4202 map<uint64_t, vector<uint32_t> > mapnodes;
4203 map<uint64_t, vector<uint32_t> >::iterator iter, iterend;
4204 uint32_t i, k, counter;
4206 uint32_t noctants = size_ghosts;
4207 u32vector2D octnodes;
4210 octnodes.reserve(global2D.
nnodes);
4212 if (ghostsnodes.size() == 0){
4213 ghostsconnectivity.resize(noctants);
4214 for (i = 0; i < noctants; i++){
4215 ghosts[i].getNodes(octnodes);
4216 for (j = 0; j < global2D.
nnodes; j++){
4218 morton = keyXY(octnodes[j][0], octnodes[j][1]);
4219 if (mapnodes[morton].size()==0){
4220 for (k = 0; k < 3; k++){
4221 mapnodes[morton].push_back(octnodes[j][k]);
4224 mapnodes[morton].push_back(i);
4226 u32vector2D().swap(octnodes);
4228 iter = mapnodes.begin();
4229 iterend = mapnodes.end();
4230 uint32_t numnodes = mapnodes.size();
4231 ghostsnodes.resize(numnodes);
4233 while (iter != iterend){
4234 vector<uint32_t> nodecasting(iter->second.begin(), iter->second.begin()+3);
4235 ghostsnodes[counter] = nodecasting;
4236 #if defined(__INTEL_COMPILER) || defined(__ICC)
4238 ghostsnodes[counter].shrink_to_fit();
4240 for(vector<uint32_t>::iterator iter2 = iter->second.begin()+3; iter2 != iter->second.end(); iter2++){
4241 if (ghostsconnectivity[
int(*iter2)].size()==0){
4242 ghostsconnectivity[int(*iter2)].reserve(4);
4244 ghostsconnectivity[int(*iter2)].push_back(counter);
4246 mapnodes.erase(iter++);
4249 #if defined(__INTEL_COMPILER) || defined(__ICC)
4251 ghostsnodes.shrink_to_fit();
4254 for (uint32_t ii=0; ii<noctants; ii++){
4255 #if defined(__INTEL_COMPILER) || defined(__ICC)
4257 ghostsconnectivity[ii].shrink_to_fit();
4266 #if defined(__INTEL_COMPILER) || defined(__ICC)
4268 ghostsconnectivity.shrink_to_fit();
4271 iter = mapnodes.end();
4278 void clearghostsConnectivity() {
4279 u32vector2D().swap(ghostsnodes);
4280 u32vector2D().swap(ghostsconnectivity);
4287 void updateghostsConnectivity() {
4288 clearghostsConnectivity();
4289 computeghostsConnectivity();
Parallel Octree Manager Class.
Octant class definition - 2D specialization.
uint64_t computeMorton() const
void setMarker(int8_t marker)
Intersection class definition - 2D specialization.
Local octree portion for each process.