10#ifndef CELLLISTBAL_HPP_
11#define CELLLISTBAL_HPP_
13#include "NN/CellList/CellList.hpp"
14#include "Space/SpaceBox.hpp"
15#include "util/mathutil.hpp"
16#include "NN/CellList/CellNNIterator.hpp"
17#include "Space/Shape/HyperCube.hpp"
40template<
typename local_index =
size_t>
55 typedef void toKernel_type;
94 inline void addCell(
size_t cell_id,
typename base::value_type
ele)
107 inline void add(
size_t cell_id,
typename base::value_type
ele)
132 return cl_base.get(cell_id).size();
143 inline auto get(local_index cell, local_index
ele) ->
decltype(
cl_base.get(0).get(0)) &
156 inline auto get(local_index cell, local_index
ele)
const ->
decltype(
cl_base.get(0).get(0)) &
187 for (
size_t i = 0 ; i <
cl_base.size() ; i++)
196 inline const local_index &
getStartId(local_index part_id)
const
198 if (
cl_base.get(part_id).size() == 0)
201 return cl_base.get(part_id).get(0);
209 inline const local_index &
getStopId(local_index part_id)
const
211 if (
cl_base.get(part_id).size() == 0)
214 return *(&
cl_base.get(part_id).last() + 1);
226 inline const local_index &
get_lin(
const local_index * part_id)
const
237 inline void set_slot(
size_t slot)
Class for BALANCED cell list implementation.
local_index local_index_type
expose the type of the local index
openfpm::vector< base > cl_base
each cell has a pointer to a dynamic structure
const local_index & get_lin(const local_index *part_id) const
get_lin
void addCell(size_t cell_id, typename base::value_type ele)
Add an element to the cell.
local_index getNelements(const local_index cell_id) const
Get the number of elements in the cell.
void swap(Mem_bal &&cell)
Swap two Mem_bal.
auto get(local_index cell, local_index ele) -> decltype(cl_base.get(0).get(0)) &
Return an element from the cell.
auto get(local_index cell, local_index ele) const -> decltype(cl_base.get(0).get(0)) &
Return an element from the cell.
local_index invalid
Invalid element.
void add(size_t 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.
openfpm::vector< local_index > base
vector that store the information
const local_index & getStopId(local_index part_id) const
Get the stop index of the selected element.
const local_index & getStartId(local_index part_id) const
Get the start index of the selected element.
void init_to_zero(size_t slot, size_t tot_n_cell)
Initialize all to zero.
void swap(Mem_bal &cl)
Swap two Mem_bal.
Mem_bal & operator=(const Mem_bal &cell)
Copy mem balanced.
void clear()
Reset the object.
Implementation of 1-D std::vector like structure.