5 #ifndef OPENFPM_PDATA_VECTOR_DIST_SUBSET_HPP
6 #define OPENFPM_PDATA_VECTOR_DIST_SUBSET_HPP
8 #include "vector_dist.hpp"
10 template<
unsigned int dim,
24 typedef boost::mpl::int_<AggregateAppend<int,prop>::type::max_prop-1> flag_prop;
26 void setSubset(
size_t key,
int sub_id)
28 this->
template getProp<flag_prop::value>(key) = sub_id;
31 int getSubset(
size_t key)
33 return this->
template getProp<flag_prop::value>(key);
36 void ghost_get_subset()
38 this->
template ghost_get<flag_prop::value>(NO_POSITION | SKIP_LABELLING);
41 void getLastSubset(
int sub_id)
43 this->
template getProp<flag_prop::value>(this->
size_local()-1) = sub_id;
46 inline bool write_frame(std::string out,
size_t iteration,
int opt = VTK_WRITER)
49 if(prop_names.size()==prop::max_prop){
50 prop_names.add({
"SubsetNumber"});
55 inline bool write_frame(std::string out,
size_t iteration,
double time,
int opt = VTK_WRITER)
58 if(prop_names.size()==prop::max_prop){
59 prop_names.add({
"SubsetNumber"});
65 inline bool write(std::string out,
int opt = VTK_WRITER)
68 if(prop_names.size()==prop::max_prop){
69 prop_names.add({
"SubsetNumber"});
77 template<
unsigned int dim,
87 typedef boost::mpl::int_<AggregateAppend<int,prop>::type::max_prop-1> flag_prop;
96 int subsetUpdate_ctr=0;
102 for (
size_t i = 0 ; i < pid.
size() ; i++)
104 if (pid.template get<0>(i) >= vd.
size_local())
106 std::cout << __FILE__ <<
":" << __LINE__ <<
" Error you have ghost particles in your subset" << std::endl;
122 typedef typename ivector_dist::stype
stype;
128 typedef int yes_i_am_vector_subset;
135 :vd(vd),sub_id(sub_id)
138 subsetUpdate_ctr=vd.getMapCtr();
148 if (vd.template getProp<flag_prop::value>(p) == sub_id)
151 pid.template get<0>(pid.
size()-1) = p;
160 void ghost_get_subset()
162 vd.template ghost_get<flag_prop::value>(NO_POSITION | SKIP_LABELLING);
176 int getUpdateCtr()
const{
177 return subsetUpdate_ctr;
181 return vd.getMapCtr();
191 subsetUpdate_ctr=vd.getMapCtr();
204 if (vd.template getProp<flag_prop::value>(p) == sub_id)
207 pid.template get<0>(pid.
size()-1) = p;
256 #ifndef ONLY_READWRITE_GETTER
269 return vd.
getPos(vec_key);
281 inline auto getPos(
size_t vec_key)
const -> decltype(vd.
getPos(vec_key))
283 return vd.
getPos(vec_key);
297 return vd.
getPos(pid.template get<0>(vec_key));
311 return vd.
getPos(pid.template get<0>(vec_key));
319 template<
unsigned int ... prp>
332 vd.template hostToDevicePos<0>();
345 template<
unsigned int id>
inline auto getProp(
size_t vec_key) -> decltype(vd.template getProp<id>(vec_key))
347 return vd.template getProp<id>(vec_key);
360 template<
unsigned int id>
inline auto getProp(
size_t vec_key)
const -> decltype(vd.template getProp<id>(vec_key))
362 return vd.template getProp<id>(vec_key);
375 template<
unsigned int id>
inline auto getPropSubset(
size_t vec_key) -> decltype(vd.template getProp<id>(vec_key))
377 return vd.template getProp<id>(pid.template get<0>(vec_key));
390 template<
unsigned int id>
inline auto getPropSubset(
size_t vec_key)
const -> decltype(vd.template getProp<id>(vec_key))
392 return vd.template getProp<id>(pid.template get<0>(vec_key));
421 template<
typename CellL = CellList<dim, St, Mem_fast<>, shift<dim, St>,
typename std::remove_reference<decltype(vd.getPosVector())>::type > >
433 return getCellList<CellL>(r_cut, g,no_se3);
448 unsigned int opt=VL_NON_SYMMETRIC,
451 VerletList_type
getVerlet(St r_cut,
bool no_se3 =
false)
458 VerletList_type verletList;
460 auto cellList = this->
template getCellList<
typename std::remove_reference<decltype(verletList.getInternalCellList())>::type>(r_cut, no_se3);
462 if (verletList.getOpt() & VL_NON_SYMMETRIC)
469 std::cerr << __FILE__ <<
":" << __LINE__ <<
" vector_dist_subset::getVerletList supports VL_NON_SYMMETRIC option only! " << std::endl;
499 VerletList<dim,St,opt,Mem_type,shift<dim,St>,vPos_type> ver_tmp = getVerlet<opt, VerletList<dim,St,opt,Mem_type,shift<dim,St>,vPos_type>>(r_cut);
500 verletList.
swap(ver_tmp);
529 template<
typename CellL = CellList<dim, St, Mem_fast<>, shift<dim, St> > >
546 cl_param_calculate(pbox, div, r_cut, enlarge);
548 cell_list.Initialize(pbox, div);
549 cell_list.setGhostMarker(pid.
size());
558 size_t key = it.get();
562 cell_list.add(pos,key);
573 size_t key = git.
get();
577 if (vd.template getProp<flag_prop::value>(key) == sub_id)
579 cell_list.add(pos,key);
606 template<
unsigned int dim,
typename St,
typename prop,
typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_lin>>
using vector_dist_ws_gpu =
vector_dist_ws<dim,St,prop,Decomposition,CudaMemory,memory_traits_lin>;
607 template<
unsigned int dim,
typename St,
typename prop,
typename Decomposition = CartDecomposition<dim,St,CudaMemory,memory_traits_lin>>
using vector_dist_subset_gpu =
vector_dist_subset<dim,St,prop,Decomposition,CudaMemory,memory_traits_lin>;
void magnify(T mg)
Magnify the box.
Box< dim, T > & getProcessorBounds()
Return the bounding box containing union of all the sub-domains for the local processor.
const Ghost< dim, T > & getGhost() const
Return the ghost.
size_t get_ndec()
Get the decomposition counter.
Class for FAST cell list implementation.
This class define the domain decomposition interface.
This class allocate, and destroy CPU memory.
This class implement the point shape in an N-dimensional space.
Class for Verlet list implementation.
void swap(VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > &vl)
Swap the memory.
Implementation of 1-D std::vector like structure.
Iterator that Iterate across particle indexes.
vect_dist_key_dx get()
Get the actual key.
auto getPropSubset(size_t vec_key) const -> decltype(vd.template getProp< id >(vec_key))
Get the property of an element.
auto getPos(size_t vec_key) const -> decltype(vd.getPos(vec_key))
Get the position of an element.
vector_dist_subset< dim, St, prop, Decomposition, Memory, layout_base > & operator=(const vector_dist_subset< dim, St, prop, Decomposition, Memory, layout_base > &v)
Operator= for distributed vector.
const Decomposition & getDecomposition() const
Get the decomposition.
auto getPosSubset(size_t vec_key) -> decltype(vd.getPos(vec_key))
Get the position of an element.
auto getProp(size_t vec_key) -> decltype(vd.template getProp< id >(vec_key))
Get the property of an element.
std::integral_constant< bool, true > is_it_a_subset
Subset detection.
static const unsigned int dims
dimensions of space
auto getPropSubset(size_t vec_key) -> decltype(vd.template getProp< id >(vec_key))
Get the property of an element.
CellL getCellList(St r_cut, bool no_se3=false)
Construct a cell list starting from the stored particles.
VerletList_type getVerlet(St r_cut, bool no_se3=false)
Construct a Verlet List from the stored particles.
void hostToDeviceProp()
Move the memory from the device to host memory.
size_t size_local() const
return the local size of vector_dist_ws
auto getPosSubset(size_t vec_key) const -> decltype(vd.getPos(vec_key))
Get the position of an element.
ivector_dist::stype stype
space type
openfpm::vector< aggregate< int > > & getIds()
Return the ids.
bool isSubset() const
Indicate that this class is not a subset.
vector_dist_iterator_subset getDomainIterator() const
Get an iterator that traverse the particles in the domain.
Decomposition & getDecomposition()
Get the decomposition.
void updateVerlet(VerletList< dim, St, opt, Mem_type, shift< dim, St >, vPos_type > &verletList, St r_cut, bool no_se3=false)
Update an existing Verlet List.
ivector_dist::value_type value_type
property object
auto getProp(size_t vec_key) const -> decltype(vd.template getProp< id >(vec_key))
Get the property of an element.
size_t size_local_subset() const
return the local size of the vector
void update()
Update the subset indexes.
auto getPos(size_t vec_key) -> decltype(vd.getPos(vec_key))
Get the position of an element.
CellL getCellList(St r_cut, const Ghost< dim, St > &enlarge, bool no_se3=false)
Construct a cell list starting from the stored particles.
void hostToDevicePos()
Move the memory from the device to host memory.
size_t size_local() const
return the local size of the vector
static const unsigned int dims
template parameters typedefs
Decomposition & getDecomposition()
Get the decomposition.
vector_dist_iterator getGhostIterator() const
Get the iterator across the position of the ghost particles.
auto getPos(vect_dist_key_dx vec_key) -> decltype(vPos.template get< 0 >(vec_key.getKey()))
Get the position of an element.
size_t opt
option used to create this vector
const vector_dist_pos & getPosVector() const
return the position vector of all the particles
vector_dist_iterator getDomainIterator() const
Get an iterator that traverse the particles in the domain.
openfpm::vector< std::string > & getPropNames()
Get the properties names.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Transform the boost::fusion::vector into memory specification (memory_traits)