Loading...
Searching...
No Matches
Octant.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_PABLO_OCTANT_HPP__
26#define __BITPIT_PABLO_OCTANT_HPP__
27
28// INCLUDES //
29#include "tree_constants.hpp"
30
31#include <vector>
32#include <bitset>
33#include <array>
34
35#include "bitpit_containers.hpp"
36
37namespace bitpit {
38
39// =================================================================================== //
40// TYPEDEFS
41// =================================================================================== //
42typedef std::vector<uint8_t> u8vector;
43typedef std::vector<uint32_t> u32vector;
44typedef std::vector<uint64_t> u64vector;
45typedef std::vector<double> dvector;
46typedef std::array<double, 3> darray3;
47typedef std::array<int8_t, 3> i8array3;
48typedef std::array<uint32_t, 3> u32array3;
49typedef std::vector<std::vector<uint32_t>> u32vector2D;
50typedef std::vector<std::vector<uint64_t>> u64vector2D;
51typedef std::vector<u32array3> u32arr3vector;
52
53// =================================================================================== //
54// STREAM OPERATORS
55// =================================================================================== //
56class Octant;
57
58IBinaryStream & operator>>(IBinaryStream &buffer, Octant& octant);
59OBinaryStream & operator<<(OBinaryStream &buffer, const Octant& octant);
60
61// =================================================================================== //
62// CLASS DEFINITION //
63// =================================================================================== //
89class Octant{
90
91 // =================================================================================== //
92 // FRIENDSHIPS
93 // =================================================================================== //
94
95 friend class LocalTree;
96 friend class ParaTree;
97 friend class Global;
98
99 friend OBinaryStream& (operator<<) (OBinaryStream& buf, const Octant& octant);
100 friend IBinaryStream& (operator>>) (IBinaryStream& buf, Octant& octant);
101
102
103 // =================================================================================== //
104 // STATIC MEMBERS
105 // =================================================================================== //
106
107 static const TreeConstants::Instances sm_treeConstants;
109 // =================================================================================== //
110 // MEMBERS
111 // =================================================================================== //
112 enum OctantInfo {
113 INFO_BOUNDFACE0 = 0,
114 INFO_BOUNDFACE1 = 1,
115 INFO_BOUNDFACE2 = 2,
116 INFO_BOUNDFACE3 = 3,
117 INFO_BOUNDFACE4 = 4,
118 INFO_BOUNDFACE5 = 5,
119 INFO_PBOUNDFACE0 = 6,
120 INFO_PBOUNDFACE1 = 7,
121 INFO_PBOUNDFACE2 = 8,
122 INFO_PBOUNDFACE3 = 9,
123 INFO_PBOUNDFACE4 = 10,
124 INFO_PBOUNDFACE5 = 11,
125 INFO_NEW4REFINEMENT = 12,
126 INFO_NEW4COARSENING = 13,
127 INFO_BALANCED = 14,
129 INFO_ITEM_COUNT = 15
130 };
131
132private:
133 uint64_t m_morton;
134 uint8_t m_level;
135 int8_t m_marker;
136 std::bitset<INFO_ITEM_COUNT> m_info;
140 uint8_t m_dim;
141 int m_ghost;
148 //TODO add bitset for edge & node
149
150 // =================================================================================== //
151 // CONSTRUCTORS AND OPERATORS
152 // =================================================================================== //
153public:
154 Octant();
155private:
156 Octant(uint8_t dim);
157 Octant(uint8_t dim, uint8_t level, uint64_t morton);
158 Octant(uint8_t dim, uint8_t level, int32_t x, int32_t y, int32_t z = 0);
159 Octant(bool bound, uint8_t dim, uint8_t level, int32_t x, int32_t y, int32_t z = 0);
160 bool operator ==(const Octant & oct2);
161
162 // =================================================================================== //
163 // STATIC METHODS
164 // =================================================================================== //
165public:
166 static unsigned int getBinarySize();
167
168private:
169 // =================================================================================== //
170 // PRIVATE METHODS
171 // =================================================================================== //
172 void initialize();
173 void initialize(uint8_t dim, uint8_t level, bool bound);
174
175public:
176 // =================================================================================== //
177 // PUBLIC METHODS
178 // =================================================================================== //
179 uint64_t computeLastDescMorton() const;
180 u32array3 computeLastDescCoordinates() const;
181 uint64_t computeFatherMorton() const;
182 u32array3 computeFatherCoordinates() const;
183
184 // =================================================================================== //
185 // BASIC GET/SET METHODS
186 // =================================================================================== //
187 uint32_t getDim() const;
188 u32array3 getLogicalCoordinates() const;
189 uint32_t getLogicalCoordinates(int coord) const;
190 uint8_t getLevel() const;
191 int8_t getMarker() const;
192 bool getBound(uint8_t face) const;
193 bool getEdgeBound(uint8_t edge) const;
194 bool getNodeBound(uint8_t node) const;
195 bool getBound() const;
196 bool getPbound(uint8_t face) const;
197 bool getPbound() const;
198 bool getIsNewR() const;
199 bool getIsNewC() const;
200 bool getIsGhost() const;
201 int getGhostLayer() const;
202 bool getBalance() const;
203protected:
204 void setBound(uint8_t face);
205 void setMarker(int8_t marker);
206 void setBalance(bool balance);
207 void setLevel(uint8_t level);
208 void setPbound(uint8_t face, bool flag);
209 void setGhostLayer(int ghostLayer);
210
211 // =================================================================================== //
212 // OTHER GET/SET METHODS
213 // =================================================================================== //
214public:
215 uint32_t getLogicalSize() const;
216 uint64_t getLogicalArea() const;
217 uint64_t getLogicalVolume() const;
218 darray3 getLogicalCenter() const;
219 darray3 getLogicalFaceCenter(uint8_t iface) const;
220 darray3 getLogicalEdgeCenter(uint8_t iedge) const;
221 void getLogicalNodes(u32arr3vector & nodes) const;
222 u32arr3vector getLogicalNodes() const;
223 void getLogicalNode(u32array3 & node, uint8_t inode) const;
224 u32array3 getLogicalNode(uint8_t inode) const;
225 void getNormal(uint8_t iface, i8array3 & normal, const int8_t (&normals)[6][3]) const;
226 uint64_t getMorton() const;
227 uint64_t computeNodePersistentKey(uint8_t inode) const;
228 uint64_t computeNodePersistentKey(const u32array3 &node) const;
229
230 // =================================================================================== //
231 // OTHER METHODS //
232 // =================================================================================== //
233 Octant buildLastDesc() const;
234 Octant buildFather() const;
235 uint8_t countChildren() const;
236 std::vector<Octant> buildChildren() const;
237 void buildChildren(Octant *children) const;
238protected:
239 uint8_t getFamilySplittingNode() const;
240};
241
242}
243
244#endif /* __BITPIT_PABLO_OCTANT_HPP__ */
Output binary stream.
Local octree portion for each process.
Definition LocalTree.hpp:71
Output binary stream.
Octant class definition.
Definition Octant.hpp:89
bool getNodeBound(uint8_t node) const
Definition Octant.cpp:296
uint64_t computeNodePersistentKey(uint8_t inode) const
Definition Octant.cpp:635
int getGhostLayer() const
Definition Octant.cpp:373
void setPbound(uint8_t face, bool flag)
Definition Octant.cpp:410
u32array3 computeLastDescCoordinates() const
Definition Octant.cpp:597
uint8_t countChildren() const
Definition Octant.cpp:700
void getLogicalNode(u32array3 &node, uint8_t inode) const
Definition Octant.cpp:541
u32arr3vector getLogicalNodes() const
Definition Octant.cpp:531
u32array3 getLogicalCoordinates() const
Definition Octant.cpp:243
static unsigned int getBinarySize()
Definition Octant.cpp:658
uint32_t getDim() const
Definition Octant.cpp:237
void getNormal(uint8_t iface, i8array3 &normal, const int8_t(&normals)[6][3]) const
Definition Octant.cpp:569
bool getIsNewR() const
Definition Octant.cpp:355
Octant buildFather() const
Definition Octant.cpp:689
uint64_t getMorton() const
Definition Octant.cpp:580
void setMarker(int8_t marker)
Definition Octant.cpp:385
uint32_t getLogicalSize() const
Definition Octant.cpp:432
void setBalance(bool balance)
Definition Octant.cpp:393
uint64_t getLogicalArea() const
Definition Octant.cpp:440
darray3 getLogicalCenter() const
Definition Octant.cpp:458
std::vector< Octant > buildChildren() const
Definition Octant.cpp:713
uint8_t getLevel() const
Definition Octant.cpp:259
void setGhostLayer(int ghostLayer)
Definition Octant.cpp:419
darray3 getLogicalEdgeCenter(uint8_t iedge) const
Definition Octant.cpp:493
bool getIsNewC() const
Definition Octant.cpp:361
void setBound(uint8_t face)
Definition Octant.cpp:324
bool getEdgeBound(uint8_t edge) const
Definition Octant.cpp:281
darray3 getLogicalFaceCenter(uint8_t iface) const
Definition Octant.cpp:474
u32array3 computeFatherCoordinates() const
Definition Octant.cpp:619
int8_t getMarker() const
Definition Octant.cpp:265
bool getBound() const
Definition Octant.cpp:310
uint8_t getFamilySplittingNode() const
Definition Octant.cpp:863
void setLevel(uint8_t level)
Definition Octant.cpp:401
uint64_t computeFatherMorton() const
Definition Octant.cpp:609
Octant buildLastDesc() const
Definition Octant.cpp:678
bool getIsGhost() const
Definition Octant.cpp:367
uint64_t getLogicalVolume() const
Definition Octant.cpp:448
uint64_t computeLastDescMorton() const
Definition Octant.cpp:587
bool getPbound() const
Definition Octant.cpp:341
bool getBalance() const
Definition Octant.cpp:379
Para Tree is the user interface class.
Definition ParaTree.hpp:113
std::ostream & operator<<(std::ostream &, const std::vector< T > &)
--- layout: doxygen_footer ---