Skip to content
Permalink
Browse files

particle: Improvements to tracking across AMIs

The projection direction has been corrected to include the effect of
mesh motion. The case where the source and receiving faces are of
differing orientations and the particle displacement points into both is
now detected and handled.
  • Loading branch information...
Will Bainbridge
Will Bainbridge committed Jun 26, 2018
1 parent fb4cb6e commit 35dd88e553328b2c00ddae722a953c44135b4236
@@ -176,9 +176,10 @@ void Foam::findCellParticle::hitCyclicPatch

void Foam::findCellParticle::hitCyclicAMIPatch
(
const vector&,
const scalar,
Cloud<findCellParticle>&,
trackingData& td,
const vector&
trackingData& td
)
{
// Remove particle
@@ -188,9 +189,23 @@ void Foam::findCellParticle::hitCyclicAMIPatch

void Foam::findCellParticle::hitCyclicACMIPatch
(
const vector&,
const scalar,
Cloud<findCellParticle>&,
trackingData& td,
const vector&
trackingData& td
)
{
// Remove particle
td.keepParticle = false;
}


void Foam::findCellParticle::hitCyclicRepeatAMIPatch
(
const vector&,
const scalar,
Cloud<findCellParticle>&,
trackingData& td
)
{
// Remove particle
@@ -228,17 +228,29 @@ public:
//- Overridable function to handle the particle hitting a cyclicAMI
void hitCyclicAMIPatch
(
const vector&,
const scalar,
Cloud<findCellParticle>&,
trackingData&,
const vector&
trackingData&
);

//- Overridable function to handle the particle hitting a cyclicACMI
void hitCyclicACMIPatch
(
const vector&,
const scalar,
Cloud<findCellParticle>&,
trackingData&,
const vector&
trackingData&
);

//- Overridable function to handle the particle hitting a
//cyclicRepeatAMI
void hitCyclicRepeatAMIPatch
(
const vector&,
const scalar,
Cloud<findCellParticle>&,
trackingData&
);

//- Overridable function to handle the particle hitting a
@@ -323,9 +323,10 @@ void Foam::streamLineParticle::hitCyclicPatch

void Foam::streamLineParticle::hitCyclicAMIPatch
(
const vector&,
const scalar,
streamLineParticleCloud&,
trackingData& td,
const vector&
trackingData& td
)
{
// Remove particle
@@ -335,9 +336,23 @@ void Foam::streamLineParticle::hitCyclicAMIPatch

void Foam::streamLineParticle::hitCyclicACMIPatch
(
const vector&,
const scalar,
streamLineParticleCloud&,
trackingData& td,
const vector&
trackingData& td
)
{
// Remove particle
td.keepParticle = false;
}


void Foam::streamLineParticle::hitCyclicRepeatAMIPatch
(
const vector&,
const scalar,
streamLineParticleCloud&,
trackingData& td
)
{
// Remove particle
@@ -231,18 +231,30 @@ public:
// cyclicAMIPatch
void hitCyclicAMIPatch
(
const vector&,
const scalar,
streamLineParticleCloud&,
trackingData&,
const vector& direction
trackingData&
);

//- Overridable function to handle the particle hitting a
// cyclicACMIPatch
void hitCyclicACMIPatch
(
const vector&,
const scalar,
streamLineParticleCloud&,
trackingData&,
const vector& direction
trackingData&
);

//- Overridable function to handle the particle hitting a
// cyclicRepeatAMIPatch
void hitCyclicRepeatAMIPatch
(
const vector&,
const scalar,
streamLineParticleCloud&,
trackingData&
);

//- Overridable function to handle the particle hitting a
@@ -409,7 +409,6 @@ void Foam::particle::changeToMasterPatch()
void Foam::particle::locate
(
const vector& position,
const vector* direction,
label celli,
const bool boundaryFail,
const string boundaryMsg
@@ -488,34 +487,11 @@ void Foam::particle::locate
}
else
{
// Re-do the track, but this time do the bit tangential to the
// direction/patch first. This gets us as close as possible to the
// original path/position.

if (direction == nullptr)
{
const polyPatch& p = mesh_.boundaryMesh()[patch()];
direction = &p.faceNormals()[p.whichFace(facei_)];
}

const vector n = *direction/mag(*direction);
const vector sN = (displacement & n)*n;
const vector sT = displacement - sN;

coordinates_ = barycentric(1, 0, 0, 0);
celli_ = celli;
tetFacei_ = minTetFacei;
tetPti_ = minTetPti;
facei_ = -1;

track(sT, 0);
track(sN, 0);

static label nWarnings = 0;
static const label maxNWarnings = 100;
if (nWarnings < maxNWarnings)
{
WarningInFunction << boundaryMsg << endl;
WarningInFunction << boundaryMsg.c_str() << endl;
++ nWarnings;
}
if (nWarnings == maxNWarnings)
@@ -572,7 +548,6 @@ Foam::particle::particle
locate
(
position,
nullptr,
celli,
false,
"Particle initialised with a location outside of the mesh."
@@ -1171,7 +1146,6 @@ void Foam::particle::autoMap
locate
(
position,
nullptr,
mapper.reverseCellMap()[celli_],
true,
"Particle mapped to a location outside of the mesh."
@@ -274,7 +274,6 @@ private:
void locate
(
const vector& position,
const vector* direction,
label celli,
const bool boundaryFail,
const string boundaryMsg
@@ -309,21 +308,34 @@ protected:

//- Overridable function to handle the particle hitting a cyclicAMIPatch
template<class TrackCloudType>
void hitCyclicAMIPatch(TrackCloudType&, trackingData&, const vector&);
void hitCyclicAMIPatch
(
const vector& displacement,
const scalar fraction,
TrackCloudType& cloud,
trackingData& td
);

//- Overridable function to handle the particle hitting a
// cyclicACMIPatch
template<class TrackCloudType>
void hitCyclicACMIPatch(TrackCloudType&, trackingData&, const vector&);
void hitCyclicACMIPatch
(
const vector& displacement,
const scalar fraction,
TrackCloudType& cloud,
trackingData& td
);

//- Overridable function to handle the particle hitting an
// cyclicRepeatAMIPolyPatch
template<class TrackCloudType>
void hitCyclicRepeatAMIPatch
(
TrackCloudType&,
trackingData&,
const vector&
const vector& displacement,
const scalar fraction,
TrackCloudType& cloud,
trackingData& td
);

//- Overridable function to handle the particle hitting a processorPatch
@@ -559,16 +571,17 @@ public:
template<class TrackCloudType>
void hitFace
(
const vector& direction,
const vector& displacement,
const scalar fraction,
TrackCloudType& cloud,
trackingData& td
);

//- Convenience function. Cobines trackToFace and hitFace
//- Convenience function. Combines trackToFace and hitFace
template<class TrackCloudType>
scalar trackToAndHitFace
(
const vector& direction,
const vector& displacement,
const scalar fraction,
TrackCloudType& cloud,
trackingData& td
@@ -582,8 +595,8 @@ public:

// Patch data

//- Get the normal and velocity of the current patch location
inline void patchData(vector& n, vector& U) const;
//- Get the normal and displacement of the current patch location
inline void patchData(vector& normal, vector& displacement) const;


// Transformations
@@ -286,7 +286,7 @@ inline Foam::vector Foam::particle::position() const
}


void Foam::particle::patchData(vector& n, vector& U) const
void Foam::particle::patchData(vector& normal, vector& displacement) const
{
if (!onBoundaryFace())
{
@@ -300,27 +300,23 @@ void Foam::particle::patchData(vector& n, vector& U) const
Pair<vector> centre, base, vertex1, vertex2;
movingTetGeometry(1, centre, base, vertex1, vertex2);

n = triPointRef(base[0], vertex1[0], vertex2[0]).normal();
normal = triPointRef(base[0], vertex1[0], vertex2[0]).normal();

// Interpolate the motion of the three face vertices to the current
// coordinates
U =
displacement =
coordinates_.b()*base[1]
+ coordinates_.c()*vertex1[1]
+ coordinates_.d()*vertex2[1];

// The movingTetGeometry method gives the motion as a displacement
// across the time-step, so we divide by the time-step to get velocity
U /= mesh_.time().deltaTValue();
}
else
{
vector centre, base, vertex1, vertex2;
stationaryTetGeometry(centre, base, vertex1, vertex2);

n = triPointRef(base, vertex1, vertex2).normal();
normal = triPointRef(base, vertex1, vertex2).normal();

U = Zero;
displacement = Zero;
}
}

0 comments on commit 35dd88e

Please sign in to comment.
You can’t perform that action at this time.