Proto  3.2
Public Types | Public Member Functions | Public Attributes | List of all members
Proto::Box Class Reference

An interval in DIM dimensional space. More...

#include <Proto_Box.H>

Public Types

typedef BoxIterator iterator
 

Public Member Functions

void recomputeSize ()
 Used to reevaluate the size of the box when it is changed. More...
 
Constructors
 Box ()
 Default Constructor. More...
 
Box faceBox (int a_idir, const Side::LoHiSide a_side) const
 
 Box (const Point &a_low, const Point &a_high)
 Two-Point Constructor. More...
 
 Box (const int *a_low, const int *a_high)
 Primitive Two-Point Constructor. More...
 
 Box (const Point &a_sizes)
 Size Constructor. More...
 
ACCEL_DECORATION Box (const Box &a_box)
 Copy Constructor. More...
 
void define (const int *a_lo, const int *a_hi)
 Primitive Two-Point Lazy Constructor. More...
 
Accessors And Queries

Stencil Offset

Used internally by Stencil, not recommended for public use.

Parameters
a_ptA Point
a_lowThe low Point of a Box
a_highThe high Point of a Box
ACCEL_DECORATION Point low () const
 Access Low Corner. More...
 
ACCEL_DECORATION Point high () const
 Access High Corner. More...
 
Point boundary (const Side::LoHiSide a_side) const
 
ACCEL_DECORATION std::size_t size (unsigned int a_dim) const
 Edge Size. More...
 
ACCEL_DECORATION std::size_t size () const
 Volumetric Size. More...
 
ACCEL_DECORATION Point sizes () const
 All Sizes. More...
 
ACCEL_DECORATION bool containsPoint (const Point &a_pt) const
 Contains Point Query. More...
 
ACCEL_DECORATION bool containsBox (const Box &a_rhs) const
 Contains Box Query. More...
 
bool onBoundary (const Point &a_p) const
 Point on Boundry Query. More...
 
Point whichBoundaryContains (const Point &a_point) const
 
ACCEL_DECORATION bool empty () const
 Empty Query. More...
 
ACCEL_DECORATION unsigned int index (const Point &a_pt) const
 Point to Linear Index. More...
 
ACCEL_DECORATION Point operator[] (unsigned int a_index) const
 Access Point by Index. More...
 
ACCEL_DECORATION Point operator() (unsigned int a_idx, unsigned int a_idy, unsigned a_idz) const
 
Operators
Box operator & (const Box &a_rightBox) const
 Intersection Operator. More...
 
void operator &= (const Box &a_rhs)
 In Place Intersection. More...
 
Box operator+ (const Box &box) const
 
void operator+= (const Box &box)
 
Box operator & (const Point &a_pt) const
 Add Point Operator. More...
 
void operator &= (const Point &a_pt)
 In Place Add Point Operator. More...
 
bool operator== (const Box &a_rhsBox) const
 Equality Operator. More...
 
bool operator!= (const Box &a_rhsBox) const
 Inequality Operator. More...
 
bool operator< (const Box &a_rhsBox) const
 Less Than Operator. More...
 
ACCEL_DECORATION Point operator% (const Point &a_pt) const
 Modulus Operator. More...
 
ACCEL_DECORATION Point mod (const Point &a_pt) const
 Modulus Function. More...
 
Transformations
Box shift (int a_direction, int a_offset) const
 Shift Transformation. More...
 
Box shift (const Point &a_pt) const
 Point Shift Transformation. More...
 
Box toOrigin () const
 Shift To Origin. More...
 
Box grow (int a_numpoints) const
 Isotropic Grow Operation. More...
 
Box grow (const Point &a_pt) const
 Anisotropic Grow Operation. More...
 
Box grow (int a_dir, int a_dist) const
 Anisotropic Grow (Int Version) More...
 
Box grow (int a_dir, Side::LoHiSide a_side, int a_dist) const
 One-Sided Grow. More...
 
Box grow (Centering a_ctr) const
 Apply Centering. More...
 
Box extrude (const Point &a_dir, int a_dist=1) const
 Extrude. More...
 
Box extrude (int a_dir, int a_dist=1, bool a_upper=true) const
 Extrude (Primitive Version) More...
 
Box growHi (int a_dir, int a_dist) const
 Grow High Side. More...
 
Box growLo (int idir, int igrow) const
 Grow Low Side. More...
 
Box coarsen (unsigned int a_ratio) const
 Isotropic Coarsen Operation. More...
 
Box coarsen (const Point &a_pt) const
 Anisotropic Coarsen Operation. More...
 
bool coarsenable (const int &a_ratio) const
 (Isotropic) Coarsenable Query More...
 
bool coarsenable (const Point &a_ratio) const
 (Anisotropic) Coarsenable Query More...
 
Box taperCoarsen (const Point &a_ref) const
 Tapered Coarsen. More...
 
Box refine (const Point &a_pt) const
 Anisotropic Refine Operation. More...
 
Box refine (unsigned int a_ratio) const
 Isotropic Refine Operation. More...
 
Box edge (const Point &a_dir, int a_dist) const
 Edge. More...
 
Box edge (const Point &a_dir) const
 Edge (Anisotropic) More...
 
Box edge (int a_dir, Side::LoHiSide a_side, int a_dist) const
 
Box face (int a_dir, Side::LoHiSide a_side, int a_dist=1) const
 Face. More...
 
Box face (Point a_dir, int a_dist=1) const
 
Box flatten (const int a_dir, bool a_upper=false) const
 Flatten. More...
 
Box adjacent (const Point &a_dir, int a_dist) const
 Adjacent Cells. More...
 
Box adjacent (const Point &a_dir) const
 Adjacent Cells (Anisotropic) More...
 
Box adjacent (int a_dir, Side::LoHiSide a_side, int a_dist) const
 Adjacent Cells (Side) More...
 
Box adjCellLo (int a_dir, int a_dist) const
 
Box adjCellHi (int a_dir, int a_dist) const
 
Box adjCellSide (int a_idir, int a_length, Side::LoHiSide a_sd) const
 
Utility
BoxIterator begin () const
 Iterator Begin. More...
 
BoxIterator end () const
 Iterator End. More...
 
BoxIterator rbegin () const
 Iterator Reverse Begin. More...
 
BoxIterator rend () const
 Iterator Reverse End. More...
 
size_t linearSize () const
 Linear Size. More...
 
void linearIn (const char *a_buf)
 Read From Buffer. More...
 
void linearOut (char *a_buf) const
 Write To Buffer. More...
 
void print () const
 Print. More...
 
std::string str () const
 

Public Attributes

Point m_low
 Point object containing the lower bounds of the Box. More...
 
Point m_high
 Point object containing the upper bounds of the Box. More...
 
int m_size
 "Volume" of the box. More...
 

Static Functions

static Box Cube (int a_size)
 
static Box Kernel (int a_radius)
 Build Kernel Box. More...
 
static ACCEL_DECORATION unsigned int sindex (Point a_pt, Point a_low, Point a_high)
 Stencil Index. More...
 

Detailed Description

An interval in DIM dimensional space.

A Box is a region in \( \mathbb{Z}^{DIM} \) specified by two corner Point objects, high and low INCLUSIVELY. Equivalently, a Box is a collection of \(DIM\) linear intervals in \(\mathbb{Z}^{DIM}\) \([low[i] ,high[i]] : i \in [0,DIM)\). Boxes are written using the notation [low, high] .

Member Typedef Documentation

◆ iterator

Constructor & Destructor Documentation

◆ Box() [1/5]

Proto::Box::Box ( )
inline

Default Constructor.

Builds the empty Box [(-1,-1,...,-1), (0,0,...,0)]

Referenced by Box(), faceBox(), and Proto::operator>>().

◆ Box() [2/5]

Proto::Box::Box ( const Point a_low,
const Point a_high 
)
inline

Two-Point Constructor.

Builds the non-trivial Box [low, high]

Parameters
a_lowlow corner
a_highhigh corner

◆ Box() [3/5]

Proto::Box::Box ( const int *  a_low,
const int *  a_high 
)
inline

Primitive Two-Point Constructor.

Used for building a Box on platforms where plain-old-data is more convenient

Parameters
a_lowC-Array representing this.low()
a_highC-Array representing this.high()

References ACCEL_DECORATION, Box(), Cube(), define(), Kernel(), and sindex().

◆ Box() [4/5]

Proto::Box::Box ( const Point a_sizes)
inline

Size Constructor.

Builds the non-trivial Box [(0,...,0), a_sizes - (1,...,1)]. This is the box with its low corner at the origin and a_sizes[dir] Points in direction dir.

Parameters
a_sizessizes

◆ Box() [5/5]

ACCEL_DECORATION Proto::Box::Box ( const Box a_box)
inline

Copy Constructor.

Member Function Documentation

◆ faceBox()

Box Proto::Box::faceBox ( int  a_idir,
const Side::LoHiSide  a_side 
) const
inline

◆ define()

void Proto::Box::define ( const int *  a_lo,
const int *  a_hi 
)
inline

Primitive Two-Point Lazy Constructor.

Weak construct this Box if necessary

Parameters
a_loC-Array representing this.low()
a_hiC-Array representing this.high()

Referenced by Box().

◆ Cube()

static Box Proto::Box::Cube ( int  a_size)
inlinestatic

Build Cube Box Creates the Box [Point::Zeros(), Point::Ones(a_size-1)], a cube in \(\bf{Z}^{DIM}\) of side length a_size

Parameters
a_sizeside length

Referenced by Box().

◆ Kernel()

static Box Proto::Box::Kernel ( int  a_radius)
inlinestatic

Build Kernel Box.

Creates a Box of size 2*a_radius + 1 on all sides with (0,...,0) at the center. Useful for iterating through boundary cells, defining symmetric Stencils, etc.

Parameters
a_radiusthe number of "rings" of cells around the center cell.

Example:

//DIM=2
using namespace Proto;
auto K0 = Box::Kernel(1);
K0.print(); // [(-1,-1), (1, 1)]
auto K1 = Box::Kernel(2);
K1.print(); // [(-2, -2), (2, 2)]

Referenced by Box().

◆ sindex()

static ACCEL_DECORATION unsigned int Proto::Box::sindex ( Point  a_pt,
Point  a_low,
Point  a_high 
)
inlinestaticprivate

Stencil Index.

Returns the linear index of a_pt inside the Box defined by [a_low, a_high]. to Box::index but does not require a Box instance.

Parameters
a_ptA Point
a_lowThe low Point of a Box
a_highThe high Point of a Box

Referenced by Box().

◆ low()

ACCEL_DECORATION Point Proto::Box::low ( ) const
inline

Access Low Corner.

This function returns by value; a Box cannot be altered through the output of low().

References ACCEL_DECORATION, and m_low.

Referenced by Proto::CompositeOp< NDOMAINS >::ghost(), and Proto::operator>>().

◆ high()

ACCEL_DECORATION Point Proto::Box::high ( ) const
inline

Access High Corner.

This function returns by value; a Box cannot be altered through the output of high().

References ACCEL_DECORATION, boundary(), containsBox(), containsPoint(), m_high, onBoundary(), size(), sizes(), and whichBoundaryContains().

Referenced by Proto::CompositeOp< NDOMAINS >::ghost(), and Proto::operator>>().

◆ boundary()

Point Proto::Box::boundary ( const Side::LoHiSide  a_side) const
inline

Referenced by high().

◆ size() [1/2]

ACCEL_DECORATION std::size_t Proto::Box::size ( unsigned int  a_dim) const
inline

Edge Size.

Returns the "edge length" of this Box on a given axis

/param a_dim direction axis in [0,DIM)

Example:

//DIM=2
using namespace Proto;
Box B(Point::Zeros(), Point({1,3}));
B.print(); //prints [(0,0),(1,3)]
std::cout << B.size(0) << std::endl; //prints 2
std::cout << B.size(1) << std::endl; //prints 4

Referenced by Proto::MBInterpLayout::isIgnoredAxis(), and Proto::BoxData< T, C, MEM, D, E >::size().

◆ size() [2/2]

ACCEL_DECORATION std::size_t Proto::Box::size ( ) const
inline

Volumetric Size.

Returns the "volume" (in number of points) of this box.

Example:

//DIM=2
using namespace Proto;
Box B(Point::Zeros(), Point({1,3}));
B.print(); //prints [(0,0),(1,3)]
std::cout << B.size() << std::endl; //prints 8 (=2*4)

Referenced by high().

◆ sizes()

ACCEL_DECORATION Point Proto::Box::sizes ( ) const
inline

All Sizes.

Returns all sizes at once in the form of a Point.

Referenced by high(), and Proto::ProblemDomain::sizes().

◆ containsPoint()

ACCEL_DECORATION bool Proto::Box::containsPoint ( const Point a_pt) const
inline

Contains Point Query.

Checks if a_pt is inside of *this. Note that this->low() and this->high() are both considered inside *this

Example:

//DIM=2
using namespace Proto;
Box B(Point::Zeros(), Point({1,3}));
std::cout << B.contains(Point({0,0})) << std::endl; //prints true
std::cout << B.contains(Point({1,1})) << std::endl; //prints true
std::cout << B.contains(Point({1,3})) << std::endl; //prints true
std::cout << B.contains(Point({1,4})) << std::endl; //prints false

Referenced by high().

◆ containsBox()

ACCEL_DECORATION bool Proto::Box::containsBox ( const Box a_rhs) const
inline

Contains Box Query.

Check if Box a_rhs is a subset of *this. Returns true even if a_rhs is not a proper subset. Equivalent to this->contains(a_rhs.low()) && this->contains(a_rhs.high()

Example:

//DIM=2
using namespace Proto;
Box B0(Point({0,0}),Point({3,3}));
Box B1(Point({1,1}),Point({2,2}));
Box B2(Point({1,1}),Point({4,4}));
Box B2(Point({-1,-1}),Point({2,2}));
std::cout << B0.contains(B0) << std::endl; //prints true
std::cout << B0.contains(B1) << std::endl; //prints true
std::cout << B0.contains(B2) << std::endl; //prints false
std::cout << B0.contains(B3) << std::endl; //prints false

Referenced by high().

◆ onBoundary()

bool Proto::Box::onBoundary ( const Point a_p) const
inline

Point on Boundry Query.

Check of a_p is part of the boundary of this Box.

Parameters
a_pA Point

Referenced by high().

◆ whichBoundaryContains()

Point Proto::Box::whichBoundaryContains ( const Point a_point) const
inline

Returns the direction of the region adjacent to this which contains a point. Point::Zeros() is returned if a_point is contained inside of this

Referenced by high().

◆ empty()

ACCEL_DECORATION bool Proto::Box::empty ( ) const
inline

◆ index()

ACCEL_DECORATION unsigned int Proto::Box::index ( const Point a_pt) const
inline

Point to Linear Index.

Returns a linear index in [0,this->size()) associated with a_pt. Fails by assertion if a_pt is not inside *this. Indices start at this->low() which has an index of 0. Indices increase fastest in dimension 0 and slowest in dimension DIM-1. this->high() has an index of this->size()-1 as is consistent with the < operator of Point.

Parameters
a_pta Point inside *this

Referenced by empty().

◆ operator[]()

ACCEL_DECORATION Point Proto::Box::operator[] ( unsigned int  a_index) const
inline

Access Point by Index.

Return a Point associated with a_index . This is the inverse of the index(Point) function.

Parameters
a_indexan index in [0,this->size())

Referenced by empty().

◆ operator()()

ACCEL_DECORATION Point Proto::Box::operator() ( unsigned int  a_idx,
unsigned int  a_idy,
unsigned  a_idz 
) const
inline

Referenced by empty().

◆ operator &() [1/2]

Box Proto::Box::operator& ( const Box a_rightBox) const
inline

Intersection Operator.

Returns a new Box which is the intersection of *this and *a_rightBox.

Parameters
a_rightBoxAnother Box

Example:

//DIM=2
using namespace Proto;
Box B0 = Box::Cube(3);
Box B2 = B0 & B1;
B0.print(); //prints [(0,0),(2,2)]
B1.print(); //prints [(1,1),(3,3)]
B2.print(); //prints [(1,1),(2,2)]

Referenced by empty().

◆ operator &=() [1/2]

void Proto::Box::operator&= ( const Box a_rhs)
inline

In Place Intersection.

Performs intersection on *this with a_rhs

Parameters
a_rhsAnother Box

Referenced by empty().

◆ operator+()

Box Proto::Box::operator+ ( const Box box) const
inline

Referenced by empty().

◆ operator+=()

void Proto::Box::operator+= ( const Box box)
inline

Referenced by empty().

◆ operator &() [2/2]

Box Proto::Box::operator& ( const Point a_pt) const
inline

Add Point Operator.

Returns a new Box which has been grown such that it contains a_pt. if this->contains(a_pt) this function returns *this.

Parameters
a_ptPoint to be added

Example:

//DIM=2
using namespace Proto;
auto B0 = Box::Cube(3);
B0.print(); //[(0,0), (2,2)]
Point p(-1,3);
auto B1 = B0 & p;
B1.print(); //[(-1,0), (2,3)]

◆ operator &=() [2/2]

void Proto::Box::operator&= ( const Point a_pt)
inline

In Place Add Point Operator.

Alters *this so that it now includes a_pt. If this->contains(a_pt), this function does nothing.

Parameters
a_ptA Point

◆ operator==()

bool Proto::Box::operator== ( const Box a_rhsBox) const
inline

Equality Operator.

Two Boxes are considered equal if they have identical (==) low() and high()

Parameters
a_rhsBoxA Box to test equality with

Referenced by Proto::BoxIterator::begin(), and empty().

◆ operator!=()

bool Proto::Box::operator!= ( const Box a_rhsBox) const
inline

Inequality Operator.

Referenced by empty().

◆ operator<()

bool Proto::Box::operator< ( const Box a_rhsBox) const
inline

Less Than Operator.

Establishes an ordering for Boxes. This ordering is defined by comparing the low corner Point and then the high corner Point of the two Boxes.

Parameters
a_rhsBoxA Box.

Referenced by empty().

◆ operator%()

ACCEL_DECORATION Point Proto::Box::operator% ( const Point a_pt) const
inline

Modulus Operator.

Convenience operator for Box::mod. Returns the periodic image of a_pt contained in *this

Parameters
a_ptA Point to mod by

Referenced by empty().

◆ mod()

ACCEL_DECORATION Point Proto::Box::mod ( const Point a_pt) const
inline

Modulus Function.

Returns the periodic image of a_pt that is inside *this.

Parameters
a_ptPoint divisor

Example:

//DIM = 2;
using namespace Proto;
Box B = Box::Cube(3); // [(0,0), (2,2)]
std::cout << B.mod(Point({3,3})) << std::endl; //prints (0,0)
std::cout << B.mod(Point({-1,-1})) << std::endl; //prints (2,2)

Referenced by empty().

◆ shift() [1/2]

Box Proto::Box::shift ( int  a_direction,
int  a_offset 
) const
inline

Shift Transformation.

Creates a new Box shifted in a_direction by a_offset units relative to *this.

Parameters
a_directionan int in /f$[0,DIM)/f$ specifying a direction
a_offsetnumber of points to offset. Use a negative value for a negative offset.

Example:

//DIM=2
using namespace Proto;
Box B1 = Box::Cube(2);
Box B2 = B1.shift(0,1);
Box B3 = B1.shift(1,-1);
B1.print(); //prints [(0,0), (1,1)]
B2.print(); //prints [(1,0), (2,1)]
B3.print(); //prints [(0,-1), (1,0)]

Referenced by empty(), and faceBox().

◆ shift() [2/2]

Box Proto::Box::shift ( const Point a_pt) const
inline

Point Shift Transformation.

Creates a new Box shifted by a_pt relative to *this. New Box is: [low() + a_pt, high() + a_pt]

Parameters
a_ptshift offset

Example:

//DIM=2
using namespace Proto;
Box B2 = B1.shift(Point({2,-3}));
B1.print(); //prints [(0,0), (1,1)]
B2.print(); //prints [(2,-3), (3,-2)]

◆ toOrigin()

Box Proto::Box::toOrigin ( ) const
inline

Shift To Origin.

Creates a new Box shifted such that this->low() == (0,...,0). Equivalent to this->shift(this->low()).

Referenced by empty().

◆ grow() [1/5]

Box Proto::Box::grow ( int  a_numpoints) const
inline

Isotropic Grow Operation.

Returns a new Box which is larger in every direction by a_numpoints units. If a_numpoints is negative, the box will shrink.

Parameters
a_numpointsnumber of points to grow by in each direction

Example:

//DIM=2
using namespace Proto;
Box B1 = B0.grow(3);
Box B2 = B1.grow(-2);
B0.print(); //prints [(0, 0), (1, 1)]
B1.print(); //prints [(-3,-3), (4, 4)]
B2.print(); //prints [(-1,-1), (2, 2)]

Referenced by Proto::MBBoundaryData< T, C, MEM >::define(), empty(), and Proto::MBBoundaryData< T, C, MEM >::localBox().

◆ grow() [2/5]

Box Proto::Box::grow ( const Point a_pt) const
inline

Anisotropic Grow Operation.

Returns the reshaped Box: [low() - a_pt, high() + a_pt] To grow a box only upwards / downwards, see Box::extrude.

Parameters
a_ptgrowth offset

Example:

//DIM=2
using namespace Proto;
Box B1 = B0.grow(Point({-1,1})); //shrink in dimension 0, grow in dimension 1
B0.print(); //prints [(0, 0), (3, 3)]
B1.print(); //prints [(1, -1), (2, 4)]

◆ grow() [3/5]

Box Proto::Box::grow ( int  a_dir,
int  a_dist 
) const
inline

Anisotropic Grow (Int Version)

Returns grow(Point::Basis(a_dir, a_dist)) Useful in places where plain-old-data inputs are preferable. To grow a grow a box only upwards / downwards, see Box::extrude.

Parameters
a_dirA direction in [0,DIM)
a_distDistance to grow

◆ grow() [4/5]

Box Proto::Box::grow ( int  a_dir,
Side::LoHiSide  a_side,
int  a_dist 
) const
inline

One-Sided Grow.

Grows the box along coordinate a_dir a distance a_dist on side a_side only. This function is equivalent to extrude(Point::Basis(a_dir, sign(a_side)*a_dist)) .

Parameters
a_dirA direction in [0, DIM)
a_sideEither Side::Lo or Side::Hi
a_distHow far to grow

◆ grow() [5/5]

Box Proto::Box::grow ( Centering  a_ctr) const
inline

Apply Centering.

Create a new Box that is grown in such a way as to accomodate the extra points needed by a domain with the specified centering. If a_ctr=PR_CELL this function is a null-op.

◆ extrude() [1/2]

Box Proto::Box::extrude ( const Point a_dir,
int  a_dist = 1 
) const
inline

Extrude.

AKA directional grow. Returns a new Box with the a_dir direction extruded a distance a_dist </code).

Parameters
a_dirDirection to extrude in.
a_dist(Optional) Distance to extrude (default: 1)

Example:

//DIM=3
using namespace Proto;
Box B1 = B0.extrude(Point::Ones(), 2);
Box B2 = B0.extrude(Point::Basis(0,-1),3);
Box B3 = B0.extrued(Point(-1, 1, 0);
B0.print(); //prints [(1, 1, 1), (4, 4, 4)]
B1.print(); //prints [(1, 1, 1), (6, 6, 6)]
B2.print(); //prints [(-2, 1, 1), (4, 4, 4)]
B3.print(); //prints [(0, 1, 1), (4, 5, 4)]

Referenced by Proto::FluxBoxData< T, C, MEM, D, E >::define(), and empty().

◆ extrude() [2/2]

Box Proto::Box::extrude ( int  a_dir,
int  a_dist = 1,
bool  a_upper = true 
) const
inline

Extrude (Primitive Version)

AKA directional grow. Returns a new Box with the a_dir direction extruded a distance a_dist </code). By default, the extrusion is upwards. If a_upper is false, extrudes downwards.

Parameters
a_dirAxis to extrude along
a_dist(Optional) Distance to extrude (default: 1)
a_upper(Optional) Extrude upwards? (default: true)

Example:

//DIM=2
using namespace Proto;
Box B1 = B0.extrude(2,3,false);
Box B2 = B0.extrude(2,3,true);
B0.print(); //prints [(1, 1, 1), (4, 4, 4)]
B1.print(); //prints [(1, 1, -2), (4, 4, 4)]
B2.print(); //prints [(1, 1, 1), (4, 4, 7)]

◆ growHi()

Box Proto::Box::growHi ( int  a_dir,
int  a_dist 
) const
inline

Grow High Side.

Equivalent to grow(a_dir, Side::Hi, a_dist)

Parameters
a_dirCoordinate axis to grow along
a_distDistance to grow

Referenced by empty().

◆ growLo()

Box Proto::Box::growLo ( int  idir,
int  igrow 
) const
inline

Grow Low Side.

Equivalent to grow(a_dir, Side::Lo, a_dist)

Parameters
a_dirCoordinate axis to grow along
a_distDistance to grow

Referenced by empty().

◆ coarsen() [1/2]

Box Proto::Box::coarsen ( unsigned int  a_ratio) const
inline

Isotropic Coarsen Operation.

Returns a new Box coarsened by a factor of a_numpoints. Fails if user tries to coarsen using a non-positive ratio. If the limits of *this are not multiples of the coarsening ratio (e.g. if this-> coarsenable() != true) the resulting Box is not guaranteed to be a subset of *this. In this situation, use Box::taperCoarsen

Parameters
a_ratioCoarsening ratio

Example:

//DIM=2
using namespace Proto;
Box B0 = Box::Cube(4);
Box B1 = B0.coarsen(2);
B0.print(); //prints [(0, 0), (3, 3)]
B1.print(); //prints [(0, 0), (1, 1)]
Box B3 = B2.coarsen(2);
B2.print(); //prints [(2, 2), (4, 4)]
B3.print(); //prints [(1, 1), (2, 2)]

Referenced by empty().

◆ coarsen() [2/2]

Box Proto::Box::coarsen ( const Point a_pt) const
inline

Anisotropic Coarsen Operation.

Returns a new Box coarsened in each direction according to a_pt. Fails if user tries to coarsen using a non-positive ratio. (*this).coarsen(a_pt).refine(a_pt) will always contain *this.

Parameters
a_ptCoarsening ratios

Example:

//DIM=2
using namespace Proto;
Box B0 = Box::Cube(4);
//coarsen in only the 1 direction
Box B1 = B0.coarsen(Point({1,2}));
B1.print(); //prints [(0,0),(3,1)]

◆ coarsenable() [1/2]

bool Proto::Box::coarsenable ( const int &  a_ratio) const
inline

(Isotropic) Coarsenable Query

Returns true if *this will coarsen normally by a given ratio.

Parameters
a_ratioCoarsening ratio

Referenced by empty().

◆ coarsenable() [2/2]

bool Proto::Box::coarsenable ( const Point a_ratio) const
inline

(Anisotropic) Coarsenable Query

Returns true if *this will coarsen normally by a given ratio.

Parameters
a_ratioCoarsening ratio

◆ taperCoarsen()

Box Proto::Box::taperCoarsen ( const Point a_ref) const
inline

Tapered Coarsen.

This function is identical to Box::coarsen when Box::coarsenable() is true. For non-coarsenable Boxes, the new Box's limits are rounded such that the result Is always a subset of *this. Specifically, the lower limits are always rounded UP. This function is used heavily in the automatic computation of domains and ranges for pointwise and Stencil operators, but generally has limited use otherwise.

Parameters
a_refCoarsening ratio

Referenced by empty().

◆ refine() [1/2]

Box Proto::Box::refine ( const Point a_pt) const
inline

Anisotropic Refine Operation.

Returns a new Box refined in each direction according to a_pt.

Parameters
a_ptRefinement ratios

Example:

//DIM=2
using namespace Proto;
Box B0 = Box::Cube(2);
Box B1 = B0.refine(Point({1,2}));
B0.print(); //prints [(0, 0), (1, 1)]
B1.print(); //prints [(0, 0), (1, 3)]

Referenced by empty().

◆ refine() [2/2]

Box Proto::Box::refine ( unsigned int  a_ratio) const
inline

Isotropic Refine Operation.

Returns a new Box refined in all directions by a_numpoints.

Parameters
a_ratioRefinement ratio

Example:

//DIM=2
using namespace Proto;
Box B0 = Box::Cube(2);
Box B1 = B0.refine(2);
B0.print(); //prints [(0, 0), (1, 1)]
B1.print(); //prints [(0, 0), (3, 3)]
Box B3 = B2.refine(2);
B2.print(); //prints [(1, 1), (2, 2)]
B3.print(); //prints [(2, 2), (5, 5)]

◆ edge() [1/3]

Box Proto::Box::edge ( const Point a_dir,
int  a_dist 
) const
inline

Edge.

Returns the subset on the boundary of *this in a given direction with specified thickness. Very handy for adjacency and boundary based computations. This function is slightly more general than face(...) in that it can return regions of all codimensionalities (faces, edges, corners, etc.) The returned Box is always a subset of *this

Parameters
a_dirDirection of desired edge with respect to the cell center of *this
a_distThickness of the output (default: 1)

Examples:

//DIM = 2
using namespace Proto;
auto B0 = Box::Cube(4).shift(Point::Ones()); //[(1,1), (4,4)]
auto B1 = B0.edge(Point::Basis(0)); //[(4,1), (4,4)]
auto B2 = B0.edge(Point::Ones(), 2); //[(3,3), (4,4)]
auto B3 = B0.edge(Point::Basis(1,-1), 2); //[(1,1), (4,2)]

Referenced by empty().

◆ edge() [2/3]

Box Proto::Box::edge ( const Point a_dir) const
inline

Edge (Anisotropic)

Returns an edge box that is allowed to be anisotropic

Example

//DIM=2
using namespace Proto;
auto B0 = Box::Cube(4).shift(Point::Ones()); //[(1,1), (4,4)]
// get the 1 x 2 Box in the (-x, +y) direction corner of B0
auto B1 = B0.edge(Point(-1,2)); //[(1,3), (1,4)]

◆ edge() [3/3]

Box Proto::Box::edge ( int  a_dir,
Side::LoHiSide  a_side,
int  a_dist 
) const
inline

◆ face() [1/2]

Box Proto::Box::face ( int  a_dir,
Side::LoHiSide  a_side,
int  a_dist = 1 
) const
inline

Face.

Returns the face (e.g. region of codimension 1) of this box in a specified direction. The output box is always contained in *this. For adjacent faces, use adjacent(...). If a_dist >= size(a_dir) , the rturned box = *this.

Parameters
a_dirCoordinate direction in [0, DIM)
a_sideSide::Lo or Side::Hi
a_dist(Optional) Thickness of the output. (default: 1)

Examples:

//DIM = 2
using namespace Proto;
auto B0 = Box::Cube(4).shift(Point::Ones()); //[(1,1), (4,4)]
auto B1 = B0.face(0, Side::Hi); //[(4,1), (4,4)]
auto B2 = B0.face(1, Side::Lo, 2); //[(1,1), (4,2)]
auto B3 = B0.face(0, Side::Lo, 5); //[(1,1), (4,4)]

Referenced by empty().

◆ face() [2/2]

Box Proto::Box::face ( Point  a_dir,
int  a_dist = 1 
) const
inline

◆ flatten()

Box Proto::Box::flatten ( const int  a_dir,
bool  a_upper = false 
) const
inline

Flatten.

Returns a copy of *this with dimension a_dir flattened to a thickness of 1. Useful for creating Boxes of dimensionality less than DIM (e.g. a plane in 3D).

Parameters
a_dirDirection to flatten
a_upperFlatten upwards?

Example:

//DIM=3
using namespace Proto;
Box B1 = B0.flatten(2);
Box B2 = B0.flatten(2,true);
B0.print(); //prints [(1, 1, 1), (4, 4, 4)]
B1.print(); //prints [(1, 1, 1), (4, 4, 1)]
B2.print(); //prints [(1, 1, 4), (4, 4, 4)]

Referenced by empty().

◆ adjacent() [1/3]

Box Proto::Box::adjacent ( const Point a_dir,
int  a_dist 
) const
inline

Adjacent Cells.

Returns a box adjacent to *this in a given direction with a thickness a_dist in the normal direction. If there are multiple non-zero entries in a_dir, a_dist will be applied to the thickness in all of those directions

Parameters
a_dir"Normal" direction of the desired adjacent cell
a_dist(Optional) "thickness" of the desired adjacent cell (default: this->size(a_dir))

Examples:

//DIM = 2;
Box B0 = Box::Cube(8); // [(0,0) , (7,7)]
B0.adjacent((1,0) , 2); // [(8,0) , (9,7)]
B0.adjacent((0,-1), 2); // [(0,-2), (7,-1)]
B0.adjacent((-1,1), 2); // [(-2,8), (-1,9)]
B0.adjacent((1,0)); // [(8,0) , (15,7)], 8 x 8 cube directly adjacent in (1, 0) direction

Referenced by empty().

◆ adjacent() [2/3]

Box Proto::Box::adjacent ( const Point a_dir) const
inline

Adjacent Cells (Anisotropic)

Overload of adjacent which allows for anisotropic outputs.

Example:

//DIM = 2;
using namespace Proto;
Box B0 = Box::Cube(8); // [(0,0) , (7,7)]
// Get the 1 x 2 Box adjacent to B0 in the (+x, -y) direction
B0.adjacent(Point(1,-2)); // [(8,-2) , (8,-1)]

◆ adjacent() [3/3]

Box Proto::Box::adjacent ( int  a_dir,
Side::LoHiSide  a_side,
int  a_dist 
) const
inline

Adjacent Cells (Side)

Overload of adjacent that uses a Side input.

Parameters
a_dirCoordinate direction (0 for x direction, etc.)
a_sideLow or high side
a_dist(optional) "thickness" of the desired adjacent cell (default: this->size(a_dir))

Examples:

//DIM = 2;
Box B0 = Box::Cube(8); // [(0,0) , (7,7)]
B0.adjacent((0, Side::Hi, 2); // [(8, 0), (9, 7)]
B0.adjacent((0, Side::Lo, 2); // [(0,-2), (7,-1)]
B0.adjacent((0, Side::Hi); // [(8, 0), (15,7)]

◆ adjCellLo()

Box Proto::Box::adjCellLo ( int  a_dir,
int  a_dist 
) const
inline

Referenced by adjCellSide(), and empty().

◆ adjCellHi()

Box Proto::Box::adjCellHi ( int  a_dir,
int  a_dist 
) const
inline

Referenced by adjCellSide(), and empty().

◆ adjCellSide()

Box Proto::Box::adjCellSide ( int  a_idir,
int  a_length,
Side::LoHiSide  a_sd 
) const
inline

◆ begin()

BoxIterator Proto::Box::begin ( ) const
inline

Iterator Begin.

See documentation for Proto::BoxIterator for a basic usage example.

Referenced by adjCellSide().

◆ end()

BoxIterator Proto::Box::end ( ) const
inline

Iterator End.

See documentation for Proto::BoxIterator for a basic usage example.

Referenced by adjCellSide().

◆ rbegin()

BoxIterator Proto::Box::rbegin ( ) const
inline

Iterator Reverse Begin.

See documentation for Proto::BoxIterator for a basic usage example.

Referenced by adjCellSide().

◆ rend()

BoxIterator Proto::Box::rend ( ) const
inline

Iterator Reverse End.

See documentation for Proto::BoxIterator for a basic usage example.

Referenced by adjCellSide().

◆ linearSize()

size_t Proto::Box::linearSize ( ) const
inline

Linear Size.

Computes the number of bytes needed to store *this in linear buffer.

Referenced by adjCellSide().

◆ linearIn()

void Proto::Box::linearIn ( const char *  a_buf)
inline

Read From Buffer.

Reads data into *this from a buffer

Referenced by adjCellSide().

◆ linearOut()

void Proto::Box::linearOut ( char *  a_buf) const
inline

Write To Buffer.

Writes the data in *this to a buffer

Referenced by adjCellSide().

◆ print()

void Proto::Box::print ( ) const
inline

Print.

Prints *this using the format [low, high]

Referenced by adjCellSide().

◆ str()

std::string Proto::Box::str ( ) const
inline

Referenced by adjCellSide(), and Proto::operator<<().

◆ recomputeSize()

void Proto::Box::recomputeSize ( )
inline

Used to reevaluate the size of the box when it is changed.

Referenced by adjCellSide().

Member Data Documentation

◆ m_low

Point Proto::Box::m_low

Point object containing the lower bounds of the Box.

Referenced by low().

◆ m_high

Point Proto::Box::m_high

Point object containing the upper bounds of the Box.

Referenced by high().

◆ m_size

int Proto::Box::m_size

"Volume" of the box.

Referenced by empty().


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