mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
lagrangian::patchInjectionBase: corrected initialization of tetFaceI and tetPtI
Patch contributed by Timo Niemi, VTT. Resolved bug-report http://bugs.openfoam.org/view.php?id=2286
This commit is contained in:
@ -28,6 +28,8 @@ License
|
|||||||
#include "SubField.H"
|
#include "SubField.H"
|
||||||
#include "cachedRandom.H"
|
#include "cachedRandom.H"
|
||||||
#include "triPointRef.H"
|
#include "triPointRef.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "polyMeshTetDecomposition.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ void Foam::patchInjectionBase::updateMesh(const polyMesh& mesh)
|
|||||||
|
|
||||||
void Foam::patchInjectionBase::setPositionAndCell
|
void Foam::patchInjectionBase::setPositionAndCell
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const fvMesh& mesh,
|
||||||
cachedRandom& rnd,
|
cachedRandom& rnd,
|
||||||
vector& position,
|
vector& position,
|
||||||
label& cellOwner,
|
label& cellOwner,
|
||||||
@ -174,25 +176,25 @@ void Foam::patchInjectionBase::setPositionAndCell
|
|||||||
if (Pstream::myProcNo() == proci)
|
if (Pstream::myProcNo() == proci)
|
||||||
{
|
{
|
||||||
// Find corresponding decomposed face triangle
|
// Find corresponding decomposed face triangle
|
||||||
label triI = 0;
|
label trii = 0;
|
||||||
scalar offset = sumTriMagSf_[proci];
|
scalar offset = sumTriMagSf_[proci];
|
||||||
forAllReverse(triCumulativeMagSf_, i)
|
forAllReverse(triCumulativeMagSf_, i)
|
||||||
{
|
{
|
||||||
if (areaFraction > triCumulativeMagSf_[i] + offset)
|
if (areaFraction > triCumulativeMagSf_[i] + offset)
|
||||||
{
|
{
|
||||||
triI = i;
|
trii = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set cellOwner
|
// Set cellOwner
|
||||||
label facei = triToFace_[triI];
|
label facei = triToFace_[trii];
|
||||||
cellOwner = cellOwners_[facei];
|
cellOwner = cellOwners_[facei];
|
||||||
|
|
||||||
// Find random point in triangle
|
// Find random point in triangle
|
||||||
const polyPatch& patch = mesh.boundaryMesh()[patchId_];
|
const polyPatch& patch = mesh.boundaryMesh()[patchId_];
|
||||||
const pointField& points = patch.points();
|
const pointField& points = patch.points();
|
||||||
const face& tf = triFace_[triI];
|
const face& tf = triFace_[trii];
|
||||||
const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]);
|
const triPointRef tri(points[tf[0]], points[tf[1]], points[tf[2]]);
|
||||||
const point pf(tri.randomPoint(rnd));
|
const point pf(tri.randomPoint(rnd));
|
||||||
|
|
||||||
@ -203,13 +205,43 @@ void Foam::patchInjectionBase::setPositionAndCell
|
|||||||
|
|
||||||
position = pf - a*d;
|
position = pf - a*d;
|
||||||
|
|
||||||
// The position is between the face and cell centre, which could
|
//Try to find tetFacei and tetPti in the current position
|
||||||
// be in any tet of the decomposed cell, so arbitrarily choose the
|
mesh.findTetFacePt(cellOwner, position, tetFacei, tetPti);
|
||||||
// first face of the cell as the tetFace and the first point after
|
|
||||||
// the base point on the face as the tetPt. The tracking will pick
|
//Search failed, choose a random position
|
||||||
// the cell consistent with the motion in the first tracking step
|
if (tetFacei == -1 ||tetPti == -1)
|
||||||
tetFacei = mesh.cells()[cellOwner][0];
|
{
|
||||||
tetPti = 1;
|
const scalarField& V = mesh.V();
|
||||||
|
|
||||||
|
// Construct cell tet indices
|
||||||
|
const List<tetIndices> cellTetIs =
|
||||||
|
polyMeshTetDecomposition::cellTetIndices(mesh, cellOwner);
|
||||||
|
|
||||||
|
// Construct cell tet volume fractions
|
||||||
|
scalarList cTetVFrac(cellTetIs.size(), 0.0);
|
||||||
|
for (label teti=1; teti<cellTetIs.size()-1; teti++)
|
||||||
|
{
|
||||||
|
cTetVFrac[teti] =
|
||||||
|
cTetVFrac[teti-1]
|
||||||
|
+ cellTetIs[teti].tet(mesh).mag()/V[cellOwner];
|
||||||
|
}
|
||||||
|
cTetVFrac.last() = 1;
|
||||||
|
|
||||||
|
// Set new particle position
|
||||||
|
const scalar volFrac = rnd.sample01<scalar>();
|
||||||
|
label teti = 0;
|
||||||
|
forAll(cTetVFrac, vfI)
|
||||||
|
{
|
||||||
|
if (cTetVFrac[vfI] > volFrac)
|
||||||
|
{
|
||||||
|
teti = vfI;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
position = cellTetIs[teti].tet(mesh).randomPoint(rnd);
|
||||||
|
tetFacei = cellTetIs[teti].face();
|
||||||
|
tetPti = cellTetIs[teti].tetPt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -28,7 +28,7 @@ Description
|
|||||||
Base class for patch-based injection models.
|
Base class for patch-based injection models.
|
||||||
|
|
||||||
Class handles injecting at a random point adjacent to the patch faces to
|
Class handles injecting at a random point adjacent to the patch faces to
|
||||||
provide a more stochsatic view of the injection process. Patch faces are
|
provide a more stochastic view of the injection process. Patch faces are
|
||||||
triangulated, and area fractions accumulated. The fractional areas are
|
triangulated, and area fractions accumulated. The fractional areas are
|
||||||
then applied to determine across which face a parcel is to be injected.
|
then applied to determine across which face a parcel is to be injected.
|
||||||
|
|
||||||
@ -53,6 +53,7 @@ namespace Foam
|
|||||||
|
|
||||||
// Forward class declarations
|
// Forward class declarations
|
||||||
class polyMesh;
|
class polyMesh;
|
||||||
|
class fvMesh;
|
||||||
class cachedRandom;
|
class cachedRandom;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
@ -116,7 +117,7 @@ public:
|
|||||||
//- Set the injection position and owner cell, tetFace and tetPt
|
//- Set the injection position and owner cell, tetFace and tetPt
|
||||||
virtual void setPositionAndCell
|
virtual void setPositionAndCell
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const fvMesh& mesh,
|
||||||
cachedRandom& rnd,
|
cachedRandom& rnd,
|
||||||
vector& position,
|
vector& position,
|
||||||
label& cellOwner,
|
label& cellOwner,
|
||||||
|
|||||||
Reference in New Issue
Block a user