Commit f9b87ff4 authored by incardon's avatar incardon
Browse files

Added new iterator

parent e955e024
......@@ -24,7 +24,7 @@ NN/CellList/CellNNIteratorRuntime.hpp NN/CellList/ParticleItCRS_Cells.hpp NN/Cel
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 \
NN/CellList/CellList_util.hpp NN/CellList/CellNNIteratorRuntimeM.hpp NN/VerletList/VerletListM.hpp NN/VerletList/VerletNNIteratorM.hpp Vector/map_vector.hpp Vector/map_vector_std_util.hpp Vector/map_vector_std_ptr.hpp Vector/map_vector_std.hpp Vector/util.hpp Vector/vect_isel.hpp Vector/vector_test_util.hpp Vector/vector_unit_tests.hpp Vector/se_vector.hpp Vector/map_vector_grow_p.hpp Vector/vector_std_pack_unpack.ipp Vector/vector_pack_unpack.ipp \
NN/CellList/CellList_util.hpp NN/CellList/CellNNIteratorRuntimeM.hpp NN/VerletList/VerletListM.hpp NN/VerletList/VerletNNIteratorM.hpp Vector/map_vector.hpp Vector/map_vector_std_util.hpp Vector/map_vector_std_ptr.hpp Vector/map_vector_std.hpp Vector/util.hpp Vector/vect_isel.hpp Vector/vector_test_util.hpp Vector/vector_unit_tests.hpp Vector/se_vector.hpp Vector/map_vector_grow_p.hpp Vector/vector_std_pack_unpack.ipp Vector/vector_pack_unpack.ipp Vector/vector_map_iterator.hpp \
timer.hpp \
util/copy_compare/compare_fusion_vector.hpp util/SimpleRNG.hpp util/copy_compare/compare_general.hpp util/copy_compare/copy_compare_aggregates.hpp util/copy_compare/copy_fusion_vector.hpp util/copy_compare/copy_general.hpp util/copy_compare/meta_compare.hpp util/copy_compare/meta_copy.hpp util/mul_array_extents.hpp \
Packer_Unpacker/Pack_selector.hpp Packer_Unpacker/Packer_nested_tests.hpp Packer_Unpacker/Packer_unit_tests.hpp Packer_Unpacker/Packer.hpp Packer_Unpacker/Unpacker.hpp Packer_Unpacker/Packer_util.hpp Packer_Unpacker/prp_all_zero.hpp Packer_Unpacker/has_pack_encap.hpp Packer_Unpacker/has_pack_agg.hpp Packer_Unpacker/has_max_prop.hpp
......
......@@ -1067,39 +1067,6 @@ public:
return cln;
}
/*! \brief Get the Neighborhood iterator for symmetric interactions
*
* This iterator work independently that the vector has been create with
* the option BIND_DEC_TO_GHOST, the only requirement is that the ghost
* is full. Does not require ghost_put
*
* \param cell cell id
* \param v vector of neighborhood cells
*
* \return An aiterator across the neighborhood particles
*
*/
/* template<unsigned int impl, typename vector>
inline CellNNIteratorSym<dim,CellList<dim,T,FAST,transform,base>,RUNTIME,impl>
getNNIteratorSym(Point<dim,T> & p,
const vector & v)
{
auto & dec = v.getDecomposition();
grid_key_dx<dim> cellg = this->getGridCell(p);
size_t map_cell = dec.get_mapped_cell(cellg);
CellNNIteratorSym<dim,CellList<dim,T,FAST,transform,base>,RUNTIME,impl> cln(cell,
p,
&dec.getDomainCellNNSym().get(map_cell).NN_subsub.get(0),
dec.getDomainCellNNSym().NN_subsub.size(),
*this,
v.getPosVector());
return cln;
}*/
/*! \brief Get the symmetric neighborhood
*
* \return the symmetric neighborhood
......
......@@ -19,6 +19,12 @@
#define WITH_RADIUS 3
#ifdef LOCAL_INDEX64
typedef size_t local_index;
#else
typedef unsigned int local_index;
#endif
/*! \brief Get the neighborhood iterator based on type
*
* \tparam dim dimensionality
......@@ -46,6 +52,16 @@ struct NNType
{
return cl.template getNNIterator<NO_CHECK>(cl.getCell(xp));
}
/*! \brief Add particle in the list of the domain particles
*
* \param p particle id
* \param pc domain particle sequence
*
*/
static inline void add(local_index p, openfpm::vector<local_index> & pc)
{
}
};
......@@ -77,6 +93,16 @@ struct NNType<dim,T,CellListImpl,PartIt,WITH_RADIUS>
{
return cl.template getNNIteratorRadius<NO_CHECK>(cl.getCell(xp),r_cut);
}
/*! \brief Add particle in the list of the domain particles
*
* \param p particle id
* \param pc domain particle sequence
*
*/
static inline void add(local_index p, openfpm::vector<local_index> & pc)
{
}
};
......@@ -108,6 +134,16 @@ struct NNType<dim,T,CellListImpl,PartIt,VL_SYMMETRIC>
{
return cl.template getNNIteratorSym<NO_CHECK>(cl.getCell(xp),p,v);
}
/*! \brief Add particle in the list of the domain particles
*
* \param p particle id
* \param pc domain particle sequence
*
*/
static inline void add(local_index p, openfpm::vector<local_index> & pc)
{
}
};
......@@ -140,6 +176,17 @@ struct NNType<dim,T,CellListImpl,PartIt,VL_CRS_SYMMETRIC>
{
return it.getNNIteratorCSR(v);
}
/*! \brief Add particle in the list of the domain particles
*
* \param p particle id
* \param pc domain particle sequence
*
*/
static inline void add(local_index p, openfpm::vector<local_index> & pc)
{
pc.add(p);
}
};
/*! \brief In general different NN scheme like full symmetric or CRS require different
......@@ -198,14 +245,17 @@ class VerletList<dim,T,FAST,transform,CellListImpl>
protected:
//! Number of slot for each particle. Or maximum number of particles for each particle
size_t slot;
local_index slot;
//! number of neighborhood particles for each particle
openfpm::vector<size_t> cl_n;
openfpm::vector<local_index> cl_n;
//! Neighborhood indexes for each particle store (each particle can store a number
//! of elements == slot)
openfpm::vector<size_t> cl_base;
openfpm::vector<local_index> cl_base;
//! Domain particles
openfpm::vector<local_index> dp;
private:
......@@ -220,7 +270,7 @@ private:
{
// we do not have enough slots reallocate the basic structure with more
// slots
openfpm::vector<size_t> cl_base_(2*slot * cl_n.size());
openfpm::vector<local_index> cl_base_(2*slot * cl_n.size());
// copy cl_base
for (size_t i = 0 ; i < cl_n.size() ; i++)
......@@ -304,17 +354,20 @@ private:
cl_base.resize(end*slot);
cl_n.fill(0);
dp.clear();
// square of the cutting radius
T r_cut2 = r_cut * r_cut;
// iterate the particles
while (it.isNext())
{
size_t i = it.get();
local_index i = it.get();
Point<dim,T> xp = pos.template get<0>(i);
// Get the neighborhood of the particle
NN_type NN = NNType<dim,T,CellListImpl,decltype(it),type>::get(it,pos,xp,i,cli,r_cut);
NNType<dim,T,CellListImpl,decltype(it),type>::add(i,dp);
while (NN.isNext())
{
......@@ -377,6 +430,9 @@ private:
public:
//! type for the local index
typedef local_index local_index_t;
//! Object type that the structure store
typedef size_t value_type;
......@@ -702,6 +758,7 @@ public:
cl_base.swap(vl.cl_base);
cli.swap(vl.cli);
dp.swap(vl.dp);
return *this;
}
......@@ -722,6 +779,8 @@ public:
cli = vl.cli;
dp = vl.dp;
return *this;
}
......@@ -759,6 +818,7 @@ public:
{
cl_n.swap(vl.cl_n);
cl_base.swap(vl.cl_base);
dp.swap(vl.dp);
size_t vl_slot_tmp = vl.slot;
vl.slot = slot;
......@@ -864,6 +924,16 @@ public:
{
return n_dec;
}
/*! \brief Return the domain particle sequence
*
* \return the particle sequence
*
*/
openfpm::vector<local_index> & getParticleSeq()
{
return dp;
}
};
......
......@@ -38,97 +38,10 @@
#include "timer.hpp"
#include "map_vector_std_util.hpp"
#include "data_type/aggregate.hpp"
#include "vector_map_iterator.hpp"
namespace openfpm
{
/*! \brief Vector iterator
*
*/
class vector_key_iterator
{
//! Linearized end element
size_t end;
protected:
//! Actual key
size_t gk;
public:
/*! \brief Constructor require the size of the vector
*
* \param end point
* \param start starting point
*
*/
vector_key_iterator(size_t end, size_t start = 0)
: end(end),gk(start)
{}
/*! \brief Get the next element
*
* Get the next element
*
* \return the next grid_key
*
*/
vector_key_iterator operator++()
{
//! increment the first index
gk++;
return *this;
}
/*! \brief Set the dimension
*
* \param d is the dimension (IGNORED is by default 0)
* \param sz set the counter to sz
*
*/
void set(int d, size_t sz)
{
// set the counter dim to sz
gk = sz;
}
/*! \brief Check if there is the next element
*
* Check if there is the next element
*
* \return true if there is the next, false otherwise
*
*/
bool isNext() const
{
if (gk < end)
{
//! we did not reach the end of the grid
return true;
}
//! we reach the end of the grid
return false;
}
/*! \brief Get the actual key
*
* Get the actual key
*
* \return the actual key
*
*/
size_t get() const
{
return gk;
}
};
/*! \brief Implementation of 1-D std::vector like structure
*
......
/*
* vector_map_iterator.hpp
*
* Created on: Apr 1, 2017
* Author: i-bird
*/
#ifndef OPENFPM_DATA_SRC_VECTOR_VECTOR_MAP_ITERATOR_HPP_
#define OPENFPM_DATA_SRC_VECTOR_VECTOR_MAP_ITERATOR_HPP_
namespace openfpm
{
/*! \brief Vector iterator
*
*/
class vector_key_iterator
{
//! Linearized end element
size_t end;
protected:
//! Actual key
size_t gk;
public:
/*! \brief Constructor require the size of the vector
*
* \param end point
* \param start starting point
*
*/
vector_key_iterator(size_t end, size_t start = 0)
: end(end),gk(start)
{}
/*! \brief Get the next element
*
* Get the next element
*
* \return the next grid_key
*
*/
vector_key_iterator operator++()
{
//! increment the first index
gk++;
return *this;
}
/*! \brief Set the dimension
*
* \param d is the dimension (IGNORED is by default 0)
* \param sz set the counter to sz
*
*/
void set(int d, size_t sz)
{
// set the counter dim to sz
gk = sz;
}
/*! \brief Check if there is the next element
*
* Check if there is the next element
*
* \return true if there is the next, false otherwise
*
*/
bool isNext() const
{
if (gk < end)
{
//! we did not reach the end of the grid
return true;
}
//! we reach the end of the grid
return false;
}
/*! \brief Get the actual key
*
* Get the actual key
*
* \return the actual key
*
*/
size_t get() const
{
return gk;
}
};
/*! \brief Vector iterator
*
* Vector iterator over a predefined sequence
*
*/
template<typename lid>
class vector_key_iterator_seq
{
openfpm::vector<lid> & dp;
protected:
//! Actual key
size_t gk;
public:
/*! \brief Constructor require the sequence
*
* \param dp
*
*/
vector_key_iterator_seq(openfpm::vector<lid> & dp)
:dp(dp),gk(0)
{}
/*! \brief Get the next element
*
* Get the next element
*
* \return the next grid_key
*
*/
vector_key_iterator_seq<lid> operator++()
{
//! increment the first index
gk++;
return *this;
}
/*! \brief Set the dimension
*
* \param d is the dimension (IGNORED is by default 0)
* \param sz set the counter to sz
*
*/
void set(int d, size_t sz)
{
// set the counter dim to sz
gk = sz;
}
/*! \brief Check if there is the next element
*
* Check if there is the next element
*
* \return true if there is the next, false otherwise
*
*/
bool isNext() const
{
if (gk < dp.size())
{
//! we did not reach the end of the grid
return true;
}
//! we reach the end of the grid
return false;
}
/*! \brief Get the actual key
*
* Get the actual key
*
* \return the actual key
*
*/
size_t get() const
{
return dp.get(gk);
}
};
}
#endif /* OPENFPM_DATA_SRC_VECTOR_VECTOR_MAP_ITERATOR_HPP_ */
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