Go to the documentation of this file.
45 for(
auto i=0; i<num;i++)
47 for(
auto j=i+1; j<num; j++)
66 auto minP =
region_->minPoint();
67 auto maxP =
region_->maxPoint();
77 REPORT(1)<<
"Positioning "<<
79 ": started with "<< startNum <<
" points."<<
endREPORT;
100 for(
int32 i=0; i<startNum; i++)
125 if(numPoints_ == 0)
return true;
128 int32 startNum = numPoints_;
130 while ( pass <maxIterations_)
132 if( positionOnePass(pass, startNum) )
return true;
133 startNum = 1.1*startNum+1;
139 " cannot position "<< numPoints_ <<
" in the domain in " << maxIterations_ <<
" iterations.\n" <<
140 " you may increase maxIterations for positioning points.\n";
151 for(
const auto& cp: position_)
153 if(
length(cp-cntr) <= diam )
return true;
167 dict.
subDict(
"positionRandomInfo")
171 prDict_.getVal<
real>(
"diameter")
175 prDict_.getVal<
size_t>(
"numPoints")
179 prDict_.getValOrSet(
"maxIterations", 10)
183 maxNumberOfParticles_,
RESERVE()
187 reportInterval_ =
max(numPoints_/numReports_,
static_cast<size_t>(2));
189 if( !positionPointsRandom() )
196 fatalErrorInFunction<<
"You must provided a region (box, cylinder, ...) for positioning particles in dictionary "<<
211 auto minP = region_().minPoint();
212 auto maxP = region_().maxPoint();
214 for(
size_t i=0; i<numPoints; i++)
223 auto pos = rand(minP, maxP);
224 if( region_().isInside(pos))
234 "could not find a point inside region"<<region_->name()<<
endl;
255 int32 numCollisions = 0;
257 Kokkos::parallel_reduce(
258 "positionRandom::findCollisions",
261 if(allPairs.isValid(i))
263 auto pair = allPairs.getPair(i);
264 if( dFlags[pair.first] ==0 )
266 dFlags[pair.first] = 1;
272 flags.modifyOnDevice();
275 return numCollisions;
INLINE_FUNCTION_H void syncViews()
positionRandom(const dictionary &dict)
INLINE_FUNCTION_HD int32 capacity() const
void fillPoints(uint numPoints, realx3Vector_HD &points, int32Vector_HD &flags)
virtual word globalName() const
uniquePtr< regionBase > region_
bool broadSearch(PairsContainer &pairs, range activeRange)
iOstream & endl(iOstream &os)
INLINE_FUNCTION_H void modifyOnHost()
INLINE_FUNCTION_H deviceViewType & deviceVectorAll()
bool positionOnePass(int32 pass, int32 startNum)
#define fatalErrorInFunction
INLINE_FUNCTION_HD T length(const triple< T > &v1)
bool positionPointsRandom()
pairAccessor getPairs() const
dictionary & subDict(const word &keyword)
T max(const Vector< T, Allocator > &v)
INLINE_FUNCTION_HD bool sphereSphereCheck(const realx3 &p1, const realx3 p2, real d1, real d2)
INLINE_FUNCTION_H deviceViewType & deviceVector()
int32 findCollisions(ContainerType &pairs, int32Vector_HD &flags)
INLINE_FUNCTION_H viewType & deviceVectorAll()
bool inCollision(const realx3 &cntr, real diam)