41 typedef vector<Class_Octant<3> > OctantsType;
42 typedef vector<double> dvector;
43 typedef vector<uint32_t> u32vector;
44 typedef vector<vector<uint32_t> > u32vector2D;
45 typedef vector<vector<uint64_t> > u64vector2D;
71 for (
int i=0; i<global3D.
nfaces; i++){
76 Class_Octant(int8_t level, int32_t x, int32_t y, int32_t z){
83 for (
int i=0; i<global3D.
nfaces; i++){
90 Class_Octant(int8_t level, int32_t x, int32_t y, int32_t z,
bool bound){
97 for (
int i=0; i<global3D.
nfaces; i++){
109 level = octant.level;
110 marker = octant.marker;
118 check = check && (x == oct2.x);
119 check = check && (y == oct2.y);
120 check = check && (z == oct2.z);
121 check = check && (level == oct2.level);
134 uint32_t
getX()
const{
return x;};
139 uint32_t
getY()
const{
return y;};
144 uint32_t
getZ()
const{
return z;};
165 void setBound(uint8_t face) {
175 return info[global3D.
nfaces+face];
202 this->marker = marker;
213 void setLevel(uint8_t level){
217 void setPbound(uint8_t face,
bool flag){
218 info[global3D.
nfaces+face] = flag;
229 uint32_t size = uint32_t(pow(
double(2),
double(MAX_LEVEL_3D-level)));
237 uint64_t area = uint64_t(pow(
double(getSize()),2.0));
245 uint64_t volume = uint64_t(pow(
double(getSize()),3.0));
257 dh = double(getSize())/2.0;
258 vector<double> center(3);
260 center[0] = (double)x + dh;
261 center[1] = (double)y + dh;
262 center[2] = (double)z + dh;
274 int A[6][3] = { {0,1,1} , {2,1,1} , {1,0,1} , {1,2,1} , {1,1,0} , {1,1,2} };
276 dh_2 = double(getSize())/2.0;
277 vector<double> center(3);
279 if (iface < global3D.
nfaces){
280 center[0] = (double)x + (
double)A[iface][0] * dh_2;
281 center[1] = (double)y + (
double)A[iface][1] * dh_2;
282 center[2] = (double)z + (
double)A[iface][2] * dh_2;
295 int A[12][3] = { {0,1,0},{2,1,0},{1,0,0},{1,2,0},{0,0,1},{2,0,1},{0,2,1},{2,2,1},{0,1,2},{2,1,2},{1,0,2},{1,2,2} };
297 dh_2 = double(getSize())/2.0;
298 vector<double> center(3);
300 if (iedge < global3D.
nedges){
301 center[0] = (double)x + (
double)A[iedge][0] * dh_2;
302 center[1] = (double)y + (
double)A[iedge][1] * dh_2;
303 center[2] = (double)z + (
double)A[iedge][2] * dh_2;
314 uint8_t i, cx, cy, cz;
319 nodes.resize(global3D.
nnodes);
321 for (i = 0; i < global3D.
nnodes; i++){
324 cy = uint8_t((i-4*(i/4))/2);
326 nodes[i][0] = x + cx*dh;
327 nodes[i][1] = y + cy*dh;
328 nodes[i][2] = z + cz*dh;
329 #if defined(__INTEL_COMPILER) || defined(__ICC)
331 nodes[i].shrink_to_fit();
334 #if defined(__INTEL_COMPILER) || defined(__ICC)
336 nodes.shrink_to_fit();
344 void getNode(u32vector & node, uint8_t inode){
352 cy = (inode-4*(inode/4))/2;
373 cy = (inode-4*(inode/4))/2;
388 vector<int8_t> & normal){
393 for (i = 0; i < 3; i++){
394 normal[i] = global3D.
normals[iface][i];
396 #if defined(__INTEL_COMPILER) || defined(__ICC)
398 normal.shrink_to_fit();
408 morton = mortonEncode_magicbits(this->x,this->y,this->z);
419 morton = mortonEncode_magicbits(this->x,this->y,this->z);
429 uint32_t delta = (uint32_t)pow(2.0,(
double)((uint8_t)MAX_LEVEL_3D - level)) - 1;
437 uint32_t deltax = x%(uint32_t(pow(2.0,(
double)((uint8_t)MAX_LEVEL_3D - (level-1)))));
438 uint32_t deltay = y%(uint32_t(pow(2.0,(
double)((uint8_t)MAX_LEVEL_3D - (level-1)))));
439 uint32_t deltaz = z%(uint32_t(pow(2.0,(
double)((uint8_t)MAX_LEVEL_3D - (level-1)))));
451 vector< Class_Octant<3> > buildChildren(){
454 if (this->level < MAX_LEVEL_3D){
455 vector< Class_Octant<3> > children(global3D.
nchildren);
456 for (
int i=0; i<global3D.
nchildren; i++){
461 oct.setMarker(max(0,oct.marker-1));
462 oct.setLevel(oct.level+1);
466 oct.info[xf] = oct.info[xf+global3D.
nfaces] =
false;
467 oct.info[yf] = oct.info[yf+global3D.
nfaces] =
false;
468 oct.info[zf] = oct.info[zf+global3D.
nfaces] =
false;
475 oct.setMarker(max(0,oct.marker-1));
476 oct.setLevel(oct.level+1);
478 uint32_t dh = oct.getSize();
482 oct.info[xf] = oct.info[xf+global3D.
nfaces] =
false;
483 oct.info[yf] = oct.info[yf+global3D.
nfaces] =
false;
484 oct.info[zf] = oct.info[zf+global3D.
nfaces] =
false;
491 oct.setMarker(max(0,oct.marker-1));
492 oct.setLevel(oct.level+1);
494 uint32_t dh = oct.getSize();
498 oct.info[xf] = oct.info[xf+global3D.
nfaces] =
false;
499 oct.info[yf] = oct.info[yf+global3D.
nfaces] =
false;
500 oct.info[zf] = oct.info[zf+global3D.
nfaces] =
false;
507 oct.setMarker(max(0,oct.marker-1));
508 oct.setLevel(oct.level+1);
510 uint32_t dh = oct.getSize();
515 oct.info[xf] = oct.info[xf+global3D.
nfaces] =
false;
516 oct.info[yf] = oct.info[yf+global3D.
nfaces] =
false;
517 oct.info[zf] = oct.info[zf+global3D.
nfaces] =
false;
524 oct.setMarker(max(0,oct.marker-1));
525 oct.setLevel(oct.level+1);
527 uint32_t dh = oct.getSize();
531 oct.info[xf] = oct.info[xf+global3D.
nfaces] =
false;
532 oct.info[yf] = oct.info[yf+global3D.
nfaces] =
false;
533 oct.info[zf] = oct.info[zf+global3D.
nfaces] =
false;
540 oct.setMarker(max(0,oct.marker-1));
541 oct.setLevel(oct.level+1);
543 uint32_t dh = oct.getSize();
548 oct.info[xf] = oct.info[xf+global3D.
nfaces] =
false;
549 oct.info[yf] = oct.info[yf+global3D.
nfaces] =
false;
550 oct.info[zf] = oct.info[zf+global3D.
nfaces] =
false;
557 oct.setMarker(max(0,oct.marker-1));
558 oct.setLevel(oct.level+1);
560 uint32_t dh = oct.getSize();
565 oct.info[xf] = oct.info[xf+global3D.
nfaces] =
false;
566 oct.info[yf] = oct.info[yf+global3D.
nfaces] =
false;
567 oct.info[zf] = oct.info[zf+global3D.
nfaces] =
false;
574 oct.setMarker(max(0,oct.marker-1));
575 oct.setLevel(oct.level+1);
577 uint32_t dh = oct.getSize();
583 oct.info[xf] = oct.info[xf+global3D.
nfaces] =
false;
584 oct.info[yf] = oct.info[yf+global3D.
nfaces] =
false;
585 oct.info[zf] = oct.info[zf+global3D.
nfaces] =
false;
594 vector< Class_Octant<3> > children(0);
602 vector<uint64_t> computeHalfSizeMorton(uint8_t iface,
608 nneigh = (level < MAX_LEVEL_3D) ? global3D.
nchildren/2 : 1;
609 dh = (level < MAX_LEVEL_3D) ? getSize()/2 : getSize();
614 vector<uint64_t> Morton(0);
618 vector<uint64_t> Morton(nneigh);
622 for (i=0; i<nneigh; i++){
625 Morton[i] = mortonEncode_magicbits(this->x-dh,this->y+dh*cy,this->z+dh*cz);
631 for (i=0; i<nneigh; i++){
634 Morton[i] = mortonEncode_magicbits(this->x+dh2,this->y+dh*cy,this->z+dh*cz);
640 for (i=0; i<nneigh; i++){
643 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y-dh,this->z+dh*cz);
649 for (i=0; i<nneigh; i++){
652 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2,this->z+dh*cz);
658 for (i=0; i<nneigh; i++){
661 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z-dh);
667 for (i=0; i<nneigh; i++){
670 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh2);
684 vector<uint64_t> computeMinSizeMorton(uint8_t iface,
685 const uint8_t & maxdepth,
688 uint32_t nneigh, nline;
691 nneigh = (level < MAX_LEVEL_3D) ? uint32_t(pow(2.0,
double(2*(maxdepth-level)))) : 1;
692 dh = (level < MAX_LEVEL_3D) ? uint32_t(pow(2.0,
double(MAX_LEVEL_3D - maxdepth))) : getSize();
694 nline = uint32_t(pow(2.0,
double((maxdepth-level))));
700 vector<uint64_t> Morton(0);
704 vector<uint64_t> Morton(nneigh);
708 for (i=0; i<nneigh; i++){
711 Morton[i] = mortonEncode_magicbits(this->x-dh,this->y+dh*cy,this->z+dh*cz);
717 for (i=0; i<nneigh; i++){
720 Morton[i] = mortonEncode_magicbits(this->x+dh2,this->y+dh*cy,this->z+dh*cz);
726 for (i=0; i<nneigh; i++){
729 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y-dh,this->z+dh*cz);
735 for (i=0; i<nneigh; i++){
738 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2,this->z+dh*cz);
744 for (i=0; i<nneigh; i++){
747 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z-dh);
753 for (i=0; i<nneigh; i++){
756 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh2);
763 sort(Morton.begin(), Morton.end());
771 vector<uint64_t> computeVirtualMorton(uint8_t iface,
772 const uint8_t & maxdepth,
773 uint32_t & sizeneigh){
774 vector<uint64_t> Morton;
775 if (getNotBalance()){
776 return computeMinSizeMorton(iface,
781 return computeHalfSizeMorton(iface,
788 vector<uint64_t> computeEdgeHalfSizeMorton(uint8_t iedge,
793 uint8_t iface1, iface2;
795 nneigh = (level < MAX_LEVEL_3D) ? 2 : 1;
796 dh = (level < MAX_LEVEL_3D) ? getSize()/2 : getSize();
798 iface1 = global3D.
edgeface[iedge][0];
799 iface2 = global3D.
edgeface[iedge][1];
801 if (info[iface1] || info[iface2]){
803 vector<uint64_t> Morton(0);
807 vector<uint64_t> Morton(nneigh);
811 for (i=0; i<nneigh; i++){
815 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh*cz);
821 for (i=0; i<nneigh; i++){
825 Morton[i] = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh*cz);
831 for (i=0; i<nneigh; i++){
835 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh*cz);
841 for (i=0; i<nneigh; i++){
845 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh*cz);
851 for (i=0; i<nneigh; i++){
855 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh*cz);
861 for (i=0; i<nneigh; i++){
865 Morton[i] = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh*cz);
871 for (i=0; i<nneigh; i++){
875 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh*cz);
881 for (i=0; i<nneigh; i++){
885 Morton[i] = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh2*cy,this->z+dh*cz);
891 for (i=0; i<nneigh; i++){
895 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh2*cz);
901 for (i=0; i<nneigh; i++){
905 Morton[i] = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh2*cz);
911 for (i=0; i<nneigh; i++){
915 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh2*cz);
921 for (i=0; i<nneigh; i++){
925 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh2*cz);
939 vector<uint64_t> computeEdgeMinSizeMorton(uint8_t iedge,
940 const uint8_t & maxdepth,
943 uint32_t nneigh, nline;
945 uint8_t iface1, iface2;
948 nneigh = (level < MAX_LEVEL_3D) ? uint32_t(pow(2.0,
double((maxdepth-level)))) : 1;
949 dh = (level < MAX_LEVEL_3D) ? uint32_t(pow(2.0,
double(MAX_LEVEL_3D - maxdepth))) : getSize();
951 nline = uint32_t(pow(2.0,
double((maxdepth-level))));
952 iface1 = global3D.
edgeface[iedge][0];
953 iface2 = global3D.
edgeface[iedge][1];
955 if (info[iface1] || info[iface2]){
957 vector<uint64_t> Morton(0);
961 vector<uint64_t> Morton(nneigh);
965 for (i=0; i<nneigh; i++){
969 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh*cz);
975 for (i=0; i<nneigh; i++){
979 Morton[i] = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh*cz);
985 for (i=0; i<nneigh; i++){
989 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh*cz);
995 for (i=0; i<nneigh; i++){
999 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh*cz);
1005 for (i=0; i<nneigh; i++){
1009 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh*cz);
1015 for (i=0; i<nneigh; i++){
1019 Morton[i] = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh*cz);
1025 for (i=0; i<nneigh; i++){
1029 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh*cz);
1035 for (i=0; i<nneigh; i++){
1039 Morton[i] = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh2*cy,this->z+dh*cz);
1045 for (i=0; i<nneigh; i++){
1049 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh2*cz);
1055 for (i=0; i<nneigh; i++){
1059 Morton[i] = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh2*cz);
1065 for (i=0; i<nneigh; i++){
1069 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh2*cz);
1075 for (i=0; i<nneigh; i++){
1079 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh2*cz);
1086 sort(Morton.begin(),Morton.end());
1093 vector<uint64_t> computeEdgeVirtualMorton(uint8_t iedge,
1094 const uint8_t & maxdepth,
1095 uint32_t & sizeneigh,
1096 uint8_t balance_codim){
1098 return computeEdgeMinSizeMorton(iedge,
1106 if(!getNotBalance() && balance_codim > 1){
1107 return computeEdgeHalfSizeMorton(iedge,
1111 return computeEdgeMinSizeMorton(iedge,
1120 uint64_t computeNodeHalfSizeMorton(uint8_t inode,
1125 uint8_t iface1, iface2, iface3;
1127 dh = (level < MAX_LEVEL_3D) ? getSize()/2 : getSize();
1129 iface1 = global3D.
nodeface[inode][0];
1130 iface2 = global3D.
nodeface[inode][1];
1131 iface3 = global3D.
nodeface[inode][2];
1133 if (info[iface1] || info[iface2] || info[iface3]){
1135 return this->computeMorton();
1145 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh*cz);
1153 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh*cz);
1161 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh*cz);
1169 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh2*cy,this->z+dh*cz);
1177 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh2*cz);
1185 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh2*cz);
1193 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh2*cz);
1201 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh2*cy,this->z+dh2*cz);
1212 uint64_t computeNodeMinSizeMorton(uint8_t inode,
1213 const uint8_t & maxdepth,
1218 uint8_t iface1, iface2, iface3;
1221 dh = (level < MAX_LEVEL_3D) ? uint32_t(pow(2.0,
double(MAX_LEVEL_3D - maxdepth))) : getSize();
1223 iface1 = global3D.
nodeface[inode][0];
1224 iface2 = global3D.
nodeface[inode][1];
1225 iface3 = global3D.
nodeface[inode][2];
1227 if (info[iface1] || info[iface2] || info[iface3]){
1229 return this->computeMorton();
1239 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh*cz);
1247 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh*cz);
1255 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh*cz);
1263 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh2*cy,this->z+dh*cz);
1271 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy,this->z+dh2*cz);
1279 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy,this->z+dh2*cz);
1287 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy,this->z+dh2*cz);
1295 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh2*cy,this->z+dh2*cz);
1307 uint64_t computeNodeVirtualMorton(uint8_t inode,
1308 const uint8_t & maxdepth,
1309 uint32_t & sizeneigh){
1311 return computeNodeMinSizeMorton(inode,
uint64_t computeMorton() const
dvector getEdgeCenter(uint8_t iedge)
Parallel Octree Manager Class.
bool getPbound(uint8_t face) const
void getNormal(uint8_t &iface, vector< int8_t > &normal)
bool getNotBalance() const
u32vector getNode(uint8_t inode)
Octant class definition - 3D specialization.
void setBalance(bool balance)
uint64_t getVolume() const
dvector getFaceCenter(uint8_t iface)
Local octree portion for each process.
bool getBound(uint8_t face) const
void getNode(u32vector &node, uint8_t inode)
void setMarker(int8_t marker)
void getNodes(u32vector2D &nodes)