OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
Mem_bal< local_index > Class Template Reference

Class for BALANCED cell list implementation. More...

Detailed Description

template<typename local_index = size_t>
class Mem_bal< local_index >

Class for BALANCED cell list implementation.

Template Parameters
local_indextype of local index

This class implement the BALANCED cell list is fast (not best) The memory allocation is small (not best). The memory allocation is (in byte) Size = M*16 + N*sizeof(ele)

Where

N = total number of elements M = number of cells sizeof(ele) = the size of the element the cell list is storing, example if the cell list store the particle id (64bit) is 8 byte

Warning
Do not use for extremely fine cell list (M big)
Template Parameters
dimDimensionality of the space
Ttype of the space float, double, complex

Definition at line 41 of file MemBalanced.hpp.

#include <MemBalanced.hpp>

Public Types

typedef void toKernel_type
 
typedef local_index local_index_type
 expose the type of the local index
 

Public Member Functions

void init_to_zero (size_t slot, size_t tot_n_cell)
 Initialize all to zero. More...
 
Mem_baloperator= (const Mem_bal &cell)
 Copy mem balanced. More...
 
void addCell (size_t cell_id, typename base::value_type ele)
 Add an element to the cell. More...
 
void add (size_t cell_id, typename base::value_type ele)
 Add an element to the cell. More...
 
void remove (local_index cell, local_index ele)
 Remove an element from the cell. More...
 
local_index getNelements (const local_index cell_id) const
 Get the number of elements in the cell. More...
 
auto get (local_index cell, local_index ele) -> decltype(cl_base.get(0).get(0)) &
 Return an element from the cell. More...
 
auto get (local_index cell, local_index ele) const -> decltype(cl_base.get(0).get(0)) &
 Return an element from the cell. More...
 
void swap (Mem_bal &cl)
 Swap two Mem_bal. More...
 
void swap (Mem_bal &&cell)
 Swap two Mem_bal. More...
 
void clear ()
 Reset the object. More...
 
const local_index & getStartId (local_index part_id) const
 Get the start index of the selected element. More...
 
const local_index & getStopId (local_index part_id) const
 Get the stop index of the selected element. More...
 
const local_index & get_lin (const local_index *part_id) const
 get_lin More...
 
 Mem_bal (size_t slot)
 
void set_slot (size_t slot)
 

Private Types

typedef openfpm::vector< local_index > base
 vector that store the information
 

Private Attributes

openfpm::vector< basecl_base
 each cell has a pointer to a dynamic structure
 
local_index invalid
 Invalid element.
 

Member Function Documentation

◆ add()

template<typename local_index = size_t>
void Mem_bal< local_index >::add ( size_t  cell_id,
typename base::value_type  ele 
)
inline

Add an element to the cell.

Parameters
cell_idid of the cell
eleelement to add

Definition at line 107 of file MemBalanced.hpp.

◆ addCell()

template<typename local_index = size_t>
void Mem_bal< local_index >::addCell ( size_t  cell_id,
typename base::value_type  ele 
)
inline

Add an element to the cell.

Parameters
cell_idid of the cell
eleelement to add

Definition at line 94 of file MemBalanced.hpp.

◆ clear()

template<typename local_index = size_t>
void Mem_bal< local_index >::clear ( )
inline

Reset the object.

Definition at line 185 of file MemBalanced.hpp.

◆ get() [1/2]

template<typename local_index = size_t>
auto Mem_bal< local_index >::get ( local_index  cell,
local_index  ele 
) -> decltype(cl_base.get(0).get(0)) &
inline

Return an element from the cell.

Parameters
cellid of the cell
eleelement id
Returns
reference to the element

Definition at line 143 of file MemBalanced.hpp.

◆ get() [2/2]

template<typename local_index = size_t>
auto Mem_bal< local_index >::get ( local_index  cell,
local_index  ele 
) const -> decltype(cl_base.get(0).get(0)) &
inline

Return an element from the cell.

Parameters
cellid of the cell
eleelement id
Returns
reference to the element

Definition at line 156 of file MemBalanced.hpp.

◆ get_lin()

template<typename local_index = size_t>
const local_index& Mem_bal< local_index >::get_lin ( const local_index *  part_id) const
inline

get_lin

It just return the element pointed by part_id

Parameters
part_idelement
Returns
the element pointed

Definition at line 226 of file MemBalanced.hpp.

◆ getNelements()

template<typename local_index = size_t>
local_index Mem_bal< local_index >::getNelements ( const local_index  cell_id) const
inline

Get the number of elements in the cell.

Parameters
cell_idid of the cell
Returns
the number of elements in the cell

Definition at line 130 of file MemBalanced.hpp.

◆ getStartId()

template<typename local_index = size_t>
const local_index& Mem_bal< local_index >::getStartId ( local_index  part_id) const
inline

Get the start index of the selected element.

Parameters
part_idelement

Definition at line 196 of file MemBalanced.hpp.

◆ getStopId()

template<typename local_index = size_t>
const local_index& Mem_bal< local_index >::getStopId ( local_index  part_id) const
inline

Get the stop index of the selected element.

Parameters
part_idelement

Definition at line 209 of file MemBalanced.hpp.

◆ init_to_zero()

template<typename local_index = size_t>
void Mem_bal< local_index >::init_to_zero ( size_t  slot,
size_t  tot_n_cell 
)
inline

Initialize all to zero.

Parameters
slotnumber of slot (unused)
tot_n_celltotal number of cells

Definition at line 66 of file MemBalanced.hpp.

◆ operator=()

template<typename local_index = size_t>
Mem_bal& Mem_bal< local_index >::operator= ( const Mem_bal< local_index > &  cell)
inline

Copy mem balanced.

Parameters
cellmemory to copy
Returns
itself

Definition at line 81 of file MemBalanced.hpp.

◆ remove()

template<typename local_index = size_t>
void Mem_bal< local_index >::remove ( local_index  cell,
local_index  ele 
)
inline

Remove an element from the cell.

Parameters
cellid of the cell
eleelement to remove

Definition at line 118 of file MemBalanced.hpp.

◆ swap() [1/2]

template<typename local_index = size_t>
void Mem_bal< local_index >::swap ( Mem_bal< local_index > &  cl)
inline

Swap two Mem_bal.

Parameters
clelement to swap with

Definition at line 166 of file MemBalanced.hpp.

◆ swap() [2/2]

template<typename local_index = size_t>
void Mem_bal< local_index >::swap ( Mem_bal< local_index > &&  cell)
inline

Swap two Mem_bal.

Parameters
cellelement to swap with

Definition at line 176 of file MemBalanced.hpp.


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