MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
cartesiangrid.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef CARTESIANGRID_H
8#define CARTESIANGRID_H
9//#define IMPAIR_SUBDIVISION
10
11#include <algorithm>
12#include <array>
13#include <cstring>
14#include <functional>
15#include <iostream>
16#include <map>
17#include <queue>
18#include <set>
19#include <unordered_map>
20#include <vector>
21
22#include "COMM/mpioverride.h"
23#include "INCLUDE/maiatypes.h"
24#include "MEMORY/alloc.h"
25#include "MEMORY/scratch.h"
26#include "UTIL/debug.h"
27#include "UTIL/functions.h"
28#include "UTIL/timer.h"
29#include "cartesiangridtree.h"
30
31template <class T>
32class Collector;
33
34// Forward declaration of cartesiangridio.h:
35namespace maia {
36namespace grid {
37template <typename Grid>
38class IO;
39template <MInt nDim>
40class Controller;
41} // namespace grid
42} // namespace maia
43
46template <MInt nDim>
52 template <MInt nDim_, class SysEqn>
53 friend class FvCartesianSolverXD;
54 template <MInt nDim_>
55 friend class LsCartesianSolver;
56 template <MInt nDim_, class SysEqn>
57 friend class FvCartesianSolverXD;
58 template <MInt nDim_, class SysEqn>
59 friend class FvBndryCnd2D;
60 template <MInt nDim_, class SysEqn>
61 friend class FvBndryCnd3D;
62 template <MInt nDim_, class SysEqn>
64 template <MInt nDim_>
65 friend class LbSolver;
66#if not defined(MAIA_MS_COMPILER)
67 template <MInt nDim_, class SysEqn>
68 friend class DgCartesianSolver;
69#endif
70 friend class maia::grid::Controller<nDim>;
71
72 public:
73 // cartesiangridio.h API:
74 friend class maia::grid::IO<CartesianGrid<nDim>>;
75 static constexpr MInt nDim_() { return nDim; }
78
79 // Type for cell properties
80 using Cell = typename Tree::Cell;
81
83 MBool hasCutOff() const { return m_cutOff; }
84
85 // NOTE: the cartesiangrid requires parent/child/neighbor relations as Longs
86 // during initialisation and balance of the grid,
87 // localToGlobalIds and changeGlobalToLocalIds switches between local and global storage!
89 MLong& a_parentId(const MInt cellId) { return m_tree.parent(cellId); }
90
92 MLong a_parentId(const MInt cellId) const { return m_tree.parent(cellId); }
93
95 MLong a_parentId(const MInt cellId, const MInt solverId) const {
96 return (m_tree.parent(cellId) > -1 && m_tree.solver(m_tree.parent(cellId), solverId)) ? m_tree.parent(cellId) : -1;
97 }
98
100 MBool a_hasParent(const MInt cellId) const { return m_tree.hasParent(cellId); }
101
103 MBool a_hasParent(const MInt cellId, const MInt solverId) const {
104 return m_tree.hasParent(cellId) && m_tree.solver(m_tree.parent(cellId), solverId);
105 }
106
108 MLong& a_childId(const MInt cellId, const MInt pos) { return m_tree.child(cellId, pos); }
109
111 MLong a_childId(const MInt cellId, const MInt pos) const { return m_tree.child(cellId, pos); }
112
114 MLong a_childId(const MInt cellId, const MInt pos, const MInt solverId) const {
115 return (m_tree.child(cellId, pos) > -1 && m_tree.solver(m_tree.child(cellId, pos), solverId))
116 ? m_tree.child(cellId, pos)
117 : -1;
118 }
119
121
123 MInt& a_level(const MInt cellId) { return m_tree.level(cellId); }
124
126 MInt a_level(const MInt cellId) const { return m_tree.level(cellId); }
127
129 MFloat a_workload(const MInt cellId) const { return m_tree.workload(cellId); }
130
132 MFloat& a_workload(const MInt cellId) { return m_tree.workload(cellId); }
133
135 MInt a_noOffsprings(const MInt cellId) const { return m_tree.noOffsprings(cellId); }
136
138 MInt& a_noOffsprings(const MInt cellId) { return m_tree.noOffsprings(cellId); }
139
141 MLong& a_globalId(const MInt cellId) { return m_tree.globalId(cellId); }
142
144 MLong a_globalId(const MInt cellId) const { return m_tree.globalId(cellId); }
145
147 MFloat& a_weight(const MInt cellId) { return m_tree.weight(cellId); }
148
150 MFloat a_weight(const MInt cellId) const { return m_tree.weight(cellId); }
151
153 MInt a_noChildren(const MInt cellId) const { return m_tree.noChildren(cellId); }
154
156 MInt a_hasChildren(const MInt cellId) const { return m_tree.hasChildren(cellId); }
157
159 MInt a_hasChildren(const MInt cellId, const MInt solverId) const { return m_tree.hasChildren(cellId, solverId); }
160
162 MInt a_hasChild(const MInt cellId, const MInt pos) const { return m_tree.hasChild(cellId, pos); }
163
165 MInt a_hasChild(const MInt cellId, const MInt pos, const MInt solverId) const {
166 return m_tree.hasChild(cellId, pos) && m_tree.solver(m_tree.child(cellId, pos), solverId);
167 }
168
170 maia::grid::cell::BitsetType::reference a_isToDelete(const MInt cellId) {
171 return m_tree.hasProperty(cellId, Cell::IsToDelete);
172 }
173
175 MBool a_isToDelete(const MInt cellId) const { return m_tree.hasProperty(cellId, Cell::IsToDelete); }
176
178 MLong& a_neighborId(const MInt cellId, const MInt dir) { return m_tree.neighbor(cellId, dir); }
179
181 MLong a_neighborId(const MInt cellId, const MInt dir) const { return m_tree.neighbor(cellId, dir); }
182
184 MLong a_neighborId(const MInt cellId, const MInt dir, const MInt solverId) const {
185 return (m_tree.neighbor(cellId, dir) > -1 && m_tree.solver(m_tree.neighbor(cellId, dir), solverId))
186 ? m_tree.neighbor(cellId, dir)
187 : -1;
188 }
189
191 MFloat& a_coordinate(const MInt cellId, const MInt dir) { return m_tree.coordinate(cellId, dir); }
192
194 MFloat a_coordinate(const MInt cellId, const MInt dir) const { return m_tree.coordinate(cellId, dir); }
195
197 template <class U>
198 MFloat a_coordinate(Collector<U>* NotUsed(cells_), const MInt cellId, const MInt dir) const {
199 return a_coordinate(cellId, dir);
200 }
201
202
204 MBool a_isLeafCell(const MInt cellId) const { return m_tree.isLeafCell(cellId); }
205
207 maia::grid::tree::SolverBitsetType::reference a_isLeafCell(const MInt cellId, const MInt solverId) {
208 return m_tree.isLeafCell(cellId, solverId);
209 }
210
212 MBool a_isLeafCell(const MInt cellId, const MInt solverId) const { return m_tree.isLeafCell(cellId, solverId); }
213
215 MBool a_hasNeighbor(const MInt cellId, const MInt dir) const { return m_tree.hasNeighbor(cellId, dir); }
216
218 MBool a_hasNeighbor(const MInt cellId, const MInt dir, const MInt solverId) const {
219 if(treeb().noSolvers() == 1 && m_tree.hasNeighbor(cellId, dir)
220 && !m_tree.solver(m_tree.neighbor(cellId, dir), solverId)) {
221 std::cerr << "mis " << cellId << " " << dir << " " << m_tree.neighbor(cellId, dir) << " " << solverId << " "
222 << m_tree.solver(m_tree.neighbor(cellId, dir), solverId) << std::endl;
223 ASSERT(false, "");
224 }
225 return m_tree.hasNeighbor(cellId, dir) && m_tree.solver(m_tree.neighbor(cellId, dir), solverId);
226 }
227
229 void a_resetProperties(const MInt cellId) { m_tree.resetProperties(cellId); }
230
232 void a_copyProperties(const MInt fromCellId, const MInt toCellId) {
233 m_tree.properties(toCellId) = m_tree.properties(fromCellId);
234 }
235
236
238 maia::grid::cell::BitsetType::reference a_hasProperty(const MInt cellId, const Cell p) {
239 return m_tree.hasProperty(cellId, p);
240 }
241
243 MBool a_hasProperty(const MInt cellId, const Cell p) const { return m_tree.hasProperty(cellId, p); }
244
246
248 MBool a_isHalo(const MInt cellId) const { return m_tree.hasProperty(cellId, Cell::IsHalo); }
249
251 maia::grid::tree::SolverBitsetType::reference a_solver(const MInt cellId, const MInt solverId) {
252 return m_tree.solver(cellId, solverId);
253 }
254
256 void setSolver(const MInt cellId, const MInt solverId, MBool flag) { m_tree.solver(cellId, solverId) = flag; }
257
259
260 MBool wasAdapted() const { return m_wasAdapted; }
261 MBool wasBalanced() const { return m_wasBalanced; }
263
267
269 std::array<MInt, 3> m_periodicCartesianDir{};
272 std::array<MFloat, 3> m_azimuthalPerCenter{};
273 std::array<MInt, 2> m_azimuthalPeriodicDir{};
280 MInt nBins[nDim];
281 MFloat* minPer3 = nullptr;
282 MFloat* maxPer3 = nullptr;
288
289 void init(MFloat angle, MInt periodicDir1, MInt periodicDir2, MInt noLayers) {
290 azimuthalAngle = angle;
291 perDir1 = periodicDir1;
292 perDir2 = periodicDir2;
293 noHaloLayers = noLayers;
294 MInt perSize1 = nBins[perDir1];
295 MInt perSize2 = nBins[perDir2];
298 mAlloc(minPer3, perSize1 * perSize2, "minPer3", std::numeric_limits<MFloat>::max(), AT_);
299 mAlloc(maxPer3, perSize1 * perSize2, "maxPer3", -std::numeric_limits<MFloat>::max(), AT_);
300 }
302 MFloat mid = center;
303 if(mid > phi) {
304 return -1;
305 } else {
306 return 1;
307 }
308 }
310 MFloat azimuthalBoundary(const MFloat* coords, MInt side) {
311 MInt perSize2 = nBins[perDir2];
312 MInt ind1 = index(coords, perDir1);
313 MInt ind2 = index(coords, perDir2);
314 if(side < 0) {
315 MFloat minPhi = center - F1B2 * azimuthalAngle; // std::numeric_limits<MFloat>::max();
316 for(MInt i = -(noHaloLayers + 1); i < (noHaloLayers + 2); i++) {
317 MInt ind1_ = ind1 + i;
318 ind1_ = mMax(0, mMin(ind1_, nBins[perDir1] - 1));
319 MInt ind2_ = ind2 + i;
320 ind2_ = mMax(0, mMin(ind2_, nBins[perDir2] - 1));
321 minPhi = mMin(minPhi, minPer3[ind1 * perSize2 + ind2_]);
322 minPhi = mMin(minPhi, minPer3[ind1_ * perSize2 + ind2]);
323 }
324 return minPhi;
325 } else if(side > 0) {
326 MFloat maxPhi = center + F1B2 * azimuthalAngle; //-std::numeric_limits<MFloat>::max();
327 for(MInt i = -(noHaloLayers + 1); i < (noHaloLayers + 2); i++) {
328 MInt ind1_ = ind1 + i;
329 ind1_ = mMax(0, mMin(ind1_, nBins[perDir1] - 1));
330 MInt ind2_ = ind2 + i;
331 ind2_ = mMax(0, mMin(ind2_, nBins[perDir2] - 1));
332 maxPhi = mMax(maxPhi, maxPer3[ind1 * perSize2 + ind2_]);
333 maxPhi = mMax(maxPhi, maxPer3[ind1_ * perSize2 + ind2]);
334 }
335 return maxPhi;
336 } else {
337 mTerm(1, AT_, "side = 0?");
338 }
339 }
340 MInt index(const MFloat* coord, MInt dir) {
341 MInt ind = -1;
342 ind = (MInt)((coord[dir] - minCoord[dir]) * nBins[dir] / boxLength[dir]);
343 if(ind < 0)
344 ind = 0;
345 else if(ind >= nBins[dir])
346 ind = nBins[dir] - 1;
347
348 return ind;
349 }
350 };
352
354
355 // Marks the beginning of halo cells in the collector
357
359
368
372
373 // Grid cell volume
375
376 // File processing
378
379 template <class F>
380 MInt reduceToLevel(const MInt reductionLevel, F interpolateToParentCells);
381
386 MFloat cellLengthAtLevel(const MInt level) const { return m_lengthLevel0 * FFPOW2(level); }
388 MFloat cellLengthAtCell(const MInt cellId) const { return cellLengthAtLevel(a_level(cellId)); }
390 MFloat halfCellLength(const MInt cellId) const { return F1B2 * cellLengthAtCell(cellId); }
391 MFloat cellVolumeAtLevel(const MInt level) const {
392 return (nDim == 3) ? POW3(cellLengthAtLevel(level)) : POW2(cellLengthAtLevel(level));
393 }
394
406 void boundingBox(MFloat* const box) const { std::copy_n(&m_boundingBox[0], 2 * nDim, box); }
407
409 const MFloat* globalBoundingBox() const { return &m_boundingBox[0]; }
410
418 void centerOfGravity(MFloat* const center) const { std::copy_n(m_centerOfGravity, nDim, center); }
419
427
430
432 MInt noNeighborDomains() const { return (signed)m_nghbrDomains.size(); }
433
435 const MInt& neighborDomain(const MInt id) const { return m_nghbrDomains[id]; }
436
438 const std::vector<MInt>& neighborDomains() const { return m_nghbrDomains; }
439
441 const MLong& domainOffset(const MInt id) const { return m_domainOffsets[id]; }
442
444 MInt noHaloCells(const MInt domainId) const { return m_haloCells[domainId].size(); }
445 constexpr MBool paraViewPlugin() const { return m_paraViewPlugin; }
446
448 MInt haloCell(const MInt domainId, const MInt cellId) const { return m_haloCells[domainId][cellId]; }
449
450 // Returns vector of halo cells
451 const std::vector<std::vector<MInt>>& haloCells() const { return m_haloCells; };
452
454 MInt noWindowCells(const MInt domainId) const { return m_windowCells[domainId].size(); }
455
457 MInt windowCell(const MInt domainId, const MInt cellId) const { return m_windowCells[domainId][cellId]; }
458
459 // Returns vector of window cells
460 const std::vector<std::vector<MInt>>& windowCells() const { return m_windowCells; };
461
462 //
463 MInt windowLayer(const MInt domainId, const MInt cellId, const MInt solverId) const {
464 return m_windowLayer_[domainId].at(cellId).get(solverId);
465 }
466
467 MBool isSolverWindowCell(const MInt domainId, const MInt cellId, const MInt solverId) const {
468#ifndef NDEBUG
469 if(m_windowLayer_[domainId].find(cellId) != m_windowLayer_[domainId].end()
470 && m_windowLayer_[domainId].at(cellId).get(solverId) <= m_noSolverHaloLayers[solverId])
471 TERMM_IF_COND(!m_tree.solver(cellId, solverId), "");
472#endif
473 return m_windowLayer_[domainId].find(cellId) != m_windowLayer_[domainId].end()
474 && m_windowLayer_[domainId].at(cellId).get(solverId) <= m_noSolverHaloLayers[solverId];
475 }
476
477 MInt noSolverWindowCells(const MInt domainId, const MInt solverId) const {
478 MInt cnt = 0;
479 for(const auto& cellId : m_windowCells[domainId]) {
480 ASSERT(m_windowLayer_[domainId].find(cellId) != m_windowLayer_[domainId].end(), "");
481 if(m_windowLayer_[domainId].at(cellId).get(solverId) <= m_noSolverHaloLayers[solverId]) {
482 ASSERT(m_tree.solver(cellId, solverId), "");
483 ++cnt;
484 }
485 }
486 return cnt;
487 }
488
489 MInt noSolverHaloCells(const MInt domainId, const MInt solverId, const MBool periodicCells) const {
490 MInt cnt = 0;
491 for(const auto& cellId : m_haloCells[domainId]) {
492 if(m_tree.solver(cellId, solverId)) {
493 if(periodicCells || !a_hasProperty(cellId, Cell::IsPeriodic)) ++cnt;
494 }
495 }
496 return cnt;
497 }
498
500 MInt noAzimuthalNeighborDomains() const { return (signed)m_azimuthalNghbrDomains.size(); }
501
503 const MInt& azimuthalNeighborDomain(const MInt id) const { return m_azimuthalNghbrDomains[id]; }
504
506 const std::vector<MInt>& azimuthalNeighborDomains() const { return m_azimuthalNghbrDomains; }
507
510
512 MInt azimuthalHaloCell(const MInt domainId, const MInt cellId) const {
513 return m_azimuthalHaloCells[domainId][cellId];
514 }
515
516 // Returns vector of azimuthal Halo cells
517 const std::vector<std::vector<MInt>>& azimuthalHaloCells() const { return m_azimuthalHaloCells; };
518
519 // Returns number of unmapped azimuthal halo cells
521
522 // Returns unmapped azimuthal halo cell id
523 MInt azimuthalUnmappedHaloCell(const MInt cellId) const { return m_azimuthalUnmappedHaloCells[cellId]; };
524
525 // Returns unmapped azimuthal halo cell id
527
530
532 MInt azimuthalWindowCell(const MInt domainId, const MInt cellId) const {
533 return m_azimuthalWindowCells[domainId][cellId];
534 }
535
536 // Returns vector of azimuthal window cells
537 const std::vector<std::vector<MInt>>& azimuthalWindowCells() const { return m_azimuthalWindowCells; };
540
543
546
549
551 MInt centerOfGravity(MInt dir) const { return m_centerOfGravity[dir]; }
552
554 MInt noMinCells() const { return m_minLevelCells.size(); }
555
557 MInt minCell(const MInt id) const { return m_minLevelCells[id]; }
558
561
563 MInt noHaloLayers() const { return m_noHaloLayers; }
564 constexpr MInt noHaloLayers(const MInt solverId) const { return m_noSolverHaloLayers[solverId]; }
565 // WH_old
566 MInt haloMode() const { return m_haloMode; }
567
569 MInt periodicCartesianDir(const MInt dir) const { return m_periodicCartesianDir[dir]; }
571 MFloat gridCellVolume(const MInt level) const { return m_gridCellVolume[level]; }
573 void tagAzimuthalHigherLevelExchangeCells(std::vector<MLong>&, /*std::vector<MLong>&,*/ std::vector<MLong>&, MInt);
574 void tagAzimuthalUnmappedHaloCells(std::vector<std::vector<MLong>>&, std::vector<MLong>&, std::vector<MInt>&, MInt);
576
578 constexpr MInt noPartitionCells() const { return m_noPartitionCells; }
580
581 void gridSanityChecks();
582 void checkWindowHaloConsistency(const MBool fullCheck = false, const MString a = "");
584 void dumpCellData(const MString name);
585
588
589 private:
593
594 // Remove the following line once transition to new grid format is complete
595 // (see also setupWindowHaloCellConnectivity())
597
601
608
611
612 // Maximum number of grid cells
614
615 // Window/Halo related props
618 // solver number of haloLayers
620
621 // Holds the ids of the adjacent domains
622 std::vector<MInt> m_nghbrDomains;
623
624 // Holds the ids of the adjacent azimuthal domains
625 std::vector<MInt> m_azimuthalNghbrDomains;
626
627 // Holds the Backup for to-be-deleted periodic-neighbor-Links
628 std::vector<std::tuple<MInt, MInt, MInt>> m_neighborBackup;
629
630 // Holds the reverse-direction-Information
631 const MInt m_revDir[6] = {1, 0, 3, 2, 5, 4};
632
633 std::vector<std::vector<MInt>> m_windowCells;
634
635 // Holds the ids of the halo cells according to original adjacent domain
636 std::vector<std::vector<MInt>> m_haloCells;
637
638 /* m_windowLayer_[nghbrDomId][cellId][solverId] stores the window layer of this cell w.r.t.
639 * solverId. The entries are initialized by the higheset possible value of 15 (corresponding
640 * to all bits set to 1), which indicates that cell is no window, so effectively allowed range is
641 * noHaloLayers<15. Note that this is not exactly the windowLayer, but an auxiliary value
642 * required by the algorithm.
643 */
644 std::vector<std::unordered_map<MInt, M32X4bit<true>>> m_windowLayer_;
645 static constexpr const auto WINDOWLAYER_MAX = decltype(m_windowLayer_)::value_type::mapped_type::MAX;
646
647 // Azimuthal periodicity exchange data
648 std::vector<std::vector<MInt>> m_azimuthalHigherLevelConnectivity;
649 std::vector<std::vector<MInt>> m_azimuthalWindowCells;
650 std::vector<std::vector<MInt>> m_azimuthalHaloCells;
653 std::vector<MInt> m_gridBndryCells;
654
655 // maximum size of a partitionCell (important for efficient distribution of cells)
658
659 // offset array
661
662 // save the offsets of the local partitionCells and the globalIds of the local partitionCells for later use (e.g. the
663 // particle restarting) chrs 26.11
667 MLong m_localPartitionCellOffsets[3]{static_cast<MLong>(-1), static_cast<MLong>(-1), static_cast<MLong>(-1)};
671
672 // Indicates that the partition cells are currently being updated (e.g. to handle the case when
673 // there are 0 local partition cells temporarily before balancing)
675 // Indicate if the partition cells have been updated/changed during balancing
677
680
684
686
687 std::vector<MInt> m_minLevelCells{};
688
690
697
698 private:
700
703 std::vector<MInt> m_partitionLevelAncestorIds{};
704
707 std::vector<std::vector<MInt>> m_partitionLevelAncestorHaloCells{};
708 std::vector<std::vector<MInt>> m_partitionLevelAncestorWindowCells{};
709
710
711 MInt** m_neighborList = nullptr;
712
715
718
720
722
724
727
728 public:
729 // Data structures for neighbor find and walk algorithms
730 // Number of possible paths for 1D neighbors
732 // Number of possible paths for 2D neighbors
734 // Number of possible paths for 3D neighbors
736
737 // Holds all possible paths to 1D neighbors
738 MInt* m_paths1D = nullptr;
739 // Holds all possible paths to 2D neighbors
740 MInt** m_paths2D = nullptr;
741 // Holds all possible paths to 3D neighbors
742 MInt** m_paths3D = nullptr;
743
744 // 2D: 11 elements, 3D: 43 elements
745 std::array<MInt, 11 + (nDim - 2) * 32> m_neighborCode{};
746
748 std::map<MLong, MInt> m_globalToLocalId{};
749
750 // Status flag for additional LB grid checks
754
755 std::set<MInt> m_freeIndices;
756
757 // Mapping from domainId to neighborDomainId
758 std::vector<MInt> m_nghbrDomainIndex;
759
760 // Mapping from domainId to azimuthalNeighborDomainId
763 MLong m_localPartitionCellOffsetsRestart[3]{static_cast<MLong>(-1), static_cast<MLong>(-1), static_cast<MLong>(-1)};
764
765 private:
766 // Store the MPI communicator to use for all MPI communication
767 const MPI_Comm m_mpiComm;
772 static constexpr MInt m_noDirs = 2 * nDim;
773 static constexpr MInt m_maxNoChilds = IPOW2(nDim);
774 // Jannik TODO labels:GRID for now needed for testcase hack -> change tagActiveWindows
776
777 public:
778 CartesianGrid(MInt maxCells, const MFloat* const bBox, const MPI_Comm comm, const MString& fileName = "");
780
782 // Accessor to tree is named "treeb" to indicate that this is the tree of the base grid and not a
783 // solver-specific grid tree
784 Tree& treeb() { return m_tree; }
785 const Tree& treeb() const { return m_tree; }
786
787 static constexpr MInt m_maxNoSensors = 64;
788
789 MInt maxLevel() const { return m_maxLevel; };
790 MInt minLevel() const { return m_minLevel; };
791
794
795
796 // Return maximum number of cells
797 MInt maxNoCells() const { return m_maxNoCells; };
798
800 MPI_Comm mpiComm() const { return m_mpiComm; }
801
803 MLong bitOffset() const { return m_32BitOffset; }
804
806 template <MBool t_correct = false>
807 MInt findContainingPartitionCell(const MFloat* const coord, const MInt solverId = -1,
808 std::function<MFloat*(MInt, MFloat* const)> correctCellCoord = nullptr);
809
810 // Return the cell Id of the partition cell intersecting with a sphere
811 MInt intersectingWithPartitioncells(MFloat* const center, MFloat const radius);
812
813 MInt intersectingWithHaloCells(MFloat* const center, MFloat const radius, MInt domainId, MBool onlyPartition);
814
815 MBool intersectingWithLocalBoundingBox(MFloat* const center, MFloat const radius);
816
817 MBool boxSphereIntersection(const MFloat* bMin, const MFloat* bMax, const MFloat* const sphereCenter,
818 MFloat const radius);
819
820 MBool hollowBoxSphereIntersection(const MFloat* bMin, const MFloat* bMax, const MFloat* const sphereCenter,
821 MFloat const radius);
822
824 inline MInt ancestorPartitionCellId(const MInt cellId) const;
825
827 inline MInt findContainingHaloPartitionCell(const MFloat* const coors, const MInt solverId = -1);
828
830 template <MBool t_correct = false>
831 MInt findContainingHaloCell(const MFloat* const coord, const MInt solverId, MInt domainId, MBool onlyPartitionCells,
832 std::function<MFloat*(MInt, MFloat* const)> correctCellCoord = nullptr);
833
835 template <MBool t_correct = false>
837 std::function<MFloat*(MInt, MFloat* const)> correctCellCoord = nullptr,
838 const MInt solverId = -1);
839
840 template <MBool t_correct = false>
841 MInt findContainingLeafCell(const std::array<MFloat, nDim>& coord, const MInt startId,
842 std::function<MFloat*(MInt, MFloat* const)>* correctCellCoord = nullptr,
843 const MInt solverId = -1, const MBool allowNonLeafHalo = false) {
844 return findContainingLeafCell<t_correct>(&coord[0], startId, correctCellCoord, solverId, allowNonLeafHalo);
845 }
846 template <MBool t_correct = false>
847 MInt findContainingLeafCell(const MFloat* const coord, const MInt startId,
848 std::function<MFloat*(MInt, MFloat* const)> correctCellCoord = nullptr,
849 const MInt solverId = -1, const MBool allowNonLeafHalo = false);
850
851 template <MBool t_correct = false, MBool insideLimit>
852 inline MBool pointWthCell(const std::array<MFloat, nDim>& coord, const MInt cellId,
853 std::function<MFloat*(MInt, MFloat* const)> correctCellCoord = nullptr) const {
854 return pointWthCell<t_correct, insideLimit>(&coord[0], cellId, correctCellCoord);
855 }
856
857 template <MBool t_correct = false, MBool insideLimit>
858 inline MBool pointWthCell(const MFloat* const coord, const MInt cellId,
859 std::function<MFloat*(MInt, MFloat* const)> correctCellCoord = nullptr) const;
860
861 inline MFloat* dummyCorrect(const MInt cellId, MFloat* coords) {
862 std::copy(&a_coordinate(cellId, 0), &a_coordinate(cellId, nDim - 1), coords);
863 return coords;
864 }
865
867 void computeLocalBoundingBox(MFloat* const bbox);
868
871
872 void propagateDistance(std::vector<MInt>& list, MIntScratchSpace& distMem, MInt dist);
873 void propagationStep(MInt cellId, MInt dist, MInt* distMem, MInt endDist);
874
875 template <typename DATATYPE>
876 void exchangeNotInPlace(DATATYPE* exchangeVar, DATATYPE* recvMem);
877 template <typename DATATYPE>
878 void generalExchange(MInt noVars, const MInt* vars, DATATYPE** exchangeVar, MInt noDomSend, MInt* domSend,
879 const MInt* noCellsSendPerDom, const MInt* cellIdsSend, MInt noDomRecv, MInt* domRecv,
880 const MInt* noCellsRecvPerDom, const MInt* cellIdsRecv);
881
882 // Create a 2D slice gird from 3D grid
883 void createGridSlice(const MString& axis, const MFloat intercept, const MString& fileName);
884 void createGridSlice(const MString& axis, const MFloat intercept, const MString& fileName, const MInt solverId,
885 MInt* const noSliceCellIds, MInt* const sliceCellIds, MInt* const noSliceHilbertIds = nullptr,
886 MInt* const sliceHilbertInfo = nullptr, MInt* const noSliceContHilbertIds = nullptr,
887 MInt* const sliceContiguousHilbertInfo = nullptr);
888
889 void computeGlobalIds();
890 void localToGlobalIds();
891 void descendNoOffsprings(const MLong cellId, const MLong offset = 0);
892 void storeMinLevelCells(const MBool updateMinlevel = false);
893 void computeLeafLevel();
894 void determineNoPartitionCellsAndOffsets(MLong* const noPartitionCells, MLong* const partitionCellOffsets);
895
896 void determinePartLvlAncestorHaloWindowCells(std::vector<std::vector<MInt>>& partLvlAncestorHaloCells,
897 std::vector<std::vector<MInt>>& partLvlAncestorWindowCells);
898
899 void balance(const MInt* const noCellsToReceiveByDomain, const MInt* const noCellsToSendByDomain,
900 const MInt* const sortedCellId, const MLong* const offset, const MLong* const globalIdOffsets);
901
902 MBool updatePartitionCells(MInt offspringThreshold, MFloat workloadThreshold);
903 MLong generateHilbertIndex(const MInt cellId, const MInt targetMinLevel) {
905 targetMinLevel);
906 }
907
908 private:
911 void descendStoreGlobalId(MInt cellId, MInt& localCnt);
912 void refineCell(const MInt cellId, const MLong* const refineChildIds = nullptr, const MBool mayHaveChildren = false,
913 const std::vector<std::function<MInt(const MFloat*, const MInt, const MInt)>>& =
914 std::vector<std::function<MInt(const MFloat*, const MInt, const MInt)>>(),
915 const std::bitset<maia::grid::tree::Tree<nDim>::maxNoSolvers()> refineFlag =
917 void removeChilds(const MInt cellId);
918 template <MBool removeChilds>
919 void removeCell(const MInt cellId);
920 MInt deleteCell(const MInt cellId);
921 void createPaths();
922 void setLevel();
924
925 void setGridInputFilename(MBool = false);
926 void loadGridFile(const MInt, const MInt);
927
928 MLong hilbertIndexGeneric(const MFloat* const coords, const MFloat* const center, const MFloat length0,
929 const MInt baseLevel) const;
930
931 inline MLong hilbertIndexGeneric(const MFloat* const coords) const {
933 }
934
935 MLong generateHilbertIndex(const MInt cellId) { return hilbertIndexGeneric(&a_coordinate(cellId, 0)); }
936
937 template <class ITERATOR, typename U>
938 MInt findIndex(ITERATOR, ITERATOR, const U&);
939 template <typename TA, typename TB, typename TC>
940 MInt setNeighborDomainIndex(const MInt, std::vector<TA>&, std::vector<TB>&, std::vector<TC>&);
941 template <typename TA, typename TB>
942 MInt setNeighborDomainIndex(const MInt, std::vector<TA>&, std::vector<TB>&);
943
944 MInt setAzimuthalNeighborDomainIndex(const MInt, std::vector<std::vector<MInt>>&, std::vector<std::vector<MInt>>&);
945 MInt setAzimuthalNeighborDomainIndex(const MInt, std::vector<std::vector<MInt>>&, std::vector<std::vector<MLong>>&);
946
947 template <std::size_t N>
948 void exchangeSolverBitset(std::bitset<N>* const data, const MBool defaultVal = false);
949 void checkWindowLayer(const MString a);
950
951 public:
952 void saveGrid(const MChar*, const std::vector<std::vector<MInt>>&, const std::vector<std::vector<MInt>>&,
953 const std::vector<std::vector<MInt>>&, const std::vector<MInt>&, const std::vector<std::vector<MInt>>&,
954 MInt* recalcIdTree = nullptr);
955 void saveGrid(const MChar*, MInt* recalcIdTree);
956 void savePartitionFile();
957 void loadPartitionFile(const MString& partitionFileName, MLong* partitionCellOffsets);
959
960 void deletePeriodicConnection(const MBool = true);
964 };
965 MInt findNeighborDomainId(const MLong globalId, const MInt noDomains, const MLong* domainOffsets);
966
967 void createLeafCellMapping(const MInt donorSolverId, const MInt gridCellId, std::vector<MInt>& mappedLeafCells,
968 MBool allChilds = false);
969 MInt globalIdToLocalId(const MLong& globalId, const MBool termIfNotExisting = false);
970
971 private:
972 void loadGrid(const MString& fileName);
973 void resetCell(const MInt& cellId);
975 void createGridMap(const MString& donorGridFileName, const MString& gridMapFileName);
976 void saveDonorGridPartition(const MString& gridMapFileName, const MString& gridPartitionFileName);
977 void loadDonorGridPartition(const MLong* const partitionCellsId, const MInt noPartitionCells);
978
979 void savePartitionFile(const MString& partitionFileNameBase, const MLong partitionCellOffset);
980
981 template <typename CELLTYPE>
982 void calculateNoOffspringsAndWorkload(Collector<CELLTYPE>* input_cells, MInt input_noCells);
983 void partitionParallel(const MInt tmpCount, const MLong tmpOffset, const MFloat* const partitionCellsWorkload,
984 const MLong* const partitionCellsGlobalId, const MFloat totalWorkload,
985 MLong* partitionCellOffsets, MLong* globalIdOffsets, MBool computeOnlyPartition = false);
986
988 void tagActiveWindows(std::vector<MLong>&, MInt);
989 void tagActiveWindows2_(std::vector<MLong>&, const MInt);
991 const MInt maxLevel, const MBool duringMeshAdaptation,
992 const std::vector<std::function<void(const MInt)>>& = std::vector<std::function<void(const MInt)>>());
994 MInt getAdjacentGridCells(MInt, MIntScratchSpace&, MInt, MBool diagonalNeighbors = true);
995 template <MBool finer, MBool coarser>
996 inline MInt getAdjacentGridCells5(const MInt, MInt* const, const MInt level = -1,
997 const MBool diagonalNeighbors = true);
998 template <MBool finer, MBool coarser>
999 inline void getAdjacentGridCells1d5(std::set<MInt>&, const MInt, const MInt, const MInt dimNext = -1,
1000 const MInt dimNextNext = -1, const uint_fast8_t childCodes = (uint_fast8_t)~0);
1004 const MInt onlyLevel = -1, const MBool duringMeshAdaptation = false,
1005 const std::vector<std::function<void(const MInt)>>& = std::vector<std::function<void(const MInt)>>(),
1006 const std::vector<std::function<void(const MInt)>>& = std::vector<std::function<void(const MInt)>>(),
1007 const MBool forceLeafLvlCorrection = false);
1009 const MInt onlyLevel = -1,
1010 const std::vector<std::function<void(const MInt)>>& = std::vector<std::function<void(const MInt)>>());
1011 MInt createAdjacentHaloCell(const MInt, const MInt, const MLong*, std::unordered_multimap<MLong, MInt>&,
1012 const MFloat*, MInt* const, std::vector<std::vector<MInt>>&,
1013 std::vector<std::vector<MLong>>&);
1014 MInt createAzimuthalHaloCell(const MInt, const MInt, const MLong*, std::unordered_multimap<MLong, MInt>&,
1015 const MFloat*, MInt* const, std::vector<std::vector<MInt>>&,
1016 std::vector<std::vector<MLong>>&);
1017 void meshAdaptation(std::vector<std::vector<MFloat>>&, std::vector<MFloat>&, std::vector<std::bitset<64>>&,
1018 std::vector<MInt>&, const std::vector<std::function<void(const MInt)>>&,
1019 const std::vector<std::function<void(const MInt)>>&,
1020 const std::vector<std::function<void(const MInt)>>&,
1021 const std::vector<std::function<void(const MInt, const MInt)>>&,
1022 const std::vector<std::function<MInt(const MFloat*, const MInt, const MInt)>>&,
1023 const std::vector<std::function<void()>>&);
1024 void meshAdaptationLowMem(std::vector<std::vector<MFloat>>&, std::vector<MFloat>&, std::vector<std::bitset<64>>&,
1025 std::vector<MInt>&, const std::vector<std::function<void(const MInt)>>&,
1026 const std::vector<std::function<void(const MInt)>>&,
1027 const std::vector<std::function<void(const MInt)>>&,
1028 const std::vector<std::function<void(const MInt, const MInt)>>&,
1029 const std::vector<std::function<MInt(const MFloat*, const MInt, const MInt)>>&,
1030 const std::vector<std::function<void()>>&);
1031
1032 void meshAdaptationDefault(std::vector<std::vector<MFloat>>&, std::vector<MFloat>&, std::vector<std::bitset<64>>&,
1033 std::vector<MInt>&, const std::vector<std::function<void(const MInt)>>&,
1034 const std::vector<std::function<void(const MInt)>>&,
1035 const std::vector<std::function<void(const MInt)>>&,
1036 const std::vector<std::function<void(const MInt, const MInt)>>&,
1037 const std::vector<std::function<MInt(const MFloat*, const MInt, const MInt)>>&,
1038 const std::vector<std::function<void()>>&);
1039
1040
1041 void compactCells(const std::vector<std::function<void(const MInt, const MInt)>>& =
1042 std::vector<std::function<void(const MInt, const MInt)>>());
1043 void swapCells(const MInt cellId, const MInt otherId);
1044 MBool refineCheck(const MInt cellId, const MInt solverId,
1045 const std::vector<std::function<MInt(const MFloat*, const MInt, const MInt)>>& cellOutsideSolver);
1046 MBool coarsenCheck(const MInt cellId, const MInt solverId);
1047 void exchangeProperties();
1048 void setChildSolverFlag(const MInt cellId, const MInt solver,
1049 const std::function<MInt(const MFloat*, const MInt, const MInt)>& cellOutsideSolver);
1050
1051 public:
1054 MInt noDomains() const { return m_noDomains; }
1055
1057 MInt domainId() const { return m_domainId; }
1058
1059 void cartesianToCylindric(const MFloat*, MFloat*);
1061
1062 private:
1063 // holds the domain id
1065
1067 MBool isMpiRoot() const { return domainId() == 0; }
1068};
1069
1070
1089template <MInt nDim>
1090template <class F>
1091MInt CartesianGrid<nDim>::reduceToLevel(const MInt reductionLevel, F interpolateToParentCells) {
1092 TRACE();
1093 // 1. before we delete, generate a copy of the global ids for the domains so
1094 // that we can identify them later (as the global id will not be updated
1095 // during delete cell)
1096 std::vector<std::vector<MInt>> old_globalhaloCells, old_globalwindowCells;
1097
1098 for(MInt i = 0; i < noNeighborDomains(); i++) {
1099 std::vector<MInt> tmp_halo;
1100 std::vector<MInt> tmp_window;
1101 for(MInt j = 0; j < (signed)m_haloCells[i].size(); j++) {
1102 tmp_halo.push_back(a_globalId(m_haloCells[i][j]));
1103 }
1104 for(MInt j = 0; j < (signed)m_windowCells[i].size(); j++) {
1105 tmp_window.push_back(a_globalId(m_windowCells[i][j]));
1106 }
1107 old_globalhaloCells.push_back(tmp_halo);
1108 old_globalwindowCells.push_back(tmp_window);
1109 }
1110
1111 // 2. we need to realloc m_haloCells and m_windowCells so that we
1112 // suit the requirements of saveGridDomainPar
1113 m_haloCells.clear();
1114 m_windowCells.clear();
1115 m_haloCells.resize(noDomains());
1116 m_windowCells.resize(noDomains());
1117
1118 // 3. Delete all cells that are above a certain level, interpolate all
1119 // finer cells to coarser cells
1120 for(MInt level = m_maxLevel; level > reductionLevel; level--) {
1121 interpolateToParentCells(level - 1);
1122 for(MInt c = m_tree.size() - 1; c >= 0; c--) {
1123 if(a_level(c) == level) {
1124 deleteCell(c);
1125 }
1126 }
1127 }
1128 m_noInternalCells = m_tree.size();
1129
1130 // 4. Update window and halo cell arrays
1131
1132 for(MInt c = 0; c < m_tree.size(); c++) {
1133 if(a_hasProperty(c, Cell::IsHalo)) {
1134 MInt nghr = -1;
1135 for(MInt i = 0; i < noNeighborDomains(); i++) {
1136 for(std::size_t j = 0; j < old_globalhaloCells[i].size(); j++)
1137 if(a_globalId(c) == old_globalhaloCells[i][j]) {
1138 nghr = i;
1139 break;
1140 }
1141 if(nghr != -1) {
1142 break;
1143 }
1144 }
1145 m_haloCells[m_nghbrDomains[nghr]].push_back(c);
1146
1147 } else if(a_hasProperty(c, Cell::IsWindow)) {
1148 MInt nghr = -1;
1149 std::vector<MInt> t;
1150 for(MInt i = 0; i < noNeighborDomains(); i++) {
1151 for(std::size_t j = 0; j < old_globalwindowCells[i].size(); j++)
1152 if(a_globalId(c) == old_globalwindowCells[i][j]) {
1153 nghr = i;
1154 t.push_back(i);
1155 break;
1156 }
1157 if(nghr != -1) {
1158 continue;
1159 }
1160 }
1161 for(MInt& i : t) {
1162 m_windowCells[m_nghbrDomains[i]].push_back(c);
1163 }
1164 }
1165 }
1166
1167
1168 // Update the number of internal cells
1169 for(MInt i = 0; i < noDomains(); i++) {
1170 m_noInternalCells -= (signed)m_haloCells[i].size();
1171 }
1172
1173 // 5. Update m_domainOffsets
1174 MIntScratchSpace rcvBufRed(noDomains(), AT_, "rcvBufRed");
1175
1176 // fill buffer and exchange
1177 MPI_Allgather(&(m_noInternalCells), 1, MPI_INT, rcvBufRed.begin(), 1, MPI_INT, mpiComm(), AT_, "(m_noInternalCells)",
1178 "rcvBufRed.begin()");
1179
1180 // put the result into the array
1181 MInt offset = 0;
1182 for(MInt i = 0; i < noDomains(); i++) {
1183 m_domainOffsets[i] = offset;
1184 offset += rcvBufRed[i];
1185 }
1186 // the last element holds the total number
1187 m_domainOffsets[noDomains()] = offset;
1188
1189 return rcvBufRed[domainId()];
1190}
1191
1192#endif
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
Definition: alloc.h:173
MBool mDeallocate(T *&a)
deallocates the memory previously allocated for element 'a'
Definition: alloc.h:544
void a_resetProperties(const MInt cellId)
Returns property p of the cell cellId.
void refineCell(const MInt cellId, const MLong *const refineChildIds=nullptr, const MBool mayHaveChildren=false, const std::vector< std::function< MInt(const MFloat *, const MInt, const MInt)> > &=std::vector< std::function< MInt(const MFloat *, const MInt, const MInt)> >(), const std::bitset< maia::grid::tree::Tree< nDim >::maxNoSolvers()> refineFlag=std::bitset< maia::grid::tree::Tree< nDim >::maxNoSolvers()>(1ul))
MFloat gridCellVolume(const MInt level) const
MInt * m_identicalSolverLvlJumps
const MBool m_paraViewPlugin
MInt m_maxLevel
The max Level of refinement of the solver length.
MInt noDomains() const
MLong * m_domainOffsets
static constexpr const auto WINDOWLAYER_MAX
MInt createAzimuthalHaloCell(const MInt, const MInt, const MLong *, std::unordered_multimap< MLong, MInt > &, const MFloat *, MInt *const, std::vector< std::vector< MInt > > &, std::vector< std::vector< MLong > > &)
Create a new azimuthal halo cell as neighbor of cellId in direction dir and find matching neighbor do...
MBool checkOutsideAzimuthalDomain(MFloat *)
void getAdjacentGridCells1d5(std::set< MInt > &, const MInt, const MInt, const MInt dimNext=-1, const MInt dimNextNext=-1, const uint_fast8_t childCodes=(uint_fast8_t)~0)
MLong a_neighborId(const MInt cellId, const MInt dir, const MInt solverId) const
Returns the neighbor id of the cell cellId dir.
MInt noHaloCells(const MInt domainId) const
Return number of halo cells for given domain.
std::vector< MInt > m_azimuthalNghbrDomainIndex
MBool hollowBoxSphereIntersection(const MFloat *bMin, const MFloat *bMax, const MFloat *const sphereCenter, MFloat const radius)
MFloat cellVolumeAtLevel(const MInt level) const
MInt maxUniformRefinementLevel() const
Return maximum homogeneously-refined level.
MBool a_isToDelete(const MInt cellId) const
Returns the delete of the cell cellId.
const MPI_Comm m_mpiComm
MInt findIndex(ITERATOR, ITERATOR, const U &)
Find index in array [first,last) with matching entry 'val'.
MLong noPartitionCellsGlobal() const
static constexpr MInt nDim_()
Definition: cartesiangrid.h:75
MLong a_neighborId(const MInt cellId, const MInt dir) const
Returns the neighbor id of the cell cellId dir.
std::vector< MInt > m_azimuthalUnmappedHaloDomains
MLong a_childId(const MInt cellId, const MInt pos, const MInt solverId) const
Returns the child id of the cell cellId at position pos.
MFloat m_partitionCellWorkloadThreshold
std::array< MInt, 3 > m_periodicCartesianDir
void tagActiveWindowsOnLeafLvl3(const MInt maxLevel, const MBool duringMeshAdaptation, const std::vector< std::function< void(const MInt)> > &=std::vector< std::function< void(const MInt)> >())
Don't touch this function, because you don't know what you are doing NOTE: Actually the most clever w...
MBool a_hasParent(const MInt cellId) const
Returns if the cell cellId has a parent.
void rotateCartesianCoordinates(MFloat *, MFloat)
Rotate caresian coordinates by angle. Azimuthal periodic center is used.
void restorePeriodicConnection()
Delete the Connection of periodic-Halo-Cells at the bounding box.
void calculateNoOffspringsAndWorkload(Collector< CELLTYPE > *input_cells, MInt input_noCells)
Caluclate the number of offsprings and the workload for each cell.
void checkWindowHaloConsistency(const MBool fullCheck=false, const MString a="")
Checks consistency of window/halo cells.
MBool m_addSolverToGrid
static constexpr MInt m_maxNoSensors
const std::vector< std::vector< MInt > > & azimuthalWindowCells() const
MString m_gridInputFileName
MInt periodicCartesianDir(const MInt dir) const
MInt ** m_neighborList
MBool m_allowInterfaceRefinement
void tagAzimuthalUnmappedHaloCells(std::vector< std::vector< MLong > > &, std::vector< MLong > &, std::vector< MInt > &, MInt)
Tag azimuthal halo cells for refinement.
MInt m_maxUniformRefinementLevel
void computeGlobalIds()
Update number of internal cells, recalculate domain offsets, recalculate global ids for all internal ...
void meshAdaptation(std::vector< std::vector< MFloat > > &, std::vector< MFloat > &, std::vector< std::bitset< 64 > > &, std::vector< MInt > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt, const MInt)> > &, const std::vector< std::function< MInt(const MFloat *, const MInt, const MInt)> > &, const std::vector< std::function< void()> > &)
MInt ancestorPartitionCellId(const MInt cellId) const
Return the cell Id of the partition cell that has the given cellId as a descendant.
MInt a_noChildren(const MInt cellId) const
Returns the no. of children of the cell cellId.
MFloat & a_weight(const MInt cellId)
Returns the weight of the cell cellId.
MFloat * dummyCorrect(const MInt cellId, MFloat *coords)
MInt * m_identicalSolvers
void loadGridFile(const MInt, const MInt)
Load grid from disk and setup communication.
MString gridInputFileName() const
Return grid file name.
void updateHaloCellCollectors()
Fill m_nghbrDomains, m_haloCells and m_windowCells with data from temporary buffers.
MInt * m_noSolverHaloLayers
void determineNoPartitionCellsAndOffsets(MLong *const noPartitionCells, MLong *const partitionCellOffsets)
Determine the number of partition cells on each domain and the corresponding offsets.
MString m_restartDir
friend class FvBndryCnd2D
Definition: cartesiangrid.h:59
MInt m_noPartitionLevelAncestors
Local number of partition level ancestors on this domain (without halos)
MInt maxPartitionLevelShift() const
MInt windowCell(const MInt domainId, const MInt cellId) const
Return window cell id.
constexpr MInt noHaloLayers(const MInt solverId) const
std::vector< MLong > m_partitionLevelAncestorChildIds
MInt noAzimuthalNeighborDomains() const
Return number of azimuthal neighbor domains.
MInt minCell(const MInt id) const
Return min-level cell id.
MLong m_noCellsGlobal
std::vector< MInt > m_gridBndryCells
MInt noWindowCells(const MInt domainId) const
Return number of window cells for given domain.
MFloat a_weight(const MInt cellId) const
Returns the weight of the cell cellId.
maia::grid::cell::BitsetType::reference a_hasProperty(const MInt cellId, const Cell p)
Returns property p of the cell cellId.
MString a_propertiesToString(const MInt cellId)
constexpr MInt noPartitionCells() const
MInt m_partitionCellOffspringThreshold
MInt m_noIdenticalSolvers
MLong a_parentId(const MInt cellId, const MInt solverId) const
Returns the parent of the cell cellId.
Definition: cartesiangrid.h:95
const MInt & neighborDomain(const MInt id) const
Return neighbor domain.
MBool pointInLocalBoundingBox(const MFloat *coord)
Check if the given point lies in the local bounding box.
MBool m_hasMultiSolverBoundingBox
MBool wasBalancedAtLeastOnce() const
std::vector< std::vector< MInt > > m_azimuthalWindowCells
MInt m_noMinLevelCellsGlobal
MInt noNeighborDomains() const
Return number of neighbor domains.
MBool m_localBoundingBoxInit
MInt globalIdToLocalId(const MLong &globalId, const MBool termIfNotExisting=false)
Global to local id mapping.
MInt * m_identicalSolverMaxLvl
MLong generateHilbertIndex(const MInt cellId, const MInt targetMinLevel)
MLong generateHilbertIndex(const MInt cellId)
void savePartitionCellWorkloadsGridFile()
Update the partition cell workloads in the grid file.
MInt maxLevel() const
MInt m_azimuthalAxialDir
void descendStoreGlobalId(MInt cellId, MInt &localCnt)
Recursively descend subtree to reset global id for internal cells.
MInt * m_localPartitionCellLocalIdsRestart
std::vector< std::vector< MInt > > m_windowCells
MInt findContainingPartitionCell(const MFloat *const coord, const MInt solverId=-1, std::function< MFloat *(MInt, MFloat *const)> correctCellCoord=nullptr)
Return the cell Id of the partition cell containing the coords.
void meshAdaptationDefault(std::vector< std::vector< MFloat > > &, std::vector< MFloat > &, std::vector< std::bitset< 64 > > &, std::vector< MInt > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt, const MInt)> > &, const std::vector< std::function< MInt(const MFloat *, const MInt, const MInt)> > &, const std::vector< std::function< void()> > &)
Performs mesh adaptation and continuously updates the window/halo cells.
MLong m_localPartitionCellOffsetsRestart[3]
friend class FvBndryCnd3D
Definition: cartesiangrid.h:61
maia::grid::tree::SolverBitsetType::reference a_solver(const MInt cellId, const MInt solverId)
Returns if cell cellId is used by solver solverId.
MLong m_localPartitionCellOffsets[3]
MInt ** m_paths2D
void tagActiveWindows(std::vector< MLong > &, MInt)
Flag m_noHaloLayers layers of halo cells adjacent to internal cells on this domain.
MLong hilbertIndexGeneric(const MFloat *const coords, const MFloat *const center, const MFloat length0, const MInt baseLevel) const
Return the hilbert index for the given coordinates in 2D/3D.
std::vector< std::vector< MInt > > m_partitionLevelAncestorWindowCells
MBool intersectingWithLocalBoundingBox(MFloat *const center, MFloat const radius)
const MInt & azimuthalNeighborDomain(const MInt id) const
Return azimuthal neighbor domain.
MBool pointWthCell(const std::array< MFloat, nDim > &coord, const MInt cellId, std::function< MFloat *(MInt, MFloat *const)> correctCellCoord=nullptr) const
void determinePartLvlAncestorHaloWindowCells(std::vector< std::vector< MInt > > &partLvlAncestorHaloCells, std::vector< std::vector< MInt > > &partLvlAncestorWindowCells)
Store partition level ancestor window/halo cells.
void tagActiveWindowsAtMinLevel(const MInt)
Actually the most clever way of tagging is to go from highest level to lower levels,...
void compactCells(const std::vector< std::function< void(const MInt, const MInt)> > &=std::vector< std::function< void(const MInt, const MInt)> >())
Removes all holes in the cell collector and moves halo cells to the back of the collector.
std::vector< MInt > m_azimuthalNghbrDomains
void computeLocalBoundingBox(MFloat *const bbox)
Compute the bounding box of all local cells.
MInt noSolverHaloCells(const MInt domainId, const MInt solverId, const MBool periodicCells) const
MBool a_hasNeighbor(const MInt cellId, const MInt dir, const MInt solverId) const
Returns noNeighborIds of the cell CellId.
const std::vector< MInt > & azimuthalNeighborDomains() const
Return vector of azimuthal neighbor domains.
MBool m_wasBalancedAtLeastOnce
MInt findNeighborDomainId(const MLong globalId)
MBool a_isLeafCell(const MInt cellId) const
Returns whether cell is leaf cellId.
void saveGrid(const MChar *, const std::vector< std::vector< MInt > > &, const std::vector< std::vector< MInt > > &, const std::vector< std::vector< MInt > > &, const std::vector< MInt > &, const std::vector< std::vector< MInt > > &, MInt *recalcIdTree=nullptr)
MBool m_updatePartitionCellsOnRestart
void exchangeNotInPlace(DATATYPE *exchangeVar, DATATYPE *recvMem)
communicates a variable from windows to halos but does not overwrite halo values. Window values are s...
MInt m_noPartitionCells
void changeGlobalToLocalIds()
Change global child/neighbor/parent cell ids into local cell ids. Requires that m_globalToLocalId con...
void centerOfGravity(MFloat *const center) const
MInt noMinCells() const
Return the number of Cells on the minLevel.
maia::grid::cell::BitsetType::reference a_isToDelete(const MInt cellId)
Returns the delete of the cell cellId.
MInt centerOfGravity(MInt dir) const
Return the center of gravity.
MPI_Comm mpiComm() const
Return the MPI communicator used by this grid.
void saveDonorGridPartition(const MString &gridMapFileName, const MString &gridPartitionFileName)
Create and store donor grid partition for volume-coupled simulations.
void balance(const MInt *const noCellsToReceiveByDomain, const MInt *const noCellsToSendByDomain, const MInt *const sortedCellId, const MLong *const offset, const MLong *const globalIdOffsets)
Balance the grid according to the given cell send/recv counts.
MInt a_noOffsprings(const MInt cellId) const
Returns the noOffsprings of the cell .
MLong noCellsGlobal() const
Return the Global-noCells.
void setGridInputFilename(MBool=false)
Read grid file name from properties or restart files.
MInt m_maxPartitionLevelShift
void createMinLevelExchangeCells()
Create window-halo-connectivity based on hilbertIndex matching for regular and periodic exchange cell...
MInt findContainingHaloCell(const MFloat *const coord, const MInt solverId, MInt domainId, MBool onlyPartitionCells, std::function< MFloat *(MInt, MFloat *const)> correctCellCoord=nullptr)
Return the cell id of the halo partition cell containing the coords.
MInt findContainingLeafCell(const std::array< MFloat, nDim > &coord, const MInt startId, std::function< MFloat *(MInt, MFloat *const)> *correctCellCoord=nullptr, const MInt solverId=-1, const MBool allowNonLeafHalo=false)
MFloat m_targetGridCenterOfGravity[3]
void correctAzimuthalSolverBits()
Corrects solver bits on azimuthal halo cells Ensure that azimuthal halo cells have all children or ar...
MFloat m_azimuthalAngle
MFloat m_centerOfGravity[3]
coordinates of the root cell
std::vector< std::tuple< MInt, MInt, MInt > > m_neighborBackup
MInt noHaloLayers() const
Return noHalo-a_noHaloLayers.
MFloat m_coarseRatio
void boundingBox(MFloat *const box) const
MLong m_noPartitionLevelAncestorsGlobal
MInt m_decisiveDirection
void createHigherLevelExchangeCells_old(const MInt onlyLevel=-1, const std::vector< std::function< void(const MInt)> > &=std::vector< std::function< void(const MInt)> >())
Iteratively create window and halo cells on levels m_minLevel+1...m_maxLevel, starting from m_minLeve...
void createPaths()
Necessary for extractPointIdsFromGrid function.
MInt & a_level(const MInt cellId)
Returns the level of the cell cellId.
MInt haloCell(const MInt domainId, const MInt cellId) const
Return halo cell id.
MInt a_level(const MInt cellId) const
Returns the level of the cell cellId.
MInt ** m_paths3D
MLong a_globalId(const MInt cellId) const
Returns the globalId of the cell cellId in collector cells_.
void descendNoOffsprings(const MLong cellId, const MLong offset=0)
void generalExchange(MInt noVars, const MInt *vars, DATATYPE **exchangeVar, MInt noDomSend, MInt *domSend, const MInt *noCellsSendPerDom, const MInt *cellIdsSend, MInt noDomRecv, MInt *domRecv, const MInt *noCellsRecvPerDom, const MInt *cellIdsRecv)
void exchangeProperties()
Exchange properties of window/halo cells.
std::vector< MInt > m_nghbrDomainIndex
MInt maxNoCells() const
MInt noAzimuthalHaloCells(const MInt domainId) const
Return number of azimuthal Halo cells for given domain.
MBool isSolverWindowCell(const MInt domainId, const MInt cellId, const MInt solverId) const
MBool * m_diagSmoothing
MBool coarsenCheck(const MInt cellId, const MInt solverId)
checks if the given cell's children may be removed
MBool boxSphereIntersection(const MFloat *bMin, const MFloat *bMax, const MFloat *const sphereCenter, MFloat const radius)
MBool hasCutOff() const
Returns weather the grid has a cutOff.
Definition: cartesiangrid.h:83
MFloat m_periodicCartesianLength[3]
const MInt m_revDir[6]
MFloat * m_gridCellVolume
void propagateDistance(std::vector< MInt > &list, MIntScratchSpace &distMem, MInt dist)
propagates a given distance from a given list of cells on equal level neighbours
void savePartitionFile()
Save current grid partitioning to file.
std::vector< MInt > m_nghbrDomains
std::vector< std::vector< MInt > > m_haloCells
std::vector< std::vector< MInt > > m_azimuthalHaloCells
void storeMinLevelCells(const MBool updateMinlevel=false)
Store cell ids of all min-level cells.
const MLong & domainOffset(const MInt id) const
Return domain offset.
MFloat m_lengthLevel0
The initial length of the solver.
MInt intersectingWithHaloCells(MFloat *const center, MFloat const radius, MInt domainId, MBool onlyPartition)
MBool m_updatedPartitionCells
MBool m_lbGridChecks
void removeChilds(const MInt cellId)
removes the children of the given cell
MLong localPartitionCellOffsets(const MInt index) const
const std::vector< std::vector< MInt > > & azimuthalHaloCells() const
MInt a_hasChildren(const MInt cellId, const MInt solverId) const
Returns if the cell cellId has children.
MBool addSolverToGrid()
MInt m_newMinLevel
The new min Level which has been increased at the restart!
MInt setNeighborDomainIndex(const MInt, std::vector< TA > &, std::vector< TB > &, std::vector< TC > &)
Find neighbor domain index or create new if not existing.
MBool a_isHalo(const MInt cellId) const
Returns property p of the cell cellId.
std::vector< MInt > m_partitionLevelAncestorNghbrDomains
std::array< MFloat, 3 > m_azimuthalPerCenter
MBool a_isLeafCell(const MInt cellId, const MInt solverId) const
Returns whether cell is leaf cellId.
const std::vector< std::vector< MInt > > & haloCells() const
void setUpdatedPartitionCells(const MBool flag)
void initGridMap()
void setLevel()
Set minimum und maximum cell levels.
MBool m_loadPartition
std::vector< std::unordered_map< MInt, M32X4bit< true > > > m_windowLayer_
void setSolver(const MInt cellId, const MInt solverId, MBool flag)
Sets if cell is used by solver.
MInt m_minLevel
The min Level of refinement of the solver length.
MBool m_updatingPartitionCells
MInt windowLayer(const MInt domainId, const MInt cellId, const MInt solverId) const
MInt m_noPeriodicCartesianDirs
MInt azimuthalHaloCell(const MInt domainId, const MInt cellId) const
Return azimuthal Halo cell id.
MLong & a_childId(const MInt cellId, const MInt pos)
Returns the child id of the cell cellId at position pos.
MLong bitOffset() const
Return the 32-BitOffset.
void setupWindowHaloCellConnectivity()
Create window and halo cell connectivity between domains.
void tagActiveWindows2_(std::vector< MLong > &, const MInt)
NOTE: Actually the most clever way of tagging is to go from highest level to lower levels,...
MInt getAdjacentGridCells5(const MInt, MInt *const, const MInt level=-1, const MBool diagonalNeighbors=true)
MFloat halfCellLength(const MInt cellId) const
Returns the half cell length of cell cellId.
MLong m_noPartitionCellsGlobal
MFloat a_coordinate(Collector< U > *NotUsed(cells_), const MInt cellId, const MInt dir) const
Returns the coordinate of the cell cellId in collector cells_ for direction dir.
void cartesianToCylindric(const MFloat *, MFloat *)
Transform cartesian cell coordinate to cylindrcal coordinats using the / using the azimuthal periodic...
MInt noAzimuthalUnmappedHaloCells() const
constexpr MBool paraViewPlugin() const
MInt intersectingWithPartitioncells(MFloat *const center, MFloat const radius)
MLong a_parentId(const MInt cellId) const
Returns the parent of the cell cellId.
Definition: cartesiangrid.h:92
MInt findContainingHaloPartitionCell(const MFloat *const coors, const MInt solverId=-1)
Return the cell id of the halo partition cell containing the coords.
MInt targetGridMinLevel() const
MBool updatePartitionCells(MInt offspringThreshold, MFloat workloadThreshold)
Determine new partition cells (i.e. in/decrease the partition level shifts) and change the grid accor...
void a_copyProperties(const MInt fromCellId, const MInt toCellId)
Returns property p of the cell cellId.
void meshAdaptationLowMem(std::vector< std::vector< MFloat > > &, std::vector< MFloat > &, std::vector< std::bitset< 64 > > &, std::vector< MInt > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt)> > &, const std::vector< std::function< void(const MInt, const MInt)> > &, const std::vector< std::function< MInt(const MFloat *, const MInt, const MInt)> > &, const std::vector< std::function< void()> > &)
Performs mesh adaptation and continuously updates the window/halo cells.
MFloat a_workload(const MInt cellId) const
Returns the workload of the cell cellId.
const Tree & treeb() const
MInt * m_localPartitionCellLocalIds
std::map< MLong, MInt > m_globalToLocalId
Mapping: global cell id -> local cell id.
void propagationStep(MInt cellId, MInt dist, MInt *distMem, MInt endDist)
starts the propagation on a cell and continues calling the function for the neighbours
MInt minLevel() const
void setChildSolverFlag(const MInt cellId, const MInt solver, const std::function< MInt(const MFloat *, const MInt, const MInt)> &cellOutsideSolver)
const MFloat * globalBoundingBox() const
return global Bounding box
MLong a_childId(const MInt cellId, const MInt pos) const
Returns the child id of the cell cellId at position pos.
MFloat cellLengthAtCell(const MInt cellId) const
Returns the cell length of cell cellId.
void deletePeriodicConnection(const MBool=true)
Delete the Connection of periodic-Halo-Cells at the bounding box.
MInt a_hasChild(const MInt cellId, const MInt pos) const
Returns if the cell cellId has a child at position pos.
MFloat m_boundingBox[6]
MFloat m_reductionFactor
MBool a_hasNeighbor(const MInt cellId, const MInt dir) const
Returns noNeighborIds of the cell CellId.
void partitionParallel(const MInt tmpCount, const MLong tmpOffset, const MFloat *const partitionCellsWorkload, const MLong *const partitionCellsGlobalId, const MFloat totalWorkload, MLong *partitionCellOffsets, MLong *globalIdOffsets, MBool computeOnlyPartition=false)
MInt m_referenceSolver
MInt createAdjacentHaloCell(const MInt, const MInt, const MLong *, std::unordered_multimap< MLong, MInt > &, const MFloat *, MInt *const, std::vector< std::vector< MInt > > &, std::vector< std::vector< MLong > > &)
Create a new halo cell (candidate) as neighbor of cellId in direction dir and find matching neighbor ...
MBool updatedPartitionCells() const
MBool wasBalanced() const
void createGridMap(const MString &donorGridFileName, const MString &gridMapFileName)
Create file that contains mapping from donor to target cell.
MFloat lengthLevel0() const
Return the length of the level 0 cell.
MFloat m_boundingBoxBackup[6]
MLong * m_localPartitionCellGlobalIds
MInt * MInt_dyn_array
Definition: cartesiangrid.h:76
MBool refineCheck(const MInt cellId, const MInt solverId, const std::vector< std::function< MInt(const MFloat *, const MInt, const MInt)> > &cellOutsideSolver)
checks if the given cell may be refined
MInt deleteCell(const MInt cellId)
Deletes a cell (without collector fragmentation) and returns new collector size.
void createGridSlice(const MString &axis, const MFloat intercept, const MString &fileName)
Overload method of createGridSlice to provide usage with or without return of cellIds which are in th...
std::vector< MInt > m_partitionLevelAncestorIds
Partition level shift.
MFloat & a_coordinate(const MInt cellId, const MInt dir)
Returns the coordinate of the cell cellId for direction dir.
void exchangeSolverBitset(std::bitset< N > *const data, const MBool defaultVal=false)
MInt & a_noOffsprings(const MInt cellId)
Returns the noOffsprings of the cell .
const std::vector< std::vector< MInt > > & windowCells() const
Tree & treeb()
Full access to tree (for now)
azimuthalBbox m_azimuthalBbox
MFloat periodicCartesianLength(const MInt dir) const
MInt azimuthalUnmappedHaloCell(const MInt cellId) const
MInt findContainingLeafCell(const MFloat *coord, std::function< MFloat *(MInt, MFloat *const)> correctCellCoord=nullptr, const MInt solverId=-1)
Return the cell Id of the leaf cell containing the coords.
MBool a_hasParent(const MInt cellId, const MInt solverId) const
Returns if the cell cellId has a parent.
void computeLeafLevel()
Compute distance to leaf level.
MBool m_partitionParallelSplit
std::set< MInt > m_freeIndices
const MInt m_maxNoNghbrs
MLong & a_globalId(const MInt cellId)
Returns the globalId of the cell cellId in collector cells_.
std::vector< MInt > m_azimuthalUnmappedHaloCells
MBool m_lowMemAdaptation
std::vector< std::vector< MInt > > m_partitionLevelAncestorHaloCells
Tree m_tree
Store the tree.
MInt haloMode() const
static constexpr MInt m_noDirs
MString m_outputDir
MLong hilbertIndexGeneric(const MFloat *const coords) const
MFloat & a_workload(const MInt cellId)
Returns the workload of the cell cellId.
MBool m_azimuthalPer
void dumpCellData(const MString name)
Write the cell data of the local tree to some file for debugging purposes.
MBool * m_checkRefinementHoles
void checkAzimuthalWindowHaloConsistency()
Checks consistency of aimuthal window/halo cells.
MFloat m_localBoundingBox[6]
Local bounding box for fast checking if a point lies outside the local domain.
MInt a_hasChildren(const MInt cellId) const
Returns if the cell cellId has children.
void removeCell(const MInt cellId)
removes the children of the given cell
MInt azimuthalWindowCell(const MInt domainId, const MInt cellId) const
Return azimuthal window cell id.
MFloat m_targetGridLengthLevel0
MInt getAdjacentGridCells(MInt, MIntScratchSpace &, MInt, MBool diagonalNeighbors=true)
Retrieves all direct and diagonal neighboring cells of the given cell on the child level if available...
void swapCells(const MInt cellId, const MInt otherId)
swap two cells; the window/halo cell arrays have to be update elsewhere for performance reasons
void createGlobalToLocalIdMapping()
Create the mapping from global to local cell ids.
MInt maxRefinementLevel() const
Return maximum possible refinement level.
MLong & a_parentId(const MInt cellId)
Returns the parent of the cell cellId.
Definition: cartesiangrid.h:89
void tagAzimuthalHigherLevelExchangeCells(std::vector< MLong > &, std::vector< MLong > &, MInt)
Tag azimuthal halo cells for refinement.
MInt m_noInternalCells
typename Tree::Cell Cell
Definition: cartesiangrid.h:80
void gridSanityChecks()
Perform grid sanity checks.
std::vector< std::vector< MInt > > m_azimuthalHigherLevelConnectivity
MInt domainId() const
Return the domainId (rank)
MInt noSolverWindowCells(const MInt domainId, const MInt solverId) const
MInt noAzimuthalWindowCells(const MInt domainId) const
Return number of azimuthal window cells for given domain.
void localToGlobalIds()
Convert parent ids, neighbor ids, and child ids from local to global cell ids.
MInt localPartitionCellLocalIds(const MInt id) const
MBool m_loadGridPartition
std::array< MInt, 2 > m_azimuthalPeriodicDir
MLong & a_neighborId(const MInt cellId, const MInt dir)
Returns the neighbor id of the cell cellId dir.
void resetCell(const MInt &cellId)
Reset cell to default values.
MFloat m_targetGridBoundingBox[6]
Multisolver grid information.
MBool isMpiRoot() const
Return true if this is domain zero (a.k.a. as the root domain)
static constexpr MInt m_maxNoChilds
CartesianGrid(MInt maxCells, const MFloat *const bBox, const MPI_Comm comm, const MString &fileName="")
MInt findContainingLeafCell(const MFloat *const coord, const MInt startId, std::function< MFloat *(MInt, MFloat *const)> correctCellCoord=nullptr, const MInt solverId=-1, const MBool allowNonLeafHalo=false)
std::vector< MInt > m_minLevelCells
void loadDonorGridPartition(const MLong *const partitionCellsId, const MInt noPartitionCells)
Return partition cell offsets based on grid partition file.
void updatePartitionCellInformation()
Update the partition cell local/global ids and the partition cell global offsets.
MInt noInternalCells() const
Return number of internal cells (i.e., excluding halo cells)
MFloat cellLengthAtLevel(const MInt level) const
Returns cell length at cell level level.
MInt reduceToLevel(const MInt reductionLevel, F interpolateToParentCells)
Reduces the current grid to a certain level.
MInt m_noHaloPartitionLevelAncestors
MInt m_targetGridMinLevel
MInt a_hasChild(const MInt cellId, const MInt pos, const MInt solverId) const
Returns if the cell cellId has a child at position pos.
MInt setAzimuthalNeighborDomainIndex(const MInt, std::vector< std::vector< MInt > > &, std::vector< std::vector< MInt > > &)
Find azimuthal neighbor domain index or create new if not existing.
void createLeafCellMapping(const MInt donorSolverId, const MInt gridCellId, std::vector< MInt > &mappedLeafCells, MBool allChilds=false)
Identify all leaf cells of one solver which are mapped to a given grid cell.
MBool a_hasProperty(const MInt cellId, const Cell p) const
Returns property p of the cell cellId.
MFloat a_coordinate(const MInt cellId, const MInt dir) const
Returns the coordinate of the cell cellId for direction dir.
const std::vector< MInt > & neighborDomains() const
Return vector of neighbor domains.
void createHigherLevelExchangeCells(const MInt onlyLevel=-1, const MBool duringMeshAdaptation=false, const std::vector< std::function< void(const MInt)> > &=std::vector< std::function< void(const MInt)> >(), const std::vector< std::function< void(const MInt)> > &=std::vector< std::function< void(const MInt)> >(), const MBool forceLeafLvlCorrection=false)
Iteratively create window and halo cells on levels m_minLevel+1...m_maxLevel, starting from m_minLeve...
constexpr MBool allowInterfaceRefinement() const
void loadGrid(const MString &fileName)
Load a grid file writen with saveGridDomainPar.
void checkWindowLayer(const MString a)
Checks variable m_windowLayer_.
MInt azimuthalUnmappedHaloDomain(const MInt cellId) const
MBool m_allowCoarsening
void loadPartitionFile(const MString &partitionFileName, MLong *partitionCellOffsets)
Load a grid partitioning from a file.
MBool wasAdapted() const
MFloat reductionFactor() const
Return the reductionFactor.
std::array< MInt, 11+(nDim - 2) *32 > m_neighborCode
maia::grid::tree::SolverBitsetType::reference a_isLeafCell(const MInt cellId, const MInt solverId)
Returns whether cell is leaf cellId.
This class is a ScratchSpace.
Definition: scratch.h:758
iterator begin()
Definition: scratch.h:273
constexpr MInt size() const
Return size (i.e., currently used number of nodes)
Definition: container.h:89
Grid controller manages adaptation and load balancing in multi-solver environment.
Class that represents grid tree and contains all relevant per-node data.
MBool hasChild(const MInt id, const MInt pos) const
Return whether node has child at given position.
MInt noChildren(const MInt id) const
Return number of children of given node.
SolverBitsetType::reference solver(const MInt id, const MInt solverId)
Accessor for solver usage.
MFloat & weight(const MInt id)
Accessor for weight.
MString propertiesToString(const MInt id) const
Convert properties to string.
MBool hasParent(const MInt id) const
Return whether node has parent.
MInt & noOffsprings(const MInt id)
Accessor for noOffsprings.
MLong & globalId(const MInt id)
Accessor for global id.
MLong & neighbor(const MInt id, const MInt dir)
Accessor for neighbor node.
PropertyBitsetType & properties(const MInt id)
Accessor for properties.
MLong & parent(const MInt id)
Accessor for parent node.
MBool hasNeighbor(const MInt id, const MInt dir) const
Return whether node has same-level neighbor in given direction.
MFloat & workload(const MInt id)
Accessor for workload.
MInt & level(const MInt id)
Accessor for level.
MBool isLeafCell(const MInt id) const
Accessor for isLeafCell usage (const version).
PropertyBitsetType::reference hasProperty(const MInt id, const Cell p)
Accessor for properties.
MLong & child(const MInt id, const MInt pos)
Accessor for child node.
void resetProperties(const MInt id)
Reset all properties.
maia::grid::tree::Cell Cell
MFloat & coordinate(const MInt id, const MInt dim)
Accessor for coordinates.
MBool hasChildren(const MInt id) const
Return whether node has any children.
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
constexpr Real POW3(const Real x)
Definition: functions.h:123
constexpr Real POW2(const Real x)
Definition: functions.h:119
constexpr T mMin(const T &x, const T &y)
Definition: functions.h:90
constexpr T mMax(const T &x, const T &y)
Definition: functions.h:94
constexpr MLong IPOW2(MInt x)
constexpr MFloat FFPOW2(MInt x)
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
MInt noSolvers
Definition: maiatypes.h:73
double MFloat
Definition: maiatypes.h:52
int64_t MLong
Definition: maiatypes.h:64
bool MBool
Definition: maiatypes.h:58
char MChar
Definition: maiatypes.h:56
MInt id
Definition: maiatypes.h:71
int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allgather
Namespace for auxiliary functions/classes.
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
Definition: pointbox.h:54
MFloat azimuthalBoundary(const MFloat *coords, MInt side)
MInt index(const MFloat *coord, MInt dir)
MInt azimuthalSide(const MFloat phi)
void init(MFloat angle, MInt periodicDir1, MInt periodicDir2, MInt noLayers)
Definition: contexttypes.h:19