correted position random
This commit is contained in:
parent
6ac5670933
commit
6152ec6a7c
|
@ -7,5 +7,5 @@ objectName sphereDict;
|
|||
objectType sphereShape;
|
||||
|
||||
names (glassBead); // names of shapes
|
||||
diameters (0.006); // diameter of shapes
|
||||
diameters (0.003); // diameter of shapes
|
||||
materials (glassMat); // material names for shapes
|
||||
|
|
|
@ -15,7 +15,7 @@ surfaces
|
|||
{
|
||||
type cylinderWall;
|
||||
p1 (0.0 0.0 0.0);
|
||||
p2 (0.0 0.0 0.8);
|
||||
p2 (0.0 0.0 1.6);
|
||||
radius1 0.2;
|
||||
radius2 0.2;
|
||||
resolution 24;
|
||||
|
@ -41,10 +41,10 @@ surfaces
|
|||
wall2
|
||||
{
|
||||
type planeWall;
|
||||
p1 (-0.2 -0.2 0.8);
|
||||
p2 ( 0.2 -0.2 0.8);
|
||||
p3 ( 0.2 0.2 0.8);
|
||||
p4 (-0.2 0.2 0.8);
|
||||
p1 (-0.2 -0.2 1.6);
|
||||
p2 ( 0.2 -0.2 1.6);
|
||||
p3 ( 0.2 0.2 1.6);
|
||||
p4 (-0.2 0.2 1.6);
|
||||
material wallMat;
|
||||
motion rotAxis;
|
||||
}
|
||||
|
|
|
@ -25,20 +25,20 @@ positionParticles
|
|||
{
|
||||
method positionOrdered;
|
||||
|
||||
maxNumberOfParticles 1000000;
|
||||
maxNumberOfParticles 4000001;
|
||||
mortonSorting Yes;
|
||||
|
||||
cylinder // box for positioning particles
|
||||
{
|
||||
p1 ( 0.0 0.0 0.0); // lower corner point of the box
|
||||
p2 ( 0.0 0.0 0.8); // upper corner point of the box
|
||||
p1 ( 0.0 0.0 0.01); // lower corner point of the box
|
||||
p2 ( 0.0 0.0 1.59); // upper corner point of the box
|
||||
radius 0.195;
|
||||
}
|
||||
|
||||
positionOrderedInfo
|
||||
{
|
||||
diameter 0.006; // minimum space between centers of particles
|
||||
numPoints 240000; // number of particles in the simulation
|
||||
diameter 0.003; // minimum space between centers of particles
|
||||
numPoints 4000000; // number of particles in the simulation
|
||||
axisOrder (z x y); // axis order for filling the space with particles
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ g (0 -9.8 0); // gravity vector (m/s2)
|
|||
|
||||
domain
|
||||
{
|
||||
min (-0.21 -0.21 -0.01);
|
||||
max ( 0.21 0.21 0.81);
|
||||
min (-0.2 -0.2 -0.0);
|
||||
max ( 0.2 0.2 1.6);
|
||||
}
|
||||
|
||||
integrationMethod AdamsBashforth3; // integration method
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
|
||||
virtual realx3 maxPoint()const =0;
|
||||
|
||||
virtual word name()const =0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -91,6 +92,11 @@ class region
|
|||
return region_.maxPoint();
|
||||
}
|
||||
|
||||
word name()const override
|
||||
{
|
||||
return region_.typeName();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class positionParticles
|
||||
|
|
|
@ -21,10 +21,9 @@ Licence:
|
|||
|
||||
#include "positionRandom.H"
|
||||
#include "uniformRandomReal.H"
|
||||
#include "VectorSingles.H"
|
||||
#include "VectorDuals.H"
|
||||
#include "NBS.H"
|
||||
#include "unsortedPairs.H"
|
||||
#include "box.H"
|
||||
|
||||
|
||||
|
||||
|
@ -35,12 +34,6 @@ using SearchType = NBS<DefaultExecutionSpace, int32> ;
|
|||
using ContainerType = unsortedPairs<DefaultExecutionSpace, int32>;
|
||||
|
||||
|
||||
void fillPoints(
|
||||
uint numPoints,
|
||||
realx3 minP,
|
||||
realx3 maxP,
|
||||
realx3Vector_HD& points,
|
||||
int32Vector_HD& flags );
|
||||
|
||||
int32 findCollisions(
|
||||
ContainerType& pairs,
|
||||
|
@ -70,11 +63,11 @@ bool pFlow::positionRandom::positionOnePass(int32 pass, int32 startNum)
|
|||
int32Vector_HD flagHD(startNum, 0);
|
||||
realx3Vector_HD positionHD(startNum);
|
||||
|
||||
auto minP = box_.minPoint() + static_cast<real>(0.5)*realx3(diameter_);
|
||||
auto maxP = box_.maxPoint() - static_cast<real>(0.5)*realx3(diameter_);
|
||||
auto minP = region_->minPoint();
|
||||
auto maxP = region_->maxPoint();
|
||||
|
||||
SearchType search(
|
||||
box_,
|
||||
box(minP, maxP),
|
||||
diameter_,
|
||||
positionHD.deviceVectorAll(),
|
||||
diameter.deviceVectorAll());
|
||||
|
@ -85,7 +78,7 @@ bool pFlow::positionRandom::positionOnePass(int32 pass, int32 startNum)
|
|||
greenText("(Pass #"<< pass+1<<")")<<
|
||||
": started with "<< startNum <<" points."<<endReport;
|
||||
|
||||
fillPoints(startNum, minP, maxP, positionHD, flagHD);
|
||||
fillPoints(startNum, positionHD, flagHD);
|
||||
|
||||
search.broadSearch(pairs, range(0, startNum), true);
|
||||
|
||||
|
@ -181,10 +174,6 @@ pFlow::positionRandom::positionRandom
|
|||
(
|
||||
prDict_.getVal<size_t>("numPoints")
|
||||
),
|
||||
box_
|
||||
(
|
||||
prDict_.subDict("box")
|
||||
),
|
||||
maxIterations_
|
||||
(
|
||||
prDict_.getValOrSet("maxIterations", 10)
|
||||
|
@ -201,24 +190,53 @@ pFlow::positionRandom::positionRandom
|
|||
{
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
if(!region_)
|
||||
{
|
||||
fatalErrorInFunction<<"You must provided a region (box, cylinder, ...) for positioning particles in dictionary "<<
|
||||
dict.globalName()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void pFlow::fillPoints(
|
||||
void pFlow::positionRandom::fillPoints(
|
||||
uint numPoints,
|
||||
realx3 minP,
|
||||
realx3 maxP,
|
||||
realx3Vector_HD& points,
|
||||
int32Vector_HD& flags )
|
||||
{
|
||||
|
||||
uniformRandomReal rand;
|
||||
|
||||
auto minP = region_().minPoint();
|
||||
auto maxP = region_().maxPoint();
|
||||
|
||||
for(size_t i=0; i<numPoints; i++)
|
||||
{
|
||||
if(flags[i] == 0)
|
||||
{
|
||||
points[i] =rand(minP, maxP);
|
||||
bool loop=true;
|
||||
size_t n=0;
|
||||
while (loop)
|
||||
{
|
||||
|
||||
auto pos = rand(minP, maxP);
|
||||
if( region_().isInside(pos))
|
||||
{
|
||||
points[i] =pos;
|
||||
loop = false;
|
||||
}
|
||||
n++;
|
||||
|
||||
if(n>100)
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
"could not find a point inside region"<<region_->name()<<endl;
|
||||
fatalExit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
points.modifyOnHost();
|
||||
|
|
|
@ -24,12 +24,14 @@ Licence:
|
|||
|
||||
#include "positionParticles.H"
|
||||
#include "VectorSingles.H"
|
||||
#include "VectorDuals.H"
|
||||
|
||||
#include "box.H"
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
||||
|
||||
class positionRandom
|
||||
:
|
||||
public positionParticles
|
||||
|
@ -42,8 +44,6 @@ protected:
|
|||
|
||||
size_t numPoints_;
|
||||
|
||||
box box_;
|
||||
|
||||
size_t maxIterations_;
|
||||
|
||||
realx3Vector position_;
|
||||
|
@ -56,6 +56,11 @@ protected:
|
|||
|
||||
bool inCollision(const realx3 &cntr, real diam);
|
||||
|
||||
void fillPoints(
|
||||
uint numPoints,
|
||||
realx3Vector_HD& points,
|
||||
int32Vector_HD& flags );
|
||||
|
||||
public:
|
||||
|
||||
// - type Info
|
||||
|
|
Loading…
Reference in New Issue