OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
Mem_mw< local_index > Class Template Reference

Class for MEMORY-WISE cell list implementation. More...

Detailed Description

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

Class for MEMORY-WISE cell list implementation.

This class implement the MEMORY-WISE cell list The memory allocation is small. The memory allocation is (in byte) Size = O(N*size_of(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

Note
It is useful when M >> N
Template Parameters
dimDimensionality of the space
Ttype of the space float, double, complex

Definition at line 34 of file MemMemoryWise.hpp.

#include <MemMemoryWise.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 (local_index slot, local_index tot_n_cell)
 Initialize the data structure to zeros.
 
Mem_mwoperator= (const Mem_mw &cell)
 Copy two data-structure.
 
void addCell (local_index cell_id, typename base::value_type ele)
 Add an element to the cell.
 
void add (local_index cell_id, typename base::value_type ele)
 Add an element to the cell.
 
void remove (local_index cell, local_index ele)
 Remove an element from the cell.
 
size_t getNelements (const local_index cell_id) const
 Get the number of elements in the cell.
 
auto get (local_index cell, local_index ele) -> decltype(cl_base[0].get(0)) &
 
auto get (local_index cell, local_index ele) const -> decltype(cl_base.find(cell) ->second.get(0)) &
 
void swap (Mem_mw &cl)
 
void swap (Mem_mw &&cell)
 
void clear ()
 
const local_index & getStartId (size_t part_id) const
 
const local_index & getStopId (size_t part_id) const
 
const local_index & get_lin (const local_index *part_id) const
 
 Mem_mw (size_t slot)
 constructor
 
void set_slot (size_t slot)
 Set the number of slots.
 

Private Types

typedef openfpm::vector< local_index > base
 Base type storing information.
 

Private Attributes

std::unordered_map< local_index, basecl_base
 
std::remove_reference< decltype(std::declval< openfpm::vector< local_index > >().get(0))>::type invalid
 In case of invalid element return this.
 

Member Typedef Documentation

◆ base

template<typename local_index = size_t>
typedef openfpm::vector<local_index> Mem_mw< local_index >::base
private

Base type storing information.

Definition at line 37 of file MemMemoryWise.hpp.

◆ local_index_type

template<typename local_index = size_t>
typedef local_index Mem_mw< local_index >::local_index_type

expose the type of the local index

Definition at line 51 of file MemMemoryWise.hpp.

◆ toKernel_type

template<typename local_index = size_t>
typedef void Mem_mw< local_index >::toKernel_type

Definition at line 48 of file MemMemoryWise.hpp.

Constructor & Destructor Documentation

◆ Mem_mw()

template<typename local_index = size_t>
Mem_mw< local_index >::Mem_mw ( size_t  slot)
inline

constructor

Parameters
slotnumber of slots (unused)

Definition at line 194 of file MemMemoryWise.hpp.

Member Function Documentation

◆ add()

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

Add an element to the cell.

Parameters
cell_idcell-id
eleelement to add

Definition at line 98 of file MemMemoryWise.hpp.

◆ addCell()

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

Add an element to the cell.

Parameters
cell_idcell-id
eleelement to add

Definition at line 85 of file MemMemoryWise.hpp.

◆ clear()

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

Definition at line 159 of file MemMemoryWise.hpp.

◆ get() [1/2]

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

Definition at line 130 of file MemMemoryWise.hpp.

◆ get() [2/2]

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

Definition at line 140 of file MemMemoryWise.hpp.

◆ get_lin()

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

Definition at line 182 of file MemMemoryWise.hpp.

◆ getNelements()

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

Get the number of elements in the cell.

Parameters
cell_id
Returns
the number of elements

Definition at line 121 of file MemMemoryWise.hpp.

◆ getStartId()

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

Definition at line 164 of file MemMemoryWise.hpp.

◆ getStopId()

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

Definition at line 173 of file MemMemoryWise.hpp.

◆ init_to_zero()

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

Initialize the data structure to zeros.

In this case it does nothing

Parameters
slots
tot_n_celltotal number of cells

Definition at line 61 of file MemMemoryWise.hpp.

◆ operator=()

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

Copy two data-structure.

Parameters
celldata-structure to copy
Returns
itself

Definition at line 73 of file MemMemoryWise.hpp.

◆ remove()

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

Remove an element from the cell.

Parameters
cellcell-id
eleelement to remove

Definition at line 109 of file MemMemoryWise.hpp.

◆ set_slot()

template<typename local_index = size_t>
void Mem_mw< local_index >::set_slot ( size_t  slot)
inline

Set the number of slots.

Parameters
slotunused

Definition at line 204 of file MemMemoryWise.hpp.

◆ swap() [1/2]

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

Definition at line 154 of file MemMemoryWise.hpp.

◆ swap() [2/2]

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

Definition at line 149 of file MemMemoryWise.hpp.

Field Documentation

◆ cl_base

template<typename local_index = size_t>
std::unordered_map<local_index,base> Mem_mw< local_index >::cl_base
private

each cell has a dynamic structure that store the elements in the cell

Definition at line 41 of file MemMemoryWise.hpp.

◆ invalid

template<typename local_index = size_t>
std::remove_reference<decltype(std::declval<openfpm::vector<local_index>>().get(0))>::type Mem_mw< local_index >::invalid
private

In case of invalid element return this.

Definition at line 44 of file MemMemoryWise.hpp.


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