OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Box< dim, T > Class Template Reference

This class represent an N-dimensional box. More...

Detailed Description

template<unsigned int dim, typename T>
class Box< dim, T >

This class represent an N-dimensional box.

The box is defined by two points p2 and p1

                     +---------+ p2
                     |         |
                     |         |
                     |         |
                     |         |
                     |         |
                p1   +---------+
Template Parameters
dimdimensionality of the Box
Ttype of space ... double float int size_t

Expand the box with some spacing

float spacing[2] = {0.1,0.1};
Box<2,float> sp({1.0,1.0},{2.0,3.0});
sp.expand(spacing);
BOOST_REQUIRE_CLOSE(sp.getLow(0),1.0,0.0001);
BOOST_REQUIRE_CLOSE(sp.getLow(1),1.0,0.0001);
BOOST_REQUIRE_CLOSE(sp.getHigh(0),2.1,0.0001);
BOOST_REQUIRE_CLOSE(sp.getHigh(1),3.1,0.0001);
This class represent an N-dimensional box.
Definition Box.hpp:61
void expand(T(&exp)[dim])
expand the box by a vector
Definition Box.hpp:793

Create an enclosing box

Box<3,float> box1({0.1,0.2,0.3},{1.0,1.1,1.3});
Box<3,float> box2({0.5,0.6,0.7},{2.0,2.1,2.2});
box1.enclose(box2);
BOOST_REQUIRE_EQUAL(box1.getLow(0),0.1f);
BOOST_REQUIRE_EQUAL(box1.getLow(1),0.2f);
BOOST_REQUIRE_EQUAL(box1.getLow(2),0.3f);
BOOST_REQUIRE_EQUAL(box1.getHigh(0),2.0f);
BOOST_REQUIRE_EQUAL(box1.getHigh(1),2.1f);
BOOST_REQUIRE_EQUAL(box1.getHigh(2),2.2f);
void enclose(const Box< dim, T > &en)
Refine the box to enclose the given box and itself.
Definition Box.hpp:935

Create the smallest boxes between several boxes

Box<3,float> box1({0.0,0.0,0.0},{1.0,1.1,1.3});
Box<3,float> box2({0.5,2.0,0.5},{2.0,2.1,2.2});
Box<3,float> box3({1.5,1.5,4.2},{5.0,5.1,5.2});
box1.contained(box2);
box1.contained(box3);
BOOST_REQUIRE_CLOSE(box1.getHigh(0),1.0f,0.0001);
BOOST_REQUIRE_CLOSE(box1.getHigh(1),0.1f,0.0001);
BOOST_REQUIRE_CLOSE(box1.getHigh(2),1.0f,0.0001);
void contained(const Box< dim, T > &en, const bool reset_p1=true)
Refine the box to be contained in the given box and itself.
Definition Box.hpp:955

Enlarge the box

Box<3,float> box1({0.1,0.2,0.3},{1.0,1.1,1.3});
Box<3,float> box2({-0.5,-0.6,-0.7},{0.5,0.6,0.7});
box1.enlarge(box2);
BOOST_REQUIRE_CLOSE(box1.getLow(0),-0.4,0.0001);
BOOST_REQUIRE_CLOSE(box1.getLow(1),-0.4,0.0001);
BOOST_REQUIRE_CLOSE(box1.getLow(2),-0.4,0.0001);
BOOST_REQUIRE_CLOSE(box1.getHigh(0),1.5,0.0001);
BOOST_REQUIRE_CLOSE(box1.getHigh(1),1.7,0.0001);
BOOST_REQUIRE_CLOSE(box1.getHigh(2),2.0,0.0001);
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
Definition Box.hpp:823

Enlarge the box with fixed P1

Box<3,float> box1({0.1,0.2,0.3},{1.0,1.1,1.3});
Box<3,float> box2({-0.5,-0.6,-0.7},{0.5,0.6,0.7});
box1.enlarge_fix_P1(box2);
BOOST_REQUIRE_CLOSE(box1.getLow(0),0.1,0.0001);
BOOST_REQUIRE_CLOSE(box1.getLow(1),0.2,0.0001);
BOOST_REQUIRE_CLOSE(box1.getLow(2),0.3,0.0001);
BOOST_REQUIRE_CLOSE(box1.getHigh(0),2.0,0.0001);
BOOST_REQUIRE_CLOSE(box1.getHigh(1),2.3,0.0001);
BOOST_REQUIRE_CLOSE(box1.getHigh(2),2.7,0.0001);
void enlarge_fix_P1(Box< dim, S > &gh)
Enlarge the box with ghost margin keeping fix the point P1.
Definition Box.hpp:856
See also
SpaceBox

Definition at line 60 of file Box.hpp.

#include <Box.hpp>

+ Inheritance diagram for Box< dim, T >:

Public Types

typedef boost::fusion::vector< T[dim], T[dim]> type
 boost fusion that store the point
 
typedef T btype
 type of the box
 
typedef int yes_is_box
 Indicate that this is a box.
 

Public Member Functions

__device__ __host__ bool Intersect (const Box< dim, T > &b, Box< dim, T > &b_out) const
 Intersect.
 
template<typename Mem >
__device__ __host__ bool Intersect (const encapc< 1, Box< dim, T >, Mem > &e_b, Box< dim, T > &b_out) const
 Intersect.
 
template<typename distance >
bool Intersect (Sphere< dim, T > &sphere)
 Check if the sphere intersect the box.
 
min_distance (Box< dim, T > &b) const
 
template<unsigned int b>
getBase (const unsigned int i) const
 Get the coordinate of the bounding point.
 
Box< dim-1, T > getSubBox ()
 Get the the box of dimensionality dim-1 (it eliminate the last dimension)
 
__device__ __host__ Box< dim, T > & operator= (const Box< dim, T > &box)
 Operator= between boxes.
 
__device__ __host__ Box ()
 default constructor
 
 Box (const Point< dim, T > &p1, const Point< dim, T > &p2)
 Constructor from two points.
 
 Box (std::initializer_list< T > p1, std::initializer_list< T > p2)
 Constructor from initializer list.
 
 Box (T *low, T *high)
 Box constructor from a box.
 
__device__ __host__ Box (const Box< dim, T > &box)
 Box constructor from a box.
 
 Box (type box_data)
 Box constructor from vector::fusion.
 
 Box (T(&box_data)[dim])
 Box constructor from an array reference.
 
 Box (const grid_key_dx< dim > &key1, const grid_key_dx< dim > &key2)
 constructor from 2 grid_key_dx
 
template<unsigned int dimS>
__device__ __host__ Box (boost::fusion::vector< T[dimS], T[dimS]> &box_data)
 Box constructor from vector::fusion of higher dimension.
 
template<typename Mem >
__device__ __host__ Box (const encapc< 1, Box< dim, T >, Mem > &b)
 Box constructor from encapsulated box.
 
template<typename S >
__device__ __host__ Box (const Box< dim, S > &b)
 constructor from a Box of different type
 
Box< dim, T > & operator/= (const Point< dim, T > &p)
 Divide component wise each box points with a point.
 
Box< dim, T > operator* (const Point< dim, T > &p)
 Multiply component wise each box points with a point.
 
void set (std::initializer_list< T > p1, std::initializer_list< T > p2)
 Constructor from initializer list.
 
__device__ __host__ void setLow (int i, T val)
 set the low interval of the box
 
__device__ __host__ void setHigh (int i, T val)
 set the high interval of the box
 
__device__ __host__ T getLow (int i) const
 get the i-coordinate of the low bound interval of the box
 
__device__ __host__ T getHigh (int i) const
 get the high interval of the box
 
void setP1 (const grid_key_dx< dim > &p1)
 Set the point P1 of the box.
 
void setP2 (const grid_key_dx< dim > &p2)
 Set the point P2 of the box.
 
void setP1 (const Point< dim, T > &p1)
 Set the point P1 of the box.
 
void setP2 (const Point< dim, T > &p2)
 Set the point P2 of the box.
 
Box< dim, T > & getBox ()
 Get the box enclosing this Box.
 
const Box< dim, T > & getBox () const
 Get the box enclosing this Box.
 
typegetVector ()
 Get the internal boost::fusion::vector that store the data.
 
grid_key_dx< dim > getKP1 () const
 Get the point p1 as grid_key_dx.
 
grid_key_dx< dim > getKP2 () const
 Get the point p12 as grid_key_dx.
 
grid_key_dx< dim, int > getKP1int () const
 Get the point p1 as grid_key_dx.
 
grid_key_dx< dim, int > getKP2int () const
 Get the point p12 as grid_key_dx.
 
Point< dim, T > getP1 () const
 Get the point p1.
 
Point< dim, T > getP2 () const
 Get the point p2.
 
Box< dim, T > & operator-= (const Point< dim, T > &p)
 Translate the box.
 
Box< dim, T > & operator+= (const Point< dim, T > &p)
 Translate the box.
 
Box< dim, T > operator+ (const Point< dim, T > &p)
 Translate the box.
 
void expand (T(&exp)[dim])
 expand the box by a vector
 
void enlarge (const Box< dim, T > &gh)
 Enlarge the box with ghost margin.
 
template<typename S >
void enlarge_fix_P1 (Box< dim, S > &gh)
 Enlarge the box with ghost margin keeping fix the point P1.
 
void invalidate ()
 Invalidate the box.
 
void magnify (T mg)
 Magnify the box.
 
void magnify_fix_P1 (T mg)
 Magnify the box by a factor keeping fix the point P1.
 
void shrinkP2 (T sh)
 Shrink moving p2 of sh quantity (on each direction)
 
void enclose (const Box< dim, T > &en)
 Refine the box to enclose the given box and itself.
 
void contained (const Box< dim, T > &en, const bool reset_p1=true)
 Refine the box to be contained in the given box and itself.
 
void zero ()
 Set p1 and p2 to 0.
 
bool isContained (const Box< dim, T > &b) const
 Check if the box is contained.
 
__host__ __device__ bool isInside (const Point< dim, T > &p) const
 Check if the point is inside the box.
 
__device__ __host__ bool isInsideNP (const Point< dim, T > &p) const
 Check if the point is inside the region excluding the positive part.
 
template<typename bc_type >
__device__ __host__ bool isInsideNP_with_border (const Point< dim, T > &p, const Box< dim, T > &border, const bc_type(&bc)[dim]) const
 Check if the point is inside the region excluding the positive part.
 
bool isInsideNB (const Point< dim, T > &p) const
 Check if the point is inside the region excluding the borders.
 
bool isInside (const T(&p)[dim]) const
 Check if the point is inside the region (Border included)
 
template<typename KeyType >
__device__ __host__ bool isInsideKey (const KeyType &k) const
 Check if the point is inside the region (Border included)
 
bool isValid () const
 Check if the Box is a valid box P2 >= P1.
 
bool isValidN () const
 Check if the Box is a valid box P2 > P1.
 
void floorP1 ()
 Apply the ceil operation to the point P1.
 
void floorP2 ()
 Apply the ceil operation to the point P2.
 
void ceilP1 ()
 Apply the ceil operation to the point P1.
 
void ceilP2 ()
 Apply the ceil operation to the point P2.
 
void shrinkP2 (const Point< dim, T > &p)
 Shrink the point P2 by one vector.
 
void swap (Box< dim, T > &b)
 exchange the data of two boxes
 
template<typename Mem >
bool isInside (const encapc< 1, Point< dim, T >, Mem > &p)
 Check if the point is inside the region.
 
getRcut () const
 Get the worst extension.
 
getVolume () const
 Get the volume of the box.
 
getVolumeKey () const
 Get the volume spanned by the Box P1 and P2 interpreted as grid key.
 
Point< dim, T > middle () const
 Return the middle point of the box.
 
std::string toString () const
 Produce a string from the object.
 
bool operator== (const Box< dim, T > &b) const
 Compare two boxes.
 
bool operator!= (const Box< dim, T > &b) const
 Compare two boxes.
 

Static Public Member Functions

static T getVolumeKey (const T(&p1)[dim], const T(&p2)[dim])
 Get the volume spanned by the Box as grid_key_dx_iterator_sub.
 
static bool noPointers ()
 This structure has no internal pointers.
 

Data Fields

type data
 It store the two point bounding the box.
 

Static Public Attributes

static const unsigned int p1 = 0
 Low point.
 
static const unsigned int p2 = 1
 High point.
 
static const unsigned int max_prop = 2
 Maximum number of properties.
 
static const unsigned int dims = dim
 dimensionality of the box
 

Member Typedef Documentation

◆ btype

template<unsigned int dim, typename T >
typedef T Box< dim, T >::btype

type of the box

Definition at line 67 of file Box.hpp.

◆ type

template<unsigned int dim, typename T >
typedef boost::fusion::vector<T[dim],T[dim]> Box< dim, T >::type

boost fusion that store the point

Definition at line 65 of file Box.hpp.

◆ yes_is_box

template<unsigned int dim, typename T >
typedef int Box< dim, T >::yes_is_box

Indicate that this is a box.

Definition at line 70 of file Box.hpp.

Constructor & Destructor Documentation

◆ Box() [1/11]

template<unsigned int dim, typename T >
__device__ __host__ Box< dim, T >::Box ( )
inline

default constructor

Definition at line 302 of file Box.hpp.

◆ Box() [2/11]

template<unsigned int dim, typename T >
Box< dim, T >::Box ( const Point< dim, T > &  p1,
const Point< dim, T > &  p2 
)
inline

Constructor from two points.

Parameters
p1Low point, initialize as a list example {0.0,0.0,0.0}
p2High point, initialized as a list example {1.0,1.0,1.0}

Definition at line 311 of file Box.hpp.

◆ Box() [3/11]

template<unsigned int dim, typename T >
Box< dim, T >::Box ( std::initializer_list< T >  p1,
std::initializer_list< T >  p2 
)
inline

Constructor from initializer list.

Parameters
p1Low point, initialize as a list example {0.0,0.0,0.0}
p2High point, initialized as a list example {1.0,1.0,1.0}

Definition at line 323 of file Box.hpp.

◆ Box() [4/11]

template<unsigned int dim, typename T >
Box< dim, T >::Box ( T *  low,
T *  high 
)
inline

Box constructor from a box.

Parameters
higharray indicating the coordinates of the low point
lowarray indicating the coordinates of the high point

Definition at line 334 of file Box.hpp.

◆ Box() [5/11]

template<unsigned int dim, typename T >
__device__ __host__ Box< dim, T >::Box ( const Box< dim, T > &  box)
inline

Box constructor from a box.

Parameters
boxfrom which to construct

Definition at line 352 of file Box.hpp.

◆ Box() [6/11]

template<unsigned int dim, typename T >
Box< dim, T >::Box ( type  box_data)
inlineexplicit

Box constructor from vector::fusion.

Parameters
box_datafrom which to construct

Definition at line 368 of file Box.hpp.

◆ Box() [7/11]

template<unsigned int dim, typename T >
Box< dim, T >::Box ( T(&)  box_data[dim])
inline

Box constructor from an array reference.

Parameters
box_dataarray from which to construct the box

Definition at line 384 of file Box.hpp.

◆ Box() [8/11]

template<unsigned int dim, typename T >
Box< dim, T >::Box ( const grid_key_dx< dim > &  key1,
const grid_key_dx< dim > &  key2 
)
inline

constructor from 2 grid_key_dx

Parameters
key1start point
key2stop point

Definition at line 401 of file Box.hpp.

◆ Box() [9/11]

template<unsigned int dim, typename T >
template<unsigned int dimS>
__device__ __host__ Box< dim, T >::Box ( boost::fusion::vector< T[dimS], T[dimS]> &  box_data)
inline

Box constructor from vector::fusion of higher dimension.

Parameters
box_datafusion vector from which to construct the vector

Definition at line 416 of file Box.hpp.

◆ Box() [10/11]

template<unsigned int dim, typename T >
template<typename Mem >
__device__ __host__ Box< dim, T >::Box ( const encapc< 1, Box< dim, T >, Mem > &  b)
inline

Box constructor from encapsulated box.

Parameters
bbox from which to construct the vector (encapsulated)

Definition at line 434 of file Box.hpp.

◆ Box() [11/11]

template<unsigned int dim, typename T >
template<typename S >
__device__ __host__ Box< dim, T >::Box ( const Box< dim, S > &  b)
inline

constructor from a Box of different type

Parameters
bbox

Definition at line 452 of file Box.hpp.

Member Function Documentation

◆ ceilP1()

template<unsigned int dim, typename T >
void Box< dim, T >::ceilP1 ( )
inline

Apply the ceil operation to the point P1.

Definition at line 1235 of file Box.hpp.

◆ ceilP2()

template<unsigned int dim, typename T >
void Box< dim, T >::ceilP2 ( )
inline

Apply the ceil operation to the point P2.

Definition at line 1247 of file Box.hpp.

◆ contained()

template<unsigned int dim, typename T >
void Box< dim, T >::contained ( const Box< dim, T > &  en,
const bool  reset_p1 = true 
)
inline

Refine the box to be contained in the given box and itself.

All the boxes are considered centered at p1, so it only count its relative size

Parameters
enBox to be contained
reset_p1if true set p1 to 0

Definition at line 955 of file Box.hpp.

◆ enclose()

template<unsigned int dim, typename T >
void Box< dim, T >::enclose ( const Box< dim, T > &  en)
inline

Refine the box to enclose the given box and itself.

Parameters
enBox to enclose

Definition at line 935 of file Box.hpp.

◆ enlarge()

template<unsigned int dim, typename T >
void Box< dim, T >::enlarge ( const Box< dim, T > &  gh)
inline

Enlarge the box with ghost margin.

Parameters
ghspacing of the margin to enlarge
                      ^ gh.p2[1]
                      |
                      |
                 +----+----+
                 |         |
                 |         |
   gh.p1[0]<-----+         +----> gh.p2[0]
                 |         |
                 |         |
                 +----+----+
                      |
                      v  gh.p1[1]

Definition at line 823 of file Box.hpp.

◆ enlarge_fix_P1()

template<unsigned int dim, typename T >
template<typename S >
void Box< dim, T >::enlarge_fix_P1 ( Box< dim, S > &  gh)
inline

Enlarge the box with ghost margin keeping fix the point P1.

Parameters
ghspacing of the margin to enlarge
                      ^ gh.p2[1]
                      |
                      |
                 +----+----+
                 |         |
                 |         |
   gh.p1[0]<-----+         +----> gh.p2[0]
                 |         |
                 |         |
                 +----+----+
                      |
                      v  gh.p1[1]

Definition at line 856 of file Box.hpp.

◆ expand()

template<unsigned int dim, typename T >
void Box< dim, T >::expand ( T(&)  exp[dim])
inline

expand the box by a vector

only P2 is expanded

Parameters
expexpand vector

Definition at line 793 of file Box.hpp.

◆ floorP1()

template<unsigned int dim, typename T >
void Box< dim, T >::floorP1 ( )
inline

Apply the ceil operation to the point P1.

Definition at line 1211 of file Box.hpp.

◆ floorP2()

template<unsigned int dim, typename T >
void Box< dim, T >::floorP2 ( )
inline

Apply the ceil operation to the point P2.

Definition at line 1223 of file Box.hpp.

◆ getBase()

template<unsigned int dim, typename T >
template<unsigned int b>
T Box< dim, T >::getBase ( const unsigned int  i) const
inline

Get the coordinate of the bounding point.

Template Parameters
binteger define (lower or upper interval)
Parameters
ii-coordinate of the point
Returns
the i-coordinate of the bounding point

Definition at line 262 of file Box.hpp.

◆ getBox() [1/2]

template<unsigned int dim, typename T >
Box< dim, T > & Box< dim, T >::getBox ( )
inline

Get the box enclosing this Box.

basically return itself

Returns
itself

Definition at line 623 of file Box.hpp.

◆ getBox() [2/2]

template<unsigned int dim, typename T >
const Box< dim, T > & Box< dim, T >::getBox ( ) const
inline

Get the box enclosing this Box.

basically return itself

Returns
itself

Definition at line 635 of file Box.hpp.

◆ getHigh()

template<unsigned int dim, typename T >
__device__ __host__ T Box< dim, T >::getHigh ( int  i) const
inline

get the high interval of the box

Parameters
idimension
Returns
i coordinate of the high interval

Definition at line 567 of file Box.hpp.

◆ getKP1()

template<unsigned int dim, typename T >
grid_key_dx< dim > Box< dim, T >::getKP1 ( ) const
inline

Get the point p1 as grid_key_dx.

Returns
the key

Definition at line 656 of file Box.hpp.

◆ getKP1int()

template<unsigned int dim, typename T >
grid_key_dx< dim, int > Box< dim, T >::getKP1int ( ) const
inline

Get the point p1 as grid_key_dx.

Returns
the key

Definition at line 682 of file Box.hpp.

◆ getKP2()

template<unsigned int dim, typename T >
grid_key_dx< dim > Box< dim, T >::getKP2 ( ) const
inline

Get the point p12 as grid_key_dx.

Returns
the key

Definition at line 669 of file Box.hpp.

◆ getKP2int()

template<unsigned int dim, typename T >
grid_key_dx< dim, int > Box< dim, T >::getKP2int ( ) const
inline

Get the point p12 as grid_key_dx.

Returns
the key

Definition at line 695 of file Box.hpp.

◆ getLow()

template<unsigned int dim, typename T >
__device__ __host__ T Box< dim, T >::getLow ( int  i) const
inline

get the i-coordinate of the low bound interval of the box

Parameters
idimension
Returns
i-coordinate

Definition at line 556 of file Box.hpp.

◆ getP1()

template<unsigned int dim, typename T >
Point< dim, T > Box< dim, T >::getP1 ( ) const
inline

Get the point p1.

Returns
the point p1

Definition at line 708 of file Box.hpp.

◆ getP2()

template<unsigned int dim, typename T >
Point< dim, T > Box< dim, T >::getP2 ( ) const
inline

Get the point p2.

Returns
the point p2

Definition at line 722 of file Box.hpp.

◆ getRcut()

template<unsigned int dim, typename T >
T Box< dim, T >::getRcut ( ) const
inline

Get the worst extension.

Returns
the worst extension

Definition at line 1322 of file Box.hpp.

◆ getSubBox()

template<unsigned int dim, typename T >
Box< dim-1, T > Box< dim, T >::getSubBox ( )
inline

Get the the box of dimensionality dim-1 (it eliminate the last dimension)

Returns
Return the sub-box of dimension dim-1

Definition at line 273 of file Box.hpp.

◆ getVector()

template<unsigned int dim, typename T >
type & Box< dim, T >::getVector ( )
inline

Get the internal boost::fusion::vector that store the data.

Returns
the internal boost::fusion::vector that store the data

Definition at line 646 of file Box.hpp.

◆ getVolume()

template<unsigned int dim, typename T >
T Box< dim, T >::getVolume ( ) const
inline

Get the volume of the box.

Returns
the box volume

Definition at line 1336 of file Box.hpp.

◆ getVolumeKey() [1/2]

template<unsigned int dim, typename T >
T Box< dim, T >::getVolumeKey ( ) const
inline

Get the volume spanned by the Box P1 and P2 interpreted as grid key.

Returns
The volume

Definition at line 1351 of file Box.hpp.

◆ getVolumeKey() [2/2]

template<unsigned int dim, typename T >
static T Box< dim, T >::getVolumeKey ( const T(&)  p1[dim],
const T(&)  p2[dim] 
)
inlinestatic

Get the volume spanned by the Box as grid_key_dx_iterator_sub.

Warning
Careful it is not the simple volume calculation there is a +1 on each dimension, consider the case of a subgrid iterator with P1 = {5,7} ; P2 = {5,7}, the sub-grid iterator has one point {5,7}, that mean Volume=1, so the volume formula is (5 - 5 + 1) * (7 - 7 + 1)
Parameters
p1point p1
p2point p2
Returns
The volume

Definition at line 1373 of file Box.hpp.

◆ Intersect() [1/3]

template<unsigned int dim, typename T >
__device__ __host__ bool Box< dim, T >::Intersect ( const Box< dim, T > &  b,
Box< dim, T > &  b_out 
) const
inline

Intersect.

Intersect two boxes and return the result boxes, if the boxes does not intersect, return false

Parameters
bbox to intersect with
b_outbox result of the intersection
Returns
true if they intersect

Definition at line 95 of file Box.hpp.

◆ Intersect() [2/3]

template<unsigned int dim, typename T >
template<typename Mem >
__device__ __host__ bool Box< dim, T >::Intersect ( const encapc< 1, Box< dim, T >, Mem > &  e_b,
Box< dim, T > &  b_out 
) const
inline

Intersect.

Intersect two boxes and return the result boxes, if the boxes does not intersect, return false

Parameters
e_bencapsulator box to intersect with
b_outbox result of the intersection
Returns
true if they intersect

Definition at line 132 of file Box.hpp.

◆ Intersect() [3/3]

template<unsigned int dim, typename T >
template<typename distance >
bool Box< dim, T >::Intersect ( Sphere< dim, T > &  sphere)
inline

Check if the sphere intersect the box.

   p1 _____
      |    |
 p.   |    |
      |____|
            p2

Given a point p and we search for the distance of the nearest point of the box from p. In this case the distance is p1.x-p0.x the Y dimension is alligned with p In general for each dimension we check if the point is in the interval if it is we do not accumulate, otherwise we accumulate the smallest between (p1-p0) (p2-p0).

if the distance of the nearest point is smaller than the radius we have an intersection

Template Parameters
distancefunctor
Parameters
sphereto check the intersection
Returns
true if intersect false otherwise

Definition at line 164 of file Box.hpp.

◆ invalidate()

template<unsigned int dim, typename T >
void Box< dim, T >::invalidate ( )
inline

Invalidate the box.

Bring the state of this box in a way that isValid return false

Definition at line 871 of file Box.hpp.

◆ isContained()

template<unsigned int dim, typename T >
bool Box< dim, T >::isContained ( const Box< dim, T > &  b) const
inline

Check if the box is contained.

Parameters
bBox
Returns
true if the box is contained

Definition at line 986 of file Box.hpp.

◆ isInside() [1/3]

template<unsigned int dim, typename T >
template<typename Mem >
bool Box< dim, T >::isInside ( const encapc< 1, Point< dim, T >, Mem > &  p)
inline

Check if the point is inside the region.

Parameters
ppoint to check
Returns
true if the point is inside the space

Definition at line 1296 of file Box.hpp.

◆ isInside() [2/3]

template<unsigned int dim, typename T >
__host__ __device__ bool Box< dim, T >::isInside ( const Point< dim, T > &  p) const
inline

Check if the point is inside the box.

Parameters
ppoint to check
Returns
true if the point is inside the space

Definition at line 1004 of file Box.hpp.

◆ isInside() [3/3]

template<unsigned int dim, typename T >
bool Box< dim, T >::isInside ( const T(&)  p[dim]) const
inline

Check if the point is inside the region (Border included)

Parameters
ppoint to check
Returns
true if the point is inside the space

Definition at line 1124 of file Box.hpp.

◆ isInsideKey()

template<unsigned int dim, typename T >
template<typename KeyType >
__device__ __host__ bool Box< dim, T >::isInsideKey ( const KeyType &  k) const
inline

Check if the point is inside the region (Border included)

Parameters
kkey to check
Returns
true if the point is inside the space

Definition at line 1153 of file Box.hpp.

◆ isInsideNB()

template<unsigned int dim, typename T >
bool Box< dim, T >::isInsideNB ( const Point< dim, T > &  p) const
inline

Check if the point is inside the region excluding the borders.

Parameters
ppoint to check
Returns
true if the point is inside the space

Definition at line 1095 of file Box.hpp.

◆ isInsideNP()

template<unsigned int dim, typename T >
__device__ __host__ bool Box< dim, T >::isInsideNP ( const Point< dim, T > &  p) const
inline

Check if the point is inside the region excluding the positive part.

In periodic boundary conditions the positive border is not included, but match the beginning

Parameters
ppoint to check
Returns
true if the point is inside the space

Definition at line 1034 of file Box.hpp.

◆ isInsideNP_with_border()

template<unsigned int dim, typename T >
template<typename bc_type >
__device__ __host__ bool Box< dim, T >::isInsideNP_with_border ( const Point< dim, T > &  p,
const Box< dim, T > &  border,
const bc_type(&)  bc[dim] 
) const
inline

Check if the point is inside the region excluding the positive part.

In periodic boundary conditions the positive border is not included, but match the beginning

Parameters
ppoint to check
Returns
true if the point is inside the space

Definition at line 1067 of file Box.hpp.

◆ isValid()

template<unsigned int dim, typename T >
bool Box< dim, T >::isValid ( ) const
inline

Check if the Box is a valid box P2 >= P1.

Returns
true if it is valid

Definition at line 1180 of file Box.hpp.

◆ isValidN()

template<unsigned int dim, typename T >
bool Box< dim, T >::isValidN ( ) const
inline

Check if the Box is a valid box P2 > P1.

Returns
true if it is valid

Definition at line 1196 of file Box.hpp.

◆ magnify()

template<unsigned int dim, typename T >
void Box< dim, T >::magnify ( mg)
inline

Magnify the box.

For example 1.001 enlarge the box of 0.1% on each direction

Warning
P1 is mooved if not zero
Parameters
mgMagnification factor

Definition at line 889 of file Box.hpp.

◆ magnify_fix_P1()

template<unsigned int dim, typename T >
void Box< dim, T >::magnify_fix_P1 ( mg)
inline

Magnify the box by a factor keeping fix the point P1.

For example 1.001 enlarge the box of 0.1% on each direction

Parameters
mgMagnification factor

Definition at line 907 of file Box.hpp.

◆ middle()

template<unsigned int dim, typename T >
Point< dim, T > Box< dim, T >::middle ( ) const
inline

Return the middle point of the box.

Returns
the middle point of the box

Definition at line 1394 of file Box.hpp.

◆ min_distance()

template<unsigned int dim, typename T >
T Box< dim, T >::min_distance ( Box< dim, T > &  b) const
inline

Definition at line 223 of file Box.hpp.

◆ noPointers()

template<unsigned int dim, typename T >
static bool Box< dim, T >::noPointers ( )
inlinestatic

This structure has no internal pointers.

Definition at line 1384 of file Box.hpp.

◆ operator!=()

template<unsigned int dim, typename T >
bool Box< dim, T >::operator!= ( const Box< dim, T > &  b) const
inline

Compare two boxes.

Parameters
b
Returns
true if the boxes are equal

Definition at line 1453 of file Box.hpp.

◆ operator*()

template<unsigned int dim, typename T >
Box< dim, T > Box< dim, T >::operator* ( const Point< dim, T > &  p)
inline

Multiply component wise each box points with a point.

Parameters
ppoint
Returns
the result box

Definition at line 485 of file Box.hpp.

◆ operator+()

template<unsigned int dim, typename T >
Box< dim, T > Box< dim, T >::operator+ ( const Point< dim, T > &  p)
inline

Translate the box.

Parameters
pPoint translation vector
Returns
the translated box

Definition at line 773 of file Box.hpp.

◆ operator+=()

template<unsigned int dim, typename T >
Box< dim, T > & Box< dim, T >::operator+= ( const Point< dim, T > &  p)
inline

Translate the box.

Parameters
pPoint translation vector
Returns
itself

Definition at line 755 of file Box.hpp.

◆ operator-=()

template<unsigned int dim, typename T >
Box< dim, T > & Box< dim, T >::operator-= ( const Point< dim, T > &  p)
inline

Translate the box.

Parameters
pPoint translation vector
Returns
itself

Definition at line 737 of file Box.hpp.

◆ operator/=()

template<unsigned int dim, typename T >
Box< dim, T > & Box< dim, T >::operator/= ( const Point< dim, T > &  p)
inline

Divide component wise each box points with a point.

Parameters
ppoint
Returns
itself

Definition at line 468 of file Box.hpp.

◆ operator=()

template<unsigned int dim, typename T >
__device__ __host__ Box< dim, T > & Box< dim, T >::operator= ( const Box< dim, T > &  box)
inline

Operator= between boxes.

Operator= between boxes of the same size

Parameters
boxis the box that store the interval
Returns
itself

Definition at line 287 of file Box.hpp.

◆ operator==()

template<unsigned int dim, typename T >
bool Box< dim, T >::operator== ( const Box< dim, T > &  b) const
inline

Compare two boxes.

Parameters
b
Returns
true if the boxes are equal

Definition at line 1431 of file Box.hpp.

◆ set()

template<unsigned int dim, typename T >
void Box< dim, T >::set ( std::initializer_list< T >  p1,
std::initializer_list< T >  p2 
)
inline

Constructor from initializer list.

Constructor from initializer list

Parameters
p1Low point, initialize as a list example {0.0,0.0,0.0}
p2High point, initialized as a list example {1.0,1.0,1.0}

Definition at line 506 of file Box.hpp.

◆ setHigh()

template<unsigned int dim, typename T >
__device__ __host__ void Box< dim, T >::setHigh ( int  i,
val 
)
inline

set the high interval of the box

Parameters
idimension
valvalue to set

Definition at line 544 of file Box.hpp.

◆ setLow()

template<unsigned int dim, typename T >
__device__ __host__ void Box< dim, T >::setLow ( int  i,
val 
)
inline

set the low interval of the box

Parameters
idimension
valvalue to set

Definition at line 533 of file Box.hpp.

◆ setP1() [1/2]

template<unsigned int dim, typename T >
void Box< dim, T >::setP1 ( const grid_key_dx< dim > &  p1)
inline

Set the point P1 of the box.

Parameters
p1point

Definition at line 577 of file Box.hpp.

◆ setP1() [2/2]

template<unsigned int dim, typename T >
void Box< dim, T >::setP1 ( const Point< dim, T > &  p1)
inline

Set the point P1 of the box.

Parameters
p1point

Definition at line 599 of file Box.hpp.

◆ setP2() [1/2]

template<unsigned int dim, typename T >
void Box< dim, T >::setP2 ( const grid_key_dx< dim > &  p2)
inline

Set the point P2 of the box.

Parameters
p2point

Definition at line 588 of file Box.hpp.

◆ setP2() [2/2]

template<unsigned int dim, typename T >
void Box< dim, T >::setP2 ( const Point< dim, T > &  p2)
inline

Set the point P2 of the box.

Parameters
p2point

Definition at line 610 of file Box.hpp.

◆ shrinkP2() [1/2]

template<unsigned int dim, typename T >
void Box< dim, T >::shrinkP2 ( const Point< dim, T > &  p)
inline

Shrink the point P2 by one vector.

Parameters
pvector

Definition at line 1260 of file Box.hpp.

◆ shrinkP2() [2/2]

template<unsigned int dim, typename T >
void Box< dim, T >::shrinkP2 ( sh)
inline

Shrink moving p2 of sh quantity (on each direction)

Parameters
sh

Definition at line 922 of file Box.hpp.

◆ swap()

template<unsigned int dim, typename T >
void Box< dim, T >::swap ( Box< dim, T > &  b)
inline

exchange the data of two boxes

Parameters
bbox to switch

Definition at line 1273 of file Box.hpp.

◆ toString()

template<unsigned int dim, typename T >
std::string Box< dim, T >::toString ( ) const
inline

Produce a string from the object.

Returns
string

Definition at line 1409 of file Box.hpp.

◆ zero()

template<unsigned int dim, typename T >
void Box< dim, T >::zero ( )
inline

Set p1 and p2 to 0.

Definition at line 970 of file Box.hpp.

Field Documentation

◆ data

template<unsigned int dim, typename T >
type Box< dim, T >::data

It store the two point bounding the box.

Definition at line 73 of file Box.hpp.

◆ dims

template<unsigned int dim, typename T >
const unsigned int Box< dim, T >::dims = dim
static

dimensionality of the box

Definition at line 83 of file Box.hpp.

◆ max_prop

template<unsigned int dim, typename T >
const unsigned int Box< dim, T >::max_prop = 2
static

Maximum number of properties.

Definition at line 80 of file Box.hpp.

◆ p1

template<unsigned int dim, typename T >
const unsigned int Box< dim, T >::p1 = 0
static

Low point.

Definition at line 76 of file Box.hpp.

◆ p2

template<unsigned int dim, typename T >
const unsigned int Box< dim, T >::p2 = 1
static

High point.

Definition at line 78 of file Box.hpp.


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