OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
SpaceBox< dim, T > Class Template Reference

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

Detailed Description

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

This class represent an N-dimensional box.

Parameters
Ttype of space ... double float int size_t
Ndimensionality of the Box

Definition of a spacebox and rescale

float spacing[2] = {0.1,0.1};
{
SpaceBox<2,float> sp({1.0,1.0},{2.0,2.0});
sp.rescale(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),1.1,0.0001);
BOOST_REQUIRE_CLOSE(sp.getHigh(1),1.1,0.0001);
}

Definition of a spaceboxes and intersection between them

{
SpaceBox<2,float> sp1({1.0,1.0},{2.0,2.0});
SpaceBox<2,float> sp2({0.5,0.5},{1.5,1.5});
bool inte = sp1.Intersect(sp2,sp3);
BOOST_REQUIRE_EQUAL(inte,true);
BOOST_REQUIRE_EQUAL(sp3.getLow(0),1.0);
BOOST_REQUIRE_EQUAL(sp3.getLow(1),1.0);
BOOST_REQUIRE_EQUAL(sp3.getHigh(0),1.5);
BOOST_REQUIRE_EQUAL(sp3.getHigh(1),1.5);

Create random points inside the SpaceBox

SpaceBox<3,float> sp_box({0.0,0.0,0.0},{1.0,1.0,1.0});
for (int i = 0 ; i < N_RANDOM_POINT ; i++)
{
Point<3,float> p = sp_box.rnd();
BOOST_REQUIRE_EQUAL(sp_box.isInside(p),true);
}

Definition at line 26 of file SpaceBox.hpp.

#include <SpaceBox.hpp>

+ Inheritance diagram for SpaceBox< dim, T >:

Public Member Functions

SpaceBox< dim, T > & operator= (const Box< dim, T > &b)
 Define the box from a box shape. More...
 
template<typename S >
 SpaceBox (const Box< dim, S > &b)
 constructor from a Box of different type More...
 
 SpaceBox (const SpaceBox< dim, T > &b)
 constructor from a SpaceBox More...
 
 SpaceBox (const Box< dim, T > &b)
 constructor from a box More...
 
template<unsigned int dim_s, typename Mem >
 SpaceBox (const encapc< dim_s, Box< dim, T >, Mem > &box)
 Constructor from a Box. More...
 
template<unsigned int dim_s, typename Mem >
 SpaceBox (const encapc< dim_s, SpaceBox< dim, T >, Mem > &box)
 Constructor from a Box. More...
 
 SpaceBox (std::initializer_list< T > p1, std::initializer_list< T > p2)
 Constructor from initializer list. More...
 
void rescale (T(&sp)[dim])
 Re-scale the space box with the coefficient defined in sp. More...
 
template<typename S >
void rescale (S(&sp)[dim])
 Re-scale the space box with the coefficient defined in sp. More...
 
void mul (T(&sp)[dim])
 multiply the space box with the coefficient defined in sp More...
 
template<typename S >
void mul (S(&sp)[dim])
 multiply the space box with the coefficient defined in sp More...
 
Point< dim, T > rnd ()
 Generate a random point inside the box. More...
 
 SpaceBox ()
 Default constructor.
 
- Public Member Functions inherited from Box< dim, T >
template<int i>
auto get () -> decltype(boost::fusion::at_c< i >(data))
 
bool Intersect (const Box< dim, T > &b, Box< dim, T > &b_out) const
 Intersect. More...
 
template<typename Mem >
bool Intersect (const encapc< 1, Box< dim, T >, Mem > &e_b, Box< dim, T > &b_out) const
 Intersect. More...
 
template<typename distance >
bool Intersect (Sphere< dim, T > &sphere)
 Check if the sphere intersect the box. More...
 
template<unsigned int b>
getBase (const unsigned int i) const
 Get the coordinate of the bounding point. More...
 
Box< dim-1, T > getSubBox ()
 Get the the box of dimensionality dim-1 (it eliminate the last dimension) More...
 
Box< dim, T > & operator= (const Box< dim, T > &box)
 Operator= between boxes. More...
 
 Box ()
 default constructor
 
 Box (const Point< dim, T > &p1, const Point< dim, T > &p2)
 Constructor from two points. More...
 
 Box (std::initializer_list< T > p1, std::initializer_list< T > p2)
 Constructor from initializer list. More...
 
 Box (T *high, T *low)
 Box constructor from a box. More...
 
 Box (const Box< dim, T > &box)
 Box constructor from a box. More...
 
 Box (type box_data)
 Box constructor from vector::fusion. More...
 
 Box (T(&box_data)[dim])
 Box constructor from an array reference. More...
 
 Box (const grid_key_dx< dim > &key1, const grid_key_dx< dim > &key2)
 constructor from 2 grid_key_dx More...
 
template<unsigned int dimS>
 Box (boost::fusion::vector< T[dimS], T[dimS]> &box_data)
 Box constructor from vector::fusion of higher dimension. More...
 
template<typename Mem >
 Box (const encapc< 1, Box< dim, T >, Mem > &b)
 Box constructor from encapsulated box. More...
 
template<typename S >
 Box (const Box< dim, S > &b)
 constructor from a Box of different type More...
 
Box< dim, T > & operator/= (const Point< dim, T > &p)
 Divide component wise each box points with a point. More...
 
Box< dim, T > operator* (const Point< dim, T > &p)
 Multiply component wise each box points with a point. More...
 
void set (std::initializer_list< T > p1, std::initializer_list< T > p2)
 Constructor from initializer list. More...
 
void setLow (int i, T val)
 set the low interval of the box More...
 
void setHigh (int i, T val)
 set the high interval of the box More...
 
getLow (int i) const
 get the i-coordinate of the low bound interval of the box More...
 
getHigh (int i) const
 get the high interval of the box More...
 
void setP1 (const grid_key_dx< dim > &p1)
 Set the point P1 of the box. More...
 
void setP2 (const grid_key_dx< dim > &p2)
 Set the point P2 of the box. More...
 
void setP1 (const Point< dim, T > &p1)
 Set the point P1 of the box. More...
 
void setP2 (const Point< dim, T > &p2)
 Set the point P2 of the box. More...
 
Box< dim, T > & getBox ()
 Get the box enclosing this Box. More...
 
typegetVector ()
 Get the internal boost::fusion::vector that store the data. More...
 
grid_key_dx< dim > getKP1 () const
 
grid_key_dx< dim > getKP2 () const
 
Point< dim, T > getP1 () const
 
Point< dim, T > getP2 () const
 
Box< dim, T > & operator-= (const Point< dim, T > &p)
 Translate the box. More...
 
Box< dim, T > & operator+= (const Point< dim, T > &p)
 Translate the box. More...
 
void expand (T(&exp)[dim])
 
void enlarge (const Box< dim, T > &gh)
 Enlarge the box with ghost margin. More...
 
template<typename S >
void enlarge_fix_P1 (Box< dim, S > &gh)
 Enlarge the box with ghost margin keeping fix the point P1. More...
 
void magnify (T mg)
 Magnify the box. More...
 
void magnify_fix_P1 (T mg)
 Magnify the box by a factor keeping fix the point P1. More...
 
void shrinkP2 (T sh)
 Shrink moving p2 of sh quantity (on each direction) More...
 
void enclose (Box< dim, T > &en)
 Refine the box to enclose the given box and itself. More...
 
void contained (const Box< dim, T > &en, const bool reset_p1=true)
 Refine the box to be contained in the given box and itself. More...
 
void zero ()
 Set p1 and p2 to 0. More...
 
bool isInside (const Point< dim, T > &p) const
 Check if the point is inside the region. More...
 
bool isInsideNP (const Point< dim, T > &p) const
 Check if the point is inside the region excluding the positive part. More...
 
bool isInside (const T(&p)[dim]) const
 Check if the point is inside the region. More...
 
bool isValid () const
 Check if the Box is a valid box P2 >= P1. More...
 
void ceilP1 ()
 Translate P1 of a given vector P1. More...
 
void ceilP2 ()
 Translate P1 of a unit vector on all directions. More...
 
void shrinkP2 (const Point< dim, T > &p)
 Shrink the point P2 by one. More...
 
template<typename Mem >
bool isInside (const encapc< 1, Point< dim, T >, Mem > &p)
 Check if the point is inside the region. More...
 
getVolumeKey () const
 Get the volume spanned by the Box P1 and P2 interpreted as grid key. More...
 
Point< dim, T > middle () const
 Return the middle point of the box. More...
 
std::string toString () const
 Produce a string from the object. More...
 
bool operator== (const Box< dim, T > &b) const
 Compare two boxes. More...
 
bool operator!= (const Box< dim, T > &b) const
 Compare two boxes. More...
 

Additional Inherited Members

- Public Types inherited from Box< dim, T >
typedef boost::fusion::vector
< T[dim], T[dim]> 
type
 boost fusion that store the point
 
typedef T btype
 type of the box
 
- Static Public Member Functions inherited from Box< dim, T >
static T getVolumeKey (T(&p1)[dim], T(&p2)[dim])
 Get the volume spanned by the Box as grid_key_dx_iterator_sub. More...
 
static bool noPointers ()
 This structure has no internal pointers.
 
- Data Fields inherited from Box< dim, T >
type data
 It store the two point bounding the box.
 
- Static Public Attributes inherited from Box< dim, T >
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
 

Constructor & Destructor Documentation

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

constructor from a Box of different type

Parameters
bbox

Definition at line 57 of file SpaceBox.hpp.

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

constructor from a SpaceBox

constructor from a SpaceBox

Parameters
bis the SpaceBox

Definition at line 73 of file SpaceBox.hpp.

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

constructor from a box

constructor from a box

Parameters
bis the box

Definition at line 86 of file SpaceBox.hpp.

template<unsigned int dim, typename T>
template<unsigned int dim_s, typename Mem >
SpaceBox< dim, T >::SpaceBox ( const encapc< dim_s, Box< dim, T >, Mem > &  box)
inline

Constructor from a Box.

Parameters
boxBox (Encapsulated)

Definition at line 97 of file SpaceBox.hpp.

template<unsigned int dim, typename T>
template<unsigned int dim_s, typename Mem >
SpaceBox< dim, T >::SpaceBox ( const encapc< dim_s, SpaceBox< dim, T >, Mem > &  box)
inline

Constructor from a Box.

Parameters
boxbox (Encapsulated)

Definition at line 113 of file SpaceBox.hpp.

template<unsigned int dim, typename T>
SpaceBox< dim, T >::SpaceBox ( 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 133 of file SpaceBox.hpp.

Member Function Documentation

template<unsigned int dim, typename T>
void SpaceBox< dim, T >::mul ( T(&)  sp[dim])
inline

multiply the space box with the coefficient defined in sp

It rescale the domain where the space box live

Parameters
spcoefficents

Definition at line 178 of file SpaceBox.hpp.

template<unsigned int dim, typename T>
template<typename S >
void SpaceBox< dim, T >::mul ( S(&)  sp[dim])
inline

multiply the space box with the coefficient defined in sp

It rescale the domain where the space box live

Parameters
spcoefficents

Definition at line 195 of file SpaceBox.hpp.

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

Define the box from a box shape.

Define the box from a box shape

Parameters
bis the box
Returns
itself

Definition at line 39 of file SpaceBox.hpp.

template<unsigned int dim, typename T>
void SpaceBox< dim, T >::rescale ( T(&)  sp[dim])
inline

Re-scale the space box with the coefficient defined in sp.

Parameters
sp

Definition at line 152 of file SpaceBox.hpp.

template<unsigned int dim, typename T>
template<typename S >
void SpaceBox< dim, T >::rescale ( S(&)  sp[dim])
inline

Re-scale the space box with the coefficient defined in sp.

Parameters
sp

Definition at line 164 of file SpaceBox.hpp.

template<unsigned int dim, typename T>
Point<dim,T> SpaceBox< dim, T >::rnd ( )
inline

Generate a random point inside the box.

Returns
a random point inside the box

Definition at line 209 of file SpaceBox.hpp.


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