13#ifndef CD_COMPUTATIONALGEOMETRY_H
14#define CD_COMPUTATIONALGEOMETRY_H
23#include <EBGeometry.hpp>
27#include <GeometryService.H>
28#include <MFIndexSpace.H>
31#include <ProblemDomain.H>
38#include <CD_NamespaceHeader.H>
56 static constexpr int K = 4;
61 using Vec3 = EBGeometry::Vec3T<Real>;
66 using BV = EBGeometry::BoundingVolumes::AABBT<Real>;
73 using BoxTree = EBGeometry::BVH::PackedBVH<Real, int, K, EBGeometry::BVH::ValueStorage<int>>;
89 const Vector<Dielectric>&
96 const Vector<Electrode>&
154 const RefCountedPtr<MultiFluidIndexSpace>&
161 const RefCountedPtr<BaseIF>&
168 const RefCountedPtr<BaseIF>&
176 const RefCountedPtr<BaseIF>&
200 makeGrids(
const ProblemDomain& a_startDomain,
201 const ProblemDomain& a_stopDomain,
202 const RealVect& a_probLo,
203 const Real a_startDx,
204 const Real a_refineAngle,
205 const int a_maxGhostEB,
206 const int a_minBlockSize,
207 const int a_maxBlockSize);
230 GeometryService::InOut
231 classify(const Box& a_box, const
int a_level, const
phase::which_phase a_phase) const;
245 GeometryService::InOut
246 classify(const Box& a_box, const ProblemDomain& a_domain, const
phase::which_phase a_phase) const;
265 ownedPieces(std::vector<std::vector<std::pair<
int, Box>>>& a_pieces, const Box& a_box, const
int a_level) const;
275 ownedPart(Vector<Box>& a_owned, const Box& a_tile, const
int a_level) const;
317 getLevel(const ProblemDomain& a_domain) const noexcept;
327 getBoxes(const
phase::which_phase a_phase, const
int a_level, const GeometryService::InOut a_type) const noexcept;
335 getBoxes(const
int a_level) const noexcept;
355 getSplitBoxes(Vector<
int>& a_reasons, const
int a_level) const noexcept;
363 const Vector<GeometryService::InOut>&
364 getTypes(const
phase::which_phase a_phase, const
int a_level) const noexcept;
372 getDomain(const
int a_level) const noexcept;
383 irregCells(const
phase::which_phase a_phase, const ProblemDomain& a_domain) const;
394 irregGrids(const
phase::which_phase a_phase, const ProblemDomain& a_domain) const;
402 getDx(const
int a_level) const noexcept;
418 const RealVect& a_probLo,
419 const Real a_finestDx,
420 const
int a_nCellMax,
421 const
int a_maxGhostEB,
422 const
int a_maxCoarsen = -1);
632 Vector<Vector<GeometryService::InOut>>&
640 const Vector<Vector<GeometryService::InOut>>&
678 buildFinerLevels(Vector<Vector<int>>& a_firstChild, Vector<Vector<int>>& a_numChildren);
692 Vector<GeometryService::InOut>& a_gasTypes,
693 Vector<GeometryService::InOut>& a_solidTypes)
const;
708 const Vector<GeometryService::InOut>& a_gasTypes,
709 const Vector<GeometryService::InOut>& a_solidTypes)
const;
739 GeometryService::InOut
868 const BaseFab<bool>& a_refined)
const;
913 classifyTiles(Vector<Vector<GeometryService::InOut>>& a_gasTileTypes,
914 Vector<Vector<GeometryService::InOut>>& a_solidTileTypes,
915 Vector<Vector<int>>& a_tileHosts,
916 const Vector<Vector<int>>& a_firstChild,
917 const Vector<Vector<int>>& a_numChildren)
const;
952 std::shared_ptr<BoxTree>
953 buildTree(
const Vector<Box>& a_boxes)
const;
963 meeting(
const std::shared_ptr<BoxTree>& a_tree,
const Vector<Box>& a_boxes,
const Box& a_box);
1013 boxesMeeting(
const int a_level,
const Box& a_box)
const;
1022 tilesMeeting(
const int a_level,
const Box& a_box)
const;
1031 containingBox(
const int a_level,
const IntVect& a_cell)
const;
1054 decimateBoxes(
const Vector<Vector<GeometryService::InOut>>& a_gasTileTypes,
1055 const Vector<Vector<GeometryService::InOut>>& a_solidTileTypes,
1056 const Vector<Vector<int>>& a_tileHosts);
1092 const ProblemDomain& a_finestDomain,
1093 const RealVect& a_probLo,
1094 const Real a_finestDx);
1105 const ProblemDomain& a_finestDomain,
1106 const RealVect& a_probLo,
1107 const Real a_finestDx);
1110#include <CD_NamespaceFooter.H>
Declaration of an electrode class.
Declaration of an axis-aligned box in space.
int m_maxBlockSize
Super-tile size, in cells; the size every box makeGrids makes is split to. ComputationalGeometry....
Definition CD_ComputationalGeometry.H:542
virtual void buildGeometries(const ProblemDomain &a_finestDomain, const RealVect &a_probLo, const Real a_finestDx, const int a_nCellMax, const int a_maxGhostEB, const int a_maxCoarsen=-1)
Build geometries and the MFIndexSpace.
Definition CD_ComputationalGeometry.cpp:248
bool tagUnresolvedSeams(Vector< IntVectSet > &a_tags) const
Tag the cells on the coarse side of a level boundary that the level above it would cross twice,...
Definition CD_ComputationalGeometry.cpp:1918
void reportGrids() const
Report the boxes and tiles of every level to pout.
Definition CD_ComputationalGeometry.cpp:2441
bool hasTwistedPatch(const Box &a_box, const int a_level, const phase::which_phase a_phase) const
Whether any cut cell of the box holds an interface patch that is twisted about its own centre.
Definition CD_ComputationalGeometry.cpp:1640
std::shared_ptr< BoxTree > buildTree(const Vector< Box > &a_boxes) const
Build one spatial index over a list of boxes.
Definition CD_ComputationalGeometry.cpp:2068
const RefCountedPtr< BaseIF > & getGasImplicitFunction() const
Get the implicit function used to generate the gas-phase EBIS.
Definition CD_ComputationalGeometry.cpp:158
Vector< std::shared_ptr< BoxTree > > m_boxTrees
Spatial index over the boxes of every level, one tree per level, holding the boxes' indices into m_bo...
Definition CD_ComputationalGeometry.H:579
bool doublyCrossedEdge(const Box &a_box, const int a_level, const phase::which_phase a_phase) const
Whether a cell edge of a box is crossed twice by the surface at the spacing of the level above it.
Definition CD_ComputationalGeometry.cpp:1459
void ownedPart(Vector< Box > &a_owned, const Box &a_tile, const int a_level) const
The cells of one cut tile that its level owns: the tile less what the next level's tiles hold.
Definition CD_ComputationalGeometry.cpp:827
Vector< Vector< GeometryService::InOut > > & types(const phase::which_phase a_phase) noexcept
The per-level classifications of one phase.
Definition CD_ComputationalGeometry.cpp:1114
const RefCountedPtr< BaseIF > & getImplicitFunction(const phase::which_phase a_phase) const
Get implicit function for the specified phase.
Definition CD_ComputationalGeometry.cpp:180
virtual void makeGrids(const ProblemDomain &a_startDomain, const ProblemDomain &a_stopDomain, const RealVect &a_probLo, const Real a_startDx, const Real a_refineAngle, const int a_maxGhostEB, const int a_minBlockSize, const int a_maxBlockSize)
Build the grids the index space is generated over.
Definition CD_ComputationalGeometry.cpp:377
int getNumGridLevels() const noexcept
Number of levels makeGrids built.
Definition CD_ComputationalGeometry.cpp:577
Vector< int > tilesMeeting(const int a_level, const Box &a_box) const
Cut tiles of a level that intersect a box.
Definition CD_ComputationalGeometry.cpp:2146
const Vector< Electrode > & getElectrodes() const
Get electrodes.
Definition CD_ComputationalGeometry.cpp:147
Vector< std::shared_ptr< BoxTree > > m_tileTrees
Spatial index over the cut tiles of every level, one tree per level, holding the tiles' indices into ...
Definition CD_ComputationalGeometry.H:585
Generator
Which generator to build the geometry with.
Definition CD_ComputationalGeometry.H:444
int getStartLevel() const noexcept
Level of the start domain. Every level at or below it is whole; the cut tiles begin above it.
Definition CD_ComputationalGeometry.cpp:930
Vector< Vector< GeometryService::InOut > > m_gasTypes
Gas-phase classification of each box in m_boxes, parallel to it.
Definition CD_ComputationalGeometry.H:606
static Vector< int > meeting(const std::shared_ptr< BoxTree > &a_tree, const Vector< Box > &a_boxes, const Box &a_box)
The boxes of a list that intersect a box, through the list's spatial index.
Definition CD_ComputationalGeometry.cpp:2088
void buildTileTrees()
Build the spatial index over the cut tiles of every level.
Definition CD_ComputationalGeometry.cpp:2053
void buildBoxTrees()
Build the spatial index over the boxes of every level.
Definition CD_ComputationalGeometry.cpp:2038
int getLevel(const ProblemDomain &a_domain) const noexcept
Level of a domain among the levels makeGrids built.
Definition CD_ComputationalGeometry.cpp:948
void useScanShop(const ProblemDomain &a_beginDomain)
Calls for ComputationalGeometry to use ScanShop rather than Chombo's default geometry generation tool...
Definition CD_ComputationalGeometry.cpp:96
void useChomboShop()
Calls for ComputationalGeometry to use Chombo's geometry generation tool.
Definition CD_ComputationalGeometry.cpp:122
bool m_refineSaddles
Whether a box holding a saddle – an interface patch twisted about its own centre – is split....
Definition CD_ComputationalGeometry.H:516
void makeTiles()
Step 2: tile the boxes that are irregular in either phase into one properly nested set per level.
Definition CD_ComputationalGeometry.cpp:1846
Real m_eps0
Background permittivity.
Definition CD_ComputationalGeometry.H:499
void decimateBoxes(const Vector< Vector< GeometryService::InOut > > &a_gasTileTypes, const Vector< Vector< GeometryService::InOut > > &a_solidTileTypes, const Vector< Vector< int > > &a_tileHosts)
Step 4: cut every hit box down to what the tiles left of it, and replace the lists on the tiled level...
Definition CD_ComputationalGeometry.cpp:2273
void usePolyhedralShop(const ProblemDomain &a_beginDomain)
Generate the geometry with PolyhedralGeometryShop.
Definition CD_ComputationalGeometry.cpp:110
ProblemDomain m_scanDomain
Grid level where we begin using ScanShop.
Definition CD_ComputationalGeometry.H:489
IntVectSet irregCells(const phase::which_phase a_phase, const ProblemDomain &a_domain) const
The cut cells of a phase on a domain that this rank holds.
Definition CD_ComputationalGeometry.cpp:1028
bool piercedSeamFace(const IntVect &a_cell, const int a_level, const phase::which_phase a_phase, const BaseFab< bool > &a_refined) const
Whether a face of a cell toward the level above is pierced at its middle by the surface.
Definition CD_ComputationalGeometry.cpp:1549
void setElectrodes(const Vector< Electrode > &a_electrodes)
Set electrodes.
Definition CD_ComputationalGeometry.cpp:226
void buildSolidGeometry(GeometryService *&a_geoserver, const ProblemDomain &a_finestDomain, const RealVect &a_probLo, const Real a_finestDx)
Set up the geometry generation tool for the solid phase, i.e. the part inside the dielectrics.
Definition CD_ComputationalGeometry.cpp:2528
virtual ~ComputationalGeometry()
Destructor.
Definition CD_ComputationalGeometry.cpp:87
bool m_profile
Whether makeGrids reports its levels and its timings to pout. ComputationalGeometry....
Definition CD_ComputationalGeometry.H:548
int getMaxGhostEB() const noexcept
The width, in cells, by which every box is grown before it is classified.
Definition CD_ComputationalGeometry.cpp:936
Vector< Electrode > m_electrodes
List of electrodes.
Definition CD_ComputationalGeometry.H:484
Vector< int > splitFlags(const Vector< Box > &a_boxes, const int a_level, const Vector< GeometryService::InOut > &a_gasTypes, const Vector< GeometryService::InOut > &a_solidTypes) const
Whether each box must split, the work shared between the ranks.
Definition CD_ComputationalGeometry.cpp:1288
void buildCoarserLevels()
Step 5: build the levels coarser than the start level, and push irregularity down onto every whole le...
Definition CD_ComputationalGeometry.cpp:2384
GeometryService::InOut classify(const Box &a_box, const int a_level, const phase::which_phase a_phase) const
Classify a box on a level from the grids makeGrids built.
Definition CD_ComputationalGeometry.cpp:583
Real m_refineAngle
Angle, in degrees, between neighbouring normals above which an irregular box is split.
Definition CD_ComputationalGeometry.H:504
int m_startLevel
Level of the start domain; every level below it is built whole.
Definition CD_ComputationalGeometry.H:526
Vector< Vector< int > > m_splitReasons
Per level, the reason each box in m_splitBoxes split.
Definition CD_ComputationalGeometry.H:601
Generator m_generator
Generator selected by the user.
Definition CD_ComputationalGeometry.H:453
const Vector< GeometryService::InOut > & getTypes(const phase::which_phase a_phase, const int a_level) const noexcept
Classification of every box on a level for a phase, parallel to getBoxes(level).
Definition CD_ComputationalGeometry.cpp:1012
static constexpr bool s_strictGeometry
Whether a cut cell whose body will not close stops the run.
Definition CD_ComputationalGeometry.H:437
SplitReason
Why a box split: not at all, a pair of cut cells inside the box turning too sharply,...
Definition CD_ComputationalGeometry.H:751
int m_maxGhostEB
Maximum number of ghost cells that we will ever need.
Definition CD_ComputationalGeometry.H:521
void buildFinerLevels(Vector< Vector< int > > &a_firstChild, Vector< Vector< int > > &a_numChildren)
Step 1: the upward pass, from the start level to the stop level.
Definition CD_ComputationalGeometry.cpp:1145
void ownedPieces(std::vector< std::vector< std::pair< int, Box > > > &a_pieces, const Box &a_box, const int a_level) const
Which level describes each part of a box, and through which of its cut tiles.
Definition CD_ComputationalGeometry.cpp:756
int getMinBlockSize() const noexcept
The edge of a tile, in cells of its own level.
Definition CD_ComputationalGeometry.cpp:942
static BV boundingVolume(const Box &a_box) noexcept
The bounding volume of a box in index space, its cells taken as the unit cubes they are.
Definition CD_ComputationalGeometry.cpp:2004
void buildStartLevel()
Step 0: build and classify the start level.
Definition CD_ComputationalGeometry.cpp:1130
void classifyTiles(Vector< Vector< GeometryService::InOut > > &a_gasTileTypes, Vector< Vector< GeometryService::InOut > > &a_solidTileTypes, Vector< Vector< int > > &a_tileHosts, const Vector< Vector< int > > &a_firstChild, const Vector< Vector< int > > &a_numChildren) const
Step 3: place every tile of every level in the boxes and classify it in both phases.
Definition CD_ComputationalGeometry.cpp:2170
void buildBoxTree(const int a_level)
Build the spatial index over the boxes of one level.
Definition CD_ComputationalGeometry.cpp:2023
RealVect m_probLo
Lower-left corner of the domain.
Definition CD_ComputationalGeometry.H:494
SplitReason exceedsCurvature(const Box &a_box, const int a_level, const phase::which_phase a_phase) const
Whether the interface turns by more than m_refineAngle between neighbouring cut cells of a box.
Definition CD_ComputationalGeometry.cpp:1733
EBGeometry::BVH::PackedBVH< Real, int, K, EBGeometry::BVH::ValueStorage< int > > BoxTree
Spatial index over the boxes of one level. The primitives are the boxes' indices into that level's li...
Definition CD_ComputationalGeometry.H:73
void checkOwnedPieces(const Box &a_box, const int a_level) const
Check ownedPieces on a box against a cell-by-cell reading of the tiles.
Definition CD_ComputationalGeometry.cpp:862
RefCountedPtr< PolyhedralGeometryShop > m_polyhedralShops[2]
The polyhedral generator of each phase, indexed by phase::which_phase, kept for the run: the index sp...
Definition CD_ComputationalGeometry.H:459
void buildImplicitFunctions()
Build the composite implicit functions of the two phases from the electrodes and dielectrics.
Definition CD_ComputationalGeometry.cpp:333
Vector< Vector< Box > > m_cutTiles
Cut-cell tiles per level, common to both phases.
Definition CD_ComputationalGeometry.H:568
void setDielectrics(const Vector< Dielectric > &a_dielectrics)
Set dielectrics.
Definition CD_ComputationalGeometry.cpp:215
Vector< Vector< Box > > m_boxes
Boxes per level, common to both phases.
Definition CD_ComputationalGeometry.H:573
const ProblemDomain & getDomain(const int a_level) const noexcept
Domain of a level.
Definition CD_ComputationalGeometry.cpp:1020
void buildGasGeometry(GeometryService *&a_geoserver, const ProblemDomain &a_finestDomain, const RealVect &a_probLo, const Real a_finestDx)
Set up the geometry generation tool for the gas phase.
Definition CD_ComputationalGeometry.cpp:2473
const RefCountedPtr< MultiFluidIndexSpace > & getMfIndexSpace() const
Get the multifluid index space.
Definition CD_ComputationalGeometry.cpp:204
RefCountedPtr< MultiFluidIndexSpace > m_multifluidIndexSpace
Multifluid index spaces.
Definition CD_ComputationalGeometry.H:464
void classifyBoxes(const Vector< Box > &a_boxes, const int a_level, Vector< GeometryService::InOut > &a_gasTypes, Vector< GeometryService::InOut > &a_solidTypes) const
Classify a list of boxes in both phases, the work shared between the ranks.
Definition CD_ComputationalGeometry.cpp:1220
Vector< Box > getBoxes(const phase::which_phase a_phase, const int a_level, const GeometryService::InOut a_type) const noexcept
Boxes of one classification for a phase on a level.
Definition CD_ComputationalGeometry.cpp:962
static constexpr int s_treeLeafSize
Boxes per leaf the spatial index over a level's boxes is built with.
Definition CD_ComputationalGeometry.H:922
GeometryService::InOut classifyBox(const Box &a_box, const int a_level, const phase::which_phase a_phase) const
Classify a box of one phase on one level as regular, covered or irregular.
Definition CD_ComputationalGeometry.cpp:1355
EBGeometry::BoundingVolumes::AABBT< Real > BV
Bounding volume of the spatial index over the boxes of a level.
Definition CD_ComputationalGeometry.H:66
Vector< Dielectric > m_dielectrics
List of dielectrics.
Definition CD_ComputationalGeometry.H:479
Real getGasPermittivity() const
Get the background gas permittivity.
Definition CD_ComputationalGeometry.cpp:193
int m_stopLevel
Level of the stop domain, the finest level.
Definition CD_ComputationalGeometry.H:531
const Vector< Box > & getCutTiles(const int a_level) const noexcept
The cut tiles on a level: the boxes of the level that carry cut cells or nest the level above,...
Definition CD_ComputationalGeometry.cpp:993
Vector< Vector< int > > m_splitCounts
Per level, the number of boxes that split for each SplitReason, and per level the number of tiles tha...
Definition CD_ComputationalGeometry.H:591
int m_minBlockSize
Tile size, in cells. ComputationalGeometry.min_block_size, 8 when not given.
Definition CD_ComputationalGeometry.H:536
bool m_verbose
Whether every member function announces itself in pout. ComputationalGeometry.verbose,...
Definition CD_ComputationalGeometry.H:553
Real getDx(const int a_level) const noexcept
Grid spacing of a level.
Definition CD_ComputationalGeometry.cpp:1106
static constexpr int s_maxTilePasses
Most times the tiles are built: the first build, and one more for every pass that finds a cell the le...
Definition CD_ComputationalGeometry.H:928
EBGeometry::Vec3T< Real > Vec3
Coordinate of a bounding volume of the spatial index.
Definition CD_ComputationalGeometry.H:61
const Vector< Dielectric > & getDielectrics() const
Get dielectrics.
Definition CD_ComputationalGeometry.cpp:136
ComputationalGeometry()
Constructor. Sets a blank geometry.
Definition CD_ComputationalGeometry.cpp:51
const Vector< Box > & getSplitBoxes(Vector< int > &a_reasons, const int a_level) const noexcept
The boxes that split in the upward pass on a level, with why: 1 a pair inside the box,...
Definition CD_ComputationalGeometry.cpp:1001
Vector< ProblemDomain > m_domains
Domains of the levels makeGrids builds, coarsest first.
Definition CD_ComputationalGeometry.H:558
const RefCountedPtr< BaseIF > & getSolidImplicitFunction() const
Get the implicit function used to generate the solid-phase EBIS.
Definition CD_ComputationalGeometry.cpp:169
static constexpr Real s_thresh
Threshold for Vof computation.
Definition CD_ComputationalGeometry.H:428
static constexpr int K
Branching factor of the spatial index over the boxes of a level.
Definition CD_ComputationalGeometry.H:56
int containingBox(const int a_level, const IntVect &a_cell) const
Index of the box of a level that contains a cell, which one box does on a level that is whole.
Definition CD_ComputationalGeometry.cpp:2157
Vector< Real > m_dx
Grid spacings of the levels makeGrids builds, coarsest first.
Definition CD_ComputationalGeometry.H:563
Vector< Vector< Box > > m_splitBoxes
Per level, the boxes that split in the upward pass, and why (SplitReason as an integer),...
Definition CD_ComputationalGeometry.H:596
DisjointBoxLayout irregGrids(const phase::which_phase a_phase, const ProblemDomain &a_domain) const
A layout of a phase on a domain whose boxes hold every cut cell of the phase there.
Definition CD_ComputationalGeometry.cpp:1082
RefCountedPtr< BaseIF > m_implicitFunctionGas
The gas-phase implicit function (i.e. outside electrodes and dielectrics).
Definition CD_ComputationalGeometry.H:469
Vector< int > boxesMeeting(const int a_level, const Box &a_box) const
Boxes of a level that intersect a box.
Definition CD_ComputationalGeometry.cpp:2135
RefCountedPtr< BaseIF > m_implicitFunctionSolid
The solid-phase implicit function (i.e. the inside of the dielectrics).
Definition CD_ComputationalGeometry.H:474
void setGasPermittivity(const Real a_eps0)
Set the background permittivity.
Definition CD_ComputationalGeometry.cpp:237
Vector< Vector< GeometryService::InOut > > m_solidTypes
Solid-phase classification of each box in m_boxes, parallel to it.
Definition CD_ComputationalGeometry.H:611
Geometry generation whose moments are exact integrals of an explicit surface.
Definition CD_PolyhedralGeometryShop.H:64
Derived version of GeometryShop that load balances based on the cut cells themselves.
Definition CD_ScanShop.H:32
Phase names namespace.
Definition CD_MultiFluidIndexSpace.H:28
which_phase
Enumeration of supported phases.
Definition CD_MultiFluidIndexSpace.H:38