Box2D Struct ReferenceΒΆ

adc_cpp: pops::Box2D Struct Reference
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends

2D integer index space, cell-centered. More...

#include <box2d.hpp>

+ Collaboration diagram for pops::Box2D:

Public Member Functions

POPS_HD int length (int d) const
 Number of cells in direction d (= hi[d] - lo[d] + 1); negative if the box is empty. POPS_HD.
 
POPS_HD int nx () const
 Width (direction 0). POPS_HD (called from Geometry::dx() in a device kernel).
 
POPS_HD int ny () const
 Height (direction 1). POPS_HD (called from Geometry::dy() in a device kernel).
 
std::int64_t num_cells () const
 Total number of cells (nx*ny, floored at 0 per direction): 0 if the box is empty.
 
bool empty () const
 true if the box contains no cell (hi < lo in one direction).
 
bool contains (int i, int j) const
 true if cell (i, j) is inside the box (lo/hi bounds inclusive).
 
bool contains (const Box2D &b) const
 true if box b (non-empty) is entirely contained in *this.
 
Box2D grow (int n) const
 Grows the box by n cells in ALL directions (uniform ghost layer).
 
Box2D grow (int d, int n) const
 Grows by n cells in the SINGLE direction d (n may be negative to shrink).
 
Box2D shift (int d, int s) const
 Translates the box by s cells in direction d (lo and hi shifted by the same s).
 
Box2D refine (int r) const
 Refines by a ratio r: each cell becomes an r x r block ([lo, hi] -> [lo*r, hi*r + r-1]).
 
Box2D coarsen (int r) const
 Coarsens by a ratio r via FLOOR division of each corner (handles the negative ghost indices).
 
Box2D intersect (const Box2D &o) const
 Intersection of the two boxes (possibly empty: hi < lo if they do not overlap).
 
bool operator== (const Box2D &) const =default
 

Static Public Member Functions

static Box2D from_extents (int nx, int ny)
 Box [0, nx-1] x [0, ny-1] covering nx*ny cells from the index origin.
 

Public Attributes

int lo [2] {0, 0}
 
int hi [2] {-1, -1}
 

Detailed Description

2D integer index space, cell-centered.

Corners lo/hi INCLUSIVE; box empty if hi < lo. Pure POD (no field data): trivially copyable, capturable by value inside a kernel. INVARIANT: indices may be negative (ghosts); refine/coarsen are block-wise bijections (refine then coarsen gives back the box, but coarsen then refine rounds it to the block).

Member Function Documentation

◆ coarsen()

Box2D pops::Box2D::coarsen ( int  r) const
inline

Coarsens by a ratio r via FLOOR division of each corner (handles the negative ghost indices).

+ Here is the call graph for this function:

◆ contains() [1/2]

bool pops::Box2D::contains ( const Box2D b) const
inline

true if box b (non-empty) is entirely contained in *this.

+ Here is the call graph for this function:

◆ contains() [2/2]

bool pops::Box2D::contains ( int  i,
int  j 
) const
inline

true if cell (i, j) is inside the box (lo/hi bounds inclusive).

+ Here is the caller graph for this function:

◆ empty()

bool pops::Box2D::empty ( ) const
inline

true if the box contains no cell (hi < lo in one direction).

+ Here is the caller graph for this function:

◆ from_extents()

static Box2D pops::Box2D::from_extents ( int  nx,
int  ny 
)
inlinestatic

Box [0, nx-1] x [0, ny-1] covering nx*ny cells from the index origin.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ grow() [1/2]

Box2D pops::Box2D::grow ( int  d,
int  n 
) const
inline

Grows by n cells in the SINGLE direction d (n may be negative to shrink).

◆ grow() [2/2]

Box2D pops::Box2D::grow ( int  n) const
inline

Grows the box by n cells in ALL directions (uniform ghost layer).

+ Here is the caller graph for this function:

◆ intersect()

Box2D pops::Box2D::intersect ( const Box2D o) const
inline

Intersection of the two boxes (possibly empty: hi < lo if they do not overlap).

+ Here is the caller graph for this function:

◆ length()

POPS_HD int pops::Box2D::length ( int  d) const
inline

Number of cells in direction d (= hi[d] - lo[d] + 1); negative if the box is empty. POPS_HD.

+ Here is the caller graph for this function:

◆ num_cells()

std::int64_t pops::Box2D::num_cells ( ) const
inline

Total number of cells (nx*ny, floored at 0 per direction): 0 if the box is empty.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nx()

POPS_HD int pops::Box2D::nx ( ) const
inline

Width (direction 0). POPS_HD (called from Geometry::dx() in a device kernel).

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ny()

POPS_HD int pops::Box2D::ny ( ) const
inline

Height (direction 1). POPS_HD (called from Geometry::dy() in a device kernel).

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator==()

bool pops::Box2D::operator== ( const Box2D ) const
default

◆ refine()

Box2D pops::Box2D::refine ( int  r) const
inline

Refines by a ratio r: each cell becomes an r x r block ([lo, hi] -> [lo*r, hi*r + r-1]).

+ Here is the caller graph for this function:

◆ shift()

Box2D pops::Box2D::shift ( int  d,
int  s 
) const
inline

Translates the box by s cells in direction d (lo and hi shifted by the same s).

Member Data Documentation

◆ hi

int pops::Box2D::hi[2] {-1, -1}

◆ lo

int pops::Box2D::lo[2] {0, 0}

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