12 #include "Space/Shape/Box.hpp"
13 #include "util/mathutil.hpp"
14 #include "Space/Shape/HyperCube.hpp"
15 #include <unordered_map>
16 #include "util/common.hpp"
17 #include "Vector/map_vector.hpp"
19 template <
typename Memory,
template <
typename>
class layout_base,
typename local_index>
37 typedef local_index local_index_type;
43 inline __device__
int getNelements(
int id)
const
45 return (
int)
cl_n.template get<0>(
id);
56 inline __device__
unsigned int get(
unsigned int cell,
unsigned int ele)
70 inline unsigned int get(
unsigned int cell,
unsigned int ele)
const
86 template <
typename Memory = HeapMemory,
typename local_index =
size_t>
116 for (
size_t i = 0 ; i <
cl_n.size() ; i++)
118 for (local_index j = 0 ; j <
cl_n.template get<0>(i) ; j++)
119 {cl_base_.template get<0>(2*i*
slot + j) =
cl_base.template get<0>(
slot * i + j);}
134 typedef local_index local_index_type;
168 cl_n.resize(tot_n_cell);
169 cl_n.template fill<0>(0);
208 template<
typename Memory2>
228 for (
int i = 0; i <
cl_n.size(); ++i)
262 cl_n.template get<0>(cell_id)++;
287 inline auto get(local_index cell, local_index
ele)
const -> decltype(
cl_base.template get<0>(cell *
slot +
ele)) &
298 inline void remove(local_index cell_id, local_index
ele)
300 cl_n.template get<0>(cell_id)--;
303 for (
int i =
ele+1; i <
cl_n.template get<0>(cell_id); ++i)
317 return cl_n.template get<0>(cell_id);
332 size_t cl_slot_tmp = mem.
slot;
358 for (
size_t i = 0 ; i <
cl_n.size() ; i++)
360 cl_n.template get<0>(i) = 0;
370 inline void clear(local_index cell_id)
372 cl_n.template get<0>(cell_id) = 0;
382 inline const local_index &
getStartId(local_index cell_id)
const
394 inline const local_index &
getGhostId(local_index cell_id)
const
406 inline const local_index &
getStopId(local_index cell_id)
const
408 return cl_base.template get<0>(cell_id*
slot+
cl_n.template get<0>(cell_id));
418 inline const local_index &
get_lin(
const local_index * part_id)
const
463 cl_n.template hostToDevice<0>();
464 cl_base.template hostToDevice<0>();
554 cl_n.template
pack<prp...>(mem, sts);
unsigned int get(unsigned int cell, unsigned int ele) const
Get an element in the cell.
__device__ unsigned int get(unsigned int cell, unsigned int ele)
Get an element in the cell.
openfpm::vector_gpu_ker< aggregate< local_index >, layout_base > base
base that store the data
openfpm::vector_gpu_ker< aggregate< local_index >, layout_base > cl_n
number of particle in each cell list
local_index slot
Number of slot for each cell.
It is a class that work like a vector of vector.
const local_index & get_lin(const local_index *part_id) const
Just return the value pointed by part_id.
openfpm::vector< aggregate< local_index >, Memory > base
base that store the data
openfpm::vector< aggregate< local_index >, Memory > cl_n
number of particle in each cell list
const openfpm::vector< aggregate< local_index >, Memory > & private_get_cl_n() const
Return the private data-structure cl_n.
void set_slot(local_index slot)
Set the number of slot for each cell.
local_index loc_index
expose the type of the local index
void operator=(Mem_fast< Memory, local_index > &&mem)
copy an object Mem_fast
const openfpm::vector< size_t > & getGhostMarkers() const
Return the private data-structure ghostMarkers.
void init_to_zero(local_index slot, local_index tot_n_cell)
Initialize the data to zero.
void realloc()
realloc the data structures
void addCellGhostMarkers()
Add ghost marker to the cell.
void clear(local_index cell_id)
Delete cell elements in Cell p.
auto get(local_index cell, local_index ele) const -> decltype(cl_base.template get< 0 >(cell *slot+ele)) &
Get an element in the cell.
void packRequest(size_t &req) const
It calculate the number of byte required to serialize the object.
void remove(local_index cell_id, local_index ele)
Remove an element in the cell.
void clear()
Delete all the elements in every cell.
static bool packRequest()
void addCell(local_index cell_id, local_index ele)
Add an element to the cell.
void destroy()
Destroy the internal memory including the retained one.
const local_index & getGhostId(local_index cell_id) const
Get the index of the first ghost element.
void swap(Mem_fast< Memory, local_index > &mem)
swap to Mem_fast object
void unpack(ExtPreAlloc< MemType > &mem, Unpack_stat &ps)
unpack a vector
void copy_general(const Mem_fast< Memory2, local_index > &mem)
copy an object Mem_fast
openfpm::vector< size_t > ghostMarkers
ghost marker for every cell (non-ghost particles < gm (ghost marker))
const base & private_get_cl_base() const
Return the private data-structure cl_base.
const local_index & getStartId(local_index cell_id) const
Get the first element of a cell (as reference)
local_index slot
Number of slot for each cell.
size_t getGhostMarker(local_index cell_id) const
Get ghost marker of the cell.
void swap(Mem_fast< Memory, local_index > &&mem)
swap to Mem_fast object
void pack(ExtPreAlloc< HeapMemory > &mem, Pack_stat &sts) const
pack a vector selecting the properties to pack
size_t size() const
return the number of elements
auto get(local_index cell, local_index ele) -> decltype(cl_base.template get< 0 >(cell *slot+ele)) &
Get an element in the cell.
const int & private_get_slot() const
Return the private slot.
const local_index & getStopId(local_index cell_id) const
Get the last element of a cell (as reference)
size_t getNelements(const local_index cell_id) const
Get the number of elements in the cell.
void operator=(const Mem_fast< Memory, local_index > &mem)
copy an object Mem_fast
Mem_fast(local_index slot)
Constructor.
static void pack(ExtPreAlloc< Mem >, const T &obj)
Error, no implementation.
static size_t packRequest(const T &obj, size_t &req)
Error, no implementation.
static void unpack(ExtPreAlloc< Mem >, T &obj)
Error, no implementation.
Implementation of 1-D std::vector like structure.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
grid interface available when on gpu