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.
This commit is contained in:
Vaggelis Papoutsis 2023-07-19 12:18:25 +03:00 committed by Andrew Heather
parent 59bf69b92e
commit 2b2c78309c
2 changed files with 24 additions and 4 deletions

View File

@ -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<wallPoint> faceDist(nPatch);
labelList changedFaces(nPatch);

View File

@ -77,6 +77,9 @@ class patchWave
//- Distance at patch faces
FieldField<Field, scalar> 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