Cloud: Accumulate warning messages associated with location failures

Warnings about initialisation of particles with locations outside of the
mesh and about the positional inaccuracy of NCC transfers are now
accumulated and printed once per time-step. This way, the log isn't
obscured by hundreds of such warnings.

Also, the pattern in which warnings are silenced after some arbitrary
number (typically 100) have been issued has been removed. This pattern
means that user viewing the log later in the run may be unaware that a
problem is still present. Accumulated warnings are concise enough that
they do not need to be silenced. They are generated every time-step, and
so remain visible throughout the log.
This commit is contained in:
Will Bainbridge
2023-09-19 09:52:35 +01:00
parent aaf04f0481
commit e5cf0cf4ed
50 changed files with 443 additions and 431 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -243,20 +243,27 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
if (targetCell >= 0) if (targetCell >= 0)
{ {
unmappedSource.erase(sourceParticleI); label nLocateBoundaryHits = 0;
addParticles.append(sourceParticleI); autoPtr<passiveParticle> pPtr
targetParcels.addParticle
( (
new passiveParticle new passiveParticle
( (
meshTarget, meshTarget,
iter().position(meshSource), iter().position(meshSource),
targetCell targetCell,
nLocateBoundaryHits
) )
); );
if (nLocateBoundaryHits == 0)
{
unmappedSource.erase(sourceParticleI);
addParticles.append(sourceParticleI);
targetParcels.addParticle(pPtr.ptr());
sourceParcels.remove(&iter()); sourceParcels.remove(&iter());
} }
} }
}
sourceParticleI++; sourceParticleI++;
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -241,15 +241,22 @@ void Foam::mapClouds(const fvMeshToFvMesh& interp)
); );
forAll(positions, tgtParticlei) forAll(positions, tgtParticlei)
{ {
tgtCloud.addParticle label nLocateBoundaryHits = 0;
autoPtr<passiveParticle> pPtr
( (
new passiveParticle new passiveParticle
( (
tgtMesh, tgtMesh,
positions[tgtParticlei], positions[tgtParticlei],
tgtCells[tgtParticlei] tgtCells[tgtParticlei],
nLocateBoundaryHits
) )
); );
if (nLocateBoundaryHits == 0)
{
tgtCloud.addParticle(pPtr.ptr());
}
} }
Info<< " mapped " Info<< " mapped "

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -32,11 +32,12 @@ Foam::findCellParticle::findCellParticle
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const vector& displacement, const vector& displacement,
const label data const label data
) )
: :
particle(mesh, position, celli), particle(mesh, position, celli, nLocateBoundaryHits),
displacement_(displacement), displacement_(displacement),
data_(data) data_(data)
{} {}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -123,6 +123,7 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const vector& displacement, const vector& displacement,
const label data const label data
); );

View File

@ -70,6 +70,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
// Add particles to track to sample locations // Add particles to track to sample locations
nPatchFaces = 0; nPatchFaces = 0;
label nLocateBoundaryHits = 0;
forAllConstIter(labelHashSet, patchSet_, iter) forAllConstIter(labelHashSet, patchSet_, iter)
{ {
label patchi = iter.key(); label patchi = iter.key();
@ -86,6 +88,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
mesh_, mesh_,
patch.Cf()[patchFacei], patch.Cf()[patchFacei],
patch.faceCells()[patchFacei], patch.faceCells()[patchFacei],
nLocateBoundaryHits,
- distance_*nf[patchFacei], - distance_*nf[patchFacei],
globalWalls.toGlobal(nPatchFaces) // passive data globalWalls.toGlobal(nPatchFaces) // passive data
) )

View File

@ -285,6 +285,7 @@ bool Foam::functionObjects::streamlines::write()
cloudName_, cloudName_,
IDLList<streamlinesParticle>() IDLList<streamlinesParticle>()
); );
label nLocateBoundaryHits;
forAll(sampledSetPtr_(), i) forAll(sampledSetPtr_(), i)
{ {
particles.addParticle particles.addParticle
@ -294,6 +295,7 @@ bool Foam::functionObjects::streamlines::write()
mesh_, mesh_,
sampledSetPtr_().positions()[i], sampledSetPtr_().positions()[i],
sampledSetPtr_().cells()[i], sampledSetPtr_().cells()[i],
nLocateBoundaryHits,
lifeTime_, lifeTime_,
gi.toGlobal(i) gi.toGlobal(i)
) )

View File

@ -132,11 +132,12 @@ Foam::streamlinesParticle::streamlinesParticle
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const label lifeTime, const label lifeTime,
const label trackIndex const label trackIndex
) )
: :
particle(mesh, position, celli), particle(mesh, position, celli, nLocateBoundaryHits),
lifeTime_(lifeTime), lifeTime_(lifeTime),
trackIndex_(trackIndex), trackIndex_(trackIndex),
trackPartIndex_(0), trackPartIndex_(0),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -208,6 +208,7 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const label lifeTime, const label lifeTime,
const label trackIndex const label trackIndex
); );

View File

@ -5,7 +5,6 @@ parcels/derived/dsmcParcel/dsmcParcel.C
clouds/Templates/DSMCCloud/DSMCCloudName.C clouds/Templates/DSMCCloud/DSMCCloudName.C
# Sub-models # Sub-models
parcels/derived/dsmcParcel/defineDSMCParcel.C
parcels/derived/dsmcParcel/makeDSMCParcelBinaryCollisionModels.C parcels/derived/dsmcParcel/makeDSMCParcelBinaryCollisionModels.C
parcels/derived/dsmcParcel/makeDSMCParcelWallInteractionModels.C parcels/derived/dsmcParcel/makeDSMCParcelWallInteractionModels.C
parcels/derived/dsmcParcel/makeDSMCParcelInflowBoundaryModels.C parcels/derived/dsmcParcel/makeDSMCParcelInflowBoundaryModels.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -107,6 +107,8 @@ void Foam::DSMCCloud<ParcelType>::initialise
numberDensities /= nParticle_; numberDensities /= nParticle_;
label nLocateBoundaryHits = 0;
forAll(mesh_.cells(), celli) forAll(mesh_.cells(), celli)
{ {
List<tetIndices> cellTets = polyMeshTetDecomposition::cellTetIndices List<tetIndices> cellTets = polyMeshTetDecomposition::cellTetIndices
@ -174,12 +176,21 @@ void Foam::DSMCCloud<ParcelType>::initialise
U += velocity; U += velocity;
addNewParcel(p, celli, U, Ei, typeId); addNewParcel(p, celli, nLocateBoundaryHits, U, Ei, typeId);
} }
} }
} }
} }
reduce(nLocateBoundaryHits, sumOp<label>());
if (nLocateBoundaryHits != 0)
{
WarningInFunction
<< "Initialisation of cloud " << this->name()
<< " did not accurately locate " << nLocateBoundaryHits
<< " particles" << endl;
}
// Initialise the sigmaTcRMax_ field to the product of the cross section of // Initialise the sigmaTcRMax_ field to the product of the cross section of
// the most abundant species and the most probable thermal speed (Bird, // the most abundant species and the most probable thermal speed (Bird,
// p222-223) // p222-223)
@ -454,12 +465,25 @@ void Foam::DSMCCloud<ParcelType>::addNewParcel
( (
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const vector& U, const vector& U,
const scalar Ei, const scalar Ei,
const label typeId const label typeId
) )
{ {
this->addParticle(new ParcelType(mesh_, position, celli, U, Ei, typeId)); this->addParticle
(
new ParcelType
(
mesh_,
position,
celli,
nLocateBoundaryHits,
U,
Ei,
typeId
)
);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -456,6 +456,7 @@ public:
( (
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const vector& U, const vector& U,
const scalar Ei, const scalar Ei,
const label typeId const label typeId

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -165,6 +165,7 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const vector& U, const vector& U,
const scalar Ei, const scalar Ei,
const label typeId const label typeId

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -58,12 +58,13 @@ inline Foam::DSMCParcel<ParcelType>::DSMCParcel
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const vector& U, const vector& U,
const scalar Ei, const scalar Ei,
const label typeId const label typeId
) )
: :
ParcelType(mesh, position, celli), ParcelType(mesh, position, celli, nLocateBoundaryHits),
U_(U), U_(U),
Ei_(Ei), Ei_(Ei),
typeId_(typeId) typeId_(typeId)

View File

@ -1,35 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 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/>.
\*---------------------------------------------------------------------------*/
#include "dsmcParcel.H"
#include "DSMCParcel.H"
namespace Foam
{
defineTemplateTypeNameAndDebug(DSMCParcel<particle>, 0);
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,59 +24,13 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "dsmcParcel.H" #include "dsmcParcel.H"
/*
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// defineTypeNameAndDebug(dsmcParcel, 0); defineTemplateTypeNameAndDebug(DSMCParcel<particle>, 0);
// defineParticleTypeNameAndDebug(dsmcParcel, 0);
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dsmcParcel::dsmcParcel
(
c& owner,
const vector& position,
const vector& U,
const scalar Ei,
const label celli,
const label tetFacei,
const label tetPti,
const label typeId
)
:
DSMCParcel<dsmcParcel>
(
owner,
position,
U,
Ei,
celli,
tetFacei,
tetPti,
typeId
)
{}
Foam::dsmcParcel::dsmcParcel
(
const Cloud<dsmcParcel>& cloud,
Istream& is,
bool readFields
)
:
DSMCParcel<dsmcParcel>(cloud, is, readFields)
{}
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * //
Foam::dsmcParcel::~dsmcParcel()
{}
*/
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -161,6 +161,7 @@ void Foam::FreeStream<CloudType>::inflow()
cloud.boundaryU().boundaryField() cloud.boundaryU().boundaryField()
); );
label nLocateBoundaryHits = 0;
forAll(patches_, p) forAll(patches_, p)
{ {
@ -401,7 +402,15 @@ void Foam::FreeStream<CloudType>::inflow()
cloud.constProps(typeId).internalDegreesOfFreedom() cloud.constProps(typeId).internalDegreesOfFreedom()
); );
cloud.addNewParcel(p, celli, U, Ei, typeId); cloud.addNewParcel
(
p,
celli,
nLocateBoundaryHits,
U,
Ei,
typeId
);
particlesInserted++; particlesInserted++;
} }
@ -409,11 +418,19 @@ void Foam::FreeStream<CloudType>::inflow()
} }
} }
reduce(nLocateBoundaryHits, sumOp<label>());
if (nLocateBoundaryHits != 0)
{
WarningInFunction
<< "Freestream inflow model for cloud " << this->owner().name()
<< " did not accurately locate " << nLocateBoundaryHits
<< " particles" << endl;
}
reduce(particlesInserted, sumOp<label>()); reduce(particlesInserted, sumOp<label>());
Info<< " Particles inserted = " Info<< " Particles inserted = "
<< particlesInserted << endl; << particlesInserted << endl;
} }

View File

@ -180,16 +180,6 @@ void Foam::Cloud<ParticleType>::storeRays() const
} }
template<class ParticleType>
Foam::string Foam::Cloud<ParticleType>::mapOutsideMsg(const point& position)
{
OStringStream oss;
oss << "Particle at " << position << " mapped to a location outside of "
<< "the new mesh. This particle will be removed.";
return oss.str();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ParticleType> template<class ParticleType>
@ -241,18 +231,23 @@ void Foam::Cloud<ParticleType>::deleteParticle(ParticleType& p)
template<class ParticleType> template<class ParticleType>
void Foam::Cloud<ParticleType>::deleteLostParticles() void Foam::Cloud<ParticleType>::deleteLostParticles()
{ {
label lostCount = 0;
forAllIter(typename Cloud<ParticleType>, *this, pIter) forAllIter(typename Cloud<ParticleType>, *this, pIter)
{ {
ParticleType& p = pIter(); if (pIter().cell() == -1)
{
deleteParticle(pIter());
lostCount ++;
}
}
if (p.cell() == -1) reduce(lostCount, sumOp<label>());
if (lostCount != 0)
{ {
WarningInFunction WarningInFunction
<< "deleting lost particle at position " << "Cloud " << this->name()
<< p.position(pMesh_) << endl; << " deleted " << lostCount << " lost particles" << endl;
deleteParticle(p);
}
} }
} }
@ -422,6 +417,23 @@ void Foam::Cloud<ParticleType>::move
} }
} }
} }
// Warn about any approximate locates
Pstream::listCombineGather(td.patchNLocateBoundaryHits, plusEqOp<label>());
if (Pstream::master())
{
forAll(td.patchNLocateBoundaryHits, patchi)
{
if (td.patchNLocateBoundaryHits[patchi] != 0)
{
WarningInFunction
<< "Cloud " << name() << " did not accurately locate "
<< td.patchNLocateBoundaryHits[patchi]
<< " particles that transferred to patch "
<< pMesh_.boundaryMesh()[patchi].name() << nl;
}
}
}
} }
@ -446,6 +458,8 @@ void Foam::Cloud<ParticleType>::topoChange(const polyTopoChangeMap& map)
const vectorField& positions = globalPositionsPtr_(); const vectorField& positions = globalPositionsPtr_();
label lostCount = 0;
label particlei = 0; label particlei = 0;
forAllIter(typename Cloud<ParticleType>, *this, iter) forAllIter(typename Cloud<ParticleType>, *this, iter)
{ {
@ -453,11 +467,20 @@ void Foam::Cloud<ParticleType>::topoChange(const polyTopoChangeMap& map)
const label celli = map.reverseCellMap()[iter().cell()]; const label celli = map.reverseCellMap()[iter().cell()];
if (!iter().map(pMesh_, pos, celli, mapOutsideMsg)) if (!iter().locate(pMesh_, pos, celli))
{ {
this->remove(iter); this->remove(iter);
lostCount ++;
} }
} }
reduce(lostCount, sumOp<label>());
if (lostCount != 0)
{
WarningInFunction
<< "Topology change of cloud " << this->name()
<< " lost " << lostCount << " particles" << endl;
}
} }
@ -485,6 +508,8 @@ void Foam::Cloud<ParticleType>::mapMesh(const polyMeshMap& map)
const vectorField& positions = globalPositionsPtr_(); const vectorField& positions = globalPositionsPtr_();
label lostCount = 0;
// Loop the particles. Map those that remain on this processor, and // Loop the particles. Map those that remain on this processor, and
// transfer others into send arrays. // transfer others into send arrays.
List<DynamicList<label>> sendCellIndices(Pstream::nProcs()); List<DynamicList<label>> sendCellIndices(Pstream::nProcs());
@ -503,14 +528,15 @@ void Foam::Cloud<ParticleType>::mapMesh(const polyMeshMap& map)
if (tgtProcCell == remote()) if (tgtProcCell == remote())
{ {
WarningInFunction << mapOutsideMsg(pos) << nl;
this->remove(iter); this->remove(iter);
lostCount ++;
} }
else if (proci == Pstream::myProcNo()) else if (proci == Pstream::myProcNo())
{ {
if (!iter().map(pMesh_, pos, celli, mapOutsideMsg)) if (!iter().locate(pMesh_, pos, celli))
{ {
this->remove(iter); this->remove(iter);
lostCount ++;
} }
} }
else else
@ -522,12 +548,10 @@ void Foam::Cloud<ParticleType>::mapMesh(const polyMeshMap& map)
} }
} }
// If serial then there is nothing more to do // If parallel then send and receive particles that move processes and map
if (!Pstream::parRun()) // those sent to this process
if (Pstream::parRun())
{ {
return;
}
// Create transfer buffers // Create transfer buffers
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking); PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
@ -566,13 +590,27 @@ void Foam::Cloud<ParticleType>::mapMesh(const polyMeshMap& map)
const label celli = receiveCellIndices[particlei]; const label celli = receiveCellIndices[particlei];
const vector& pos = receivePositions[particlei ++]; const vector& pos = receivePositions[particlei ++];
if (iter().map(pMesh_, pos, celli, mapOutsideMsg)) if (iter().locate(pMesh_, pos, celli))
{ {
this->append(receiveParticles.remove(iter)); this->append(receiveParticles.remove(iter));
} }
else
{
receiveParticles.remove(iter);
lostCount ++;
} }
} }
} }
}
}
reduce(lostCount, sumOp<label>());
if (lostCount != 0)
{
WarningInFunction
<< "Mesh-to-mesh mapping of cloud " << this->name()
<< " lost " << lostCount << " particles" << endl;
}
} }
@ -660,6 +698,8 @@ void Foam::Cloud<ParticleType>::distribute(const polyDistributionMap& map)
IDLList<ParticleType>() IDLList<ParticleType>()
); );
label lostCount = 0;
// Locate the particles within the new mesh // Locate the particles within the new mesh
forAll(cellParticles, celli) forAll(cellParticles, celli)
{ {
@ -668,12 +708,25 @@ void Foam::Cloud<ParticleType>::distribute(const polyDistributionMap& map)
{ {
const point& pos = cellParticlePositions[celli][cellParticlei++]; const point& pos = cellParticlePositions[celli][cellParticlei++];
if (iter().map(pMesh_, pos, celli, mapOutsideMsg)) if (iter().locate(pMesh_, pos, celli))
{ {
this->append(cellParticles[celli].remove(iter)); this->append(cellParticles[celli].remove(iter));
} }
else
{
cellParticles[celli].remove(iter);
lostCount ++;
} }
} }
}
reduce(lostCount, sumOp<label>());
if (lostCount != 0)
{
WarningInFunction
<< "Mesh-to-mesh mapping of cloud " << this->name()
<< " lost " << lostCount << " particles" << endl;
}
} }

View File

@ -119,9 +119,6 @@ class Cloud
//- Store rays necessary for non conformal cyclic transfer //- Store rays necessary for non conformal cyclic transfer
void storeRays() const; void storeRays() const;
//- Generate a "mapped outside" warning messgage
static string mapOutsideMsg(const point& position);
public: public:

View File

@ -369,6 +369,74 @@ void Foam::particle::changeCell(const polyMesh& mesh)
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::particle::particle
(
const polyMesh& mesh,
const barycentric& coordinates,
const label celli,
const label tetFacei,
const label tetPti,
const label facei
)
:
coordinates_(coordinates),
celli_(celli),
tetFacei_(tetFacei),
tetPti_(tetPti),
facei_(facei),
stepFraction_(1),
stepFractionBehind_(0),
nTracksBehind_(0),
origProc_(Pstream::myProcNo()),
origId_(getNewParticleID())
{}
Foam::particle::particle
(
const polyMesh& mesh,
const vector& position,
const label celli,
label& nLocateBoundaryHits
)
:
coordinates_(- vGreat, - vGreat, - vGreat, - vGreat),
celli_(celli),
tetFacei_(-1),
tetPti_(-1),
facei_(-1),
stepFraction_(1),
stepFractionBehind_(0),
nTracksBehind_(0),
origProc_(Pstream::myProcNo()),
origId_(getNewParticleID())
{
if (!locate(mesh, position, celli))
{
nLocateBoundaryHits ++;
}
}
Foam::particle::particle(const particle& p)
:
coordinates_(p.coordinates_),
celli_(p.celli_),
tetFacei_(p.tetFacei_),
tetPti_(p.tetPti_),
facei_(p.facei_),
stepFraction_(p.stepFraction_),
stepFractionBehind_(p.stepFractionBehind_),
nTracksBehind_(p.nTracksBehind_),
origProc_(p.origProc_),
origId_(p.origId_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::particle::locate bool Foam::particle::locate
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -438,96 +506,13 @@ bool Foam::particle::locate
tetPti_ = minTetPti; tetPti_ = minTetPti;
facei_ = -1; facei_ = -1;
reset(1); reset(1);
track(mesh, displacement, 0); track(mesh, displacement, 0);
if (!onFace())
{
return true;
}
return false; // Return successful if in a cell
return !onBoundaryFace(mesh);
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::particle::particle
(
const polyMesh& mesh,
const barycentric& coordinates,
const label celli,
const label tetFacei,
const label tetPti,
const label facei
)
:
coordinates_(coordinates),
celli_(celli),
tetFacei_(tetFacei),
tetPti_(tetPti),
facei_(facei),
stepFraction_(1),
stepFractionBehind_(0),
nTracksBehind_(0),
origProc_(Pstream::myProcNo()),
origId_(getNewParticleID())
{}
Foam::particle::particle
(
const polyMesh& mesh,
const vector& position,
const label celli
)
:
coordinates_(- vGreat, - vGreat, - vGreat, - vGreat),
celli_(celli),
tetFacei_(-1),
tetPti_(-1),
facei_(-1),
stepFraction_(1),
stepFractionBehind_(0),
nTracksBehind_(0),
origProc_(Pstream::myProcNo()),
origId_(getNewParticleID())
{
auto boundaryMsg = [](const point& position)
{
OStringStream oss;
oss << "Particle at " << position << " initialised in a location "
<< "outside of the mesh.";
return oss.str();
};
locate
(
mesh,
position,
celli,
false,
boundaryMsg
);
}
Foam::particle::particle(const particle& p)
:
coordinates_(p.coordinates_),
celli_(p.celli_),
tetFacei_(p.tetFacei_),
tetPti_(p.tetPti_),
facei_(p.facei_),
stepFraction_(p.stepFraction_),
stepFractionBehind_(p.stepFractionBehind_),
nTracksBehind_(p.nTracksBehind_),
origProc_(p.origProc_),
origId_(p.origId_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalar Foam::particle::track Foam::scalar Foam::particle::track
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -1086,7 +1071,8 @@ void Foam::particle::prepareForNonConformalCyclicTransfer
void Foam::particle::correctAfterNonConformalCyclicTransfer void Foam::particle::correctAfterNonConformalCyclicTransfer
( (
const polyMesh& mesh, const polyMesh& mesh,
const label sendToPatch const label sendToPatch,
labelList& patchNLocateBoundaryHits
) )
{ {
const nonConformalCyclicPolyPatch& nccpp = const nonConformalCyclicPolyPatch& nccpp =
@ -1103,24 +1089,12 @@ void Foam::particle::correctAfterNonConformalCyclicTransfer
coordinates_.d() coordinates_.d()
); );
auto boundaryMsg = [&nccpp](const point& position)
{
return
"Particle at " + name(position) + " crossed between "
+ nonConformalCyclicPolyPatch::typeName + " patches "
+ nccpp.name() + " and " + nccpp.nbrPatch().name()
+ " to a location outside of the mesh.";
};
// Locate the particle on the receiving side // Locate the particle on the receiving side
locate const label celli = mesh.faceOwner()[facei_ + nccpp.origPatch().start()];
( if (!locate(mesh, receivePos, celli))
mesh, {
receivePos, patchNLocateBoundaryHits[sendToPatch] ++;
mesh.faceOwner()[facei_ + nccpp.origPatch().start()], }
false,
boundaryMsg
);
// The particle must remain associated with a face for the tracking to // The particle must remain associated with a face for the tracking to
// register as incomplete // register as incomplete
@ -1221,6 +1195,7 @@ Foam::label Foam::particle::procTetPt
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
//
bool Foam::operator==(const particle& pA, const particle& pB) bool Foam::operator==(const particle& pA, const particle& pB)
{ {

View File

@ -122,6 +122,10 @@ public:
//- Patch face to which to send the particle //- Patch face to which to send the particle
label sendToPatchFace; label sendToPatchFace;
//- Number of boundary hits that occurred during locate executions
// following (non-conformal) patch transfers. For reporting.
labelList patchNLocateBoundaryHits;
// Constructor // Constructor
template <class TrackCloudType> template <class TrackCloudType>
@ -132,7 +136,13 @@ public:
sendToProc(-1), sendToProc(-1),
sendFromPatch(-1), sendFromPatch(-1),
sendToPatch(-1), sendToPatch(-1),
sendToPatchFace(-1) sendToPatchFace(-1),
patchNLocateBoundaryHits
(
mesh.boundaryMesh().size()
- mesh.globalData().processorPatches().size(),
0
)
{} {}
}; };
@ -298,28 +308,6 @@ private:
void changeCell(const polyMesh& mesh); void changeCell(const polyMesh& mesh);
// Geometry changes
//- Locate the particle at the given position
bool locate
(
const polyMesh& mesh,
const vector& position,
label celli
);
//- Locate the particle at the given position
template<class BoundaryMsg>
bool locate
(
const polyMesh& mesh,
const vector& position,
label celli,
const bool boundaryFail,
BoundaryMsg boundaryMsg
);
public: public:
// Static Data Members // Static Data Members
@ -358,7 +346,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
); );
//- Construct from Istream //- Construct from Istream
@ -467,6 +456,14 @@ public:
// for a new track // for a new track
inline void reset(const scalar stepFraction); inline void reset(const scalar stepFraction);
//- Locate the particle at the given position
bool locate
(
const polyMesh& mesh,
const vector& position,
label celli
);
//- Track along the displacement for a given fraction of the overall //- Track along the displacement for a given fraction of the overall
// step. End when the track is complete, or when a boundary is hit. // step. End when the track is complete, or when a boundary is hit.
// On exit, stepFraction_ will have been incremented to the current // On exit, stepFraction_ will have been incremented to the current
@ -610,7 +607,8 @@ public:
void correctAfterNonConformalCyclicTransfer void correctAfterNonConformalCyclicTransfer
( (
const polyMesh& mesh, const polyMesh& mesh,
const label sendToPatch const label sendToPatch,
labelList& patchNLocateBoundaryHits
); );
@ -700,19 +698,6 @@ public:
) const; ) const;
// Mapping
//- Map after a mesh change
template<class BoundaryMsg>
bool map
(
const polyMesh& mesh,
const point& position,
const label celli,
BoundaryMsg boundaryMsg
);
// I-O // I-O
//- Read the fields associated with the owner cloud //- Read the fields associated with the owner cloud

View File

@ -35,74 +35,8 @@ License
#include "wedgePolyPatch.H" #include "wedgePolyPatch.H"
#include "meshTools.H" #include "meshTools.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class BoundaryMsg>
bool Foam::particle::locate
(
const polyMesh& mesh,
const vector& position,
label celli,
const bool boundaryFail,
BoundaryMsg boundaryMsg
)
{
if (locate(mesh, position, celli))
{
return true;
}
// If we are here then we hit a boundary
if (boundaryFail)
{
FatalErrorInFunction << boundaryMsg(position).c_str()
<< exit(FatalError);
}
else
{
static label nWarnings = 0;
static const label maxNWarnings = 100;
if (nWarnings < maxNWarnings)
{
WarningInFunction << boundaryMsg(position).c_str() << endl;
++ nWarnings;
}
if (nWarnings == maxNWarnings)
{
WarningInFunction
<< "Suppressing any further warnings about particles being "
<< "located outside of the mesh." << endl;
++ nWarnings;
}
}
return false;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BoundaryMsg>
bool Foam::particle::map
(
const polyMesh& mesh,
const vector& position,
const label celli,
BoundaryMsg boundaryMsg
)
{
return
locate
(
mesh,
position,
celli,
true,
boundaryMsg
);
}
template<class TrackCloudType> template<class TrackCloudType>
void Foam::particle::readFields(TrackCloudType& c) void Foam::particle::readFields(TrackCloudType& c)
{ {
@ -206,7 +140,12 @@ void Foam::particle::correctAfterParallelTransfer
} }
else if (isA<nonConformalCyclicPolyPatch>(pp)) else if (isA<nonConformalCyclicPolyPatch>(pp))
{ {
correctAfterNonConformalCyclicTransfer(td.mesh, td.sendToPatch); correctAfterNonConformalCyclicTransfer
(
td.mesh,
td.sendToPatch,
td.patchNLocateBoundaryHits
);
} }
else else
{ {
@ -447,7 +386,8 @@ bool Foam::particle::hitNonConformalCyclicPatch
correctAfterNonConformalCyclicTransfer correctAfterNonConformalCyclicTransfer
( (
td.mesh, td.mesh,
nccpp.nbrPatchID() nccpp.nbrPatchID(),
td.patchNLocateBoundaryHits
); );
return true; return true;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -77,10 +77,11 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
) )
: :
particle(mesh, position, celli) particle(mesh, position, celli, nLocateBoundaryHits)
{} {}
//- Construct from Istream //- Construct from Istream

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -266,6 +266,7 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const tensor& Q, const tensor& Q,
const vector& v, const vector& v,
const vector& a, const vector& a,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -224,6 +224,7 @@ inline Foam::molecule::molecule
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const tensor& Q, const tensor& Q,
const vector& v, const vector& v,
const vector& a, const vector& a,
@ -236,7 +237,7 @@ inline Foam::molecule::molecule
) )
: :
particle(mesh, position, celli), particle(mesh, position, celli, nLocateBoundaryHits),
Q_(Q), Q_(Q),
v_(v), v_(v),
a_(a), a_(a),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -490,6 +490,8 @@ void Foam::moleculeCloud::initialiseMolecules
<< abort(FatalError); << abort(FatalError);
} }
label nLocateBoundaryHits = 0;
forAll(cellZones, z) forAll(cellZones, z)
{ {
const cellZone& zone(cellZones[z]); const cellZone& zone(cellZones[z]);
@ -750,6 +752,7 @@ void Foam::moleculeCloud::initialiseMolecules
( (
globalPosition, globalPosition,
cell, cell,
nLocateBoundaryHits,
id, id,
tethered, tethered,
temperature, temperature,
@ -830,6 +833,7 @@ void Foam::moleculeCloud::initialiseMolecules
( (
globalPosition, globalPosition,
cell, cell,
nLocateBoundaryHits,
id, id,
tethered, tethered,
temperature, temperature,
@ -901,6 +905,7 @@ void Foam::moleculeCloud::initialiseMolecules
( (
globalPosition, globalPosition,
cell, cell,
nLocateBoundaryHits,
id, id,
tethered, tethered,
temperature, temperature,
@ -957,6 +962,15 @@ void Foam::moleculeCloud::initialiseMolecules
} }
} }
} }
reduce(nLocateBoundaryHits, sumOp<label>());
if (nLocateBoundaryHits != 0)
{
WarningInFunction
<< "Initialisation of cloud " << this->name()
<< " did not accurately locate " << nLocateBoundaryHits
<< " particles" << endl;
}
} }
@ -964,6 +978,7 @@ void Foam::moleculeCloud::createMolecule
( (
const point& position, const point& position,
label cell, label cell,
label& nLocateBoundaryHits,
label id, label id,
bool tethered, bool tethered,
scalar temperature, scalar temperature,
@ -1022,6 +1037,7 @@ void Foam::moleculeCloud::createMolecule
mesh_, mesh_,
position, position,
cell, cell,
nLocateBoundaryHits,
Q, Q,
v, v,
Zero, Zero,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -111,6 +111,7 @@ class moleculeCloud
( (
const point& position, const point& position,
label cell, label cell,
label& nLocateBoundaryHits,
label id, label id,
bool tethered, bool tethered,
scalar temperature, scalar temperature,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -229,7 +229,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
); );
//- Construct from Istream //- Construct from Istream

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -83,10 +83,11 @@ inline Foam::CollidingParcel<ParcelType>::CollidingParcel
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
) )
: :
ParcelType(mesh, position, celli), ParcelType(mesh, position, celli, nLocateBoundaryHits),
f_(Zero), f_(Zero),
angularMomentum_(Zero), angularMomentum_(Zero),
torque_(Zero), torque_(Zero),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -174,7 +174,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
); );
//- Construct from Istream //- Construct from Istream

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,10 +48,11 @@ inline Foam::MPPICParcel<ParcelType>::MPPICParcel
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
) )
: :
ParcelType(mesh, position, celli), ParcelType(mesh, position, celli, nLocateBoundaryHits),
id_(-1, -1) id_(-1, -1)
{} {}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -387,7 +387,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
); );
//- Construct from Istream //- Construct from Istream

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -100,10 +100,11 @@ inline Foam::MomentumParcel<ParcelType>::MomentumParcel
( (
const polyMesh& owner, const polyMesh& owner,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
) )
: :
ParcelType(owner, position, celli), ParcelType(owner, position, celli, nLocateBoundaryHits),
moving_(true), moving_(true),
typeId_(-1), typeId_(-1),
nParticle_(0), nParticle_(0),

View File

@ -304,7 +304,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
); );
//- Construct from Istream //- Construct from Istream

View File

@ -91,10 +91,11 @@ inline Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
) )
: :
ParcelType(mesh, position, celli), ParcelType(mesh, position, celli, nLocateBoundaryHits),
mass0_(0), mass0_(0),
YGas_(0), YGas_(0),
YLiquid_(0), YLiquid_(0),

View File

@ -203,7 +203,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
); );
//- Construct from Istream //- Construct from Istream

View File

@ -82,10 +82,11 @@ inline Foam::ReactingParcel<ParcelType>::ReactingParcel
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
) )
: :
ParcelType(mesh, position, celli), ParcelType(mesh, position, celli, nLocateBoundaryHits),
Y_(0) Y_(0)
{} {}

View File

@ -208,7 +208,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
); );
//- Construct from Istream //- Construct from Istream

View File

@ -138,10 +138,11 @@ inline Foam::SprayParcel<ParcelType>::SprayParcel
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
) )
: :
ParcelType(mesh, position, celli), ParcelType(mesh, position, celli, nLocateBoundaryHits),
d0_(this->d()), d0_(this->d()),
mass0_(this->mass()), mass0_(this->mass()),
position0_(this->position(mesh)), position0_(this->position(mesh)),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -324,7 +324,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
); );
//- Construct from Istream //- Construct from Istream

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -94,10 +94,11 @@ inline Foam::ThermoParcel<ParcelType>::ThermoParcel
( (
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli const label celli,
label& nLocateBoundaryHits
) )
: :
ParcelType(mesh, position, celli), ParcelType(mesh, position, celli, nLocateBoundaryHits),
T_(0.0), T_(0.0),
Cp_(0.0) Cp_(0.0)
{} {}

View File

@ -281,7 +281,18 @@ bool Foam::InjectionModel<CloudType>::findCellAtPosition
// Found it. Construct the barycentric coordinates. // Found it. Construct the barycentric coordinates.
if (proci == Pstream::myProcNo()) if (proci == Pstream::myProcNo())
{ {
particle p(this->owner().mesh(), pos, celli); label nLocateBoundaryHits;
particle p(this->owner().mesh(), pos, celli, nLocateBoundaryHits);
if (nLocateBoundaryHits != 0)
{
WarningInFunction
<< "Injection model " << this->modelName()
<< " for cloud " << this->owner().name()
<< " did not accurately locate the position "
<< pos << " within the mesh" << endl;
}
coordinates = p.coordinates(); coordinates = p.coordinates();
celli = p.cell(); celli = p.cell();
tetFacei = p.tetFace(); tetFacei = p.tetFace();

View File

@ -113,6 +113,8 @@ void Foam::SurfaceFilmModel<CloudType>::inject(TrackCloudType& cloud)
const vectorField& Sf = mesh.Sf().boundaryField()[filmPatchi]; const vectorField& Sf = mesh.Sf().boundaryField()[filmPatchi];
const scalarField& magSf = mesh.magSf().boundaryField()[filmPatchi]; const scalarField& magSf = mesh.magSf().boundaryField()[filmPatchi];
label nLocateBoundaryHits = 0;
if (massParcelPatch_.size()) if (massParcelPatch_.size())
{ {
forAll(injectorCellsPatch, j) forAll(injectorCellsPatch, j)
@ -131,7 +133,13 @@ void Foam::SurfaceFilmModel<CloudType>::inject(TrackCloudType& cloud)
// Create a new parcel // Create a new parcel
parcelType* pPtr = parcelType* pPtr =
new parcelType(this->owner().pMesh(), pos, celli); new parcelType
(
this->owner().pMesh(),
pos,
celli,
nLocateBoundaryHits
);
// Check/set new parcel thermo properties // Check/set new parcel thermo properties
cloud.setParcelThermoProperties(*pPtr); cloud.setParcelThermoProperties(*pPtr);
@ -156,6 +164,17 @@ void Foam::SurfaceFilmModel<CloudType>::inject(TrackCloudType& cloud)
} }
} }
} }
reduce(nLocateBoundaryHits, sumOp<label>());
if (nLocateBoundaryHits != 0)
{
WarningInFunction
<< "Injection by surface film model for cloud "
<< this->owner().name()
<< " on patch " << pbm[filmPatchi].name()
<< " did not accurately locate " << nLocateBoundaryHits
<< " particles" << endl;
}
} }
} }

View File

@ -347,6 +347,8 @@ void Foam::meshRefinement::markFeatureCellLevel
// what to seed. Do this on only the processor that // what to seed. Do this on only the processor that
// holds the insidePoint. // holds the insidePoint.
label nLocateBoundaryHits = 0;
forAll(insidePoints, i) forAll(insidePoints, i)
{ {
const point& insidePoint = insidePoints[i]; const point& insidePoint = insidePoints[i];
@ -395,6 +397,7 @@ void Foam::meshRefinement::markFeatureCellLevel
mesh_, mesh_,
insidePoint, insidePoint,
celli, celli,
nLocateBoundaryHits,
featureMesh.points()[pointi], // endpos featureMesh.points()[pointi], // endpos
featureLevel, // level featureLevel, // level
feati, // featureMesh feati, // featureMesh
@ -438,6 +441,7 @@ void Foam::meshRefinement::markFeatureCellLevel
mesh_, mesh_,
insidePoint, insidePoint,
celli, celli,
nLocateBoundaryHits,
featureMesh.points()[pointi], // endpos featureMesh.points()[pointi], // endpos
featureLevel, // level featureLevel, // level
feati, // featureMesh feati, // featureMesh

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,6 +33,7 @@ Foam::trackedParticle::trackedParticle
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const point& end, const point& end,
const label level, const label level,
const label i, const label i,
@ -40,7 +41,7 @@ Foam::trackedParticle::trackedParticle
const label k const label k
) )
: :
particle(mesh, position, celli), particle(mesh, position, celli, nLocateBoundaryHits),
start_(this->position(mesh)), start_(this->position(mesh)),
end_(end), end_(end),
level_(level), level_(level),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -127,6 +127,7 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const vector& position, const vector& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const point& end, const point& end,
const label level, const label level,
const label i, const label i,

View File

@ -121,6 +121,7 @@ void Foam::sampledSets::lineFace::calcSamples
// Create each segment in turn // Create each segment in turn
label segmenti = 0; label segmenti = 0;
label nLocateBoundaryHits = 0;
forAll(procCandidateCells, proci) forAll(procCandidateCells, proci)
{ {
forAll(procCandidateCells[proci], candidatei) forAll(procCandidateCells[proci], candidatei)
@ -160,6 +161,7 @@ void Foam::sampledSets::lineFace::calcSamples
mesh, mesh,
p, p,
celli, celli,
nLocateBoundaryHits,
0, 0,
i == 0 ? t : 1 - t, i == 0 ? t : 1 - t,
0 0
@ -206,7 +208,8 @@ void Foam::sampledSets::lineFace::calcSamples
// the tracks // the tracks
if (proci == Pstream::myProcNo() && i == 0 && storeCells) if (proci == Pstream::myProcNo() && i == 0 && storeCells)
{ {
particle trackBwd(mesh, p, celli), trackFwd(trackBwd); particle trackBwd(mesh, p, celli, nLocateBoundaryHits);
particle trackFwd(trackBwd);
trackBwd.trackToFace(mesh, start - p, 0); trackBwd.trackToFace(mesh, start - p, 0);
trackFwd.trackToFace(mesh, end - p, 0); trackFwd.trackToFace(mesh, end - p, 0);
if (trackBwd.onFace() && trackFwd.onFace()) if (trackBwd.onFace() && trackFwd.onFace())

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -66,6 +66,7 @@ void Foam::sampledSets::points::calcSamples
// Consider each point // Consider each point
label segmenti = 0, samplei = 0, pointi0 = labelMax, pointi = 0; label segmenti = 0, samplei = 0, pointi0 = labelMax, pointi = 0;
label nLocateBoundaryHits = 0;
scalar distance = 0; scalar distance = 0;
while (pointi < points.size()) while (pointi < points.size())
{ {
@ -129,6 +130,7 @@ void Foam::sampledSets::points::calcSamples
mesh, mesh,
points[pointi], points[pointi],
procAndCelli.second(), procAndCelli.second(),
nLocateBoundaryHits,
pointi, pointi,
1, 1,
distance distance

View File

@ -33,12 +33,13 @@ Foam::sampledSetParticle::sampledSetParticle
const polyMesh& mesh, const polyMesh& mesh,
const point& position, const point& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const label seti, const label seti,
const scalar setF, const scalar setF,
const scalar distance const scalar distance
) )
: :
particle(mesh, position, celli), particle(mesh, position, celli, nLocateBoundaryHits),
seti_(seti), seti_(seti),
setF_(setF), setF_(setF),
distance_(distance), distance_(distance),

View File

@ -149,6 +149,7 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const point& position, const point& position,
const label celli, const label celli,
label& nLocateBoundaryHits,
const label seti, const label seti,
const scalar setF, const scalar setF,
const scalar distance const scalar distance