mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: partilceCollector cloud function object - added polygonWithNormal option
This commit is contained in:
@ -106,11 +106,13 @@ void Foam::ParticleCollector<CloudType>::makeLogFile
|
|||||||
|
|
||||||
|
|
||||||
template<class CloudType>
|
template<class CloudType>
|
||||||
void Foam::ParticleCollector<CloudType>::initPolygons()
|
void Foam::ParticleCollector<CloudType>::initPolygons
|
||||||
|
(
|
||||||
|
const List<Field<point> >& polygons
|
||||||
|
)
|
||||||
{
|
{
|
||||||
mode_ = mtPolygon;
|
mode_ = mtPolygon;
|
||||||
|
|
||||||
List<Field<point> > polygons(this->coeffDict().lookup("polygons"));
|
|
||||||
label nPoints = 0;
|
label nPoints = 0;
|
||||||
forAll(polygons, polyI)
|
forAll(polygons, polyI)
|
||||||
{
|
{
|
||||||
@ -168,7 +170,7 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles()
|
|||||||
if (nSector_ > 1)
|
if (nSector_ > 1)
|
||||||
{
|
{
|
||||||
refDir = this->coeffDict().lookup("refDir");
|
refDir = this->coeffDict().lookup("refDir");
|
||||||
refDir -= normal_*(normal_ & refDir);
|
refDir -= normal_[0]*(normal_[0] & refDir);
|
||||||
refDir /= mag(refDir);
|
refDir /= mag(refDir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -184,7 +186,7 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles()
|
|||||||
{
|
{
|
||||||
vector v = rnd.vector01();
|
vector v = rnd.vector01();
|
||||||
|
|
||||||
tangent = v - (v & normal_)*normal_;
|
tangent = v - (v & normal_[0])*normal_[0];
|
||||||
magTangent = mag(tangent);
|
magTangent = mag(tangent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +211,7 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles()
|
|||||||
faces_.setSize(nFace);
|
faces_.setSize(nFace);
|
||||||
area_.setSize(nFace);
|
area_.setSize(nFace);
|
||||||
|
|
||||||
coordSys_ = cylindricalCS("coordSys", origin, normal_, refDir, false);
|
coordSys_ = cylindricalCS("coordSys", origin, normal_[0], refDir, false);
|
||||||
|
|
||||||
List<label> ptIDs(identity(nPointPerRadius));
|
List<label> ptIDs(identity(nPointPerRadius));
|
||||||
|
|
||||||
@ -301,8 +303,8 @@ void Foam::ParticleCollector<CloudType>::collectParcelPolygon
|
|||||||
|
|
||||||
const point& pf = points_[facePoint0];
|
const point& pf = points_[facePoint0];
|
||||||
|
|
||||||
const scalar d1 = normal_ & (p1 - pf);
|
const scalar d1 = normal_[faceI] & (p1 - pf);
|
||||||
const scalar d2 = normal_ & (p2 - pf);
|
const scalar d2 = normal_[faceI] & (p2 - pf);
|
||||||
|
|
||||||
if (sign(d1) == sign(d2))
|
if (sign(d1) == sign(d2))
|
||||||
{
|
{
|
||||||
@ -344,8 +346,8 @@ void Foam::ParticleCollector<CloudType>::collectParcelConcentricCircles
|
|||||||
{
|
{
|
||||||
label secI = -1;
|
label secI = -1;
|
||||||
|
|
||||||
const scalar d1 = normal_ & (p1 - coordSys_.origin());
|
const scalar d1 = normal_[0] & (p1 - coordSys_.origin());
|
||||||
const scalar d2 = normal_ & (p2 - coordSys_.origin());
|
const scalar d2 = normal_[0] & (p2 - coordSys_.origin());
|
||||||
|
|
||||||
if (sign(d1) == sign(d2))
|
if (sign(d1) == sign(d2))
|
||||||
{
|
{
|
||||||
@ -526,7 +528,7 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
|
|||||||
nSector_(0),
|
nSector_(0),
|
||||||
radius_(),
|
radius_(),
|
||||||
coordSys_(false),
|
coordSys_(false),
|
||||||
normal_(this->coeffDict().lookup("normal")),
|
normal_(),
|
||||||
negateParcelsOppositeNormal_
|
negateParcelsOppositeNormal_
|
||||||
(
|
(
|
||||||
readBool(this->coeffDict().lookup("negateParcelsOppositeNormal"))
|
readBool(this->coeffDict().lookup("negateParcelsOppositeNormal"))
|
||||||
@ -547,10 +549,37 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
|
|||||||
word mode(this->coeffDict().lookup("mode"));
|
word mode(this->coeffDict().lookup("mode"));
|
||||||
if (mode == "polygon")
|
if (mode == "polygon")
|
||||||
{
|
{
|
||||||
initPolygons();
|
List<Field<point> > polygons(this->coeffDict().lookup("polygons"));
|
||||||
|
|
||||||
|
initPolygons(polygons);
|
||||||
|
|
||||||
|
vector n0(this->coeffDict().lookup("normal"));
|
||||||
|
normal_ = vectorField(faces_.size(), n0);
|
||||||
|
}
|
||||||
|
else if (mode == "polygonWithNormal")
|
||||||
|
{
|
||||||
|
List<Tuple2<Field<point>, vector> > polygonAndNormal
|
||||||
|
(
|
||||||
|
this->coeffDict().lookup("polygons")
|
||||||
|
);
|
||||||
|
|
||||||
|
List<Field<point> > polygons(polygonAndNormal.size());
|
||||||
|
normal_.setSize(polygonAndNormal.size());
|
||||||
|
|
||||||
|
forAll(polygons, polyI)
|
||||||
|
{
|
||||||
|
polygons[polyI] = polygonAndNormal[polyI].first();
|
||||||
|
normal_[polyI] = polygonAndNormal[polyI].second();
|
||||||
|
normal_[polyI] /= mag(normal_[polyI]) + ROOTVSMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
initPolygons(polygons);
|
||||||
}
|
}
|
||||||
else if (mode == "concentricCircle")
|
else if (mode == "concentricCircle")
|
||||||
{
|
{
|
||||||
|
vector n0(this->coeffDict().lookup("normal"));
|
||||||
|
normal_ = vectorField(1, n0);
|
||||||
|
|
||||||
initConcentricCircles();
|
initConcentricCircles();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -560,12 +589,14 @@ Foam::ParticleCollector<CloudType>::ParticleCollector
|
|||||||
"Foam::ParticleCollector<CloudType>::ParticleCollector"
|
"Foam::ParticleCollector<CloudType>::ParticleCollector"
|
||||||
"("
|
"("
|
||||||
"const dictionary&,"
|
"const dictionary&,"
|
||||||
"CloudType&"
|
"CloudType&, "
|
||||||
|
"const word&"
|
||||||
")",
|
")",
|
||||||
this->coeffDict()
|
this->coeffDict()
|
||||||
)
|
)
|
||||||
<< "Unknown mode " << mode << ". Available options are "
|
<< "Unknown mode " << mode << ". Available options are "
|
||||||
<< "polygon and concentricCircle" << exit(FatalIOError);
|
<< "polygon, polygonWithNormal and concentricCircle"
|
||||||
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
mass_.setSize(faces_.size(), 0.0);
|
mass_.setSize(faces_.size(), 0.0);
|
||||||
@ -663,7 +694,7 @@ void Foam::ParticleCollector<CloudType>::postMove
|
|||||||
{
|
{
|
||||||
vector Uhat = p.U();
|
vector Uhat = p.U();
|
||||||
Uhat /= mag(Uhat) + ROOTVSMALL;
|
Uhat /= mag(Uhat) + ROOTVSMALL;
|
||||||
if ((Uhat & normal_) < 0)
|
if ((Uhat & normal_[faceI]) < 0)
|
||||||
{
|
{
|
||||||
m *= -1.0;
|
m *= -1.0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -164,8 +164,8 @@ private:
|
|||||||
//- Face areas
|
//- Face areas
|
||||||
Field<scalar> area_;
|
Field<scalar> area_;
|
||||||
|
|
||||||
//- Polygon normal vector
|
//- Polygon normal vector per face
|
||||||
vector normal_;
|
Field<vector> normal_;
|
||||||
|
|
||||||
//- Remove mass of parcel travelling in opposite direction to normal_
|
//- Remove mass of parcel travelling in opposite direction to normal_
|
||||||
bool negateParcelsOppositeNormal_;
|
bool negateParcelsOppositeNormal_;
|
||||||
@ -212,7 +212,7 @@ private:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Initialise polygon collectors
|
//- Initialise polygon collectors
|
||||||
void initPolygons();
|
void initPolygons(const List<Field<point> >& polygons);
|
||||||
|
|
||||||
//- Initialise concentric circle collectors
|
//- Initialise concentric circle collectors
|
||||||
void initConcentricCircles();
|
void initConcentricCircles();
|
||||||
|
|||||||
Reference in New Issue
Block a user