11#ifndef EBGEOMETRY_SURFACEGROUPS_HPP
12#define EBGEOMETRY_SURFACEGROUPS_HPP
44 static constexpr uint32_t
Any = 0xFFFFFFFFU;
105 selector.
m_surface = a_surface.m_surface;
106 selector.
m_regionA = a_surface.m_ownerRegion;
107 selector.
m_regionB = a_surface.m_neighborRegion;
153 surfaces(
const uint32_t a_first,
const uint32_t a_count)
noexcept
174 selector.
m_label = a_label.value();
187 interface(
const uint32_t a_first,
const uint32_t a_second)
noexcept
258 const auto is = [](
const uint32_t a_condition,
const uint32_t a_value) {
259 return a_condition ==
Any || a_condition == a_value;
264 [&is](
const uint32_t a_first,
const uint32_t a_second,
const uint32_t a_minus,
const uint32_t a_plus) {
265 if (a_first ==
Any && a_second ==
Any) {
268 if (a_second ==
Any) {
269 return a_first == a_minus || a_first == a_plus;
272 return (is(a_first, a_minus) && is(a_second, a_plus)) || (is(a_first, a_plus) && is(a_second, a_minus));
278 return surface && is(
m_part, a_surface.m_part) && is(
m_label, a_surface.m_surfaceLabel.value()) &&
301 static constexpr uint32_t
None = 0xFFFFFFFFU;
341 const std::vector<uint32_t>& a_surfaceGroups,
342 const uint32_t a_numSurfaceGroups)
345 "SurfaceGroups: %zu selectors and %zu surface groups of them",
347 a_surfaceGroups.size());
349 this->
attach(a_pool,
"SurfaceGroups");
351 const uint32_t n =
static_cast<uint32_t
>(a_selectors.size());
357 for (uint32_t i = 0; i < n; i++) {
359 "SurfaceGroups: selector %u is in surface group %u of %u",
361 unsigned(a_surfaceGroups[i]),
362 unsigned(a_numSurfaceGroups));
459 for (
int pass = 0; pass < 2; pass++) {
460 for (uint32_t i = 0; i < n; i++) {
461 if (selectors[i].m_rest == (pass == 1) && selectors[i].matches(a_surface)) {
493static_assert(std::is_trivially_copyable_v<SurfaceGroups>,
494 "SurfaceGroups must be trivially copyable, for a kernel to take it");
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
LabelId: the number of a label, typed by what it labels (SurfaceLabelId, MaterialLabelId).
Utility macros for EBGeometry.
#define EBGEOMETRY_REQUIRE(cond,...)
Always-on check of user input and one-time host setup.
Definition EBGeometry_Macros.hpp:200
Placement-independent POD array views for the GPU memory foundation.
Growable bump arena for the GPU memory foundation.
SurfaceRef: which surface of a shape decides its value at a point, and the container protocol that na...
Base of every pool-resident handle: the one PoolLocation its arrays resolve against.
Definition EBGeometry_Pool.hpp:563
PoolLocation rebasedLocation(const Pool &a_pool, uint64_t a_endByte, const char *a_who) const noexcept
The location of this handle's arrays in another pool of its mirror chain; see PoolLocation::rebasedOn...
Definition EBGeometry_Pool.hpp:680
PoolHandle() noexcept=default
An unset location; the first reservation attaches it.
void attach(const Pool &a_pool, const char *a_who, const bool a_deviceWritten=false) noexcept
Follow a_pool, as the first reservation does; see PoolLocation::attach().
Definition EBGeometry_Pool.hpp:665
void * base() noexcept
The base address this handle's offsets resolve against; see PoolLocation::base().
Definition EBGeometry_Pool.hpp:639
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:205
A domain's surface groups, read on the host or a device: each group a set of surfaces,...
Definition EBGeometry_SurfaceGroups.hpp:296
uint32_t getNumSelectors() const noexcept
How many selectors there are, over all surface groups.
Definition EBGeometry_SurfaceGroups.hpp:407
uint32_t getSurfaceGroupOfSelector(const uint32_t a_selector) const noexcept
The surface group of a selector.
Definition EBGeometry_SurfaceGroups.hpp:431
SurfaceGroups() noexcept=default
No surface groups.
const Layout & layout() const noexcept
The arrays, as offsets.
Definition EBGeometry_SurfaceGroups.hpp:385
uint32_t surfaceGroupOf(const SurfaceRef< T > &a_surface) const noexcept
The surface group a surface point is in: that of the first selector it matches, those of the remainin...
Definition EBGeometry_SurfaceGroups.hpp:447
uint32_t getNumSurfaceGroups() const noexcept
How many surface groups there are.
Definition EBGeometry_SurfaceGroups.hpp:396
SurfaceGroups(const Layout &a_layout, const PoolLocation &a_location) noexcept
Rebuild a view from a stored layout and the location of the pool that holds it (as a Domain does).
Definition EBGeometry_SurfaceGroups.hpp:375
SurfaceGroups rebasedView(const Pool &a_pool) const noexcept
A view resolving against another pool of the selectors' mirror chain (see PoolHandle).
Definition EBGeometry_SurfaceGroups.hpp:477
static constexpr uint32_t None
No surface group: a surface no selector matches.
Definition EBGeometry_SurfaceGroups.hpp:301
const SurfaceSelector & getSelector(const uint32_t a_selector) const noexcept
A selector.
Definition EBGeometry_SurfaceGroups.hpp:419
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
constexpr uint32_t value() const noexcept
The number, for indexing an array of your own.
Definition EBGeometry_LabelId.hpp:74
static constexpr LabelId none() noexcept
No label.
Definition EBGeometry_LabelId.hpp:63
Placement-independent descriptor of a POD array inside a Pool.
Definition EBGeometry_PODVector.hpp:131
void reserveSizedFrom(Pool &a_pool, uint32_t a_count)
Reserve a_count slots from a_pool and count them all as elements.
Definition EBGeometry_PODVector.hpp:181
uint64_t endByte() const noexcept
One past the last byte this array occupies, measured from the pool base.
Definition EBGeometry_PODVector.hpp:264
T & at(void *a_base, uint32_t a_i) const noexcept
Mutable element access against a_base.
Definition EBGeometry_PODVector.hpp:220
T * data(void *a_base) const noexcept
Mutable pointer to element 0 against a_base.
Definition EBGeometry_PODVector.hpp:195
Where a pool-resident descriptor resolves its offsets, and the rules for moving it.
Definition EBGeometry_Pool.hpp:99
The arrays, as offsets: what a Domain stores.
Definition EBGeometry_SurfaceGroups.hpp:307
PODVector< uint32_t > m_groupOf
Each selector's surface group.
Definition EBGeometry_SurfaceGroups.hpp:316
uint32_t m_numSurfaceGroups
How many surface groups there are.
Definition EBGeometry_SurfaceGroups.hpp:321
PODVector< SurfaceSelector > m_selectors
The selectors, in the order added.
Definition EBGeometry_SurfaceGroups.hpp:311
The surface that decides a shape's value at a point, as closestSurface() reports it.
Definition EBGeometry_SurfaceRef.hpp:39
Conditions on a point of a surface, all of which must hold; an unset one (Any) matches anything.
Definition EBGeometry_SurfaceGroups.hpp:40
uint32_t m_regionB
The region on the other side, or Any (with m_regionA set: m_regionA on either side,...
Definition EBGeometry_SurfaceGroups.hpp:64
static SurfaceSelector piece(const SurfaceRef< T > &a_surface) noexcept
The piece a surface point belongs to: its surface between the two regions on its sides,...
Definition EBGeometry_SurfaceGroups.hpp:101
static SurfaceSelector label(const SurfaceLabelId a_label) noexcept
Every surface with a surface label.
Definition EBGeometry_SurfaceGroups.hpp:170
static SurfaceSelector interface(const uint32_t a_first, const uint32_t a_second) noexcept
Every surface between two regions, either way round: an interface.
Definition EBGeometry_SurfaceGroups.hpp:187
SurfaceSelector withPart(const uint32_t a_part) const noexcept
The same selector restricted to one part (a cylinder's cap, a box's face).
Definition EBGeometry_SurfaceGroups.hpp:238
uint32_t m_materialB
The material on the other side, or Any (as m_regionB).
Definition EBGeometry_SurfaceGroups.hpp:79
bool m_rest
Whether the selector holds the remaining surfaces (rest()): surface groups try it after every other.
Definition EBGeometry_SurfaceGroups.hpp:84
bool matches(const SurfaceRef< T > &a_surface) const noexcept
Whether a surface point matches every condition set.
Definition EBGeometry_SurfaceGroups.hpp:256
static SurfaceSelector rest() noexcept
The remaining surfaces: every surface no other selector of the surface groups holds,...
Definition EBGeometry_SurfaceGroups.hpp:119
uint32_t m_numSurfaces
How many surfaces from m_surface it holds (1: one surface); unused when m_surface is Any.
Definition EBGeometry_SurfaceGroups.hpp:89
uint32_t m_materialA
A material on one side, or Any.
Definition EBGeometry_SurfaceGroups.hpp:74
static SurfaceSelector region(const uint32_t a_region) noexcept
Every surface of a region: those with the region on either side.
Definition EBGeometry_SurfaceGroups.hpp:204
static SurfaceSelector surfaces(const uint32_t a_first, const uint32_t a_count) noexcept
Every point of a range of surfaces, whatever their parts, labels and sides: a node of an expression a...
Definition EBGeometry_SurfaceGroups.hpp:153
static constexpr uint32_t Any
An unset condition: matches anything.
Definition EBGeometry_SurfaceGroups.hpp:44
uint32_t m_label
The surface label (SurfaceRef::m_surfaceLabel), or Any.
Definition EBGeometry_SurfaceGroups.hpp:69
uint32_t m_surface
The surface (SurfaceRef::m_surface), or the first of a range of them (see m_numSurfaces); or Any.
Definition EBGeometry_SurfaceGroups.hpp:49
static SurfaceSelector surface(const uint32_t a_surface) noexcept
Every point of a surface, whatever its part and sides.
Definition EBGeometry_SurfaceGroups.hpp:135
uint32_t m_regionA
A region on one side, or Any.
Definition EBGeometry_SurfaceGroups.hpp:59
static SurfaceSelector materials(const MaterialLabelId a_first, const MaterialLabelId a_second=MaterialLabelId::none()) noexcept
Every surface between two materials, either way round (one material alone: on either side).
Definition EBGeometry_SurfaceGroups.hpp:221
uint32_t m_part
The part (SurfaceRef::m_part), or Any.
Definition EBGeometry_SurfaceGroups.hpp:54