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

This class implement the point shape in an N-dimensional space. More...

Detailed Description

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

This class implement the point shape in an N-dimensional space.

Parameters
Ttype of the space
dimdimensionality

Definition at line 27 of file Point.hpp.

#include <Point.hpp>

Public Types

typedef int is_vtk_writable
 Indicate that this object is vtk writable.
 
typedef T coord_type
 coordinate type
 
typedef boost::fusion::vector< T[dim]> type
 boost fusion that store the point
 
typedef int yes_is_point
 Indicate that is a Point.
 
typedef native_encapsulated_type< T[dim]>::type type_native
 

Public Member Functions

template<typename orig , typename exp1 , typename exp2 , unsigned int op>
__device__ __host__ Point (const point_expression_op< orig, exp1, exp2, op > &p_exp)
 Evaluate the expression and save the result on the point.
 
__device__ __host__ Point (const Point< dim, T > &&p)
 Point constructor from point.
 
__device__ __host__ Point (const Point< dim, T > &p)
 Point constructor from point.
 
__device__ __host__ Point (const T(&p)[dim])
 Constructor from an array.
 
__device__ __host__ Point (T d)
 Constructor from scalar.
 
template<typename S >
__device__ __host__ Point (const Point< dim, S > &p)
 Point constructor.
 
template<unsigned int d, typename M >
 Point (const encapc< d, Point< dim, T >, M > &p)
 Point constructor.
 
template<typename vmpl >
__device__ __host__ Point (const openfpm::detail::multi_array::sub_array_openfpm< T, 1, vmpl > &mar)
 Point constructor from multi array.
 
template<typename vmpl >
__device__ __host__ Point (const openfpm::detail::multi_array::const_sub_array_openfpm< T, 1, vmpl > &mar)
 Point constructor from multi array.
 
__device__ __host__ Point (std::initializer_list< T > p1)
 Constructor from a list.
 
__device__ __host__ Point ()
 Default contructor.
 
__device__ __host__ const T & get (unsigned int i) const
 Get coordinate.
 
get_vtk (size_t i) const
 Get coordinate.
 
__device__ __host__ T & get (unsigned int i)
 Get coordinate.
 
__device__ __host__ T & operator[] (unsigned int i)
 Get the component i.
 
__device__ __host__ const T & operator[] (unsigned int i) const
 Get the component i.
 
__device__ __host__ T norm () const
 norm of the vector
 
__device__ __host__ T distance (const Point< dim, T > &q) const
 It calculate the distance between 2 points.
 
distance2 (const Point< dim, T > &q) const
 It calculate the square distance between 2 points.
 
__device__ __host__ void zero ()
 Set to zero the point coordinate.
 
void one ()
 Set to one the point coordinate.
 
std::string toPointString () const
 Convert the point into a string.
 
void swap (Point< dim, T > &p)
 exchange the data of two points
 
__device__ __host__ bool operator== (const Point< dim, T > &p) const
 Check if two points match.
 
__device__ __host__ bool operator!= (const Point< dim, T > &p) const
 Check if two points match.
 
std::string to_string () const
 Return the string with the point coordinate.
 
std::string toString () const
 Return the string with the point coordinate.
 
__device__ __host__ T & value (size_t i)
 Return the reference to the value at coordinate i.
 
__device__ __host__ T value (size_t i) const
 Return the value at coordinate i.
 
T(& asArray ())[dim]
 Return the coordinated of the point as reference array.
 
template<typename A >
Point< dim, A > convertPoint () const
 
template<typename orig , typename exp1 , typename exp2 , unsigned int op>
__device__ __host__ Point< dim, T > & operator= (const point_expression_op< orig, exp1, exp2, op > &p_exp)
 Fill the vector with the evaluated expression.
 
template<typename any >
__device__ __host__ Point< dim, T > & operator= (const point_expression< any > &p_exp)
 Fill the vector property with the evaluated expression.
 
__device__ __host__ Point< dim, T > & operator= (const T(&p)[dim])
 Fill the point with the value specified in the array.
 
template<typename T1 , typename check = typename std::enable_if<std::is_const<T1>::value == false>::type>
__device__ __host__ Point< dim, T > & operator= (const point_expression< const T1[dim]> &p_exp)
 Fill the vector property with the evaluated expression.
 
template<typename aT >
__device__ __host__ Point< dim, T > operator/ (const aT(&ar)[dim])
 divide each component by an array
 
template<typename aT >
__device__ __host__ Point< dim, T > operator/= (const aT c)
 divide each component by a constant
 
__device__ __host__ Point< dim, T > & operator= (T d)
 Fill the vector property with some value.
 
__device__ __host__ Point< dim, T > & operator= (const Point< dim, T > &p)
 operator= between points
 
__device__ __host__ Point< dim, T > & operator-= (const Point< dim, T > &p)
 Subtract two points.
 
__device__ __host__ Point< dim, T > & operator+= (const Point< dim, T > &p)
 Sum two points.
 
__device__ __host__ void init () const
 Do nothing stub operation.
 

Static Public Member Functions

static Point< dim, T > zero_p ()
 Create a point set to zero.
 
static bool noPointers ()
 This structure has no internal pointers.
 

Data Fields

type data
 structure that store the data of the point
 

Static Public Attributes

static const unsigned int x = 0
 Property id of the point.
 
static const unsigned int max_prop = 1
 The point has one property.
 
static const unsigned int max_prop_real = 1
 
static const unsigned int dims = dim
 expose the dimension
 
static const unsigned int nvals = dim
 expose the dimension with a different name
 

Member Typedef Documentation

◆ coord_type

template<unsigned int dim, typename T >
typedef T Point< dim, T >::coord_type

coordinate type

Definition at line 35 of file Point.hpp.

◆ is_vtk_writable

template<unsigned int dim, typename T >
typedef int Point< dim, T >::is_vtk_writable

Indicate that this object is vtk writable.

Definition at line 32 of file Point.hpp.

◆ type

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

boost fusion that store the point

Definition at line 38 of file Point.hpp.

◆ type_native

template<unsigned int dim, typename T >
typedef native_encapsulated_type<T[dim]>::type Point< dim, T >::type_native

Definition at line 49 of file Point.hpp.

◆ yes_is_point

template<unsigned int dim, typename T >
typedef int Point< dim, T >::yes_is_point

Indicate that is a Point.

Definition at line 41 of file Point.hpp.

Constructor & Destructor Documentation

◆ Point() [1/11]

template<unsigned int dim, typename T >
template<typename orig , typename exp1 , typename exp2 , unsigned int op>
__device__ __host__ Point< dim, T >::Point ( const point_expression_op< orig, exp1, exp2, op > &  p_exp)
inline

Evaluate the expression and save the result on the point.

Parameters
p_exppoint expression to evaluate

Definition at line 56 of file Point.hpp.

◆ Point() [2/11]

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

Point constructor from point.

Parameters
pthe point

Definition at line 66 of file Point.hpp.

◆ Point() [3/11]

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

Point constructor from point.

Parameters
pthe point

Definition at line 77 of file Point.hpp.

◆ Point() [4/11]

template<unsigned int dim, typename T >
__device__ __host__ Point< dim, T >::Point ( const T(&)  p[dim])
inline

Constructor from an array.

Parameters
parray with the coordinate of the point

Definition at line 88 of file Point.hpp.

◆ Point() [5/11]

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

Constructor from scalar.

Parameters
dscalar

Definition at line 99 of file Point.hpp.

◆ Point() [6/11]

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

Point constructor.

Parameters
pPoint

Definition at line 109 of file Point.hpp.

◆ Point() [7/11]

template<unsigned int dim, typename T >
template<unsigned int d, typename M >
Point< dim, T >::Point ( const encapc< d, Point< dim, T >, M > &  p)
inline

Point constructor.

Parameters
pencapc Point

Definition at line 120 of file Point.hpp.

◆ Point() [8/11]

template<unsigned int dim, typename T >
template<typename vmpl >
__device__ __host__ Point< dim, T >::Point ( const openfpm::detail::multi_array::sub_array_openfpm< T, 1, vmpl > &  mar)
inline

Point constructor from multi array.

Definition at line 131 of file Point.hpp.

◆ Point() [9/11]

template<unsigned int dim, typename T >
template<typename vmpl >
__device__ __host__ Point< dim, T >::Point ( const openfpm::detail::multi_array::const_sub_array_openfpm< T, 1, vmpl > &  mar)
inline

Point constructor from multi array.

Definition at line 142 of file Point.hpp.

◆ Point() [10/11]

template<unsigned int dim, typename T >
__device__ __host__ Point< dim, T >::Point ( std::initializer_list< T >  p1)
inline

Constructor from a list.

[Example] Point<3,float> p({0.0,0.0,1.0})

Parameters
p1initializer list

Definition at line 155 of file Point.hpp.

◆ Point() [11/11]

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

Default contructor.

Definition at line 163 of file Point.hpp.

Member Function Documentation

◆ asArray()

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

Return the coordinated of the point as reference array.

Returns
the reference array

Definition at line 441 of file Point.hpp.

◆ convertPoint()

template<unsigned int dim, typename T >
template<typename A >
Point< dim, A > Point< dim, T >::convertPoint ( ) const
inline

Convert the point from Point<dim,T> to Point<dim,A>

Returns
the converted point

Definition at line 451 of file Point.hpp.

◆ distance()

template<unsigned int dim, typename T >
__device__ __host__ T Point< dim, T >::distance ( const Point< dim, T > &  q) const
inline

It calculate the distance between 2 points.

The distance between itself (p) and the other point (q)

Parameters
qtarget point
Returns
the distance

Definition at line 250 of file Point.hpp.

◆ distance2()

template<unsigned int dim, typename T >
T Point< dim, T >::distance2 ( const Point< dim, T > &  q) const
inline

It calculate the square distance between 2 points.

The distance between itself (p) and the other point (q)

Parameters
qtarget point
Returns
the square of the distance

Definition at line 269 of file Point.hpp.

◆ get() [1/2]

template<unsigned int dim, typename T >
__device__ __host__ T & Point< dim, T >::get ( unsigned int  i)
inline

Get coordinate.

Parameters
idimension
Returns
the i-coordinate of the point

Definition at line 195 of file Point.hpp.

◆ get() [2/2]

template<unsigned int dim, typename T >
__device__ __host__ const T & Point< dim, T >::get ( unsigned int  i) const
inline

Get coordinate.

Parameters
idimension
Returns
the i-coordinate of the point

Definition at line 172 of file Point.hpp.

◆ get_vtk()

template<unsigned int dim, typename T >
T Point< dim, T >::get_vtk ( size_t  i) const
inline

Get coordinate.

Parameters
idimension
Returns
the i-coordinate of the point

Definition at line 184 of file Point.hpp.

◆ init()

template<unsigned int dim, typename T >
__device__ __host__ void Point< dim, T >::init ( ) const
inline

Do nothing stub operation.

Required to make the code compilable

Definition at line 639 of file Point.hpp.

◆ noPointers()

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

This structure has no internal pointers.

Definition at line 463 of file Point.hpp.

◆ norm()

template<unsigned int dim, typename T >
__device__ __host__ T Point< dim, T >::norm ( ) const
inline

norm of the vector

Returns
the norm of the vector

Definition at line 231 of file Point.hpp.

◆ one()

template<unsigned int dim, typename T >
void Point< dim, T >::one ( )
inline

Set to one the point coordinate.

Definition at line 296 of file Point.hpp.

◆ operator!=()

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

Check if two points match.

Parameters
ppoint to compare with
Returns
true if two points match

Definition at line 378 of file Point.hpp.

◆ operator+=()

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

Sum two points.

Parameters
ppoint to sum
Returns
itself

Definition at line 626 of file Point.hpp.

◆ operator-=()

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

Subtract two points.

Parameters
ppoint to subtract
Returns
itself

Definition at line 611 of file Point.hpp.

◆ operator/()

template<unsigned int dim, typename T >
template<typename aT >
__device__ __host__ Point< dim, T > Point< dim, T >::operator/ ( const aT(&)  ar[dim])
inline

divide each component by an array

Parameters
arComponent wise division
Returns
itself

Definition at line 548 of file Point.hpp.

◆ operator/=()

template<unsigned int dim, typename T >
template<typename aT >
__device__ __host__ Point< dim, T > Point< dim, T >::operator/= ( const aT  c)
inline

divide each component by a constant

Parameters
cconstant
Returns
itself

Definition at line 565 of file Point.hpp.

◆ operator=() [1/6]

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

operator= between points

Parameters
pPoint
Returns
itself

Definition at line 596 of file Point.hpp.

◆ operator=() [2/6]

template<unsigned int dim, typename T >
template<typename any >
__device__ __host__ Point< dim, T > & Point< dim, T >::operator= ( const point_expression< any > &  p_exp)
inline

Fill the vector property with the evaluated expression.

Parameters
p_expexpression to evaluate
Returns
itself

Definition at line 497 of file Point.hpp.

◆ operator=() [3/6]

template<unsigned int dim, typename T >
template<typename T1 , typename check = typename std::enable_if<std::is_const<T1>::value == false>::type>
__device__ __host__ Point< dim, T > & Point< dim, T >::operator= ( const point_expression< const T1[dim]> &  p_exp)
inline

Fill the vector property with the evaluated expression.

Template Parameters
checkdisable this method if T is a constant
Parameters
p_expexpression to evaluate
Returns
itself

Definition at line 531 of file Point.hpp.

◆ operator=() [4/6]

template<unsigned int dim, typename T >
template<typename orig , typename exp1 , typename exp2 , unsigned int op>
__device__ __host__ Point< dim, T > & Point< dim, T >::operator= ( const point_expression_op< orig, exp1, exp2, op > &  p_exp)
inline

Fill the vector with the evaluated expression.

Parameters
p_expexpression to evaluate
Returns
itself

Definition at line 479 of file Point.hpp.

◆ operator=() [5/6]

template<unsigned int dim, typename T >
__device__ __host__ Point< dim, T > & Point< dim, T >::operator= ( const T(&)  p[dim])
inline

Fill the point with the value specified in the array.

Parameters
parray
Returns
itself

Definition at line 514 of file Point.hpp.

◆ operator=() [6/6]

template<unsigned int dim, typename T >
__device__ __host__ Point< dim, T > & Point< dim, T >::operator= ( d)
inline

Fill the vector property with some value.

Parameters
dvalue to fill
Returns
itself

Definition at line 581 of file Point.hpp.

◆ operator==()

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

Check if two points match.

Parameters
ppoint to compare with
Returns
true if two points match

Definition at line 360 of file Point.hpp.

◆ operator[]() [1/2]

template<unsigned int dim, typename T >
__device__ __host__ T & Point< dim, T >::operator[] ( unsigned int  i)
inline

Get the component i.

Parameters
icomponent
Returns
the i-component

Definition at line 208 of file Point.hpp.

◆ operator[]() [2/2]

template<unsigned int dim, typename T >
__device__ __host__ const T & Point< dim, T >::operator[] ( unsigned int  i) const
inline

Get the component i.

Parameters
icomponent
Returns
the i-component

Definition at line 221 of file Point.hpp.

◆ swap()

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

exchange the data of two points

Parameters
pPoint to swap with

Definition at line 343 of file Point.hpp.

◆ to_string()

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

Return the string with the point coordinate.

Returns
the string

Definition at line 388 of file Point.hpp.

◆ toPointString()

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

Convert the point into a string.

Returns
the string

Definition at line 326 of file Point.hpp.

◆ toString()

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

Return the string with the point coordinate.

Returns
the string

Definition at line 398 of file Point.hpp.

◆ value() [1/2]

template<unsigned int dim, typename T >
__device__ __host__ T & Point< dim, T >::value ( size_t  i)
inline

Return the reference to the value at coordinate i.

Parameters
icoordinate to return
Returns
the reference

Definition at line 419 of file Point.hpp.

◆ value() [2/2]

template<unsigned int dim, typename T >
__device__ __host__ T Point< dim, T >::value ( size_t  i) const
inline

Return the value at coordinate i.

Parameters
icoordinate to return
Returns
the value

Definition at line 431 of file Point.hpp.

◆ zero()

template<unsigned int dim, typename T >
__device__ __host__ void Point< dim, T >::zero ( )
inline

Set to zero the point coordinate.

Definition at line 284 of file Point.hpp.

◆ zero_p()

template<unsigned int dim, typename T >
static Point< dim, T > Point< dim, T >::zero_p ( )
inlinestatic

Create a point set to zero.

Returns
a point with all coorfinate set to 0

Definition at line 309 of file Point.hpp.

Field Documentation

◆ data

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

structure that store the data of the point

Definition at line 44 of file Point.hpp.

◆ dims

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

expose the dimension

Definition at line 650 of file Point.hpp.

◆ max_prop

template<unsigned int dim, typename T >
const unsigned int Point< dim, T >::max_prop = 1
static

The point has one property.

Definition at line 646 of file Point.hpp.

◆ max_prop_real

template<unsigned int dim, typename T >
const unsigned int Point< dim, T >::max_prop_real = 1
static

Definition at line 647 of file Point.hpp.

◆ nvals

template<unsigned int dim, typename T >
const unsigned int Point< dim, T >::nvals = dim
static

expose the dimension with a different name

Definition at line 653 of file Point.hpp.

◆ x

template<unsigned int dim, typename T >
const unsigned int Point< dim, T >::x = 0
static

Property id of the point.

Definition at line 47 of file Point.hpp.


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