Commit cd8e5c54 authored by mattijs's avatar mattijs
Browse files

ENH: sampledSet: make point location consistent with lagrangian tracking

parent 3858ac11
...@@ -28,6 +28,7 @@ License ...@@ -28,6 +28,7 @@ License
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "meshSearch.H" #include "meshSearch.H"
#include "writer.H" #include "writer.H"
#include "particle.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...@@ -183,26 +184,58 @@ Foam::point Foam::sampledSet::pushIn ...@@ -183,26 +184,58 @@ Foam::point Foam::sampledSet::pushIn
) const ) const
{ {
label cellI = mesh().faceOwner()[faceI]; label cellI = mesh().faceOwner()[faceI];
const point& cC = mesh().cellCentres()[cellI];
const point& cellCtr = mesh().cellCentres()[cellI]; point newPosition = facePt;
point newSample = // Taken from particle::initCellFacePt()
facePt + tol*(cellCtr - facePt); label tetFaceI;
label tetPtI;
mesh().findTetFacePt(cellI, facePt, tetFaceI, tetPtI);
if (!searchEngine().pointInCell(newSample, cellI)) if (tetFaceI == -1 || tetPtI == -1)
{
newPosition = facePt;
label trap(1.0/particle::trackingCorrectionTol + 1);
label iterNo = 0;
do
{
newPosition += particle::trackingCorrectionTol*(cC - facePt);
mesh().findTetFacePt
(
cellI,
newPosition,
tetFaceI,
tetPtI
);
iterNo++;
} while (tetFaceI < 0 && iterNo <= trap);
}
if (tetFaceI == -1)
{ {
FatalErrorIn FatalErrorIn
( (
"sampledSet::pushIn(const point&, const label)" "sampledSet::pushIn(const point&, const label)"
) << "After pushing " << facePt << " to " << newSample ) << "After pushing " << facePt << " to " << newPosition
<< " it is still outside faceI " << faceI << endl << " it is still outside face " << faceI
<< " at " << mesh().faceCentres()[faceI]
<< " of cell " << cellI
<< " at " << cC << endl
<< "Please change your starting point" << "Please change your starting point"
<< abort(FatalError); << abort(FatalError);
} }
//Info<< "pushIn : moved " << facePt << " to " << newSample
//Info<< "pushIn : moved " << facePt << " to " << newPosition
// << endl; // << endl;
return newSample; return newPosition;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment