OpenFPM  5.2.0
Project that contain the implementation of distributed structures
Mem_bal< local_index > Class Template Reference

Class for BALANCED cell list implementation. More...

#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 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 addCellGhostMarkers ()
 Add ghost marker to the cell. More...
 
size_t getGhostMarker (local_index cell_id) const
 Get ghost marker of the cell.
 
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.
 
const local_index & getStartId (local_index cell_id) const
 Get the start index of the selected element. More...
 
const local_index & getGhostId (local_index cell_id) const
 Get the index of the first ghost element. More...
 
const local_index & getStopId (local_index cell_id) const
 Get the stop index of the selected element. More...
 
const local_index & get_lin (const local_index *cell_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
 
openfpm::vector< size_t > ghostMarkers
 ghost marker for every cell (non-ghost particles < gm (ghost marker))
 
local_index invalid
 Invalid element.
 

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 39 of file MemBalanced.hpp.

Member Function Documentation

◆ 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 97 of file MemBalanced.hpp.

◆ addCellGhostMarkers()

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

Add ghost marker to the cell.

Parameters
cell_idid of the cell
g_mghost marker to add

Definition at line 159 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 135 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 148 of file MemBalanced.hpp.

◆ get_lin()

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

get_lin

It just return the element pointed by cell_id

Parameters
cell_idelement
Returns
the element pointed

Definition at line 259 of file MemBalanced.hpp.

◆ getGhostId()

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

Get the index of the first ghost element.

Parameters
cell_idelement

Definition at line 229 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 122 of file MemBalanced.hpp.

◆ getStartId()

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

Get the start index of the selected element.

Parameters
cell_idelement

Definition at line 216 of file MemBalanced.hpp.

◆ getStopId()

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

Get the stop index of the selected element.

Parameters
cell_idelement

Definition at line 242 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 67 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 83 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 110 of file MemBalanced.hpp.

◆ swap() [1/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 193 of file MemBalanced.hpp.

◆ swap() [2/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 182 of file MemBalanced.hpp.


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