ENH: Added initial support for particle tracking across AMI patches

This commit is contained in:
andy
2013-08-14 15:54:40 +01:00
parent 43d09748f7
commit 8e79bf1b82
7 changed files with 278 additions and 7 deletions

View File

@ -1248,6 +1248,114 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
}
template<class SourcePatch, class TargetPatch>
Foam::label Foam::AMIInterpolation<SourcePatch, TargetPatch>::srcPointFace
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const vector& n,
const label tgtFaceI,
point& tgtPoint
)
const
{
const pointField& srcPoints = srcPatch.points();
// source face addresses that intersect target face tgtFaceI
const labelList& addr = tgtAddress_[tgtFaceI];
forAll(addr, i)
{
label srcFaceI = addr[i];
const face& f = srcPatch[tgtFaceI];
pointHit ray = f.ray(tgtPoint, n, srcPoints);
if (ray.hit())
{
tgtPoint = ray.rawPoint();
return srcFaceI;
}
}
// no hit registered - try with face normal instead of input normal
forAll(addr, i)
{
label srcFaceI = addr[i];
const face& f = srcPatch[tgtFaceI];
vector nFace(-srcPatch.faceNormals()[srcFaceI]);
nFace += tgtPatch.faceNormals()[tgtFaceI];
pointHit ray = f.ray(tgtPoint, nFace, srcPoints);
if (ray.hit())
{
tgtPoint = ray.rawPoint();
return srcFaceI;
}
}
return -1;
}
template<class SourcePatch, class TargetPatch>
Foam::label Foam::AMIInterpolation<SourcePatch, TargetPatch>::tgtPointFace
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const vector& n,
const label srcFaceI,
point& srcPoint
)
const
{
const pointField& tgtPoints = tgtPatch.points();
// target face addresses that intersect source face srcFaceI
const labelList& addr = srcAddress_[srcFaceI];
forAll(addr, i)
{
label tgtFaceI = addr[i];
const face& f = tgtPatch[tgtFaceI];
pointHit ray = f.ray(srcPoint, n, tgtPoints);
if (ray.hit())
{
srcPoint = ray.rawPoint();
return tgtFaceI;
}
}
// no hit registered - try with face normal instead of input normal
forAll(addr, i)
{
label tgtFaceI = addr[i];
const face& f = tgtPatch[tgtFaceI];
vector nFace(-srcPatch.faceNormals()[srcFaceI]);
nFace += tgtPatch.faceNormals()[tgtFaceI];
pointHit ray = f.ray(srcPoint, n, tgtPoints);
if (ray.hit())
{
srcPoint = ray.rawPoint();
return tgtFaceI;
}
}
return -1;
}
template<class SourcePatch, class TargetPatch>
void Foam::AMIInterpolation<SourcePatch, TargetPatch>::writeFaceConnectivity
(

View File

@ -454,6 +454,31 @@ public:
) const;
// Point intersections
//- Return source patch face index of point on target patch face
label srcPointFace
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const vector& n,
const label tgtFaceI,
point& tgtPoint
)
const;
//- Return target patch face index of point on source patch face
label tgtPointFace
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const vector& n,
const label srcFaceI,
point& srcPoint
)
const;
// Checks
//- Write face connectivity as OBJ file

View File

@ -797,6 +797,38 @@ bool Foam::cyclicAMIPolyPatch::order
}
Foam::label Foam::cyclicAMIPolyPatch::pointFace
(
const label faceI,
const vector& n,
point& p
) const
{
if (owner())
{
return AMI().tgtPointFace
(
*this,
neighbPatch(),
n,
faceI,
p
);
}
else
{
return neighbPatch().AMI().srcPointFace
(
neighbPatch(),
*this,
n,
faceI,
p
);
}
}
void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
{
coupledPolyPatch::write(os);

View File

@ -367,6 +367,15 @@ public:
labelList& rotation
) const;
//- Return face index on neighbour patch which shares point p
// following trajectory vector n
label pointFace
(
const label faceI,
const vector& n,
point& p
) const;
//- Write the polyPatch data as a dictionary
virtual void write(Ostream&) const;
};