From 2b2c78309caa35461ca39142bbbe037e86965d90 Mon Sep 17 00:00:00 2001 From: Vaggelis Papoutsis Date: Wed, 19 Jul 2023 12:18:25 +0300 Subject: [PATCH] ENH: added an optional argument to the constructor of patchWave This provides a list of faces (can be internal ones) to act as additional seeds for the wave algorithm. The default argument provides an empty list, so the behaviour of patchWave should not change. Useful in topology optimisation, for propagating the active design variables from the seed faces to the interior, with a given number of cells at a time. --- src/meshTools/cellDist/patchWave/patchWave.C | 22 +++++++++++++++++--- src/meshTools/cellDist/patchWave/patchWave.H | 6 +++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/meshTools/cellDist/patchWave/patchWave.C b/src/meshTools/cellDist/patchWave/patchWave.C index e4ef840fe1..6f07859038 100644 --- a/src/meshTools/cellDist/patchWave/patchWave.C +++ b/src/meshTools/cellDist/patchWave/patchWave.C @@ -66,6 +66,20 @@ void Foam::patchWave::setChangedFaces } } } + + for (const label facei : sourceIDs_) + { + changedFaces[nChangedFaces] = facei; + + faceDist[nChangedFaces] = + wallPoint + ( + mesh.faceCentres()[facei], + 0.0 + ); + + nChangedFaces++; + } } @@ -137,7 +151,8 @@ Foam::patchWave::patchWave ( const polyMesh& mesh, const labelHashSet& patchIDs, - const bool correctWalls + const bool correctWalls, + const labelList& sourceIDs ) : cellDistFuncs(mesh), @@ -145,7 +160,8 @@ Foam::patchWave::patchWave correctWalls_(correctWalls), nUnset_(0), distance_(mesh.nCells()), - patchDistance_(mesh.boundaryMesh().size()) + patchDistance_(mesh.boundaryMesh().size()), + sourceIDs_(sourceIDs) { patchWave::correct(); } @@ -163,7 +179,7 @@ void Foam::patchWave::correct() { // Set initial changed faces: set wallPoint for wall faces to wall centre - label nPatch = sumPatchSize(patchIDs_); + label nPatch = sumPatchSize(patchIDs_) + sourceIDs_.size(); List faceDist(nPatch); labelList changedFaces(nPatch); diff --git a/src/meshTools/cellDist/patchWave/patchWave.H b/src/meshTools/cellDist/patchWave/patchWave.H index 8e2178e26a..d7259d78a1 100644 --- a/src/meshTools/cellDist/patchWave/patchWave.H +++ b/src/meshTools/cellDist/patchWave/patchWave.H @@ -77,6 +77,9 @@ class patchWave //- Distance at patch faces FieldField patchDistance_; + //- Additional faces to be used as seeds for distance calculations + labelList sourceIDs_; + // Private Member Functions @@ -107,7 +110,8 @@ public: ( const polyMesh& mesh, const labelHashSet& patchIDs, - bool correctWalls = true + bool correctWalls = true, + const labelList& sourceFaceIDs = labelList() ); //- Destructor