Commit b78d844c authored by Will Bainbridge's avatar Will Bainbridge Committed by Andrew Heather
Browse files

lagrangian: Removed duplicate data from method arguments

A lot of methods were taking argument data which could be referenced or
generated from the parcel class at little or no additional cost. This
was confusing and generated the possibility of inconsistent data states.
parent 22bd3919
......@@ -125,10 +125,7 @@ bool Foam::findCellParticle::hitPatch
(
const polyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td,
const label patchi,
const scalar trackFraction,
const tetIndices& tetIs
trackingData& td
)
{
return false;
......@@ -183,24 +180,25 @@ void Foam::findCellParticle::hitCyclicPatch
}
void Foam::findCellParticle::hitProcessorPatch
void Foam::findCellParticle::hitCyclicAMIPatch
(
const processorPolyPatch&,
const cyclicAMIPolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td
trackingData& td,
const vector&
)
{
// Remove particle
td.switchProcessor = true;
td.keepParticle = false;
}
void Foam::findCellParticle::hitWallPatch
void Foam::findCellParticle::hitCyclicACMIPatch
(
const wallPolyPatch& wpp,
const cyclicACMIPolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td,
const tetIndices&
const vector&
)
{
// Remove particle
......@@ -208,9 +206,21 @@ void Foam::findCellParticle::hitWallPatch
}
void Foam::findCellParticle::hitPatch
void Foam::findCellParticle::hitProcessorPatch
(
const processorPolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td
)
{
// Remove particle
td.switchProcessor = true;
}
void Foam::findCellParticle::hitWallPatch
(
const polyPatch& wpp,
const wallPolyPatch& wpp,
Cloud<findCellParticle>& cloud,
trackingData& td
)
......
......@@ -229,10 +229,7 @@ public:
(
const polyPatch&,
Cloud<findCellParticle>&,
trackingData& td,
const label patchi,
const scalar trackFraction,
const tetIndices& tetIs
trackingData& td
);
//- Overridable function to handle the particle hitting a wedge
......@@ -269,6 +266,24 @@ public:
trackingData& td
);
//- Overridable function to handle the particle hitting a cyclicAMI
void hitCyclicAMIPatch
(
const cyclicAMIPolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td,
const vector&
);
//- Overridable function to handle the particle hitting a cyclicACMI
void hitCyclicACMIPatch
(
const cyclicACMIPolyPatch&,
Cloud<findCellParticle>& cloud,
trackingData& td,
const vector&
);
//- Overridable function to handle the particle hitting a
//- processorPatch
void hitProcessorPatch
......@@ -283,15 +298,6 @@ public:
(
const wallPolyPatch&,
Cloud<findCellParticle>&,
trackingData& td,
const tetIndices&
);
//- Overridable function to handle the particle hitting a polyPatch
void hitPatch
(
const polyPatch&,
Cloud<findCellParticle>&,
trackingData& td
);
......
......@@ -269,10 +269,7 @@ bool Foam::streamLineParticle::hitPatch
(
const polyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const label patchi,
const scalar trackFraction,
const tetIndices& tetIs
trackingData& td
)
{
// Disable generic patch interaction
......@@ -328,24 +325,25 @@ void Foam::streamLineParticle::hitCyclicPatch
}
void Foam::streamLineParticle::hitProcessorPatch
void Foam::streamLineParticle::hitCyclicAMIPatch
(
const processorPolyPatch&,
const cyclicAMIPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
trackingData& td,
const vector&
)
{
// Switch particle
td.switchProcessor = true;
// Remove particle
td.keepParticle = false;
}
void Foam::streamLineParticle::hitWallPatch
void Foam::streamLineParticle::hitCyclicACMIPatch
(
const wallPolyPatch& wpp,
const cyclicACMIPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const tetIndices&
const vector&
)
{
// Remove particle
......@@ -353,9 +351,21 @@ void Foam::streamLineParticle::hitWallPatch
}
void Foam::streamLineParticle::hitPatch
void Foam::streamLineParticle::hitProcessorPatch
(
const processorPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
)
{
// Switch particle
td.switchProcessor = true;
}
void Foam::streamLineParticle::hitWallPatch
(
const polyPatch& wpp,
const wallPolyPatch& wpp,
streamLineParticleCloud& cloud,
trackingData& td
)
......
......@@ -220,10 +220,7 @@ public:
(
const polyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const label patchi,
const scalar trackFraction,
const tetIndices& tetIs
trackingData& td
);
//- Overridable function to handle the particle hitting a wedge
......@@ -260,6 +257,26 @@ public:
trackingData& td
);
//- Overridable function to handle the particle hitting a
// cyclicAMIPatch
void hitCyclicAMIPatch
(
const cyclicAMIPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const vector& direction
);
//- Overridable function to handle the particle hitting a
// cyclicACMIPatch
void hitCyclicACMIPatch
(
const cyclicACMIPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const vector& direction
);
//- Overridable function to handle the particle hitting a
//- processorPatch
void hitProcessorPatch
......@@ -274,15 +291,6 @@ public:
(
const wallPolyPatch&,
streamLineParticleCloud& cloud,
trackingData& td,
const tetIndices&
);
//- Overridable function to handle the particle hitting a polyPatch
void hitPatch
(
const polyPatch&,
streamLineParticleCloud& cloud,
trackingData& td
);
......
......@@ -85,10 +85,7 @@ bool Foam::DSMCParcel<ParcelType>::hitPatch
(
const polyPatch&,
TrackCloudType& cloud,
trackingData& td,
const label,
const scalar,
const tetIndices&
trackingData& td
)
{
return false;
......@@ -114,8 +111,7 @@ void Foam::DSMCParcel<ParcelType>::hitWallPatch
(
const wallPolyPatch& wpp,
TrackCloudType& cloud,
trackingData& td,
const tetIndices& tetIs
trackingData& td
)
{
label wppIndex = wpp.index();
......@@ -202,19 +198,6 @@ void Foam::DSMCParcel<ParcelType>::hitWallPatch
}
template<class ParcelType>
template<class TrackCloudType>
void Foam::DSMCParcel<ParcelType>::hitPatch
(
const polyPatch&,
TrackCloudType& cloud,
trackingData& td
)
{
td.keepParticle = false;
}
template<class ParcelType>
void Foam::DSMCParcel<ParcelType>::transformProperties(const tensor& T)
{
......
......@@ -264,10 +264,7 @@ public:
(
const polyPatch&,
TrackCloudType& cloud,
trackingData& td,
const label patchi,
const scalar trackFraction,
const tetIndices& tetIs
trackingData& td
);
//- Overridable function to handle the particle hitting a
......@@ -286,16 +283,6 @@ public:
(
const wallPolyPatch&,
TrackCloudType& cloud,
trackingData& td,
const tetIndices&
);
//- Overridable function to handle the particle hitting a polyPatch
template<class TrackCloudType>
void hitPatch
(
const polyPatch&,
TrackCloudType& cloud,
trackingData& td
);
......
......@@ -64,32 +64,6 @@ void Foam::Cloud<ParticleType>::checkPatches() const
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::calcCellWallFaces() const
{
cellWallFacesPtr_.reset(new PackedBoolList(pMesh().nCells(), false));
PackedBoolList& cellWallFaces = cellWallFacesPtr_();
const polyBoundaryMesh& patches = polyMesh_.boundaryMesh();
forAll(patches, patchi)
{
if (isA<wallPolyPatch>(patches[patchi]))
{
const polyPatch& patch = patches[patchi];
const labelList& pFaceCells = patch.faceCells();
forAll(pFaceCells, pFCI)
{
cellWallFaces[pFaceCells[pFCI]] = true;
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParticleType>
......@@ -104,8 +78,6 @@ Foam::Cloud<ParticleType>::Cloud
IDLList<ParticleType>(),
polyMesh_(pMesh),
labels_(),
nTrackingRescues_(),
cellWallFacesPtr_(),
globalPositionsPtr_()
{
checkPatches();
......@@ -124,19 +96,6 @@ Foam::Cloud<ParticleType>::Cloud
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParticleType>
const Foam::PackedBoolList& Foam::Cloud<ParticleType>::cellHasWallFaces()
const
{
if (!cellWallFacesPtr_.valid())
{
calcCellWallFaces();
}
return cellWallFacesPtr_();
}
template<class ParticleType>
void Foam::Cloud<ParticleType>::addParticle(ParticleType* pPtr)
{
......@@ -195,9 +154,6 @@ void Foam::Cloud<ParticleType>::move
// Which patches are processor patches
const labelList& procPatches = pData.processorPatches();
// Indexing of patches into the procPatches list
const labelList& procPatchIndices = pData.processorPatchIndices();
// Indexing of equivalent patch on neighbour processor into the
// procPatches list on the neighbour
const labelList& procPatchNeighbours = pData.processorPatchNeighbours();
......@@ -219,10 +175,6 @@ void Foam::Cloud<ParticleType>::move
pIter().stepFraction() = 0;
}
// Reset nTrackingRescues
nTrackingRescues_ = 0;
// List of lists of particles to be transfered for all of the
// neighbour processors
List<IDLList<ParticleType>> particleTransferLists
......@@ -271,7 +223,7 @@ void Foam::Cloud<ParticleType>::move
(
!Pstream::parRun()
|| !p.onBoundaryFace()
|| procPatchIndices[p.patch()] < 0
|| procPatchNeighbours[p.patch()] < 0
)
{
FatalErrorInFunction
......@@ -390,16 +342,6 @@ void Foam::Cloud<ParticleType>::move
}
}
}
if (cloud::debug)
{
reduce(nTrackingRescues_, sumOp<label>());
if (nTrackingRescues_ > 0)
{
Info<< nTrackingRescues_ << " tracking rescue corrections" << endl;
}
}
}
......
......@@ -80,10 +80,6 @@ class Cloud
//- Temporary storage for addressing. Used in findTris.
mutable DynamicList<label> labels_;
//- Count of how many tracking rescue corrections have been
// applied
mutable label nTrackingRescues_;
//- Does the cell have wall faces
mutable autoPtr<PackedBoolList> cellWallFacesPtr_;
......@@ -160,45 +156,18 @@ public:
return polyMesh_;
}
//- Return the number of particles in the cloud
label size() const
{
return IDLList<ParticleType>::size();
};
//- Return temporary addressing
DynamicList<label>& labels() const
{
return labels_;
}
//- Return nTrackingRescues
label nTrackingRescues() const
{
return nTrackingRescues_;
}
//- Increment the nTrackingRescues counter
void trackingRescue() const
{
nTrackingRescues_++;
if (cloud::debug && size() && (nTrackingRescues_ % size() == 0))
{
Pout<< " " << nTrackingRescues_
<< " tracking rescues " << endl;
}
}
//- Whether each cell has any wall faces (demand driven data)
const PackedBoolList& cellHasWallFaces() const;
//- Switch to specify if particles of the cloud can return
// non-zero wall distance values. By default, assume
// that they can't (default for wallImpactDistance in
// particle is 0.0).
bool hasWallImpactDistance() const
{
return false;
}
// Iterators
......
......@@ -150,7 +150,6 @@ Foam::Cloud<ParticleType>::Cloud
cloud(pMesh, cloudName),
polyMesh_(pMesh),
labels_(),
nTrackingRescues_(),
cellWallFacesPtr_()
{
checkPatches();
......
......@@ -284,17 +284,12 @@ protected:
//- Overridable function to handle the particle hitting a
// patch. Executed before other patch-hitting functions.
// trackFraction is passed in to allow mesh motion to
// interpolate in time to the correct face state.
template<class TrackCloudType>
bool hitPatch
(
const polyPatch&,
TrackCloudType& cloud,
trackingData& td,
const label patchi,
const scalar trackFraction,
const tetIndices& tetIs
trackingData& td
);
//- Overridable function to handle the particle hitting a wedgePatch
......@@ -372,17 +367,6 @@ protected:
(
const wallPolyPatch&,
TrackCloudType& cloud,
trackingData& td,
const tetIndices& tetIs
);
//- Overridable function to handle the particle hitting a
// general patch
template<class TrackCloudType>
void hitPatch
(
const polyPatch&,
TrackCloudType& cloud,
trackingData& td
);
......
......@@ -203,7 +203,7 @@ inline bool Foam::particle::onBoundaryFace() const
inline Foam::label Foam::particle::patch() const
{
return mesh_.boundaryMesh().whichPatch(facei_);
return onFace() ? mesh_.boundaryMesh().whichPatch(facei_) : -1;
}
......
......@@ -140,22 +140,9 @@ void Foam::particle::hitFace
}
else if (onBoundaryFace())
{
const tetIndices faceHitTetIs(celli_, tetFacei_, tetPti_);
if
(
!p.hitPatch
(
mesh_.boundaryMesh()[patch()],
cloud,
ttd,
patch(),
stepFraction(),
faceHitTetIs
)
)
if(!p.hitPatch(mesh_.boundaryMesh()[p.patch()], cloud, ttd))
{
const polyPatch& patch = mesh_.boundaryMesh()[this->patch()];
const polyPatch& patch = mesh_.boundaryMesh()[p.patch()];
if (isA<wedgePolyPatch>(patch))
{
......@@ -218,15 +205,12 @@ void Foam::particle::hitFace
{
p.hitWallPatch
(
static_cast<const wallPolyPatch&>(patch),
cloud,
ttd,
faceHitTetIs
static_cast<const wallPolyPatch&>(patch), cloud, ttd
);
}
else
{
p.hitPatch(patch, cloud, ttd);
td.keepParticle = false;
}
}
}
......@@ -258,10 +242,7 @@ bool Foam::particle::hitPatch
(
const polyPatch&,
TrackCloudType&,
trackingData&,
const label,
const scalar,
const tetIndices&
trackingData&