mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: CollidingParcel - refactored to remove code duplication
This commit is contained in:
@ -69,13 +69,6 @@ bool Foam::CollidingParcel<ParcelType>::move
|
|||||||
typename TrackData::cloudType::parcelType& p =
|
typename TrackData::cloudType::parcelType& p =
|
||||||
static_cast<typename TrackData::cloudType::parcelType&>(*this);
|
static_cast<typename TrackData::cloudType::parcelType&>(*this);
|
||||||
|
|
||||||
td.switchProcessor = false;
|
|
||||||
td.keepParticle = true;
|
|
||||||
|
|
||||||
const polyMesh& mesh = td.cloud().pMesh();
|
|
||||||
const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
|
|
||||||
const scalarField& V = mesh.cellVolumes();
|
|
||||||
|
|
||||||
switch (td.part())
|
switch (td.part())
|
||||||
{
|
{
|
||||||
case TrackData::tpVelocityHalfStep:
|
case TrackData::tpVelocityHalfStep:
|
||||||
@ -92,70 +85,7 @@ bool Foam::CollidingParcel<ParcelType>::move
|
|||||||
|
|
||||||
case TrackData::tpLinearTrack:
|
case TrackData::tpLinearTrack:
|
||||||
{
|
{
|
||||||
scalar tEnd = (1.0 - p.stepFraction())*trackTime;
|
ParcelType::move(td, trackTime);
|
||||||
const scalar dtMax = tEnd;
|
|
||||||
|
|
||||||
while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL)
|
|
||||||
{
|
|
||||||
// Apply correction to position for reduced-D cases
|
|
||||||
meshTools::constrainToMeshCentre(mesh, p.position());
|
|
||||||
|
|
||||||
const point start(p.position());
|
|
||||||
|
|
||||||
// Set the Lagrangian time-step
|
|
||||||
scalar dt = min(dtMax, tEnd);
|
|
||||||
|
|
||||||
// Remember which cell the parcel is in since this
|
|
||||||
// will change if a face is hit
|
|
||||||
const label cellI = p.cell();
|
|
||||||
|
|
||||||
const scalar magU = mag(p.U());
|
|
||||||
if (p.active() && magU > ROOTVSMALL)
|
|
||||||
{
|
|
||||||
const scalar d = dt*magU;
|
|
||||||
const scalar maxCo = td.cloud().solution().maxCo();
|
|
||||||
const scalar dCorr = min(d, maxCo*cbrt(V[cellI]));
|
|
||||||
dt *=
|
|
||||||
dCorr/d
|
|
||||||
*p.trackToFace(p.position() + dCorr*p.U()/magU, td);
|
|
||||||
}
|
|
||||||
|
|
||||||
tEnd -= dt;
|
|
||||||
p.stepFraction() = 1.0 - tEnd/trackTime;
|
|
||||||
|
|
||||||
// Avoid problems with extremely small timesteps
|
|
||||||
if (dt > ROOTVSMALL)
|
|
||||||
{
|
|
||||||
// Update cell based properties
|
|
||||||
p.setCellValues(td, dt, cellI);
|
|
||||||
|
|
||||||
if (td.cloud().solution().cellValueSourceCorrection())
|
|
||||||
{
|
|
||||||
p.cellValueSourceCorrection(td, dt, cellI);
|
|
||||||
}
|
|
||||||
|
|
||||||
p.calc(td, dt, cellI);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p.onBoundary() && td.keepParticle)
|
|
||||||
{
|
|
||||||
if (isA<processorPolyPatch>(pbMesh[p.patch(p.face())]))
|
|
||||||
{
|
|
||||||
td.switchProcessor = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.age() += dt;
|
|
||||||
|
|
||||||
td.cloud().functions().postMove
|
|
||||||
(
|
|
||||||
p,
|
|
||||||
cellI,
|
|
||||||
dt,
|
|
||||||
start,
|
|
||||||
td.keepParticle
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user