Commit ca483215 authored by incardon's avatar incardon
Browse files

Fixing conflicts

parents 06f4f02b ca77e05c
......@@ -20,7 +20,11 @@ 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 \
<<<<<<< HEAD
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/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/CellListFast_gen.hpp NN/CellList/CellList.hpp NN/CellList/CellList_test.hpp NN/CellList/MemBalanced.hpp NN/CellList/MemFast.hpp NN/CellList/MemMemoryWise.hpp NN/CellList/CellNNIterator.hpp \
>>>>>>> Cell_list_refactor
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 \
......
......@@ -10,6 +10,7 @@
#include "Vector/map_vector.hpp"
#include "CellDecomposer.hpp"
<<<<<<< HEAD
#include "Space/SpaceBox.hpp"
#include "util/mathutil.hpp"
#include "CellNNIterator.hpp"
......@@ -26,6 +27,12 @@
#include "MemBalanced.hpp"
#include "MemMemoryWise.hpp"
=======
#include "CellNNIterator.hpp"
#include "CellListNNIteratorRadius.hpp"
#include <unordered_map>
>>>>>>> Cell_list_refactor
//! Wrapper of the unordered map
template<typename key,typename val>
class wrap_unordered_map: public std::unordered_map<key,val>
......@@ -50,6 +57,7 @@ class wrap_unordered_map<boost::multiprecision::float128,val>
#define STARTING_NSLOT 16
<<<<<<< HEAD
/*! \brief Calculate the the Neighborhood for symmetric interactions CSR scheme
*
* \param cNN calculated cross neighborhood
......@@ -213,6 +221,8 @@ template<unsigned int dim> void NNcalc_full(openfpm::vector<grid_key_dx<dim>> &
};
=======
>>>>>>> Cell_list_refactor
/* NOTE all the implementations
*
* has complexity O(1) in getting the cell id and the elements in a cell
......@@ -228,11 +238,19 @@ template<unsigned int dim> void NNcalc_full(openfpm::vector<grid_key_dx<dim>> &
* * M = number of cells
* * N_cell_max = maximum number of elements in a cell
* * ele = element the structure is storing
<<<<<<< HEAD
*
* \note Because N_cell_max >= N/M then M * N_cell_max >= O(N)
*
* \warning Not not use for high asymmetric distribution
*
=======
*
* \note Because N_cell_max >= N/M then M * N_cell_max >= O(N)
*
* \warning Not not use for high asymmetric distribution
*
>>>>>>> Cell_list_refactor
* Example of a 2D Cell list 6x6 structure with padding 1 without shift, cell indicated with p are padding cell
* the origin of the cell or point (0,0) is marked with cell number 9
*
......@@ -268,7 +286,11 @@ template<unsigned int dim> void NNcalc_full(openfpm::vector<grid_key_dx<dim>> &
*
*/
template<unsigned int dim, typename T, typename Mem_type, typename transform = no_transform<dim,T>, typename base=openfpm::vector<size_t>>
<<<<<<< HEAD
class CellList : public CellDecomposer_sm<dim,T,transform>, public Mem_type
=======
class CellList : public CellDecomposer_sm<dim,T,transform>, Mem_type
>>>>>>> Cell_list_refactor
{
protected:
//! The array contain the neighborhood of the cell-id in case of asymmetric interaction
......@@ -286,17 +308,30 @@ protected:
//
long int NNc_sym[openfpm::math::pow(3,dim)/2+1];
<<<<<<< HEAD
=======
//! The array contain the neighborhood of the cell-id in case of symmetric interaction (Optimized)
//
// * *
// x *
//
long int NNc_cr[openfpm::math::pow(2,dim)];
>>>>>>> Cell_list_refactor
private:
//! Caching of r_cutoff radius
wrap_unordered_map<T,openfpm::vector<long int>> rcache;
<<<<<<< HEAD
//! True if has been initialized from CellDecomposer
bool from_cd;
//! Additional information in general (used to understand if the cell-list)
//! has been constructed from an old decomposition
size_t n_dec;
=======
>>>>>>> Cell_list_refactor
/*! Calculate the neighborhood cells based on the radius
*
......@@ -413,6 +448,7 @@ private:
++gr_sub3;
i++;
}
<<<<<<< HEAD
}
void setCellDecomposer(CellDecomposer_sm<dim,T,transform> & cd, const CellDecomposer_sm<dim,T,transform> & cd_sm, const Box<dim,T> & dom_box, size_t pad) const
......@@ -434,16 +470,39 @@ private:
}
cd.setDimensions(cd_sm.getDomain(),div_big,div, pad, bx.getP1());
=======
// Calculate the NNc_cross array
i = 0;
grid_key_dx_iterator_sub<dim> gr_sub2(gs,NNzero::data,NNone::data);
while (gr_sub2.isNext())
{
auto key = gr_sub2.get();
NNc_cr[i] = (long int)gs.LinId(key);
++gr_sub2;
i++;
}
>>>>>>> Cell_list_refactor
}
public:
<<<<<<< HEAD
typedef CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,base>,RUNTIME,NO_CHECK> SymNNIterator;
//! Object type that the structure store
typedef typename base::value_type value_type;
//! Type of the coordinate space (double float)
=======
//! Object type that the structure store
typedef typename base::value_type value_type;
>>>>>>> Cell_list_refactor
typedef T stype;
/*! \brief Return the underlying grid information of the cell list
......@@ -475,14 +534,22 @@ public:
for (size_t i = 0 ; i < dim ; i++) {bc[i] = NON_PERIODIC;}
Box<dim,long int> bx = cd_sm.convertDomainSpaceIntoCellUnits(dom_box,bc);
<<<<<<< HEAD
setCellDecomposer(*this,cd_sm,dom_box,pad);
=======
// Box<dim,T> bxd = cd_sm.convertCellUnitsIntoDomainSpace(bx);
size_t div[dim];
size_t div_big[dim];
>>>>>>> Cell_list_refactor
size_t div_w_pad[dim];
size_t tot_cell = 1;
for (size_t i = 0 ; i < dim ; i++)
{
<<<<<<< HEAD
div_w_pad[i] = bx.getHigh(i) - bx.getLow(i) + 2*pad;
tot_cell *= div_w_pad[i];
}
......@@ -493,6 +560,20 @@ public:
// Initialized from CellDecomposer
from_cd = true;
=======
div[i] = bx.getHigh(i) - bx.getLow(i);
div_w_pad[i] = bx.getHigh(i) - bx.getLow(i) + 2*pad;
tot_cell *= div_w_pad[i];
div_big[i] = cd_sm.getDiv()[i] - 2*cd_sm.getPadding(i);
}
CellDecomposer_sm<dim,T,transform>::setDimensions(cd_sm.getDomain(),div_big,div, pad, bx.getP1());
// here we set the cell-shift for the CellDecomposer
// Initialize(cd_sm.getDomain(),div,bx.getP1(),pad,slot);
InitializeStructures(div_w_pad,tot_cell);
>>>>>>> Cell_list_refactor
}
/*! Initialize the cell list
......@@ -522,31 +603,53 @@ public:
*/
void Initialize(const SpaceBox<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
{
<<<<<<< HEAD
Matrix<dim,T> mat;
CellDecomposer_sm<dim,T,transform>::setDimensions(box,div, mat, pad);
Mem_type::set_slot(slot);
=======
Matrix<dim,T> mat;
CellDecomposer_sm<dim,T,transform>::setDimensions(box,div, mat, pad);
>>>>>>> Cell_list_refactor
// create the array that store the number of particle on each cell and se it to 0
InitializeStructures(this->gr_cell.getSize(),this->gr_cell.size());
<<<<<<< HEAD
from_cd = false;
}
//! Default Constructor
CellList()
=======
}
//! Default Constructor
CellList(size_t slot=STARTING_NSLOT)
>>>>>>> Cell_list_refactor
:Mem_type(STARTING_NSLOT)
{};
//! Copy constructor
<<<<<<< HEAD
CellList(const CellList<dim,T,Mem_type,transform,base> & cell)
=======
CellList(const CellList<dim,T,Mem_type,transform,base> & cell, size_t slot=STARTING_NSLOT)
>>>>>>> Cell_list_refactor
:Mem_type(STARTING_NSLOT)
{
this->operator=(cell);
}
//! Copy constructor
<<<<<<< HEAD
CellList(CellList<dim,T,Mem_type,transform,base> && cell)
=======
CellList(CellList<dim,T,Mem_type,transform,base> && cell, size_t slot=STARTING_NSLOT)
>>>>>>> Cell_list_refactor
:Mem_type(STARTING_NSLOT)
{
this->operator=(cell);
......@@ -578,7 +681,11 @@ public:
*
*/
CellList(Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
<<<<<<< HEAD
:Mem_type(slot)
=======
:Mem_type(STARTING_NSLOT)
>>>>>>> Cell_list_refactor
{
SpaceBox<dim,T> sbox(box);
Initialize(sbox,div,pad,slot);
......@@ -593,7 +700,11 @@ public:
*
*/
CellList(SpaceBox<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
<<<<<<< HEAD
:Mem_type(slot)
=======
:Mem_type(STARTING_NSLOT)
>>>>>>> Cell_list_refactor
{
Initialize(box,div,pad,slot);
}
......@@ -609,7 +720,11 @@ public:
*
*/
CellList(CellDecomposer_sm<dim,T,transform> & cd_sm, const Box<dim,T> & box, const size_t pad = 1, size_t slot=STARTING_NSLOT)
<<<<<<< HEAD
:Mem_type(slot)
=======
:Mem_type(STARTING_NSLOT)
>>>>>>> Cell_list_refactor
{
Initialize(cd_sm,box,pad,slot);
}
......@@ -632,6 +747,10 @@ public:
{
std::copy(&cell.NNc_full[0],&cell.NNc_full[openfpm::math::pow(3,dim)],&NNc_full[0]);
std::copy(&cell.NNc_sym[0],&cell.NNc_sym[openfpm::math::pow(3,dim)/2+1],&NNc_sym[0]);
<<<<<<< HEAD
=======
std::copy(&cell.NNc_cr[0],&cell.NNc_cr[openfpm::math::pow(2,dim)],&NNc_cr[0]);
>>>>>>> Cell_list_refactor
Mem_type::swap(static_cast<Mem_type &&>(cell));
......@@ -651,6 +770,10 @@ public:
{
std::copy(&cell.NNc_full[0],&cell.NNc_full[openfpm::math::pow(3,dim)],&NNc_full[0]);
std::copy(&cell.NNc_sym[0],&cell.NNc_sym[openfpm::math::pow(3,dim)/2+1],&NNc_sym[0]);
<<<<<<< HEAD
=======
std::copy(&cell.NNc_cr[0],&cell.NNc_cr[openfpm::math::pow(2,dim)],&NNc_cr[0]);
>>>>>>> Cell_list_refactor
Mem_type::operator=(static_cast<const Mem_type &>(cell));
......@@ -659,6 +782,7 @@ public:
return *this;
}
<<<<<<< HEAD
/*! \brief Get an iterator over particles following the cell structure
*
* \return a particle iterator
......@@ -671,6 +795,8 @@ public:
return it;
}
=======
>>>>>>> Cell_list_refactor
/*! \brief Add to the cell
*
* \param cell_id Cell id where to add
......@@ -710,6 +836,7 @@ public:
Mem_type::add(cell_id,ele);
}
<<<<<<< HEAD
/*! \brief Add an element in the cell list forcing to be in the domain cells
*
......@@ -787,6 +914,8 @@ public:
addCell(cell_id,ele);
}
=======
>>>>>>> Cell_list_refactor
/*! \brief remove an element from the cell
*
* \param cell cell id
......@@ -834,6 +963,7 @@ public:
inline void swap(CellList<dim,T,Mem_type,transform,base> & cl)
{
long int NNc_full_tmp[openfpm::math::pow(3,dim)];
<<<<<<< HEAD
long int NNc_sym_tmp[openfpm::math::pow(3,dim)/2+1];
std::copy(&cl.NNc_full[0],&cl.NNc_full[openfpm::math::pow(3,dim)],&NNc_full_tmp[0]);
......@@ -845,6 +975,22 @@ public:
std::copy(&NNc_full_tmp[0],&NNc_full_tmp[openfpm::math::pow(3,dim)],&NNc_full[0]);
std::copy(&NNc_sym_tmp[0],&NNc_sym_tmp[openfpm::math::pow(3,dim)/2+1],&NNc_sym[0]);
=======
long int NNc_sym_tmp[openfpm::math::pow(3,dim)];
long int NNc_cr_tmp[openfpm::math::pow(3,dim)];
std::copy(&cl.NNc_full[0],&cl.NNc_full[openfpm::math::pow(3,dim)],&NNc_full_tmp[0]);
std::copy(&cl.NNc_sym[0],&cl.NNc_sym[openfpm::math::pow(3,dim)/2+1],&NNc_sym_tmp[0]);
std::copy(&cl.NNc_cr[0],&cl.NNc_cr[openfpm::math::pow(2,dim)],&NNc_cr_tmp[0]);
std::copy(&NNc_full[0],&NNc_full[openfpm::math::pow(3,dim)],&cl.NNc_full[0]);
std::copy(&NNc_sym[0],&NNc_sym[openfpm::math::pow(3,dim)/2+1],&cl.NNc_sym[0]);
std::copy(&NNc_cr[0],&NNc_cr[openfpm::math::pow(2,dim)],&cl.NNc_cr[0]);
std::copy(&NNc_full_tmp[0],&NNc_full_tmp[openfpm::math::pow(3,dim)],&NNc_full[0]);
std::copy(&NNc_sym_tmp[0],&NNc_sym_tmp[openfpm::math::pow(3,dim)/2+1],&NNc_sym[0]);
std::copy(&NNc_cr_tmp[0],&NNc_cr_tmp[openfpm::math::pow(2,dim)],&NNc_cr[0]);
>>>>>>> Cell_list_refactor
Mem_type::swap(static_cast<Mem_type &>(cl));
......@@ -934,15 +1080,19 @@ public:
*/
template<unsigned int impl> inline CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,base>,SYM,impl> getNNIteratorSym(size_t cell, size_t p, const openfpm::vector<Point<dim,T>> & v)
{
<<<<<<< HEAD
#ifdef SE_CLASS1
if (from_cd == false)
std::cerr << __FILE__ << ":" << __LINE__ << " Warning when you try to get a symmetric neighborhood iterator, you must construct the Cell-list in a symmetric way" << std::endl;
#endif
=======
>>>>>>> Cell_list_refactor
CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,base>,SYM,impl> cln(cell,p,NNc_sym,*this,v);
return cln;
}
<<<<<<< HEAD
/*! \brief Get the symmetric neighborhood
*
* \return the symmetric neighborhood
......@@ -951,6 +1101,32 @@ public:
const long int (& getNNc_sym() const)[openfpm::math::pow(3,dim)/2+1]
{
return NNc_sym;
=======
/*! \brief Get the Neighborhood iterator
*
* It iterate across all the element of the selected cell and the near cells
*
* \verbatim
* *
x *
\endverbatim
*
* * x is the selected cell
* * * are the near cell
*
* \param cell cell id
*
* \return an iterator across the neighborhood params
*
*/
template<unsigned int impl> inline CellNNIterator<dim,CellList<dim,T,Mem_type,transform,base>,CRS,impl> getNNIteratorCross(size_t cell)
{
CellNNIterator<dim,CellList<dim,T,Mem_type,transform,base>,CRS,impl> cln(cell,NNc_cr,*this);
return cln;
>>>>>>> Cell_list_refactor
}
/*! \brief Return the number of padding cells of the Cell decomposer
......@@ -960,11 +1136,93 @@ public:
* \return the number of padding cells
*
*/
<<<<<<< HEAD
size_t getPadding(size_t i) const
=======
size_t getPadding(size_t i)
>>>>>>> Cell_list_refactor
{
return CellDecomposer_sm<dim,T,transform>::getPadding(i);
}
<<<<<<< HEAD
=======
/*! \brief Add an element in the cell list forcing to be in the domain cells
*
* \warning careful is intended to be used ONLY to avoid round-off problems
*
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
inline void addDom(const T (& pos)[dim], typename base::value_type ele)
{
// calculate the Cell id
size_t cell_id = this->getCell(pos);
// add the element to the cell
addCell(cell_id,ele);
}
/*! \brief Add an element in the cell list forcing to be in the domain cells
*
* \warning careful is intended to be used ONLY to avoid round-off problems
*
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
inline void addDom(const Point<dim,T> & pos, typename base::value_type ele)
{
// calculate the Cell id
size_t cell_id = this->getCell(pos);
// add the element to the cell
addCell(cell_id,ele);
}
/*! \brief Add an element in the cell list forcing to be in the padding cells
*
* \warning careful is intended to be used ONLY to avoid round-off problems
*
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
inline void addPad(const T (& pos)[dim], typename base::value_type ele)
{
// calculate the Cell id
size_t cell_id = this->getCell(pos);
// add the element to the cell
addCell(cell_id,ele);
}
/*! \brief Add an element in the cell list forcing to be in the padding cells
*
* \warning careful is intended to be used ONLY to avoid round-off problems
*
* \param pos array that contain the coordinate
* \param ele element to store
*
*/
inline void addPad(const Point<dim,T> & pos, typename base::value_type ele)
{
// calculate the Cell id
size_t cell_id = this->getCell(pos);
// add the element to the cell
addCell(cell_id,ele);
}
>>>>>>> Cell_list_refactor
/*! \brief Clear the cell list
*
......@@ -981,7 +1239,11 @@ public:
* \return the index
*
*/
<<<<<<< HEAD
inline const size_t & getStartId(size_t cell_id) const
=======
inline size_t * getStartId(size_t cell_id)
>>>>>>> Cell_list_refactor
{
return Mem_type::getStartId(cell_id);
}
......@@ -993,7 +1255,11 @@ public:
* \return the stop index
*
*/
<<<<<<< HEAD
inline const size_t & getStopId(size_t cell_id) const
=======
inline size_t * getStopId(size_t cell_id)
>>>>>>> Cell_list_refactor
{
return Mem_type::getStopId(cell_id);
}
......@@ -1005,7 +1271,11 @@ public:
* \return the neighborhood id
*
*/
<<<<<<< HEAD
inline const size_t & get_lin(const size_t * part_id) const
=======
inline size_t & get_lin(size_t * part_id)
>>>>>>> Cell_list_refactor
{
return Mem_type::get_lin(part_id);
}
......@@ -1036,6 +1306,7 @@ public:
}
/////////////////////////////////////
<<<<<<< HEAD
/////////////////////////////////////
......@@ -1060,6 +1331,8 @@ public:
}
/////////////////////////////////////
=======
>>>>>>> Cell_list_refactor
};
/*! \brief Calculate parameters for the cell list
......@@ -1117,6 +1390,12 @@ template<unsigned int dim, typename St> static inline void cl_param_calculateSym
cd_sm.setDimensions(dom,div,pad);
}
<<<<<<< HEAD
=======
#include "MemFast.hpp"
#include "MemBalanced.hpp"
#include "MemMemoryWise.hpp"
>>>>>>> Cell_list_refactor
/*! \brief Calculate parameters for the symmetric cell list
*
......@@ -1140,6 +1419,9 @@ template<unsigned int dim, typename St> static inline void cl_param_calculateSym
cd_sm.setDimensions(dom,div,pad);
}
<<<<<<< HEAD
=======
>>>>>>> Cell_list_refactor
#endif /* CELLLIST_HPP_ */
......@@ -11,13 +11,17 @@
#define HILBERT 1
#include "CellList.hpp"
<<<<<<< HEAD
#include "ProcKeys.hpp"
=======
>>>>>>> Cell_list_refactor
extern "C"
{
#include "hilbertKey.h"
}
<<<<<<< HEAD
/* \brief Cell list implementation with particle iterator over cells
......@@ -45,20 +49,156 @@ private:
// size_t g_m = 0;
/*
*/
=======
/* !Brief Class for a linear (1D-like) order processing of cell keys for CellList_gen implementation
*
* \tparam dim Dimansionality of the space
*/
template<unsigned int dim>
class Process_keys_lin
{
public:
/*! \brief Get a linear (1D-like) key from the coordinates and add to the getKeys vector
*
* \tparam S Cell list type