Commit 2c313203 authored by incardon's avatar incardon
Browse files

Latest working grid yaroslav thesis

parent 3a732c98
......@@ -20,7 +20,7 @@ Grid/iterators/grid_key_dx_iterator_sp.hpp Grid/grid_key_dx_iterator_hilbert.hpp
Point_test.hpp \
Point_orig.hpp \
memory_ly/memory_array.hpp memory_ly/memory_c.hpp memory_ly/memory_conf.hpp memory_ly/t_to_memory_c.hpp \
NN/CellList/MemBalanced.hpp NN/CellList/MemFast.hpp NN/CellList/MemMemoryWise.hpp NN/CellList/CellNNIteratorRuntime.hpp NN/CellList/ParticleItCRS_Cells.hpp NN/CellList/ParticleIt_Cells.hpp NN/CellList/CellDecomposer.hpp NN/VerletList/VerletList.hpp NN/VerletList/VerletListFast.hpp NN/VerletList/VerletNNIterator.hpp NN/CellList/CellListNNIteratorRadius.hpp NN/CellList/CellListIterator.hpp NN/CellList/CellListM.hpp NN/CellList/CellNNIteratorM.hpp NN/CellList/CellList.hpp NN/CellList/CellList_test.hpp NN/CellList/CellListFast.hpp NN/CellList/CellNNIterator.hpp \
NN/CellList/MemBalanced.hpp NN/CellList/MemFast.hpp NN/CellList/MemMemoryWise.hpp NN/CellList/CellNNIteratorRuntime.hpp NN/CellList/ParticleItCRS_Cells.hpp NN/CellList/ParticleIt_Cells.hpp NN/CellList/CellDecomposer.hpp NN/VerletList/VerletList.hpp NN/VerletList/VerletListFast.hpp NN/VerletList/VerletNNIterator.hpp NN/CellList/CellListNNIteratorRadius.hpp NN/CellList/CellListIterator.hpp NN/CellList/CellListM.hpp NN/CellList/CellNNIteratorM.hpp NN/CellList/CellList.hpp NN/CellList/CellList_test.hpp NN/CellList/CellListFast_gen.hpp NN/CellList/CellNNIterator.hpp NN/CellList/ProcKeys.hpp \
Space/Ghost.hpp Space/Matrix.hpp Space/SpaceBox.hpp Space/SpaceBox_unit_tests.hpp \
Space/Shape/AdaptiveCylinderCone.hpp Space/Shape/Box.hpp Space/Shape/Box_unit_tests.hpp Space/Shape/HyperCube.hpp Space/Shape/HyperCube_unit_test.hpp Space/Shape/Point.hpp Space/Shape/Point_unit_test.hpp Space/Shape/Point_operators_functions.hpp Space/Shape/Point_operators.hpp Space/Shape/Sphere.hpp \
util/check_no_pointers.hpp util/common.hpp util/convert.hpp util/create_vmpl_sequence.hpp util/ct_array.hpp util/for_each_ref.hpp util/mathutil.hpp util/object_creator.hpp util/object_s_di.hpp util/object_si_d.hpp util/object_util.hpp util/util_debug.hpp util/util_test.hpp util/variadic_to_vmpl.hpp util/variadic_to_vmpl_unit_test.hpp util/Pack_stat.hpp \
......
......@@ -826,6 +826,20 @@ public:
return Mem_type::get(cell,ele);
}
/*! \brief Get an element in the cell
*
* \tparam i property to get
*
* \param cell cell id
* \param ele element id
*
* \return The element value
*
*/
inline auto get(size_t cell, size_t ele) const -> const decltype(this->Mem_type::get(cell,ele))
{
return Mem_type::get(cell,ele);
}
/*! \brief Swap the memory
*
......
......@@ -50,58 +50,63 @@ public:
// Object type that the structure store
typedef T value_type;
void init_to_zero(size_t slot, size_t tot_n_cell)
inline void init_to_zero(size_t slot, size_t tot_n_cell)
{
//resize the vector to needed number of cells
cl_base.resize(tot_n_cell);
}
Mem_bal & operator=(const Mem_bal & cell)
inline Mem_bal & operator=(const Mem_bal & cell)
{
cl_base = cell.cl_base;
return *this;
}
void addCell(size_t cell_id, typename base::value_type ele)
inline void addCell(size_t cell_id, typename base::value_type ele)
{
//add another neighbor element
cl_base.get(cell_id).add(ele);
}
void add(size_t cell_id, typename base::value_type ele)
inline void add(size_t cell_id, typename base::value_type ele)
{
this->addCell(cell_id,ele);
}
void remove(size_t cell, size_t ele)
inline void remove(size_t cell, size_t ele)
{
cl_base.get(cell).remove(ele);
}
size_t getNelements(const size_t cell_id) const
inline size_t getNelements(const size_t cell_id) const
{
return cl_base.get(cell_id).size();
}
auto get(size_t cell, size_t ele) -> decltype(cl_base.get(0).get(0)) &
inline auto get(size_t cell, size_t ele) -> decltype(cl_base.get(0).get(0)) &
{
return cl_base.get(cell).get(ele);
}
void swap(Mem_bal & cl)
inline auto get(size_t cell, size_t ele) const -> const decltype(cl_base.get(0).get(0)) &
{
return cl_base.get(cell).get(ele);
}
inline void swap(Mem_bal & cl)
{
cl_base.swap(cl.cl_base);
}
void swap(Mem_bal && cell)
inline void swap(Mem_bal && cell)
{
cl_base.swap(cell.cl_base);
}
void clear()
inline void clear()
{
for (size_t i = 0 ; i < cl_base.size() ; i++)
cl_base.get(i).clear();
......@@ -124,10 +129,10 @@ public:
public:
Mem_bal(size_t slot)
inline Mem_bal(size_t slot)
{}
void set_slot(size_t slot)
inline void set_slot(size_t slot)
{}
};
......
......@@ -5,8 +5,8 @@
* Author: Pietro Incardona
*/
#ifndef CELLLISTSTANDARD_HPP_
#define CELLLISTSTANDARD_HPP_
#ifndef MEMFAST_HPP_
#define MEMFAST_HPP_
#include "CellList.hpp"
#include "Space/SpaceBox.hpp"
......@@ -37,7 +37,7 @@ class Mem_fast
*
*
*/
void realloc()
inline void realloc()
{
// we do not have enough slots reallocate the basic structure with more
// slots
......@@ -59,7 +59,7 @@ class Mem_fast
protected:
void init_to_zero(size_t slot, size_t tot_n_cell)
inline void init_to_zero(size_t slot, size_t tot_n_cell)
{
this->slot = slot;
......@@ -73,7 +73,7 @@ protected:
cl_base.resize(tot_n_cell * slot);
}
void operator=(const Mem_fast & mem)
inline void operator=(const Mem_fast & mem)
{
slot = mem.slot;
......@@ -81,7 +81,7 @@ protected:
cl_base = mem.cl_base;
}
void addCell(size_t cell_id, typename base::value_type ele)
inline void addCell(size_t cell_id, typename base::value_type ele)
{
// Get the number of element the cell is storing
......@@ -98,29 +98,34 @@ protected:
cl_n.get(cell_id)++;
}
void add(size_t cell_id, typename base::value_type ele)
inline void add(size_t cell_id, typename base::value_type ele)
{
// add the element to the cell
this->addCell(cell_id,ele);
}
auto get(size_t cell, size_t ele) -> decltype(cl_base.get(cell * slot + ele)) &
inline auto get(size_t cell, size_t ele) -> decltype(cl_base.get(cell * slot + ele)) &
{
return cl_base.get(cell * slot + ele);
}
void remove(size_t cell, size_t ele)
inline auto get(size_t cell, size_t ele) const -> const decltype(cl_base.get(cell * slot + ele)) &
{
return cl_base.get(cell * slot + ele);
}
inline void remove(size_t cell, size_t ele)
{
cl_n.get(cell)--;
}
size_t getNelements(const size_t cell_id) const
inline size_t getNelements(const size_t cell_id) const
{
return cl_n.get(cell_id);
}
void swap(Mem_fast & mem)
inline void swap(Mem_fast & mem)
{
cl_n.swap(mem.cl_n);
cl_base.swap(mem.cl_base);
......@@ -130,7 +135,7 @@ protected:
slot = cl_slot_tmp;
}
void swap(Mem_fast && mem)
inline void swap(Mem_fast && mem)
{
slot = mem.slot;
......@@ -138,7 +143,7 @@ protected:
cl_base.swap(mem.cl_base);
}
void clear()
inline void clear()
{
for (size_t i = 0 ; i < cl_n.size() ; i++)
cl_n.get(i) = 0;
......@@ -161,11 +166,11 @@ protected:
public:
Mem_fast(size_t slot)
inline Mem_fast(size_t slot)
:slot(slot)
{}
void set_slot(size_t slot)
inline void set_slot(size_t slot)
{
this->slot = slot;
}
......
......@@ -49,34 +49,34 @@ public:
typedef T value_type;
void init_to_zero(size_t slot, size_t tot_n_cell)
inline void init_to_zero(size_t slot, size_t tot_n_cell)
{
}
Mem_mw & operator=(const Mem_mw & cell)
inline Mem_mw & operator=(const Mem_mw & cell)
{
cl_base = cell.cl_base;
return *this;
}
void addCell(size_t cell_id, typename base::value_type ele)
inline void addCell(size_t cell_id, typename base::value_type ele)
{
//add another neighbor element
cl_base[cell_id].add(ele);
}
void add(size_t cell_id, typename base::value_type ele)
inline void add(size_t cell_id, typename base::value_type ele)
{
this->addCell(cell_id,ele);
}
void remove(size_t cell, size_t ele)
inline void remove(size_t cell, size_t ele)
{
cl_base[cell].remove(ele);
}
size_t getNelements(const size_t cell_id) const
inline size_t getNelements(const size_t cell_id) const
{
auto it = cl_base.find(cell_id);
if (it == cl_base.end())
......@@ -85,7 +85,7 @@ public:
return it->second.size();
}
auto get(size_t cell, size_t ele) -> decltype(cl_base[0].get(0)) &
inline auto get(size_t cell, size_t ele) -> decltype(cl_base[0].get(0)) &
{
auto it = cl_base.find(cell);
if (it == cl_base.end())
......@@ -94,7 +94,7 @@ public:
return it->second.get(ele);
}
auto get_v(size_t cell) -> decltype(cl_base[0]) &
inline auto get_v(size_t cell) -> decltype(cl_base[0]) &
{
auto it = cl_base.find(cell);
if (it == cl_base.end())
......@@ -103,7 +103,7 @@ public:
return it->second;
}
auto get(size_t cell, size_t ele) const -> const decltype(cl_base.find(cell)->second.get(0)) &
inline auto get(size_t cell, size_t ele) const -> const decltype(cl_base.find(cell)->second.get(0)) &
{
auto it = cl_base.find(cell);
if (it == cl_base.end())
......@@ -112,7 +112,7 @@ public:
return it->second.get(ele);
}
auto get_v(size_t cell) const -> const decltype(cl_base.find(cell)->second) &
inline auto get_v(size_t cell) const -> const decltype(cl_base.find(cell)->second) &
{
auto it = cl_base.find(cell);
if (it == cl_base.end())
......@@ -121,31 +121,37 @@ public:
return it->second;
}
void swap(Mem_mw & cl)
inline void swap(Mem_mw & cl)
{
swap(cl_base, cl.cl_base);
cl_base.swap(cl.cl_base);
}
void swap(Mem_mw && cell)
inline void swap(Mem_mw && cell)
{
swap(cl_base, cell.cl_base);
cl_base.swap(cell.cl_base);
}
void clear()
inline void clear()
{
cl_base.clear();
}
inline const size_t & getStartId(size_t part_id) const
{
return get(part_id,0);
auto it = cl_base.find(part_id);
if (it == cl_base.end())
return *(&invalid_v.get(0));
return it->second.get(0);
}
inline const size_t & getStopId(size_t part_id) const
{
auto & v_ele = get_v(part_id);
auto it = cl_base.find(part_id);
if (it == cl_base.end())
return *(&invalid_v.get(0));
return *(&v_ele.last() + 1);
return *(&it->second.last() + 1);
}
inline const size_t & get_lin(const size_t * part_id) const
......@@ -155,10 +161,10 @@ public:
public:
Mem_mw(size_t slot)
inline Mem_mw(size_t slot)
{}
void set_slot(size_t slot)
inline void set_slot(size_t slot)
{}
};
......
......@@ -358,7 +358,9 @@ namespace openfpm
* \param start index from where to start the merging
*
*/
template <template<typename,typename> class op, typename S, typename M, typename gp, unsigned int ...args> void merge_prp(const vector<S,M,typename layout_base<S>::type,layout_base,gp,OPENFPM_NATIVE> & v, const openfpm::vector<size_t> & opart)
template <template<typename,typename> class op, typename S, typename M, typename gp, unsigned int ...args>
void merge_prp(const vector<S,M,typename layout_base<S>::type,layout_base,gp,OPENFPM_NATIVE> & v,
const openfpm::vector<size_t> & opart)
{
#ifdef SE_CLASS2
check_valid(this,8);
......@@ -419,7 +421,9 @@ namespace openfpm
* \param start index from where to start the merging
*
*/
template <template<typename,typename> class op, typename S, typename M, typename gp, unsigned int ...args> void merge_prp_v(const vector<S,M,typename layout_base<S>::type,layout_base,gp,OPENFPM_NATIVE> & v, const openfpm::vector<aggregate<size_t,size_t>> & opart)
template <template<typename,typename> class op, typename S, typename M, typename gp, unsigned int ...args>
void merge_prp_v(const vector<S,M,typename layout_base<S>::type,layout_base,gp,OPENFPM_NATIVE> & v,
const openfpm::vector<aggregate<size_t,size_t>> & opart)
{
#ifdef SE_CLASS2
check_valid(this,8);
......@@ -479,7 +483,9 @@ namespace openfpm
* \param start index from where to start the merging
*
*/
template <template<typename,typename> class op, typename S, typename M, typename gp, unsigned int ...args> void merge_prp_v(const vector<S,M,typename layout_base<S>::type,layout_base,gp,OPENFPM_NATIVE> & v, size_t start)
template <template<typename,typename> class op, typename S, typename M, typename gp, unsigned int ...args>
void merge_prp_v(const vector<S,M,typename layout_base<S>::type,layout_base,gp,OPENFPM_NATIVE> & v,
size_t start)
{
#ifdef SE_CLASS2
check_valid(this,8);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment