6#ifndef OPENFPM_PDATA_SUPPORTBUILDER_HPP
7#define OPENFPM_PDATA_SUPPORTBUILDER_HPP
12#include <Space/Shape/Point.hpp>
13#include <Vector/vector_dist.hpp>
26template<
typename vector_type,
typename vector_type2>
31 decltype(std::declval<vector_type>().getCellList(0.0)) cellList;
33 typename vector_type::stype rCut, MinSpacing, AdapFac=1;
34 bool is_interpolation;
40 typename vector_type::stype rCut,
41 bool is_interpolation)
42 : domainFrom(domainFrom),
44 differentialSignature(differentialSignature),
45 rCut(rCut), is_interpolation(is_interpolation) {
50 unsigned int differentialSignature[
vector_type::dims],
typename vector_type::stype rCut,
51 bool is_interpolation)
55 template<
typename iterator_type>
56 Support getSupport(iterator_type itPoint,
unsigned int requiredSize, support_options opt) {
65 std::set<grid_key_dx<vector_type::dims>> supportCells;
66 supportCells.insert(curCellKey);
69 enlargeSetOfCellsUntilSize(supportCells, requiredSize + 1,
74 std::vector<size_t> supportKeys = getPointsInSetOfCells(supportCells, p, pOrig, requiredSize, opt);
76 if (is_interpolation ==
false) {
77 auto p_o = domainFrom.getOriginKey(p.
getKey());
78 std::remove(supportKeys.begin(), supportKeys.end(), p_o.getKey());
81 auto p_o = domainTo.getOriginKey(p.
getKey());
85 typename vector_type::stype getLastMinspacing() {
86 return this->MinSpacing;
89 void setAdapFac(
typename vector_type::stype fac) {
96 mem_id
id = cellList.getGrid().LinId(cellKey);
97 return static_cast<size_t>(id);
101 const size_t curCellId = getCellLinId(cellKey);
102 size_t numElements = cellList.getNelements(curCellId);
108 for (
const auto cell: set) {
109 tot += getNumElementsInCell(cell);
115 support_options opt) {
116 if (opt == support_options::RADIUS || opt == support_options::ADAPTIVE) {
117 auto cell = *set.begin();
119 int n = std::ceil(rCut / cellList.getCellBox().getHigh(0));
128 auto key = g_k.
get();
129 key = cell + key - middle;
130 if (isCellKeyInBounds(key)) {
136 while (getNumElementsInSetOfCells(set) <
140 for (
const auto el: tmpSet) {
142 const auto pOneEl = el.move(i, +1);
143 const auto mOneEl = el.move(i, -1);
144 if (isCellKeyInBounds(pOneEl)) {
147 if (isCellKeyInBounds(mOneEl)) {
160 size_t requiredSupportSize,
161 support_options opt) {
163 typename vector_type::stype dist;
166 bool operator<(
const reord &p)
const {
return this->dist < p.dist; }
170 std::vector<size_t> points;
172 for (
const auto cellKey: set) {
173 const size_t cellLinId = getCellLinId(cellKey);
174 const size_t elemsInCell = getNumElementsInCell(cellKey);
175 for (
size_t k = 0; k < elemsInCell; ++k) {
176 size_t el = cellList.get(cellLinId, k);
178 if (pOrig.
getKey() == el && is_interpolation ==
false) {
continue; }
191 if (opt == support_options::RADIUS) {
192 for (
int i = 0; i < rp.
size(); i++) {
193 if (rp.get(i).dist < rCut) {
194 points.push_back(rp.get(i).offset);
205 else if(opt == support_options::ADAPTIVE) {
206 MinSpacing = std::numeric_limits<double>::max();
207 for (
int i = 0; i < rp.
size(); i++) {
208 if (MinSpacing > rp.get(i).dist && rp.get(i).dist != 0) {
209 MinSpacing = rp.get(i).dist;
213 assert(MinSpacing !=0 &&
"You have multiple particles on the same position.");
215 for (
int i = 0; i < rp.
size(); i++) {
216 if (rp.get(i).dist < AdapFac * MinSpacing) {
217 points.push_back(rp.get(i).offset);
223 for (
int i = 0; i < requiredSupportSize; i++) {
224 points.push_back(rp.get(i).offset);
234 const size_t *cellGridSize = cellList.getGrid().getSize();
237 if (key.
value(i) < 0 || key.
value(i) >= cellGridSize[i])
This class implement the point shape in an N-dimensional space.
__device__ __host__ T distance(const Point< dim, T > &q) const
It calculate the distance between 2 points.
const grid_key_dx< dim > & get() const
Get the actual key.
bool isNext()
Check if there is the next element.
grid_key_dx is the key to access any element in the grid
__device__ __host__ mem_id value(size_t i) const
Get the i index.
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
Implementation of 1-D std::vector like structure.
Grid key for a distributed grid.
__device__ __host__ size_t getKey() const
Get the key.
auto getPos(vect_dist_key_dx vec_key) -> decltype(vd.getPos(vec_key))
Get the position of an element.
static const unsigned int dims
template parameters typedefs
CellL getCellList(St r_cut, bool no_se3=false)
Construct a cell list starting from the stored particles.
auto getPosOrig(vect_dist_key_dx vec_key) const -> decltype(v_pos.template get< 0 >(vec_key.getKey()))
Get the position of an element.