EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
EBGeometry::Domain< T, UserPrimitives > Class Template Reference

A computational domain over a tape, for a downstream code (a solver EBGeometry does not provide): the regions it computes in (its subdomains) and its surface groups (each a set of surfaces the caller gives one meaning, a boundary condition say: named by the caller, numbered here), with the queries a cut-cell code makes. More...

#include <EBGeometry_Domain.hpp>

Inheritance diagram for EBGeometry::Domain< T, UserPrimitives >:
Inheritance graph
[legend]
Collaboration diagram for EBGeometry::Domain< T, UserPrimitives >:
Collaboration graph
[legend]

Public Types

using TapeType = Tape< T, UserPrimitives... >
 The tape it is built for.
 

Public Member Functions

 Domain (Pool &a_tables, const TapeType &a_tape, const DomainSetup &a_setup)
 Build a domain over a tape.
 
const TapeType & tape () const noexcept
 The tape the domain was built for.
 
Subdomains subdomains () const noexcept
 The subdomains, for the tape's own queries that take them (Tape::firstSurface(ray, ..., subdomains, ...)).
 
SurfaceGroups surfaceGroups () const noexcept
 The surface groups.
 
uint32_t getNumSubdomainFunctions () const noexcept
 How many functions signedDistances() gives: one per subdomain, then Excluded's.
 
bool computesIn (const uint32_t a_region) const noexcept
 Whether it computes in a region.
 
bool touches (const uint32_t a_first, const uint32_t a_second) const noexcept
 Whether a surface between two regions is one it must give a condition: one side or both in its regions.
 
uint32_t subdomainAt (const Vec3T< T > &a_point) const noexcept
 The subdomain a point is in: that of the region it is in, or Excluded.
 
T signedDistance (const Vec3T< T > &a_point, const uint32_t a_subdomain) const noexcept
 A subdomain's function (Tape::signedDistance(p, subdomains, subdomain)), or Excluded's, negative exactly in the regions of no subdomain.
 
void signedDistances (const Vec3T< T > &a_point, T *a_values, const uint32_t a_capacity) const noexcept
 Every subdomain's function at a point, and Excluded's, each region's function evaluated once: what a cut-cell code samples at a node. The same values as signedDistance(), one by one.
 
template<std::size_t N>
void signedDistances (const Vec3T< T > &a_point, T(&a_values)[N]) const noexcept
 Every subdomain's function at a point, and Excluded's, into an array whose size is the capacity (see signedDistances()).
 
SurfaceRef< T > closestSurface (const Vec3T< T > &a_point, const uint32_t a_subdomain) const noexcept
 The surface of a subdomain closest to a point, with what is on its other side (Tape::closestSurface(p, subdomains, subdomain)): never a contact between two of its own regions.
 
SurfaceRole role (const SurfaceRef< T > &a_surface) const noexcept
 What a surface is to the domain (Subdomains::role()).
 
uint32_t surfaceGroupOf (const SurfaceRef< T > &a_surface) const noexcept
 A surface's group (SurfaceGroups::surfaceGroupOf()).
 
Domain rebasedView (const Pool &a_pool) const
 A view resolving against mirrors, the tape and the tables in one pool.
 
Domain rebasedView (const Pool &a_tapePool, const Pool &a_tablesPool) const
 A view resolving against mirrors, the tape and the tables in two pools.
 
- Public Member Functions inherited from EBGeometry::PoolHandle
PoolLocation location () const noexcept
 Where this handle's arrays live.
 
bool isAttachedTo (const Pool &a_pool) const noexcept
 Check whether this handle's arrays were reserved from a_pool.
 

Static Public Attributes

static constexpr uint32_t Excluded = Subdomains::None
 What subdomainAt() gives for a point in the regions of no subdomain.
 

Additional Inherited Members

- Protected Member Functions inherited from EBGeometry::PoolHandle
 PoolHandle () noexcept=default
 An unset location; the first reservation attaches it.
 
 PoolHandle (const PoolLocation &a_location) noexcept
 Adopt a location, as a handle rebuilt from a stored layout does.
 
 PoolHandle (const PoolHandle &) noexcept=default
 Copy a handle, as a derived handle's copy does.
 
 PoolHandle (PoolHandle &&) noexcept=default
 Move a handle; the same as a copy.
 
PoolHandle & operator= (const PoolHandle &) noexcept=default
 Copy-assign a handle, as a derived handle's assignment does.
 
PoolHandle & operator= (PoolHandle &&) noexcept=default
 Move-assign a handle; the same as a copy.
 
 ~PoolHandle () noexcept=default
 Destructor; protected, since a PoolHandle exists only as the base of a handle.
 
void * base () noexcept
 The base address this handle's offsets resolve against; see PoolLocation::base().
 
const void * base () const noexcept
 The base address this handle's offsets resolve against, for read-only access.
 
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().
 
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::rebasedOnto().
 
void setLocation (const PoolLocation &a_location) noexcept
 Replace the location, for a view or a copy made by a derived handle.
 

Detailed Description

template<class T, class... UserPrimitives>
class EBGeometry::Domain< T, UserPrimitives >

A computational domain over a tape, for a downstream code (a solver EBGeometry does not provide): the regions it computes in (its subdomains) and its surface groups (each a set of surfaces the caller gives one meaning, a boundary condition say: named by the caller, numbered here), with the queries a cut-cell code makes.

Built on the host from a DomainSetup, for one tape, which it holds: its queries take no tape, so a domain cannot be used with a tape it was not built for. Its tables, a subdomain per region of the tape and the selectors with their surface groups, live in a pool (the tables pool); there is no limit on subdomains, surface groups or selectors. A trivially copyable handle (see PoolHandle): rebasedView() moves it to a device, where every query is callable.

The tables pool is usually the tape's own: one mirror, one lifetime. It may be another one, so that a domain built after the tape's pool was mirrored (a viewer's edited surface groups, a solver changing its setup) costs a copy of the small tables only, never the geometry. That is why a domain holds its tape as a handle, with the tape's own location, beside the location of its tables: the one pool-resident class holding a second handle rather than the layouts of its parts, so that several domains can share one tape whose pool is frozen.

The domain divides space among its subdomains and Excluded, the regions in none (where it does not compute). Every point is in one of them (subdomainAt()), and each has a function negative exactly in it (signedDistance()), so that at a point, off the surfaces, exactly one is negative. A cut-cell code samples them all at a node (signedDistances()): an edge whose ends are in different subdomains (or Excluded) crosses a surface, an interface between two subdomains (where their two functions are zero, with opposite signs) or a subdomain's boundary with the excluded regions (where its function is zero); its root along the edge is the crossing. Excluded's function is the negative of the function of all the subdomains together. Materials and their properties are the regions' (MaterialLabel()).

A domain and every copy and view of it need the tape's pool and the tables pool (or their mirrors) to outlive them.

Template Parameters
TFloating-point precision, the tape's.
UserPrimitivesThe tape's user primitive types and features. Both deduced from the constructor.

Constructor & Destructor Documentation

◆ Domain()

template<class T , class... UserPrimitives>
EBGeometry::Domain< T, UserPrimitives >::Domain ( Pool &  a_tables,
const TapeType &  a_tape,
const DomainSetup &  a_setup 
)
inline

Build a domain over a tape.

Aborts with a message, in every build, when a subdomain of the setup holds a region the tape does not have, or when the tables pool is frozen.

Parameters
[in,out]a_tablesThe pool to hold the domain's tables: the tape's pool, or another.
[in]a_tapeThe tape, which must outlive the domain with its pool.
[in]a_setupHow the domain is made.

Member Function Documentation

◆ closestSurface()

template<class T , class... UserPrimitives>
SurfaceRef< T > EBGeometry::Domain< T, UserPrimitives >::closestSurface ( const Vec3T< T > &  a_point,
const uint32_t  a_subdomain 
) const
inlinenoexcept

The surface of a subdomain closest to a point, with what is on its other side (Tape::closestSurface(p, subdomains, subdomain)): never a contact between two of its own regions.

Parameters
[in]a_pointPoint.
[in]a_subdomainThe subdomain.
Returns
The surface, with its sides and their materials.

◆ computesIn()

template<class T , class... UserPrimitives>
bool EBGeometry::Domain< T, UserPrimitives >::computesIn ( const uint32_t  a_region) const
inlinenoexcept

Whether it computes in a region.

Parameters
[in]a_regionThe region.
Returns
True if the region is in one of its subdomains.

◆ getNumSubdomainFunctions()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Domain< T, UserPrimitives >::getNumSubdomainFunctions ( ) const
inlinenoexcept

How many functions signedDistances() gives: one per subdomain, then Excluded's.

Returns
The count, the number of subdomains plus one.

◆ rebasedView() [1/2]

template<class T , class... UserPrimitives>
Domain EBGeometry::Domain< T, UserPrimitives >::rebasedView ( const Pool &  a_pool) const
inline

A view resolving against mirrors, the tape and the tables in one pool.

Parameters
[in]a_poolThe pool holding both, or a mirror of it.
Returns
The view.

◆ rebasedView() [2/2]

template<class T , class... UserPrimitives>
Domain EBGeometry::Domain< T, UserPrimitives >::rebasedView ( const Pool &  a_tapePool,
const Pool &  a_tablesPool 
) const
inline

A view resolving against mirrors, the tape and the tables in two pools.

Parameters
[in]a_tapePoolThe tape's pool, or a mirror of it.
[in]a_tablesPoolThe tables pool, or a mirror of it.
Returns
The view.

◆ role()

template<class T , class... UserPrimitives>
SurfaceRole EBGeometry::Domain< T, UserPrimitives >::role ( const SurfaceRef< T > &  a_surface) const
inlinenoexcept

What a surface is to the domain (Subdomains::role()).

Parameters
[in]a_surfaceThe surface, with its sides.
Returns
None, Boundary, Interface or Internal.

◆ signedDistance()

template<class T , class... UserPrimitives>
T EBGeometry::Domain< T, UserPrimitives >::signedDistance ( const Vec3T< T > &  a_point,
const uint32_t  a_subdomain 
) const
inlinenoexcept

A subdomain's function (Tape::signedDistance(p, subdomains, subdomain)), or Excluded's, negative exactly in the regions of no subdomain.

Parameters
[in]a_pointPoint.
[in]a_subdomainA subdomain (below getNumSubdomainFunctions() - 1), or Excluded.
Returns
The value: half the difference of the smallest function of a region in it and of one not in it.

◆ signedDistances() [1/2]

template<class T , class... UserPrimitives>
void EBGeometry::Domain< T, UserPrimitives >::signedDistances ( const Vec3T< T > &  a_point,
T *  a_values,
const uint32_t  a_capacity 
) const
inlinenoexcept

Every subdomain's function at a point, and Excluded's, each region's function evaluated once: what a cut-cell code samples at a node. The same values as signedDistance(), one by one.

The buffer's size is checked in every build on the host, and with EBGEOMETRY_ENABLE_ASSERTIONS on a device, where this is called once per point.

Parameters
[in]a_pointPoint.
[out]a_valuesThe functions, getNumSubdomainFunctions() of them: the subdomains' in order, then Excluded's.
[in]a_capacityThe buffer's size: at least getNumSubdomainFunctions().

◆ signedDistances() [2/2]

template<class T , class... UserPrimitives>
template<std::size_t N>
void EBGeometry::Domain< T, UserPrimitives >::signedDistances ( const Vec3T< T > &  a_point,
T(&)  a_values[N] 
) const
inlinenoexcept

Every subdomain's function at a point, and Excluded's, into an array whose size is the capacity (see signedDistances()).

Template Parameters
NThe array's size: at least getNumSubdomainFunctions().
Parameters
[in]a_pointPoint.
[out]a_valuesThe functions: the subdomains' in order, then Excluded's.

◆ subdomainAt()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Domain< T, UserPrimitives >::subdomainAt ( const Vec3T< T > &  a_point) const
inlinenoexcept

The subdomain a point is in: that of the region it is in, or Excluded.

Parameters
[in]a_pointPoint.
Returns
Its subdomain, or Excluded.

◆ subdomains()

template<class T , class... UserPrimitives>
Subdomains EBGeometry::Domain< T, UserPrimitives >::subdomains ( ) const
inlinenoexcept

The subdomains, for the tape's own queries that take them (Tape::firstSurface(ray, ..., subdomains, ...)).

Returns
A view of the table.

◆ surfaceGroupOf()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Domain< T, UserPrimitives >::surfaceGroupOf ( const SurfaceRef< T > &  a_surface) const
inlinenoexcept

A surface's group (SurfaceGroups::surfaceGroupOf()).

Parameters
[in]a_surfaceThe surface, with its sides and their materials.
Returns
The surface group, or SurfaceGroups::None.

◆ surfaceGroups()

template<class T , class... UserPrimitives>
SurfaceGroups EBGeometry::Domain< T, UserPrimitives >::surfaceGroups ( ) const
inlinenoexcept

The surface groups.

Returns
A view of the selectors.

◆ tape()

template<class T , class... UserPrimitives>
const TapeType & EBGeometry::Domain< T, UserPrimitives >::tape ( ) const
inlinenoexcept

The tape the domain was built for.

Returns
The tape.

◆ touches()

template<class T , class... UserPrimitives>
bool EBGeometry::Domain< T, UserPrimitives >::touches ( const uint32_t  a_first,
const uint32_t  a_second 
) const
inlinenoexcept

Whether a surface between two regions is one it must give a condition: one side or both in its regions.

Parameters
[in]a_firstA region on one side.
[in]a_secondThe region on the other.
Returns
True if it touches the domain's regions.

The documentation for this class was generated from the following file: