terms of the local barycentric coordinates of the current tetrahedron, rather than the global coordinate system. Barycentric tracking works on any mesh, irrespective of mesh quality. Particles do not get "lost", and tracking does not require ad-hoc "corrections" or "rescues" to function robustly, because the calculation of particle-face intersections is unambiguous and reproducible, even at small angles of incidence. Each particle position is defined by topology (i.e. the decomposed tet cell it is in) and geometry (i.e. where it is in the cell). No search operations are needed on restart or reconstruct, unlike when particle positions are stored in the global coordinate system. The particle positions file now contains particles' local coordinates and topology, rather than the global coordinates and cell. This change to the output format is not backwards compatible. Existing cases with Lagrangian data will not restart, but they will still run from time zero without any modification. This change was necessary in order to guarantee that the loaded particle is valid, and therefore fundamentally prevent "loss" and "search-failure" type bugs (e.g., 2517, 2442, 2286, 1836, 1461, 1341, 1097). The tracking functions have also been converted to function in terms of displacement, rather than end position. This helps remove floating point error issues, particularly towards the end of a tracking step. Wall bounded streamlines have been removed. The implementation proved incompatible with the new tracking algorithm. ParaView has a surface LIC plugin which provides equivalent, or better, functionality. Additionally, bug report <https://bugs.openfoam.org/view.php?id=2517> is resolved by this change.
105 lines
3.3 KiB
C
105 lines
3.3 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM.
|
|
|
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
Description
|
|
Lagrangian field decomposer.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "lagrangianFieldDecomposer.H"
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
|
|
(
|
|
const polyMesh& mesh,
|
|
const polyMesh& procMesh,
|
|
const labelList& faceProcAddressing,
|
|
const labelList& cellProcAddressing,
|
|
const word& cloudName,
|
|
const Cloud<indexedParticle>& lagrangianPositions,
|
|
const List<SLList<indexedParticle*>*>& cellParticles
|
|
)
|
|
:
|
|
procMesh_(procMesh),
|
|
positions_(procMesh, cloudName, IDLList<passiveParticle>()),
|
|
particleIndices_(lagrangianPositions.size())
|
|
{
|
|
label pi = 0;
|
|
|
|
labelList decodedProcFaceAddressing(faceProcAddressing.size());
|
|
|
|
forAll(faceProcAddressing, i)
|
|
{
|
|
decodedProcFaceAddressing[i] = mag(faceProcAddressing[i]) - 1;
|
|
}
|
|
|
|
forAll(cellProcAddressing, procCelli)
|
|
{
|
|
label celli = cellProcAddressing[procCelli];
|
|
|
|
if (cellParticles[celli])
|
|
{
|
|
SLList<indexedParticle*>& particlePtrs = *cellParticles[celli];
|
|
|
|
forAllConstIter(SLList<indexedParticle*>, particlePtrs, iter)
|
|
{
|
|
const indexedParticle& ppi = *iter();
|
|
particleIndices_[pi++] = ppi.index();
|
|
|
|
label mappedTetFace = findIndex
|
|
(
|
|
decodedProcFaceAddressing,
|
|
ppi.tetFace()
|
|
);
|
|
|
|
if (mappedTetFace == -1)
|
|
{
|
|
FatalErrorInFunction
|
|
<< "Face lookup failure." << nl
|
|
<< abort(FatalError);
|
|
}
|
|
|
|
positions_.append
|
|
(
|
|
new passiveParticle
|
|
(
|
|
procMesh,
|
|
ppi.coordinates(),
|
|
procCelli,
|
|
mappedTetFace,
|
|
ppi.procTetPt(procMesh, procCelli, mappedTetFace)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
particleIndices_.setSize(pi);
|
|
|
|
IOPosition<Cloud<passiveParticle>>(positions_).write();
|
|
}
|
|
|
|
|
|
// ************************************************************************* //
|