Commit c3a4a081 authored by incardon's avatar incardon
Browse files

Adding symmetric cell-list for the MP case

parent 6c2a5911
......@@ -863,7 +863,7 @@ public:
}
/*! \brief Get the Neighborhood iterator
/*! \brief Get the symmetric Neighborhood iterator
*
* It iterate across all the element of the selected cell and the near cells up to some selected radius
*
......@@ -885,7 +885,9 @@ public:
return cln;
}
/*! \brief Get the Neighborhood iterator
/*! \brief Get the symmetric Neighborhood iterator
*
* It iterate across all the element of the selected cell and the near cells
*
......@@ -918,6 +920,41 @@ public:
return cln;
}
/*! \brief Get the symmetric 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
* \param p particle id
* \param v_p1 first phase for particle p
* \param v_p2 second phase for particle q
*
* \return An aiterator across the neighborhood particles
*
*/
template<unsigned int impl>
inline CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,base>,(unsigned int)SYM,impl>
getNNIteratorSymMP(size_t cell, size_t p, const openfpm::vector<Point<dim,T>> & v_p1, const openfpm::vector<Point<dim,T>> & v_p2)
{
#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
CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,base>,SYM,impl> cln(cell,p,NNc_sym,*this,v_p1,v_p2);
return cln;
}
/*! \brief Get the symmetric neighborhood
*
* \return the symmetric neighborhood
......
......@@ -235,6 +235,101 @@ public:
}
};
/*! \brief Symmetric iterator for the neighborhood of the cell structures
*
* In general you never create it directly but you get it from the CellList structures
*
* It iterate across all the element of the selected cell and the near cells.
*
* \note if we query the neighborhood of p and q is the neighborhood of p
* when we will query the neighborhood of q p is not present. This is
* useful to implement formula like \f$ \sum_{q = neighborhood(p) and p <= q} \f$
*
* \tparam dim dimensionality of the space where the cell live
* \tparam Cell cell type on which the iterator is working
* \tparam NNc_size neighborhood size
* \tparam impl implementation specific options NO_CHECK do not do check on access, SAFE do check on access
*
*/
template<unsigned int dim, typename Cell,int NNc_size, unsigned int impl> class CellNNIteratorSymMP : public CellNNIterator<dim,Cell,NNc_size,impl>
{
//! index of the particle p
size_t p;
//! Phase vector for particle p
const openfpm::vector<Point<dim,typename Cell::stype>> & v_p1;
//! Phase vector for particle q
const openfpm::vector<Point<dim,typename Cell::stype>> & v_p2;
/*! Select the next valid element
*
*/
inline void selectValid()
{
if (this->NNc[this->NNc_id] == 0)
{
while (this->start_id < this->stop_id)
{
size_t q = this->cl.get_lin(this->start_id);
for (long int i = dim-1 ; i >= 0 ; i--)
{
if (v_p1.template get<0>(p)[i] < v_p2.template get<0>(q)[i])
return;
else if (v_p1.template get<0>(p)[i] > v_p2.template get<0>(q)[i])
goto next;
}
if (q >= p) return;
next:
this->start_id++;
}
CellNNIterator<dim,Cell,NNc_size,impl>::selectValid();
}
else
{
CellNNIterator<dim,Cell,NNc_size,impl>::selectValid();
}
}
public:
/*! \brief
*
* Cell NN iterator
*
* \param cell Cell id
* \param p index of the particle from which we are searching the neighborhood particles
* \param NNc Cell neighborhood indexes (relative)
* \param cl Cell structure
*
*/
inline CellNNIteratorSymMP(size_t cell,
size_t p,
const NNc_array<dim,NNc_size> &NNc,
Cell & cl,
const openfpm::vector<Point<dim,typename Cell::stype>> & v_p1,
const openfpm::vector<Point<dim,typename Cell::stype>> & v_p2)
:CellNNIterator<dim,Cell,NNc_size,impl>(cell,NNc,cl),p(p),v_p1(v_p1),v_p2(v_p2)
{
selectValid();
}
/*! \brief take the next element
*
* \return itself
*
*/
inline CellNNIteratorSymMP<dim,Cell,NNc_size,impl> & operator++()
{
this->start_id++;
selectValid();
return *this;
}
};
/*! \brief it iterate through the elements of a cell
*
......
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