STYLE: adjust comments and adjust surfaceMeshTriangulate code

- note that it does not actually triangulate unless necessary, should
  probably receive a new name.

- use newer constructs for handling processor/non-processor patch
  selection etc.
This commit is contained in:
Mark Olesen 2018-12-16 16:16:00 +01:00
parent 24c8f5a597
commit b6983e6af5

View File

@ -28,16 +28,15 @@ Group
grpSurfaceUtilities grpSurfaceUtilities
Description Description
Extracts surface from a polyMesh. Depending on output surface format Extract patch or faceZone surfaces from a polyMesh.
triangulates faces. Depending on output surface format triangulates faces.
Region numbers on faces cannot be guaranteed to be the same as the patch Region numbers on faces no guaranteed to be the same as the patch indices.
indices.
Optionally only triangulates named patches. Optionally only extracts named patches.
If run in parallel the processor patches get filtered out by default and If run in parallel, processor patches get filtered out by default and
the mesh gets merged (based on topology). the mesh is merged (based on topology).
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -62,7 +61,9 @@ int main(int argc, char *argv[])
{ {
argList::addNote argList::addNote
( (
"Extract surface from a polyMesh" "Extract patch or faceZone surfaces from a polyMesh."
" The name is historical, it only triangulates faces"
" when the output format requires it."
); );
timeSelector::addOptions(); timeSelector::addOptions();
@ -77,14 +78,16 @@ int main(int argc, char *argv[])
argList::addOption argList::addOption
( (
"patches", "patches",
"(patch0 .. patchN)", "wordRes"
"Only triangulate selected patches (wildcards supported)" "Specify single patch or multiple patches to extract.\n"
"Eg, 'top' or '( front \".*back\" )'"
); );
argList::addOption argList::addOption
( (
"faceZones", "faceZones",
"(fz0 .. fzN)", "wordRes",
"Triangulate selected faceZones (wildcards supported)" "Specify single or multiple faceZones to extract\n"
"Eg, 'cells' or '( slice \"mfp-.*\" )'"
); );
#include "setRootCase.H" #include "setRootCase.H"
@ -99,8 +102,7 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
Info<< "Extracting surface from boundaryMesh ..." Info<< "Extracting surface from boundaryMesh ..." << nl << nl;
<< endl << endl;
const bool includeProcPatches = const bool includeProcPatches =
!( !(
@ -134,7 +136,6 @@ int main(int argc, char *argv[])
if (timeDirs.size() == 1) if (timeDirs.size() == 1)
{ {
outFileName = userOutFileName; outFileName = userOutFileName;
Info<< nl;
} }
else else
{ {
@ -144,15 +145,11 @@ int main(int argc, char *argv[])
Info<<" ... no mesh change." << nl; Info<<" ... no mesh change." << nl;
continue; continue;
} }
else
{
Info<< nl;
}
// The filename based on the original, but with additional // The filename based on the original, but with additional
// time information. The extension was previously checked that // time information. The extension was previously checked that
// it exists // it exists
std::string::size_type dot = userOutFileName.rfind('.'); const auto dot = userOutFileName.rfind('.');
outFileName = outFileName =
userOutFileName.substr(0, dot) + "_" userOutFileName.substr(0, dot) + "_"
@ -160,6 +157,8 @@ int main(int argc, char *argv[])
+ userOutFileName.ext(); + userOutFileName.ext();
} }
Info<< nl;
// Create local surface from: // Create local surface from:
// - explicitly named patches only (-patches (at your option) // - explicitly named patches only (-patches (at your option)
// - all patches (default in sequential mode) // - all patches (default in sequential mode)
@ -170,37 +169,39 @@ int main(int argc, char *argv[])
// Construct table of patches to include. // Construct table of patches to include.
const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
labelHashSet includePatches(bMesh.size()); labelList includePatches;
if (args.found("patches")) if (args.found("patches"))
{ {
includePatches = bMesh.patchSet(args.getList<wordRe>("patches")); includePatches =
bMesh.patchSet(args.getList<wordRe>("patches")).sortedToc();
}
else if (includeProcPatches)
{
includePatches = identity(bMesh.size());
} }
else else
{ {
forAll(bMesh, patchi) includePatches = identity(bMesh.nNonProcessor());
{
const polyPatch& patch = bMesh[patchi];
if (includeProcPatches || !isA<processorPolyPatch>(patch))
{
includePatches.insert(patchi);
}
}
} }
labelList includeFaceZones;
const faceZoneMesh& fzm = mesh.faceZones(); const faceZoneMesh& fzm = mesh.faceZones();
labelHashSet includeFaceZones(fzm.size());
if (args.found("faceZones")) if (args.found("faceZones"))
{ {
wordReList zoneNames(args.getList<wordRe>("faceZones"));
const wordList allZoneNames(fzm.names()); const wordList allZoneNames(fzm.names());
const wordRes zoneNames(args.getList<wordRe>("faceZones"));
labelHashSet hashed(2*fzm.size());
for (const wordRe& zoneName : zoneNames) for (const wordRe& zoneName : zoneNames)
{ {
labelList zoneIDs = findStrings(zoneName, allZoneNames); labelList zoneIDs = findStrings(zoneName, allZoneNames);
includeFaceZones.insert(zoneIDs); hashed.insert(zoneIDs);
if (zoneIDs.empty()) if (zoneIDs.empty())
{ {
@ -209,17 +210,15 @@ int main(int argc, char *argv[])
<< zoneName << endl; << zoneName << endl;
} }
} }
Info<< "Additionally triangulating faceZones "
<< UIndirectList<word> includeFaceZones = hashed.sortedToc();
(
allZoneNames, Info<< "Additionally extracting faceZones "
includeFaceZones.sortedToc() << UIndirectList<word>(allZoneNames, includeFaceZones)
)
<< endl; << endl;
} }
// From (name of) patch to compact 'zone' index // From (name of) patch to compact 'zone' index
HashTable<label> compactZoneID(1024); HashTable<label> compactZoneID(1024);
// Mesh face and compact zone indx // Mesh face and compact zone indx
@ -252,18 +251,14 @@ int main(int argc, char *argv[])
// Allocate compact numbering for all patches/faceZones // Allocate compact numbering for all patches/faceZones
forAllConstIter(HashTable<label>, patchSize, iter) forAllConstIters(patchSize, iter)
{ {
label sz = compactZoneID.size(); compactZoneID.insert(iter.key(), compactZoneID.size());
compactZoneID.insert(iter.key(), sz);
} }
forAllConstIter(HashTable<label>, zoneSize, iter) forAllConstIters(zoneSize, iter)
{ {
label sz = compactZoneID.size(); compactZoneID.insert(iter.key(), compactZoneID.size());
//Info<< "For faceZone " << iter.key() << " allocating zoneID "
// << sz << endl;
compactZoneID.insert(iter.key(), sz);
} }
@ -273,7 +268,7 @@ int main(int argc, char *argv[])
// Rework HashTable into labelList just for speed of conversion // Rework HashTable into labelList just for speed of conversion
labelList patchToCompactZone(bMesh.size(), -1); labelList patchToCompactZone(bMesh.size(), -1);
labelList faceZoneToCompactZone(bMesh.size(), -1); labelList faceZoneToCompactZone(bMesh.size(), -1);
forAllConstIter(HashTable<label>, compactZoneID, iter) forAllConstIters(compactZoneID, iter)
{ {
label patchi = bMesh.findPatchID(iter.key()); label patchi = bMesh.findPatchID(iter.key());
if (patchi != -1) if (patchi != -1)