mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Moving the calculation of the lambda denominator/numerator upwards.
Expensive to look it up in the lambda function, passing from trackToFace as an argument.
This commit is contained in:
@ -32,6 +32,8 @@ Foam::label Foam::particle::particleCount_ = 0;
|
|||||||
|
|
||||||
const Foam::scalar Foam::particle::trackingCorrectionTol = 1e-5;
|
const Foam::scalar Foam::particle::trackingCorrectionTol = 1e-5;
|
||||||
|
|
||||||
|
const Foam::scalar Foam::particle::lambdaDistanceToleranceCoeff = 1e3*SMALL;
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
defineTypeNameAndDebug(particle, 0);
|
defineTypeNameAndDebug(particle, 0);
|
||||||
|
|||||||
@ -164,7 +164,8 @@ protected:
|
|||||||
DynamicList<label>& faceList,
|
DynamicList<label>& faceList,
|
||||||
const tetPointRef& tet,
|
const tetPointRef& tet,
|
||||||
const FixedList<vector, 4>& tetAreas,
|
const FixedList<vector, 4>& tetAreas,
|
||||||
const FixedList<label, 4>& tetPlaneBasePtIs
|
const FixedList<label, 4>& tetPlaneBasePtIs,
|
||||||
|
const scalar tol
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Find the lambda value for the line to-from across the
|
//- Find the lambda value for the line to-from across the
|
||||||
@ -178,7 +179,8 @@ protected:
|
|||||||
const label tetPlaneBasePtI,
|
const label tetPlaneBasePtI,
|
||||||
const label cellI,
|
const label cellI,
|
||||||
const label tetFaceI,
|
const label tetFaceI,
|
||||||
const label tetPtI
|
const label tetPtI,
|
||||||
|
const scalar tol
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Find the lambda value for a moving tri face
|
//- Find the lambda value for a moving tri face
|
||||||
@ -191,7 +193,8 @@ protected:
|
|||||||
const label tetPlaneBasePtI,
|
const label tetPlaneBasePtI,
|
||||||
const label cellI,
|
const label cellI,
|
||||||
const label tetFaceI,
|
const label tetFaceI,
|
||||||
const label tetPtI
|
const label tetPtI,
|
||||||
|
const scalar tol
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Modify the tet owner data by crossing triI
|
//- Modify the tet owner data by crossing triI
|
||||||
@ -291,6 +294,10 @@ public:
|
|||||||
// 'rescue' it from a tracking problem
|
// 'rescue' it from a tracking problem
|
||||||
static const scalar trackingCorrectionTol;
|
static const scalar trackingCorrectionTol;
|
||||||
|
|
||||||
|
//- Fraction of the cell volume to use in determining tolerance values
|
||||||
|
// for the denominator and numerator of lambda
|
||||||
|
static const scalar lambdaDistanceToleranceCoeff;
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,8 @@ inline void Foam::particle::findTris
|
|||||||
DynamicList<label>& faceList,
|
DynamicList<label>& faceList,
|
||||||
const tetPointRef& tet,
|
const tetPointRef& tet,
|
||||||
const FixedList<vector, 4>& tetAreas,
|
const FixedList<vector, 4>& tetAreas,
|
||||||
const FixedList<label, 4>& tetPlaneBasePtIs
|
const FixedList<label, 4>& tetPlaneBasePtIs,
|
||||||
|
const scalar tol
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
faceList.clear();
|
faceList.clear();
|
||||||
@ -52,7 +53,8 @@ inline void Foam::particle::findTris
|
|||||||
tetPlaneBasePtIs[i],
|
tetPlaneBasePtIs[i],
|
||||||
cellI_,
|
cellI_,
|
||||||
tetFaceI_,
|
tetFaceI_,
|
||||||
tetPtI_
|
tetPtI_,
|
||||||
|
tol
|
||||||
);
|
);
|
||||||
|
|
||||||
if ((lambda > 0.0) && (lambda < 1.0))
|
if ((lambda > 0.0) && (lambda < 1.0))
|
||||||
@ -72,7 +74,8 @@ inline Foam::scalar Foam::particle::tetLambda
|
|||||||
const label tetPlaneBasePtI,
|
const label tetPlaneBasePtI,
|
||||||
const label cellI,
|
const label cellI,
|
||||||
const label tetFaceI,
|
const label tetFaceI,
|
||||||
const label tetPtI
|
const label tetPtI,
|
||||||
|
const scalar tol
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const pointField& pPts = mesh_.points();
|
const pointField& pPts = mesh_.points();
|
||||||
@ -88,7 +91,8 @@ inline Foam::scalar Foam::particle::tetLambda
|
|||||||
tetPlaneBasePtI,
|
tetPlaneBasePtI,
|
||||||
cellI,
|
cellI,
|
||||||
tetFaceI,
|
tetFaceI,
|
||||||
tetPtI
|
tetPtI,
|
||||||
|
tol
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,8 +106,6 @@ inline Foam::scalar Foam::particle::tetLambda
|
|||||||
// delta-length in the direction of n times the face area to a fraction of
|
// delta-length in the direction of n times the face area to a fraction of
|
||||||
// the cell volume.
|
// the cell volume.
|
||||||
|
|
||||||
scalar tol = 1e3*SMALL*mesh_.cellVolumes()[cellI];
|
|
||||||
|
|
||||||
if (mag(lambdaDenominator) < tol)
|
if (mag(lambdaDenominator) < tol)
|
||||||
{
|
{
|
||||||
if (mag(lambdaNumerator) < tol)
|
if (mag(lambdaNumerator) < tol)
|
||||||
@ -147,7 +149,8 @@ inline Foam::scalar Foam::particle::movingTetLambda
|
|||||||
const label tetPlaneBasePtI,
|
const label tetPlaneBasePtI,
|
||||||
const label cellI,
|
const label cellI,
|
||||||
const label tetFaceI,
|
const label tetFaceI,
|
||||||
const label tetPtI
|
const label tetPtI,
|
||||||
|
const scalar tol
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const pointField& pPts = mesh_.points();
|
const pointField& pPts = mesh_.points();
|
||||||
@ -299,8 +302,6 @@ inline Foam::scalar Foam::particle::movingTetLambda
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scalar tol = 1e3*SMALL*mesh_.cellVolumes()[cellI];
|
|
||||||
|
|
||||||
if (mag(lambdaDenominator) < tol)
|
if (mag(lambdaDenominator) < tol)
|
||||||
{
|
{
|
||||||
if (mag(lambdaNumerator) < tol)
|
if (mag(lambdaNumerator) < tol)
|
||||||
|
|||||||
@ -286,6 +286,11 @@ Foam::scalar Foam::particle::trackToFace
|
|||||||
// be a different tet to the one that the particle occupies.
|
// be a different tet to the one that the particle occupies.
|
||||||
tetIndices faceHitTetIs;
|
tetIndices faceHitTetIs;
|
||||||
|
|
||||||
|
// What tolerance is appropriate the minimum lambda numerator and
|
||||||
|
// denominator for tracking in this cell.
|
||||||
|
scalar lambdaDistanceTolerance =
|
||||||
|
lambdaDistanceToleranceCoeff*mesh_.cellVolumes()[cellI_];
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (triI != -1)
|
if (triI != -1)
|
||||||
@ -371,7 +376,15 @@ Foam::scalar Foam::particle::trackToFace
|
|||||||
tetPlaneBasePtIs[2] = basePtI;
|
tetPlaneBasePtIs[2] = basePtI;
|
||||||
tetPlaneBasePtIs[3] = basePtI;
|
tetPlaneBasePtIs[3] = basePtI;
|
||||||
|
|
||||||
findTris(endPosition, tris, tet, tetAreas, tetPlaneBasePtIs);
|
findTris
|
||||||
|
(
|
||||||
|
endPosition,
|
||||||
|
tris,
|
||||||
|
tet,
|
||||||
|
tetAreas,
|
||||||
|
tetPlaneBasePtIs,
|
||||||
|
lambdaDistanceTolerance
|
||||||
|
);
|
||||||
|
|
||||||
// Reset variables for new track
|
// Reset variables for new track
|
||||||
triI = -1;
|
triI = -1;
|
||||||
@ -415,7 +428,8 @@ Foam::scalar Foam::particle::trackToFace
|
|||||||
tetPlaneBasePtIs[tI],
|
tetPlaneBasePtIs[tI],
|
||||||
cellI_,
|
cellI_,
|
||||||
tetFaceI_,
|
tetFaceI_,
|
||||||
tetPtI_
|
tetPtI_,
|
||||||
|
lambdaDistanceTolerance
|
||||||
);
|
);
|
||||||
|
|
||||||
if (lam < lambdaMin)
|
if (lam < lambdaMin)
|
||||||
@ -704,6 +718,9 @@ void Foam::particle::hitWallFaces
|
|||||||
|
|
||||||
const Foam::cell& thisCell = mesh_.cells()[cellI_];
|
const Foam::cell& thisCell = mesh_.cells()[cellI_];
|
||||||
|
|
||||||
|
scalar lambdaDistanceTolerance =
|
||||||
|
lambdaDistanceToleranceCoeff*mesh_.cellVolumes()[cellI_];
|
||||||
|
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
forAll(thisCell, cFI)
|
forAll(thisCell, cFI)
|
||||||
@ -755,7 +772,8 @@ void Foam::particle::hitWallFaces
|
|||||||
f[tetIs.faceBasePt()],
|
f[tetIs.faceBasePt()],
|
||||||
cellI_,
|
cellI_,
|
||||||
fI,
|
fI,
|
||||||
tetIs.tetPt()
|
tetIs.tetPt(),
|
||||||
|
lambdaDistanceTolerance
|
||||||
);
|
);
|
||||||
|
|
||||||
if ((tetClambda <= 0.0) || (tetClambda >= 1.0))
|
if ((tetClambda <= 0.0) || (tetClambda >= 1.0))
|
||||||
@ -781,7 +799,8 @@ void Foam::particle::hitWallFaces
|
|||||||
f[tetIs.faceBasePt()],
|
f[tetIs.faceBasePt()],
|
||||||
cellI_,
|
cellI_,
|
||||||
fI,
|
fI,
|
||||||
tetIs.tetPt()
|
tetIs.tetPt(),
|
||||||
|
lambdaDistanceTolerance
|
||||||
);
|
);
|
||||||
|
|
||||||
pointHit hitInfo(vector::zero);
|
pointHit hitInfo(vector::zero);
|
||||||
|
|||||||
Reference in New Issue
Block a user