46IBinaryStream& operator>>(IBinaryStream &buffer, Octant &octant)
54 octant.initialize(dimensions, level,
true);
56 buffer >> octant.m_morton;
58 buffer >> octant.m_marker;
60 buffer >> octant.m_ghost;
62 for(
int i = 0; i < Octant::INFO_ITEM_COUNT; ++i){
65 octant.m_info[i] = value;
79OBinaryStream&
operator<<(OBinaryStream &buffer,
const Octant &octant)
81 buffer << octant.m_dim;
82 buffer << octant.m_level;
84 buffer << octant.m_morton;
86 buffer << octant.m_marker;
88 buffer << octant.m_ghost;
90 for(
int i = 0; i < Octant::INFO_ITEM_COUNT; ++i){
91 buffer << (bool) octant.m_info[i];
127 initialize(dim, 0,
true);
137 initialize(dim, level,
true);
152Octant::Octant(uint8_t dim, uint8_t level, int32_t x, int32_t y, int32_t z){
153 initialize(dim, level,
true);
156 m_morton = PABLO::computeMorton(m_dim, x, y, z);
169Octant::Octant(
bool bound, uint8_t dim, uint8_t level, int32_t x, int32_t y, int32_t z){
170 initialize(dim, level, bound);
173 m_morton = PABLO::computeMorton(m_dim, x, y, z);
179bool Octant::operator ==(
const Octant & oct2){
194Octant::initialize() {
195 initialize(0, 0,
false);
204Octant::initialize(uint8_t dim, uint8_t level,
bool bound) {
216 m_info[OctantInfo::INFO_BALANCED] =
true;
221 if (m_dim >= 2 && m_level == 0) {
222 uint8_t nf = m_dim*2;
223 for (uint8_t i=0; i<nf; i++){
252 return PABLO::computeCoordinate(m_dim, m_morton, coord);
273 return (m_info[OctantInfo::INFO_BOUNDFACE0 + face]);
282 for (
int face : sm_treeConstants[m_dim].edgeFace[edge]) {
297 for (
int face : sm_treeConstants[m_dim].nodeFace[node]) {
311 for (
int i = 0; i < sm_treeConstants[m_dim].nFaces; ++i) {
325 m_info[INFO_BOUNDFACE0 + face] =
true;
334 return m_info[INFO_PBOUNDFACE0 + face];
342 for (
int i = 0; i < sm_treeConstants[m_dim].nFaces; ++i) {
386 this->m_marker = marker;
394 m_info[OctantInfo::INFO_BALANCED] = balance;
402 this->m_level = level;
411 m_info[INFO_PBOUNDFACE0 + face] = flag;
420 m_ghost = ghostLayer;
433 return sm_treeConstants[m_dim].lengths[m_level];
441 return sm_treeConstants[m_dim].areas[m_level];
449 return sm_treeConstants[m_dim].volumes[m_level];
460 darray3 center = {{0., 0., 0.}};
475 assert(iface < m_dim*2);
478 darray3 center = {{0., 0., 0.}};
479 center[0] =
getLogicalCoordinates(0) + (double)sm_treeConstants[m_dim].faceDisplacements[iface][0] * dh_2;
480 center[1] =
getLogicalCoordinates(1) + (double)sm_treeConstants[m_dim].faceDisplacements[iface][1] * dh_2;
481 center[2] =
getLogicalCoordinates(2) + double(m_dim-2) * (double)sm_treeConstants[m_dim].faceDisplacements[iface][2] * dh_2;
495 darray3 center = {{0., 0., 0.}};
498 center[0] =
getLogicalCoordinates(0) + (double)sm_treeConstants[m_dim].edgeDisplacements[iedge][0] * dh_2;
499 center[1] =
getLogicalCoordinates(1) + (double)sm_treeConstants[m_dim].edgeDisplacements[iedge][1] * dh_2;
500 center[2] =
getLogicalCoordinates(2) + double(m_dim-2) * (double)sm_treeConstants[m_dim].edgeDisplacements[iedge][2] * dh_2;
513 uint8_t nn = uint8_t(1)<<m_dim;
520 for (i = 0; i < nn; i++){
521 nodes[i][0] = coords[0] + uint32_t(sm_treeConstants[m_dim].nodeCoordinates[i][0])*dh;
522 nodes[i][1] = coords[1] + uint32_t(sm_treeConstants[m_dim].nodeCoordinates[i][1])*dh;
523 nodes[i][2] = coords[2] + uint32_t(sm_treeConstants[m_dim].nodeCoordinates[i][2])*dh;
548 node[0] += sm_treeConstants[m_dim].nodeCoordinates[inode][0]*dh;
549 node[1] += sm_treeConstants[m_dim].nodeCoordinates[inode][1]*dh;
550 node[2] += sm_treeConstants[m_dim].nodeCoordinates[inode][2]*dh;
571 for (i = 0; i < 3; i++){
572 normal[i] = normals[iface][i];
589 return PABLO::computeMorton(m_dim, lastDescCoordinates[0], lastDescCoordinates[1], lastDescCoordinates[2]);
599 for (
int i=0; i<m_dim; i++){
600 lastDescCoords[i] += (uint32_t(1) << (sm_treeConstants[m_dim].maxLevel - m_level)) - 1;
603 return lastDescCoords;
611 return PABLO::computeMorton(m_dim, fatherCoordinates[0], fatherCoordinates[1], fatherCoordinates[2]);
621 for (
int i=0; i<m_dim; i++){
622 fatherCoordinates[i] -= fatherCoordinates[i]%(uint32_t(1) << (sm_treeConstants[m_dim].maxLevel -
max(0,(m_level-1))));
624 return fatherCoordinates;
652 return PABLO::computeXYZKey(m_dim, node[0], node[1], node[2]);
660 unsigned int binarySize = 0;
661 binarySize +=
sizeof(uint8_t);
662 binarySize +=
sizeof(uint8_t);
663 binarySize +=
sizeof(uint64_t);
664 binarySize +=
sizeof(int8_t);
665 binarySize +=
sizeof(int);
666 binarySize += INFO_ITEM_COUNT *
sizeof(bool);
680 Octant lastDesc(m_dim, sm_treeConstants[m_dim].maxLevel, lastDescMorton);
691 Octant father(m_dim,
max(0,m_level-1), fatherMorton);
701 if (this->m_level < sm_treeConstants[m_dim].maxLevel){
702 return sm_treeConstants[m_dim].nChildren;
716 std::vector< Octant > children(nchildren);
734 for (
int i=0; i<nChildren; ++i){
838 children[i] =
Octant(*
this);
839 Octant &oct = children[i];
841 oct.
setMarker(std::max(0, oct.m_marker - 1));
845 oct.m_morton = PABLO::computeMorton(m_dim, coords[0] + dh * dx, coords[1] + dh * dy, coords[2] + dh * dz);
847 oct.m_info[OctantInfo::INFO_NEW4REFINEMENT] =
true;
849 oct.m_info[INFO_BOUNDFACE0 + xf] =
false;
850 oct.m_info[INFO_BOUNDFACE0 + yf] =
false;
851 oct.m_info[INFO_BOUNDFACE0 + zf] =
false;
853 oct.m_info[INFO_PBOUNDFACE0 + xf] =
false;
854 oct.m_info[INFO_PBOUNDFACE0 + yf] =
false;
855 oct.m_info[INFO_PBOUNDFACE0 + zf] =
false;
870 for (
int i=0; i<m_dim; i++){
871 delta[i] = ((xx[i]%(uint32_t(1) << (sm_treeConstants[m_dim].maxLevel -
max(0,(m_level-1))))) == 0);
873 return sm_treeConstants[m_dim].nodeFromCoordinates[delta[0]][delta[1]][delta[2]];
bool getNodeBound(uint8_t node) const
uint64_t computeNodePersistentKey(uint8_t inode) const
int getGhostLayer() const
void setPbound(uint8_t face, bool flag)
u32array3 computeLastDescCoordinates() const
uint8_t countChildren() const
void getLogicalNode(u32array3 &node, uint8_t inode) const
u32arr3vector getLogicalNodes() const
u32array3 getLogicalCoordinates() const
static unsigned int getBinarySize()
void getNormal(uint8_t iface, i8array3 &normal, const int8_t(&normals)[6][3]) const
Octant buildFather() const
uint64_t getMorton() const
void setMarker(int8_t marker)
uint32_t getLogicalSize() const
void setBalance(bool balance)
uint64_t getLogicalArea() const
darray3 getLogicalCenter() const
std::vector< Octant > buildChildren() const
void setGhostLayer(int ghostLayer)
darray3 getLogicalEdgeCenter(uint8_t iedge) const
void setBound(uint8_t face)
bool getEdgeBound(uint8_t edge) const
darray3 getLogicalFaceCenter(uint8_t iface) const
u32array3 computeFatherCoordinates() const
uint8_t getFamilySplittingNode() const
void setLevel(uint8_t level)
uint64_t computeFatherMorton() const
Octant buildLastDesc() const
uint64_t getLogicalVolume() const
uint64_t computeLastDescMorton() const
std::array< T, d > max(const std::array< T, d > &x, const std::array< T, d > &y)
#define BITPIT_UNREACHABLE(str)
unsigned int check(std::ifstream &, std::vector< std::vector< int > > &)
Logger & operator<<(Logger &logger, LoggerManipulator< T > &&m)
static BITPIT_PUBLIC_API const Instances & instances()