ENH: ensightWrite: allow inGroup names in patches and excludePatches

This commit is contained in:
Kutalmis Bercin
2025-06-11 12:12:39 +01:00
parent 75b2d0b656
commit 34df4eaf40
2 changed files with 47 additions and 14 deletions

View File

@ -122,6 +122,29 @@ Foam::functionObjects::ensightWrite::ensightWrite
} }
Foam::wordRes Foam::functionObjects::ensightWrite::patchNameSet
(
const UList<wordRe>& select
) const
{
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
const labelList patchIDs
(
pbm.patchSet(select).sortedToc()
);
wordRes names(patchIDs.size());
for (const label patchi : patchIDs)
{
names[patchi] = mesh_.boundary()[patchi].name();
}
return names;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::ensightWrite::read(const dictionary& dict) bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
@ -152,22 +175,27 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
<< "conversion of the boundaries" << endl; << "conversion of the boundaries" << endl;
} }
wordRes list;
if (dict.readIfPresent("patches", list))
{
list.uniq();
writeOpts_.patchSelection(list);
}
if (dict.readIfPresent("excludePatches", list))
{
list.uniq();
writeOpts_.patchExclude(list);
}
if (dict.readIfPresent("faceZones", list)) if (dict.found("patches"))
{ {
list.uniq(); writeOpts_.patchSelection
writeOpts_.faceZoneSelection(list); (
wordRes::uniq(patchNameSet(dict.get<wordRes>("patches")))
);
}
if (dict.found("excludePatches"))
{
writeOpts_.patchExclude
(
wordRes::uniq(patchNameSet(dict.get<wordRes>("excludePatches")))
);
}
if (dict.found("faceZones"))
{
writeOpts_.faceZoneSelection
(
wordRes::uniq(dict.get<wordRes>("faceZones"))
);
} }

View File

@ -233,6 +233,11 @@ class ensightWrite
//- Update meshes, subMeshes etc. //- Update meshes, subMeshes etc.
bool update(); bool update();
//- Return the set of names of available patches and patch groups
//- corresponding to the given names
// A convenience wrapper for \c polyBoundaryMesh::patchSet
wordRes patchNameSet(const UList<wordRe>& select) const;
// Write // Write