From e5cf0cf4ed6b7c053825ad64e7eca352906b1ef4 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Tue, 19 Sep 2023 09:52:35 +0100 Subject: [PATCH] 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. --- .../preProcessing/mapFields/mapLagrangian.C | 19 +- .../preProcessing/mapFieldsPar/mapClouds.C | 13 +- .../field/nearWallFields/findCellParticle.C | 5 +- .../field/nearWallFields/findCellParticle.H | 3 +- .../field/nearWallFields/nearWallFields.C | 3 + .../field/streamlines/streamlines.C | 2 + .../field/streamlines/streamlinesParticle.C | 3 +- .../field/streamlines/streamlinesParticle.H | 3 +- src/lagrangian/DSMC/Make/files | 1 - .../clouds/Templates/DSMCCloud/DSMCCloud.C | 30 ++- .../clouds/Templates/DSMCCloud/DSMCCloud.H | 3 +- .../parcels/Templates/DSMCParcel/DSMCParcel.H | 3 +- .../Templates/DSMCParcel/DSMCParcelI.H | 5 +- .../derived/dsmcParcel/defineDSMCParcel.C | 35 ---- .../parcels/derived/dsmcParcel/dsmcParcel.C | 52 +---- .../parcels/derived/dsmcParcel/dsmcParcel.H | 4 +- .../FreeStream/FreeStream.C | 23 ++- src/lagrangian/basic/Cloud/Cloud.C | 179 +++++++++++------ src/lagrangian/basic/Cloud/Cloud.H | 3 - src/lagrangian/basic/particle/particle.C | 181 ++++++++---------- src/lagrangian/basic/particle/particle.H | 61 +++--- .../basic/particle/particleTemplates.C | 76 +------- .../basic/passiveParticle/passiveParticle.H | 7 +- .../molecule/molecule/molecule.H | 3 +- .../molecule/molecule/moleculeI.H | 5 +- .../molecule/moleculeCloud/moleculeCloud.C | 18 +- .../molecule/moleculeCloud/moleculeCloud.H | 3 +- .../CollidingParcel/CollidingParcel.H | 5 +- .../CollidingParcel/CollidingParcelI.H | 7 +- .../Templates/MPPICParcel/MPPICParcel.H | 5 +- .../Templates/MPPICParcel/MPPICParcelI.H | 7 +- .../Templates/MomentumParcel/MomentumParcel.H | 5 +- .../MomentumParcel/MomentumParcelI.H | 7 +- .../ReactingMultiphaseParcel.H | 3 +- .../ReactingMultiphaseParcelI.H | 5 +- .../Templates/ReactingParcel/ReactingParcel.H | 3 +- .../ReactingParcel/ReactingParcelI.H | 5 +- .../Templates/SprayParcel/SprayParcel.H | 3 +- .../Templates/SprayParcel/SprayParcelI.H | 5 +- .../Templates/ThermoParcel/ThermoParcel.H | 5 +- .../Templates/ThermoParcel/ThermoParcelI.H | 7 +- .../InjectionModel/InjectionModel.C | 13 +- .../SurfaceFilmModel/SurfaceFilmModel.C | 21 +- .../meshRefinement/meshRefinementRefine.C | 4 + .../trackedParticle/trackedParticle.C | 5 +- .../trackedParticle/trackedParticle.H | 3 +- src/sampling/sampledSet/lineFace/lineFace.C | 5 +- src/sampling/sampledSet/points/points.C | 4 +- .../sampledSet/sampledSetParticle.C | 3 +- .../sampledSet/sampledSetParticle.H | 1 + 50 files changed, 443 insertions(+), 431 deletions(-) delete mode 100644 src/lagrangian/DSMC/parcels/derived/dsmcParcel/defineDSMCParcel.C diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C index ed529dade8..b6d0902152 100644 --- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -243,18 +243,25 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp) if (targetCell >= 0) { - unmappedSource.erase(sourceParticleI); - addParticles.append(sourceParticleI); - targetParcels.addParticle + label nLocateBoundaryHits = 0; + autoPtr pPtr ( new passiveParticle ( meshTarget, iter().position(meshSource), - targetCell + targetCell, + nLocateBoundaryHits ) ); - sourceParcels.remove(&iter()); + + if (nLocateBoundaryHits == 0) + { + unmappedSource.erase(sourceParticleI); + addParticles.append(sourceParticleI); + targetParcels.addParticle(pPtr.ptr()); + sourceParcels.remove(&iter()); + } } } sourceParticleI++; diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapClouds.C b/applications/utilities/preProcessing/mapFieldsPar/mapClouds.C index be02531167..bdb9bb882a 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapClouds.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapClouds.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -241,15 +241,22 @@ void Foam::mapClouds(const fvMeshToFvMesh& interp) ); forAll(positions, tgtParticlei) { - tgtCloud.addParticle + label nLocateBoundaryHits = 0; + autoPtr pPtr ( new passiveParticle ( tgtMesh, positions[tgtParticlei], - tgtCells[tgtParticlei] + tgtCells[tgtParticlei], + nLocateBoundaryHits ) ); + + if (nLocateBoundaryHits == 0) + { + tgtCloud.addParticle(pPtr.ptr()); + } } Info<< " mapped " diff --git a/src/functionObjects/field/nearWallFields/findCellParticle.C b/src/functionObjects/field/nearWallFields/findCellParticle.C index 9fba611f9e..5ba9c2c562 100644 --- a/src/functionObjects/field/nearWallFields/findCellParticle.C +++ b/src/functionObjects/field/nearWallFields/findCellParticle.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,11 +32,12 @@ Foam::findCellParticle::findCellParticle const polyMesh& mesh, const vector& position, const label celli, + label& nLocateBoundaryHits, const vector& displacement, const label data ) : - particle(mesh, position, celli), + particle(mesh, position, celli, nLocateBoundaryHits), displacement_(displacement), data_(data) {} diff --git a/src/functionObjects/field/nearWallFields/findCellParticle.H b/src/functionObjects/field/nearWallFields/findCellParticle.H index 8b07eff819..5277d45022 100644 --- a/src/functionObjects/field/nearWallFields/findCellParticle.H +++ b/src/functionObjects/field/nearWallFields/findCellParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -123,6 +123,7 @@ public: const polyMesh& mesh, const vector& position, const label celli, + label& nLocateBoundaryHits, const vector& displacement, const label data ); diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.C b/src/functionObjects/field/nearWallFields/nearWallFields.C index 4bb8133730..f5a2add237 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/functionObjects/field/nearWallFields/nearWallFields.C @@ -70,6 +70,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing() // Add particles to track to sample locations nPatchFaces = 0; + label nLocateBoundaryHits = 0; + forAllConstIter(labelHashSet, patchSet_, iter) { label patchi = iter.key(); @@ -86,6 +88,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing() mesh_, patch.Cf()[patchFacei], patch.faceCells()[patchFacei], + nLocateBoundaryHits, - distance_*nf[patchFacei], globalWalls.toGlobal(nPatchFaces) // passive data ) diff --git a/src/functionObjects/field/streamlines/streamlines.C b/src/functionObjects/field/streamlines/streamlines.C index 72b5cf06b8..0fc761f5c5 100644 --- a/src/functionObjects/field/streamlines/streamlines.C +++ b/src/functionObjects/field/streamlines/streamlines.C @@ -285,6 +285,7 @@ bool Foam::functionObjects::streamlines::write() cloudName_, IDLList() ); + label nLocateBoundaryHits; forAll(sampledSetPtr_(), i) { particles.addParticle @@ -294,6 +295,7 @@ bool Foam::functionObjects::streamlines::write() mesh_, sampledSetPtr_().positions()[i], sampledSetPtr_().cells()[i], + nLocateBoundaryHits, lifeTime_, gi.toGlobal(i) ) diff --git a/src/functionObjects/field/streamlines/streamlinesParticle.C b/src/functionObjects/field/streamlines/streamlinesParticle.C index 26730d783e..7a01dceaac 100644 --- a/src/functionObjects/field/streamlines/streamlinesParticle.C +++ b/src/functionObjects/field/streamlines/streamlinesParticle.C @@ -132,11 +132,12 @@ Foam::streamlinesParticle::streamlinesParticle const polyMesh& mesh, const vector& position, const label celli, + label& nLocateBoundaryHits, const label lifeTime, const label trackIndex ) : - particle(mesh, position, celli), + particle(mesh, position, celli, nLocateBoundaryHits), lifeTime_(lifeTime), trackIndex_(trackIndex), trackPartIndex_(0), diff --git a/src/functionObjects/field/streamlines/streamlinesParticle.H b/src/functionObjects/field/streamlines/streamlinesParticle.H index a435dcd7a7..56e4bdee21 100644 --- a/src/functionObjects/field/streamlines/streamlinesParticle.H +++ b/src/functionObjects/field/streamlines/streamlinesParticle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -208,6 +208,7 @@ public: const polyMesh& mesh, const vector& position, const label celli, + label& nLocateBoundaryHits, const label lifeTime, const label trackIndex ); diff --git a/src/lagrangian/DSMC/Make/files b/src/lagrangian/DSMC/Make/files index d02b37d1a7..0dcbd04a51 100644 --- a/src/lagrangian/DSMC/Make/files +++ b/src/lagrangian/DSMC/Make/files @@ -5,7 +5,6 @@ parcels/derived/dsmcParcel/dsmcParcel.C clouds/Templates/DSMCCloud/DSMCCloudName.C # Sub-models -parcels/derived/dsmcParcel/defineDSMCParcel.C parcels/derived/dsmcParcel/makeDSMCParcelBinaryCollisionModels.C parcels/derived/dsmcParcel/makeDSMCParcelWallInteractionModels.C parcels/derived/dsmcParcel/makeDSMCParcelInflowBoundaryModels.C diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C index afbf2c4288..3d35beb48a 100644 --- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C +++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -107,6 +107,8 @@ void Foam::DSMCCloud::initialise numberDensities /= nParticle_; + label nLocateBoundaryHits = 0; + forAll(mesh_.cells(), celli) { List cellTets = polyMeshTetDecomposition::cellTetIndices @@ -174,12 +176,21 @@ void Foam::DSMCCloud::initialise U += velocity; - addNewParcel(p, celli, U, Ei, typeId); + addNewParcel(p, celli, nLocateBoundaryHits, U, Ei, typeId); } } } } + reduce(nLocateBoundaryHits, sumOp