43 typedef vector<Class_Octant<2> > OctantsType;
44 typedef vector<double> dvector;
45 typedef vector<uint32_t> u32vector;
46 typedef vector<vector<uint32_t> > u32vector2D;
47 typedef vector<vector<uint64_t> > u64vector2D;
71 for (
int i=0; i<global2D.
nfaces; i++){
81 for (
int i=0; i<global2D.
nfaces; i++){
88 Class_Octant(uint8_t level, uint32_t x, uint32_t y,
bool bound){
94 for (
int i=0; i<global2D.
nfaces; i++){
104 level = octant.level;
105 marker = octant.marker;
113 check = check && (x == oct2.x);
114 check = check && (y == oct2.y);
115 check = check && (level == oct2.level);
128 uint32_t
getX()
const{
return x;};
133 uint32_t
getY()
const{
return y;};
138 uint32_t
getZ()
const{
return 0;};
159 void setBound(uint8_t face) {
169 return info[global2D.
nfaces+face];
196 this->marker = marker;
207 void setLevel(uint8_t level){
210 void setPbound(uint8_t face,
bool flag){
211 info[global2D.
nfaces+face] = flag;
223 uint32_t size = uint32_t(pow(
double(2),
double(MAX_LEVEL_2D-level)));
231 uint32_t area =getSize();
239 uint64_t volume = uint64_t(pow(
double(getSize()),2.0));
251 dh = double(getSize())/2.0;
252 vector<double> center(3);
254 center[0] = (double)x + dh;
255 center[1] = (double)y + dh;
268 int A[4][2] = { {0,1} , {2,1} , {1,0} , {1,2} };
270 dh_2 = double(getSize())/2.0;
271 vector<double> center(3);
273 if (iface < global2D.
nfaces){
274 center[0] = (double)x + (
double)A[iface][0] * dh_2;
275 center[1] = (double)y + (
double)A[iface][1] * dh_2;
292 nodes.resize(global2D.
nnodes);
294 for (i = 0; i < global2D.
nnodes; i++){
298 nodes[i][0] = x + cx*dh;
299 nodes[i][1] = y + cy*dh;
301 #if defined(__INTEL_COMPILER) || defined(__ICC)
303 nodes[i].shrink_to_fit();
306 #if defined(__INTEL_COMPILER) || defined(__ICC)
308 nodes.shrink_to_fit();
316 void getNode(u32vector & node, uint8_t inode){
323 cx = uint8_t(inode%2);
324 cy = uint8_t(inode/2);
339 cx = uint8_t(inode%2);
340 cy = uint8_t(inode/2);
354 vector<int8_t> & normal){
359 for (i = 0; i < 3; i++){
360 normal[i] = global2D.
normals[iface][i];
362 #if defined(__INTEL_COMPILER) || defined(__ICC)
364 normal.shrink_to_fit();
375 morton = mortonEncode_magicbits(this->x,this->y);
386 morton = mortonEncode_magicbits(this->x,this->y);
395 uint32_t delta = (uint32_t)pow(2.0,(
double)((uint8_t)MAX_LEVEL_2D - level)) - 1;
403 uint32_t deltax = x%(uint32_t(pow(2.0,(
double)((uint8_t)MAX_LEVEL_2D - (level-1)))));
404 uint32_t deltay = y%(uint32_t(pow(2.0,(
double)((uint8_t)MAX_LEVEL_2D - (level-1)))));
414 vector<Class_Octant<2> > buildChildren(){
417 if (this->level < MAX_LEVEL_2D){
418 vector<Class_Octant<2> > children(global2D.
nchildren);
419 for (
int i=0; i<global2D.
nchildren; i++){
424 oct.setMarker(max(0,oct.marker-1));
425 oct.setLevel(oct.level+1);
429 oct.info[xf] = oct.info[xf+global2D.
nfaces] =
false;
430 oct.info[yf] = oct.info[yf+global2D.
nfaces] =
false;
437 oct.setMarker(max(0,oct.marker-1));
438 oct.setLevel(oct.level+1);
440 uint32_t dh = oct.getSize();
444 oct.info[xf] = oct.info[xf+global2D.
nfaces] =
false;
445 oct.info[yf] = oct.info[yf+global2D.
nfaces] =
false;
452 oct.setMarker(max(0,oct.marker-1));
453 oct.setLevel(oct.level+1);
455 uint32_t dh = oct.getSize();
459 oct.info[xf] = oct.info[xf+global2D.
nfaces] =
false;
460 oct.info[yf] = oct.info[yf+global2D.
nfaces] =
false;
467 oct.setMarker(max(0,oct.marker-1));
468 oct.setLevel(oct.level+1);
470 uint32_t dh = oct.getSize();
475 oct.info[xf] = oct.info[xf+global2D.
nfaces] =
false;
476 oct.info[yf] = oct.info[yf+global2D.
nfaces] =
false;
485 vector<Class_Octant<2> > children(0);
493 vector<uint64_t > computeHalfSizeMorton(uint8_t iface,
499 nneigh = (level < MAX_LEVEL_2D) ? global2D.
nchildren/2 : 1;
500 dh = (level < MAX_LEVEL_2D) ? getSize()/2 : getSize();
505 vector<uint64_t> Morton(0);
509 vector<uint64_t> Morton(nneigh);
513 for (i=0; i<nneigh; i++){
515 Morton[i] = mortonEncode_magicbits(this->x-dh,this->y+dh*cy);
521 for (i=0; i<nneigh; i++){
523 Morton[i] = mortonEncode_magicbits(this->x+dh2,this->y+dh*cy);
529 for (i=0; i<nneigh; i++){
531 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y-dh);
537 for (i=0; i<nneigh; i++){
539 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2);
553 vector<uint64_t> computeMinSizeMorton(uint8_t iface,
554 const uint8_t & maxdepth,
557 uint32_t nneigh, nline;
560 nneigh = (level < MAX_LEVEL_2D) ? uint32_t(pow(2.0,
double(maxdepth-level))) : 1;
561 dh = (level < MAX_LEVEL_2D) ? uint32_t(pow(2.0,
double(MAX_LEVEL_2D - maxdepth))) : getSize();
563 nline = uint32_t(pow(2.0,
double((maxdepth-level))));
567 vector<uint64_t> Morton(0);
571 vector<uint64_t> Morton(nneigh);
575 for (i=0; i<nneigh; i++){
577 Morton[i] = mortonEncode_magicbits(this->x-dh,this->y+dh*cy);
583 for (i=0; i<nneigh; i++){
585 Morton[i] = mortonEncode_magicbits(this->x+dh2,this->y+dh*cy);
591 for (i=0; i<nneigh; i++){
593 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y-dh);
599 for (i=0; i<nneigh; i++){
601 Morton[i] = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2);
607 sort(Morton.begin(), Morton.end());
615 vector<uint64_t> computeVirtualMorton(uint8_t iface,
616 const uint8_t & maxdepth,
617 uint32_t & sizeneigh){
618 if (getNotBalance()){
619 return computeMinSizeMorton(iface,
624 return computeHalfSizeMorton(iface,
631 uint64_t computeNodeHalfSizeMorton(uint8_t inode,
636 uint8_t iface1, iface2;
638 dh = (level < MAX_LEVEL_2D) ? getSize()/2 : getSize();
640 iface1 = global3D.
nodeface[inode][0];
641 iface2 = global3D.
nodeface[inode][1];
643 if (info[iface1] || info[iface2]){
645 return this->computeMorton();
654 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy);
661 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy);
668 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy);
675 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh2*cy);
686 uint64_t computeNodeMinSizeMorton(uint8_t inode,
687 const uint8_t & maxdepth,
692 uint8_t iface1, iface2;
695 dh = (level < MAX_LEVEL_2D) ? uint32_t(pow(2.0,
double(MAX_LEVEL_2D - maxdepth))) : getSize();
697 iface1 = global3D.
nodeface[inode][0];
698 iface2 = global3D.
nodeface[inode][1];
700 if (info[iface1] || info[iface2]){
702 return this->computeMorton();
711 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh*cy);
718 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh*cy);
725 Morton = mortonEncode_magicbits(this->x+dh*cx,this->y+dh2*cy);
732 Morton = mortonEncode_magicbits(this->x+dh2*cx,this->y+dh2*cy);
744 uint64_t computeNodeVirtualMorton(uint8_t inode,
745 const uint8_t & maxdepth,
746 uint32_t & sizeneigh){
748 return computeNodeMinSizeMorton(inode,
void setBalance(bool balance)
Parallel Octree Manager Class.
u32vector getNode(uint8_t inode)
Octant class definition - 2D specialization.
uint64_t computeMorton() const
dvector getFaceCenter(uint8_t iface)
void setMarker(int8_t marker)
void getNodes(u32vector2D &nodes)
uint64_t getVolume() const
bool getBound(uint8_t face) const
void getNormal(uint8_t &iface, vector< int8_t > &normal)
bool getPbound(uint8_t face) const
Local octree portion for each process.
void getNode(u32vector &node, uint8_t inode)
bool getNotBalance() const