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
HyperCube< dim > Class Template Reference

This class calculate elements of the hyper-cube. More...

Detailed Description

template<unsigned int dim>
class HyperCube< dim >

This class calculate elements of the hyper-cube.

This class give you a set of utility functions for the hyper-cube like getting number of faces, number of edge, number of vertex, or in general number of elements of dimension d, position of each element

  • 0d Hyper-cube vertex
  • 1d Hypercube segment
  • 2d Hypercube square
  • 3d Hypercube Cube ...
Template Parameters
dimdimensionality of the Hyper-cube

Get vertex and edge on a line

// Get the number of vertex (elements of dimension 0) of a line (dimension 1)
// Get the number of edge (elements of dimension 1) of a line (dimension 1)
// Get combination for each dimensions
std::vector<comb<1>> v_c1_0 = HyperCube<1>::getCombinations_R(0);

Get vertex edge and surfaces of a square

// Number of vertex
// Number of edge
// Number of faces
// Get combination for vertex (1,1) (-1,1) (-1,1) (-1,-1)
std::vector<comb<2>> v_c2_0 = HyperCube<2>::getCombinations_R(0);
// Get combination for edges (1,0) (-1,0) (0,1) (0,-1)
std::vector<comb<2>> v_c2_1 = HyperCube<2>::getCombinations_R(1);

Get vertex edge surfaces and volumes of a cube

// Number of vertex
// Number of edge
// Number of faces
// Number of Cubes
// Get combination for vertex
std::vector<comb<3>> v_c3_0 = HyperCube<3>::getCombinations_R(0);
// Get combinations for edge
std::vector<comb<3>> v_c3_1 = HyperCube<3>::getCombinations_R(1);
// Get combinations for surfaces
std::vector<comb<3>> v_c3_2 = HyperCube<3>::getCombinations_R(2);

hyper-cube define only the features of an N-dimensional hyper-cube, does not define where is is located and its size, use Box for that purpose

Definition at line 54 of file HyperCube.hpp.

#include <HyperCube.hpp>

Static Public Member Functions

static size_t getNumberOfElements_R (size_t d)
 Get the number of Elements of dimension d. More...
 
static size_t getNumberOfElementsTo_R (size_t d_t)
 Get the sum of the number of elements from d to d_t (included) More...
 
static std::vector< comb< dim > > getCombinations_R (size_t d)
 
static void BinPermutations (grid_key_dx_r &pos, std::vector< comb< dim >> &v)
 Binary permutations. More...
 
static void BinPermutationsSt (std::vector< comb< dim >> &v)
 Binary permutations. More...
 
static size_t LinPerm (comb< dim > &c)
 Linearize the Permitation given by BinPermutationSt. More...
 
static size_t LinId (comb< dim > &c)
 Linearize the combination. More...
 
static bool isPositive (size_t d)
 isPositive return if the combination d is a positive or a negative More...
 
static int positiveFace (int d)
 return the combination of the positive face on direction d More...
 
static int negativeFace (int d)
 Return the combination of the negative face on direction d. More...
 

Member Function Documentation

template<unsigned int dim>
static void HyperCube< dim >::BinPermutations ( grid_key_dx_r pos,
std::vector< comb< dim >> &  v 
)
inlinestatic

Binary permutations.

Fill v with all the possible binary permutations it produce 2^(pos.getDim()) Permutations

Example

if getDim() is 2

it produce 4 configuration

(1,1) (1,-1) (-1,1) (-1,-1)

and fill the number in the position indicated by Iterator_g_const

Parameters
posslots inside comb to fill with all permutations
vvector to fill with the permutations

Definition at line 160 of file HyperCube.hpp.

template<unsigned int dim>
static void HyperCube< dim >::BinPermutationsSt ( std::vector< comb< dim >> &  v)
inlinestatic

Binary permutations.

Fill v with all the possible binary permutations it produce 2^(pos.getDim()) Permutations

Example

if getDim() is 2

it produce 4 configuration

(1,1) (1,-0) (0,1) (0,0)

from another prospective given

*
*    +----#----+
*    |         |
*    |         |
*    #    *    #
*    |         |
*    |         |
*    +----#----+
*
* 

combination in the center (*) the down-left vertex (+). down and left edge (#)

Parameters
posslots inside comb to fill with all permutations
vvector to fill with the permutations

Definition at line 222 of file HyperCube.hpp.

template<unsigned int dim>
static std::vector<comb<dim> > HyperCube< dim >::getCombinations_R ( size_t  d)
inlinestatic

brief Calculate the position (combinations) of all the elements of size d

Parameters
ddimensionality of the object returned in the combinations
Returns
all the combinations

Definition at line 97 of file HyperCube.hpp.

template<unsigned int dim>
static size_t HyperCube< dim >::getNumberOfElements_R ( size_t  d)
inlinestatic

Get the number of Elements of dimension d.

Parameters
ddimensionality of the element
Returns
the number of elements of dimension d

Definition at line 64 of file HyperCube.hpp.

template<unsigned int dim>
static size_t HyperCube< dim >::getNumberOfElementsTo_R ( size_t  d_t)
inlinestatic

Get the sum of the number of elements from d to d_t (included)

Parameters
d_t
Returns
the sum of the number of elements from d to d_t

Definition at line 80 of file HyperCube.hpp.

template<unsigned int dim>
static bool HyperCube< dim >::isPositive ( size_t  d)
inlinestatic

isPositive return if the combination d is a positive or a negative

For an hyper-cube of dimension dim we have 2*dim faces combinations half on positive direction half on negative direction, the function check if the d combination is negative or positive

Parameters
d

Definition at line 369 of file HyperCube.hpp.

template<unsigned int dim>
static size_t HyperCube< dim >::LinId ( comb< dim > &  c)
inlinestatic

Linearize the combination.

It map the combination into a linear id, in particular given the vector of combinations with get getCombinations_R, given the combination it give where is located in the vector

Parameters
cgiven combination
Returns
the linearized combination

Definition at line 294 of file HyperCube.hpp.

template<unsigned int dim>
static size_t HyperCube< dim >::LinPerm ( comb< dim > &  c)
inlinestatic

Linearize the Permitation given by BinPermutationSt.

Suppose BinPermutation return the following combination

(-1,-1) (-1,0) (0,-1) (0,0)

giving (0,-1) it return 2

Parameters
ccombination to linearize
See Also
BinPermitationSt

Definition at line 264 of file HyperCube.hpp.

template<unsigned int dim>
static int HyperCube< dim >::negativeFace ( int  d)
inlinestatic

Return the combination of the negative face on direction d.

Parameters
ddirection
Returns
id of the combination

Definition at line 393 of file HyperCube.hpp.

template<unsigned int dim>
static int HyperCube< dim >::positiveFace ( int  d)
inlinestatic

return the combination of the positive face on direction d

Parameters
ddirection
Returns
id of the combination

Definition at line 381 of file HyperCube.hpp.


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