73 stringListOps::findMatching
86 for (
const label patchi : indices)
90 if (isType<emptyPolyPatch>(pp))
94 else if (Pstream::parRun() &&
bool(isA<processorPolyPatch>(pp)))
99 indices[
count] = patchi;
103 indices.resize(count);
111int main(
int argc,
char *argv[])
115 "Extract patch or faceZone surfaces from a polyMesh."
116 " The name is historical, it only triangulates faces"
117 " when the output format requires it."
119 timeSelector::addOptions();
122 argList::setAdvanced(
"decomposeParDict");
123 argList::setAdvanced(
"noFunctionObjects");
125 argList::addArgument(
"output",
"The output surface file");
128 argList::addBoolOption
130 "excludeProcPatches",
131 "Exclude processor patches"
137 "Specify single or multiple faceZones to extract\n"
138 "Eg, 'cells' or '( slice \"mfp-.*\" )'"
144 "Specify single patch or multiple patches to extract.\n"
145 "Eg, 'top' or '( front \".*back\" )'"
151 "Specify single patch or multiple patches to exclude from writing."
152 " Eg, 'outlet' or '( inlet \".*Wall\" )'",
161 if (!userOutFileName.hasExt())
164 <<
"Missing extension on output name " << userOutFileName
168 Info<<
"Extracting surface from boundaryMesh ..." <<
nl <<
nl;
170 const bool includeProcPatches =
176 if (includeProcPatches)
178 Info<<
"Including all processor patches." <<
nl <<
endl;
180 else if (Pstream::parRun())
182 Info<<
"Excluding all processor patches." <<
nl <<
endl;
185 wordRes includePatches, excludePatches;
199 if (selectedFaceZones.size())
218 if (timeDirs.
size() == 1)
220 outFileName = userOutFileName;
225 if (
timeIndex && meshState == polyMesh::UNCHANGED)
227 Info<<
" ... no mesh change." <<
nl;
234 const auto dot = userOutFileName.rfind(
'.');
237 userOutFileName.substr(0, dot) +
"_"
239 + userOutFileName.
ext();
256 (includePatches.
size() || excludePatches.
size())
257 ? getSelectedPatches(
bMesh, includePatches, excludePatches)
267 if (selectedFaceZones.size())
269 faceZoneIds = fzm.
indices(selectedFaceZones);
271 Info<<
"Additionally extracting faceZones "
272 << fzm.
names(selectedFaceZones) <<
nl;
290 patchSize.insert(pp.
name(), pp.size());
295 for (
const label zonei : faceZoneIds)
298 zoneSize.insert(pp.
name(), pp.
size());
309 compactZoneID.insert(iter.key(), compactZoneID.size());
314 compactZoneID.insert(iter.key(), compactZoneID.size());
317 Pstream::broadcast(compactZoneID);
325 label patchi =
bMesh.findPatchID(iter.key());
328 patchToCompactZone[patchi] = iter.val();
333 faceZoneToCompactZone[zoneI] = iter.val();
348 compactZones.
append(patchToCompactZone[pp.
index()]);
352 for (
const label zonei : faceZoneIds)
358 compactZones.
append(faceZoneToCompactZone[pp.
index()]);
377 allBoundary.meshPoints(),
378 allBoundary.meshPointMap(),
385 gatheredPoints[Pstream::myProcNo()] =
pointField
390 Pstream::gatherList(gatheredPoints);
394 gatheredFaces[Pstream::myProcNo()] = allBoundary.localFaces();
395 forAll(gatheredFaces[Pstream::myProcNo()], i)
400 gatheredFaces[Pstream::myProcNo()][i]
403 Pstream::gatherList(gatheredFaces);
407 gatheredZones[Pstream::myProcNo()].transfer(compactZones);
408 Pstream::gatherList(gatheredZones);
411 if (Pstream::master())
418 gatheredPoints.clear();
420 faceList allFaces = ListListOps::combine<faceList>
425 gatheredFaces.clear();
427 labelList allZones = ListListOps::combine<labelList>
432 gatheredZones.clear();
440 Info<<
"surfZone " << *iter
441 <<
" : " << surfZones[*iter].name()
447 std::move(allPoints),
462 ?
runTime.globalPath()/outFileName
467 Info<<
"Writing merged surface to " << globalCasePath <<
endl;
469 sortedFace.
write(globalCasePath);
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
void setCapacity(const label len)
Alter the size of the underlying storage.
A HashTable similar to std::unordered_map.
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A list of faces which address into the list of points.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
wordList names() const
A list of the zone names.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) zone indices for all matches.
T get(const label index) const
Get a value from the argument at index.
bool readListIfPresent(const word &optName, List< T > &list) const
bool found(const word &optName) const
Return true if the named option is found.
List< T > getList(const label index) const
Get a List of values from the argument at index.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A subset of mesh faces organised as a primitive patch.
A class for handling file names.
static bool isAbsolute(const std::string &str)
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
readUpdateState
Enumeration defining the state of the mesh after a read update.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
Identifies a surface patch/zone by name and index, with optional geometric type.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
A List of wordRe with additional matching capabilities.
word ext() const
Return file name extension (part after last .)
label index() const noexcept
The index of this zone in the zone list.
const word & name() const noexcept
The zone name.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
const label nNonProcessor
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
void inplaceRenumber(const labelUList &oldToNew, IntListType &lists)
Inplace renumber the values (not the indices) of a list of lists.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
messageStream Info
Information stream (stdout output on master, null elsewhere)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Extract name (as a word) from an object, typically using its name() method.