Commit dde50897 authored by incardon's avatar incardon
Browse files

Fixing Cell List

parent 1152e735
......@@ -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/CellNNIteratorRuntime.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/CellListFast_hilb.hpp NN/CellList/CellList.hpp NN/CellList/CellList_test.hpp NN/CellList/CellListBal.hpp NN/CellList/CellListFast.hpp NN/CellList/CellListMem.hpp NN/CellList/CellNNIterator.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/CellListFast_hilb.hpp NN/CellList/CellList.hpp NN/CellList/CellList_test.hpp NN/CellList/CellListBal.hpp NN/CellList/CellListFast.hpp NN/CellList/CellListMem.hpp NN/CellList/CellNNIterator.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 \
......
......@@ -399,7 +399,7 @@ class CellDecomposer_sm
check_and_print_error(pos,0);
size_t cell_id = ConvertToID(pos,0);
cell_id = (cell_id == gr_cell.size(0) - off[0])?gr_cell.size(0) - off[0] - 1:cell_id;
cell_id = (cell_id == gr_cell2.size(0) - off[0])?gr_cell2.size(0) - off[0] - 1:cell_id;
cell_id = (cell_id == off[0]-1)?off[0]:cell_id;
for (size_t s = 1 ; s < dim ; s++)
......@@ -407,7 +407,7 @@ class CellDecomposer_sm
check_and_print_error(pos,s);
size_t cell_idt = ConvertToID(pos,s);
cell_idt = (cell_idt == gr_cell.size(s) - off[s])?gr_cell.size(s) - off[s] - 1:cell_idt;
cell_idt = (cell_idt == gr_cell2.size(s) - off[s])?gr_cell2.size(s) - off[s] - 1:cell_idt;
cell_idt = (cell_idt == off[s]-1)?off[s]:cell_idt;
cell_id += gr_cell2.size_s(s-1) * cell_idt;
......@@ -1632,6 +1632,9 @@ Box "b" <-----------------+ | | | | | | Grid (7, 6)
}
/*! \brief Return the index of the first cell in the domain
*
* This function make sense if the CellDecomposer has been
* created with setDimensions with div and div2
*
* \return the first domain cell
*
......@@ -1649,6 +1652,9 @@ Box "b" <-----------------+ | | | | | | Grid (7, 6)
}
/*! \brief Return the index of the last cell in the domain
*
* This function make sense if the CellDecomposer has been
* created with setDimensions with div and div2
*
* \return the last domain cell
*
......
......@@ -17,6 +17,7 @@
#include "CellListNNIteratorRadius.hpp"
#include <unordered_map>
#include "ParticleIt_Cells.hpp"
#include "ParticleItCRS_Cells.hpp"
#include "util/common.hpp"
......@@ -599,6 +600,18 @@ public:
return *this;
}
/*! \brief Get an iterator over particles following the cell structure
*
* \return a particle iterator
*
*/
ParticleIt_Cells<dim,CellList<dim,T,FAST,transform,base>> getDomainIterator(openfpm::vector<size_t> & dom_cells)
{
ParticleIt_Cells<dim,CellList<dim,T,FAST,transform,base>> it(*this,dom_cells);
return it;
}
/*! \brief Add to the cell
*
* \param cell_id Cell id where to add
......@@ -668,7 +681,7 @@ public:
{
// calculate the Cell id
size_t cell_id = this->getCell(pos);
size_t cell_id = this->getCellDom(pos);
// add the element to the cell
......@@ -687,7 +700,7 @@ public:
{
// calculate the Cell id
size_t cell_id = this->getCell(pos);
size_t cell_id = this->getCellDom(pos);
// add the element to the cell
......@@ -706,7 +719,7 @@ public:
{
// calculate the Cell id
size_t cell_id = this->getCell(pos);
size_t cell_id = this->getCellPad(pos);
// add the element to the cell
......@@ -1082,6 +1095,7 @@ public:
}
/*! \brief Get the starting domain Cell
*
*
* \return
*
......
......@@ -379,9 +379,19 @@ BOOST_AUTO_TEST_CASE( ParticleIt_Cells_iterator )
// No anomalous cells + all domain cells
grid_key_dx_iterator_sub<dim> it(gs,start,stop);
openfpm::vector<size_t> dom;
while (it.isNext())
{
auto key = it.get();
dom.add(gs.LinId(key));
++it;
}
//Test the iterator
ParticleIt_Cells<dim,CellList<dim,float,FAST,shift<dim,float>>,grid_key_dx_iterator_sub<dim>> it_cl(NN,it);
ParticleIt_Cells<dim,CellList<dim,float,FAST,shift<dim,float>>> it_cl(NN,dom);
size_t count = 0;
......
......@@ -13,10 +13,9 @@
*
* \tparam dim Dimensionality
* \tparam CellListType type of the cell-list
* \tparam CellIterator type of iterator over the cell
*
*/
template<unsigned int dim,typename CellListType, typename CellIt> class ParticleIt_Cells
template<unsigned int dim,typename CellListType> class ParticleIt_Cells
{
private:
......@@ -26,12 +25,14 @@ private:
//! stop position
const size_t * stop;
//! Celllist type
CellListType & cli;
//! Actual cell
size_t cid;
//! grid iterator for cells iteration
CellIt it;
//! List of all the domain cells
const openfpm::vector<size_t> &dom_cell;
//! Celllist type
CellListType & cli;
/*! \brief Adjust the counters to reach a valid particle element
*
......@@ -39,21 +40,21 @@ private:
*/
void selectValid()
{
while (it.isNext())
while (start == stop)
{
auto cell = it.get();
size_t s_cell = cli.getGrid().LinId(cell);
cid++;
size_t s_cell;
if (cid >= dom_cell.size())
return;
else
s_cell = dom_cell.get(cid);
// Get the starting particle
start = &cli.getStartId(s_cell);
// Get the stop particle
stop = &cli.getStopId(s_cell);
if (start == stop)
++it;
else
break;
}
}
......@@ -62,13 +63,34 @@ public:
/*! \brief Initialize the iterator
*
* \param cli Cell-list
* \param size_t internal grid cells
* \param
* \param dom_cell domain cell
* \param anom_dom_cell anomalous domain cell
* \param NNc_sym symmetric neighborhood
*
*
*/
ParticleIt_Cells(CellListType & cli, CellIt & cit)
:cli(cli),it(cit)
ParticleIt_Cells(CellListType & cli,
const openfpm::vector<size_t> & dom_cell)
:cid(0),dom_cell(dom_cell),cli(cli)
{
size_t s_cell;
if (dom_cell.size() != 0)
s_cell = dom_cell.get(0);
else
{
cid = 1;
start = NULL;
stop = NULL;
return;
}
// Get the starting particle
start = &cli.getStartId(s_cell);
// Get the stop particle
stop = &cli.getStopId(s_cell);
selectValid();
}
......@@ -81,11 +103,7 @@ public:
{
++start;
if (start == stop)
{
++it;
selectValid();
}
selectValid();
return *this;
}
......@@ -97,7 +115,7 @@ public:
*/
bool isNext()
{
return it.isNext();
return cid < dom_cell.size();
}
/*! \brief Get the actual particle id
......
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