Loading...
Searching...
No Matches
LocalTree.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_LOCALTREE_HPP__
26#define __BITPIT_PABLO_LOCALTREE_HPP__
27
28// =================================================================================== //
29// INCLUDES //
30// =================================================================================== //
31#include "tree_constants.hpp"
32#include "Octant.hpp"
33#include "Intersection.hpp"
34
35namespace bitpit {
36
37// =================================================================================== //
38// TYPEDEFS
39// =================================================================================== //
40
41typedef std::vector<Octant> octvector;
42typedef std::vector<Intersection> intervector;
43
44// =================================================================================== //
45// CLASS DEFINITION //
46// =================================================================================== //
72
73 // =================================================================================== //
74 // FRIENDSHIPS
75 // =================================================================================== //
76
77 friend class ParaTree;
78
79 // =================================================================================== //
80 // TYPEDEFS
81 // =================================================================================== //
82public:
83
86 typedef std::vector<Octant> octvector;
87
90 typedef std::vector<Intersection> intervector;
91
94 typedef std::vector<bool> bvector;
95
98 typedef std::vector<uint8_t> u8vector;
99
102 typedef std::vector<uint32_t> u32vector;
103
106 typedef std::vector<uint64_t> u64vector;
107
110 typedef std::vector<u32array3> u32arr3vector;
111
112 // =================================================================================== //
113 // MEMBERS
114 // =================================================================================== //
115
116private:
117 octvector m_octants;
118 octvector m_ghosts;
119 intervector m_intersections;
120 u64vector m_globalIdxGhosts;
121 uint64_t m_firstDescMorton;
122 uint64_t m_lastDescMorton;
123 int8_t m_localMaxDepth;
124 uint8_t m_balanceCodim;
127 u32vector m_lastGhostBros;
128 u32vector m_firstGhostBros;
129 u32vector2D m_connectivity;
131 u32vector2D m_ghostsConnectivity;
133 u32arr3vector m_nodes;
135 uint8_t m_dim;
136 const TreeConstants *m_treeConstants;
137 bvector m_periodic;
140 // =================================================================================== //
141 // CONSTRUCTORS
142 // =================================================================================== //
143 LocalTree();
144 LocalTree(uint8_t dim);
145
146 // =================================================================================== //
147 // METHODS
148 // =================================================================================== //
149
150protected:
151 std::array<int64_t, 3> computeFirstVirtualNeighOffset(uint8_t level, uint8_t iface, uint8_t neighLevel) const;
152 std::array<int64_t, 3> computeLastVirtualNeighOffset(uint8_t level, uint8_t iface, uint8_t neighLevel) const;
153 void computeVirtualNeighOffsets(uint8_t level, uint8_t iface, uint8_t neighLevel, std::vector<std::array<int64_t, 3>> *neighOffsets) const;
154
155 std::array<int64_t, 3> computeFirstVirtualNodeNeighOffset(uint8_t level, uint8_t inode, uint8_t neighLevel) const;
156 std::array<int64_t, 3> computeLastVirtualNodeNeighOffset(uint8_t level, uint8_t inode, uint8_t neighLevel) const;
157 void computeVirtualNodeNeighOffsets(uint8_t level, uint8_t inode, uint8_t neighLevel, std::vector<std::array<int64_t, 3>> *neighOffsets) const;
158
159 std::array<int64_t, 3> computeFirstVirtualEdgeNeighOffset(uint8_t level, uint8_t iedge, uint8_t neighLevel) const;
160 std::array<int64_t, 3> computeLastVirtualEdgeNeighOffset(uint8_t level, uint8_t iedge, uint8_t neighLevel) const;
161 void computeVirtualEdgeNeighOffsets(uint8_t level, uint8_t iedge, uint8_t neighLevel, std::vector<std::array<int64_t, 3>> *neighOffsets) const;
162
163 std::array<int64_t, 3> getPeriodicOffset(const Octant &octant, uint8_t iface) const;
164 std::array<int64_t, 3> getNodePeriodicOffset(const Octant &octant, uint8_t inode) const;
165 std::array<int64_t, 3> getEdgePeriodicOffset(const Octant &octant, uint8_t iedge) const;
166
167 uint8_t getMaxNeighLevel(const Octant &octant) const;
168 uint8_t getMaxNodeNeighLevel(const Octant &octant) const;
169 uint8_t getMaxEdgeNeighLevel(const Octant &octant) const;
170
171 // =================================================================================== //
172 // BASIC GET/SET METHODS
173 // =================================================================================== //
174private:
175 uint64_t getFirstDescMorton() const;
176 uint64_t getLastDescMorton() const;
177 uint32_t getNumGhosts() const;
178 uint32_t getNumOctants() const;
179 int8_t getLocalMaxDepth() const;
180 int8_t getMarker(int32_t idx) const;
181 uint8_t getLevel(int32_t idx) const;
182 uint64_t getMorton(int32_t idx) const;
183 uint64_t computeNodePersistentKey(int32_t idx, uint8_t inode) const;
184 uint8_t getGhostLevel(int32_t idx) const;
185 uint64_t computeGhostMorton(int32_t idx) const;
186 uint64_t computeGhostNodePersistentKey(int32_t idx, uint8_t inode) const;
187 bool getBalance(int32_t idx) const;
188 uint8_t getBalanceCodim() const;
189 void setMarker(int32_t idx, int8_t marker);
190 void setBalance(int32_t idx, bool balance);
191 void setBalanceCodim(uint8_t b21codim);
192 void setFirstDescMorton();
193 void setLastDescMorton();
194 void setPeriodic(bvector & periodic);
195
196 // =================================================================================== //
197 // OTHER GET/SET METHODS
198 // =================================================================================== //
199 bool isPeriodic(const Octant* oct, uint8_t iface) const;
200 bool isEdgePeriodic(const Octant* oct, uint8_t iedge) const;
201 bool isNodePeriodic(const Octant* oct, uint8_t inode) const;
202
203 // =================================================================================== //
204 // OTHER METHODS
205 // =================================================================================== //
206
207 void initialize();
208 void initialize(uint8_t dim);
209 void reset(bool createRoot);
210
211 Octant& extractOctant(uint32_t idx);
212 const Octant& extractOctant(uint32_t idx) const;
213 Octant& extractGhostOctant(uint32_t idx);
214 const Octant& extractGhostOctant(uint32_t idx) const;
215
216
217 bool refine(u32vector & mapidx);
218 bool coarse(u32vector & mapidx);
219 bool globalRefine(u32vector & mapidx);
220 bool globalCoarse(u32vector & mapidx);
221 void checkCoarse(uint64_t partLastDesc, u32vector & mapidx);
222 void updateLocalMaxDepth();
223
224 void findNeighbours(const Octant* oct, uint8_t iface, u32vector & neighbours, bvector & isghost, bool onlyinternal, bool append) const;
225 void findEdgeNeighbours(const Octant* oct, uint8_t iedge, u32vector & neighbours, bvector & isghost, bool onlyinternal, bool append) const;
226 void findNodeNeighbours(const Octant* oct, uint8_t inode, u32vector & neighbours, bvector & isghost, bool onlyinternal, bool append) const;
227
228 void computeNeighSearchBegin(uint64_t sameSizeVirtualNeighMorton, const octvector &octants, uint32_t *searchBeginIdx, uint64_t *searchBeginMorton) const;
229
230 bool localBalance(bool doNew, bool checkInterior, bool checkGhost);
231
232 bool fixBrokenFamiliesMarkers(std::vector<Octant *> *updatedOctants = nullptr, std::vector<bool> *updatedGhostFlags = nullptr);
233
234 void computeIntersections();
235
236 uint32_t findMorton(uint64_t targetMorton) const;
237 uint32_t findGhostMorton(uint64_t targetMorton) const;
238 uint32_t findMorton(uint64_t targetMorton, const octvector &octants) const;
239 void findMortonLowerBound(uint64_t targetMorton, const octvector &octants, uint32_t *lowerBoundIdx, uint64_t *lowerBoundMorton) const;
240 void findMortonUpperBound(uint64_t targetMorton, const octvector &octants, uint32_t *upperBoundIdx, uint64_t *upperBoundMorton) const;
241
242 void computeConnectivity();
243 void clearConnectivity(bool release = true);
244 void updateConnectivity();
245
246 // =================================================================================== //
247
248};
249
250}
251
252#endif /* __BITPIT_PABLO_LOCALTREE_HPP__ */
Local octree portion for each process.
Definition LocalTree.hpp:71
void computeVirtualNodeNeighOffsets(uint8_t level, uint8_t inode, uint8_t neighLevel, std::vector< std::array< int64_t, 3 > > *neighOffsets) const
uint8_t getMaxEdgeNeighLevel(const Octant &octant) const
std::array< int64_t, 3 > computeLastVirtualEdgeNeighOffset(uint8_t level, uint8_t iedge, uint8_t neighLevel) const
std::vector< Intersection > intervector
Definition LocalTree.hpp:90
uint8_t getMaxNeighLevel(const Octant &octant) const
uint8_t getMaxNodeNeighLevel(const Octant &octant) const
std::vector< bool > bvector
Definition LocalTree.hpp:94
std::array< int64_t, 3 > getEdgePeriodicOffset(const Octant &octant, uint8_t iedge) const
std::array< int64_t, 3 > getPeriodicOffset(const Octant &octant, uint8_t iface) const
std::array< int64_t, 3 > computeLastVirtualNeighOffset(uint8_t level, uint8_t iface, uint8_t neighLevel) const
std::vector< Octant > octvector
Definition LocalTree.hpp:86
std::vector< uint8_t > u8vector
Definition LocalTree.hpp:98
std::vector< uint32_t > u32vector
void computeVirtualEdgeNeighOffsets(uint8_t level, uint8_t iedge, uint8_t neighLevel, std::vector< std::array< int64_t, 3 > > *neighOffsets) const
std::vector< u32array3 > u32arr3vector
std::array< int64_t, 3 > computeLastVirtualNodeNeighOffset(uint8_t level, uint8_t inode, uint8_t neighLevel) const
std::array< int64_t, 3 > computeFirstVirtualNeighOffset(uint8_t level, uint8_t iface, uint8_t neighLevel) const
std::array< int64_t, 3 > computeFirstVirtualEdgeNeighOffset(uint8_t level, uint8_t iedge, uint8_t neighLevel) const
std::vector< uint64_t > u64vector
void computeVirtualNeighOffsets(uint8_t level, uint8_t iface, uint8_t neighLevel, std::vector< std::array< int64_t, 3 > > *neighOffsets) const
std::array< int64_t, 3 > computeFirstVirtualNodeNeighOffset(uint8_t level, uint8_t inode, uint8_t neighLevel) const
std::array< int64_t, 3 > getNodePeriodicOffset(const Octant &octant, uint8_t inode) const
Octant class definition.
Definition Octant.hpp:89
Para Tree is the user interface class.
Definition ParaTree.hpp:113
Global constants associated to a PABLO tree.
--- layout: doxygen_footer ---