45 OctantInfo(uint32_t _id,
bool _internal) : id(_id), internal(_internal) {};
49 return (
id == other.id && internal == other.internal);
62 std::size_t operator()(
const OctantInfo& k)
const
64 return std::hash<uint32_t>()(k.id);
68#if BITPIT_ENABLE_MPI==1
69 VolOctree(MPI_Comm communicator, std::size_t haloSize = 1);
70 VolOctree(
int dimension,
const std::array<double, 3> &origin,
double length,
double dh, MPI_Comm communicator, std::size_t haloSize = 1);
71 VolOctree(
int id,
int dimension,
const std::array<double, 3> &origin,
double length,
double dh, MPI_Comm communicator, std::size_t haloSize = 1);
72 VolOctree(std::istream &stream, MPI_Comm communicator, std::size_t haloSize = 1);
75 VolOctree(
int dimension,
const std::array<double, 3> &origin,
double length,
double dh);
76 VolOctree(
int id,
int dimension,
const std::array<double, 3> &origin,
double length,
double dh);
79 VolOctree(std::unique_ptr<PabloUniform> &&tree, std::unique_ptr<PabloUniform> *adopter =
nullptr);
80 VolOctree(
int id, std::unique_ptr<PabloUniform> &&tree, std::unique_ptr<PabloUniform> *adopter =
nullptr);
88 std::unique_ptr<PatchKernel>
clone()
const override;
90 void reset()
override;
116 bool isPointInside(
const std::array<double, 3> &point)
const override;
117 bool isPointInside(
long id,
const std::array<double, 3> &point)
const override;
118 long locatePoint(
const std::array<double, 3> &point)
const override;
121 void setOrigin(
const std::array<double, 3> &origin);
122 void translate(
const std::array<double, 3> &translation)
override;
125 void scale(
const std::array<double, 3> &scaling,
const std::array<double, 3> ¢er)
override;
130#if BITPIT_ENABLE_MPI==1
137 std::vector<adaption::Info>
_adaptionAlter(
bool trackAdaption)
override;
144 void _setTol(
double tolerance)
override;
148 void _dump(std::ostream &stream)
const override;
149 void _restore(std::istream &stream)
override;
153 void _findCellNeighs(
long id,
const std::vector<long> *blackList, std::vector<long> *neighs)
const override;
154 void _findCellEdgeNeighs(
long id,
int edge,
const std::vector<long> *blackList, std::vector<long> *neighs)
const override;
155 void _findCellVertexNeighs(
long id,
int vertex,
const std::vector<long> *blackList, std::vector<long> *neighs)
const override;
157#if BITPIT_ENABLE_MPI==1
161 std::vector<adaption::Info>
_partitioningPrepare(
const std::unordered_map<long, double> &cellWeights,
double defaultWeight,
bool trackPartitioning)
override;
169 bool isSameFace(
const Cell &cell_A,
int face_A,
const Cell &cell_B,
int face_B)
const override;
174 typedef std::bitset<72> OctantHash;
176 struct RenumberInfo {
178 : cellId(
Cell::NULL_ID), newTreeId(0)
182 RenumberInfo(
long _cellId, uint32_t _newTreeId)
183 : cellId(_cellId), newTreeId(_newTreeId)
193 : cellId(Element::NULL_ID), trigger(adaption::TYPE_UNKNOWN), rank(-1)
197 DeleteInfo(
long _cellId, adaption::Type _trigger,
int _rank = -1)
198 : cellId(_cellId), trigger(_trigger), rank(_rank)
203 adaption::Type trigger;
208 FaceInfo() : id(Element::NULL_ID), face(-1) {};
209 FaceInfo(
long _id,
int _face) : id(_id), face(_face) {};
211 bool operator==(
const FaceInfo &other)
const
213 return (
id == other.id && face == other.face);
220 struct FaceInfoHasher
225 std::size_t operator()(
const FaceInfo& k)
const
227 return std::hash<long>()(k.id);
231 typedef std::unordered_set<FaceInfo, FaceInfoHasher> FaceInfoSet;
233 typedef std::unordered_map<uint64_t, long> StitchInfo;
235 std::vector<std::vector<int>> m_octantLocalFacesOnVertex;
236 std::vector<std::vector<int>> m_octantLocalFacesOnEdge;
237 std::vector<std::vector<int>> m_octantLocalEdgesOnVertex;
239 const ReferenceElementInfo *m_cellTypeInfo;
240 const ReferenceElementInfo *m_interfaceTypeInfo;
242 std::unordered_map<long, uint32_t, Element::IdHasher> m_cellToOctant;
243 std::unordered_map<long, uint32_t, Element::IdHasher> m_cellToGhost;
244 std::unordered_map<uint32_t, long> m_octantToCell;
245 std::unordered_map<uint32_t, long> m_ghostToCell;
247 std::unique_ptr<PabloUniform> m_tree;
248 std::unique_ptr<PabloUniform> *m_treeAdopter;
250 std::unique_ptr<std::vector<double>> m_partitioningOctantWeights;
254 void setBoundingBox();
256 void __reset(
bool resetTree);
257 void __setDimension(
int dimension);
259 bool setMarker(
long id, int8_t value);
261 OctantHash evaluateOctantHash(
const OctantInfo &octantInfo);
263 StitchInfo deleteCells(
const std::vector<DeleteInfo> &deletedOctants);
264 void renumberCells(
const std::vector<RenumberInfo> &renumberedOctants);
265 std::vector<long> importCells(
const std::vector<OctantInfo> &octantTreeIds, StitchInfo &stitchInfo, std::istream *stream =
nullptr);
267 std::vector<adaption::Info> sync(
bool trackChanges);
269 void findOctantCodimensionNeighs(
const OctantInfo &octantInfo,
int index,
int codimension,
270 const std::vector<long> *blackList, std::vector<long> *neighs)
const;
272 void computePartitioningOctantWeights(
const std::unordered_map<long, double> &cellWeights,
double defaultWeight);
273 void clearPartitioningOctantWeights();
275#if BITPIT_ENABLE_MPI==1
276 void initializeTree(std::unique_ptr<PabloUniform> *adopter, std::size_t haloSize);
277 void initializeTreePartitioning();
278 void initializeTreeHaloSize(std::size_t haloSize);
280 void initializeTree(std::unique_ptr<PabloUniform> *adopter);