OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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);
static std::vector< comb< dim > > getCombinations_R(size_t d)
static size_t getNumberOfElements_R(size_t d)
Get the number of Elements of dimension d.
Definition HyperCube.hpp:67

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 57 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.
 
static size_t getNumberOfElementsTo_R (size_t d_t)
 Get the sum of the number of elements from d to d_t (included)
 
static std::vector< comb< dim > > getCombinations_R (size_t d)
 
static std::vector< comb< dim > > getCombinations_R_bc (size_t d, const size_t(&bc)[dim])
 
static void BinPermutations (grid_key_dx_r &pos, std::vector< comb< dim > > &v)
 Binary permutations.
 
static void BinPermutationsSt (std::vector< comb< dim > > &v)
 Binary permutations.
 
static size_t LinPerm (comb< dim > &c)
 Linearize the permutation given by BinPermutationSt.
 
static size_t LinId (comb< dim > &c)
 Linearize the combination.
 
static bool isPositive (size_t d)
 isPositive return if the combination d is a positive or a negative
 
static int positiveFace (int d)
 return the combination of the positive face on direction d
 
static int negativeFace (int d)
 Return the combination of the negative face on direction d.
 

Member Function Documentation

◆ BinPermutations()

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 232 of file HyperCube.hpp.

◆ BinPermutationsSt()

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
vvector to fill with the permutations

Definition at line 293 of file HyperCube.hpp.

◆ getCombinations_R()

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 100 of file HyperCube.hpp.

◆ getCombinations_R_bc()

template<unsigned int dim>
static std::vector< comb< dim > > HyperCube< dim >::getCombinations_R_bc ( size_t  d,
const size_t(&)  bc[dim] 
)
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 151 of file HyperCube.hpp.

◆ getNumberOfElements_R()

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 67 of file HyperCube.hpp.

◆ getNumberOfElementsTo_R()

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 83 of file HyperCube.hpp.

◆ isPositive()

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
Returns
true if the combination is in positive direction

Definition at line 451 of file HyperCube.hpp.

◆ LinId()

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 367 of file HyperCube.hpp.

◆ LinPerm()

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

Linearize the permutation 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
Returns
the linearized permutation
See also
BinPermitationSt

Definition at line 337 of file HyperCube.hpp.

◆ negativeFace()

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 475 of file HyperCube.hpp.

◆ positiveFace()

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 463 of file HyperCube.hpp.


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