87 for (
const label patchi : indices)
91 if (isType<emptyPolyPatch>(
pp))
100 indices[
count] = patchi;
104 indices.resize(
count);
112 int main(
int argc,
char *argv[])
116 "Extract patch or faceZone surfaces from a polyMesh." 117 " The name is historical, it only triangulates faces" 118 " when the output format requires it." 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 -patches." 152 " Eg, 'outlet' or '( inlet \".*Wall\" )'",
162 if (!userOutFileName.has_ext())
165 <<
"Missing extension on output name " << userOutFileName
169 Info<<
"Extracting surface from boundaryMesh ..." <<
nl <<
nl;
171 const bool includeProcPatches =
174 if (includeProcPatches)
176 Info<<
"Including all processor patches." <<
nl <<
endl;
180 Info<<
"Excluding all processor patches." <<
nl <<
endl;
183 wordRes includePatches, excludePatches;
197 if (selectedFaceZones.size())
216 if (timeDirs.
size() == 1)
218 outFileName = userOutFileName;
225 Info<<
" ... no mesh change." <<
nl;
232 const auto dot = userOutFileName.rfind(
'.');
235 userOutFileName.substr(0,
dot) +
"_" 237 + userOutFileName.
ext();
254 (includePatches.
size() || excludePatches.
size())
255 ? getSelectedPatches(
bMesh, includePatches, excludePatches)
265 if (selectedFaceZones.size())
267 faceZoneIds = fzm.
indices(selectedFaceZones);
269 Info<<
"Additionally extracting faceZones " 270 << fzm.
names(selectedFaceZones) <<
nl;
288 patchSize.insert(
pp.name(),
pp.size());
293 for (
const label zonei : faceZoneIds)
296 zoneSize.insert(
pp.name(),
pp.size());
309 compactZoneID.insert(iter.key(), compactZoneID.size());
314 compactZoneID.insert(iter.key(), compactZoneID.size());
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(),
414 gatheredPoints.clear();
416 faceList allFaces = ListListOps::combine<faceList>
421 gatheredFaces.clear();
423 labelList allZones = ListListOps::combine<labelList>
428 gatheredZones.clear();
436 Info<<
"surfZone " << *iter
437 <<
" : " << surfZones[*iter].name()
463 Info<<
"Writing merged surface to " << globalCasePath <<
endl;
465 sortedFace.
write(globalCasePath);
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
const Type & value() const noexcept
Return const reference to value.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
static void mapCombineGather(Container &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Combine Map elements.
fileName path() const
Return path = rootPath/caseName. Same as TimePaths::path()
A class for handling file names.
static void setAdvanced(const word &optName, bool advanced=true)
Set an existing option as being 'advanced' or normal.
Identifies a surface patch/zone by name and index, with optional geometric type.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
constexpr char nl
The newline '\n' character (0x0a)
Object access operator or list access operator (default is pass-through)
Database for mesh data, solution data, solver performance and other reduced data. ...
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void gatherList(const UList< commsStruct > &comms, UList< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
List< T > getList(const label index) const
Get a List of values from the argument at index.
static bool & parRun() noexcept
Test if this a parallel run.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
static void addOptionCompat(const word &optName, std::pair< const char *, int > compat)
Specify an alias for the option name.
void setCapacity(const label len)
Alter the size of the underlying storage.
autoPtr< globalIndex > mergePoints(labelList &pointToGlobal, labelList &uniquePoints) const
Helper for merging (collocated!) mesh point data.
Operations on lists of strings.
static bool isAbsolute(const std::string &str)
Return true if filename starts with a '/' or '\' or (windows-only) with a filesystem-root.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
labelList faceLabels(nFaceLabels)
bool processorCase() const noexcept
True if this is a processor case.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all communicator ranks. Does nothing in non-paral...
Extract name (as a word) from an object, typically using its name() method.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
word ext() const
Return file name extension (part after last .)
A list of faces which address into the list of points.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) zone indices for all matches.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
fileName globalPath() const
Return global path for the case = rootPath/globalCaseName. Same as TimePaths::globalPath() ...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
labelList findMatching(const StringListType &input, const wordRes::filter &pred, AccessOp aop=identityOp())
Return ids for items with matching names.
A List of wordRe with additional matching capabilities.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
void append(const T &val)
Copy append an element to the end of this list.
virtual const faceList & faces() const
Return raw faces.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
bool readListIfPresent(const word &optName, List< T > &list) const
If named option is present, get a List of values treating a single entry like a list of size 1...
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
T get(const label index) const
Get a value from the argument at index.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
const polyBoundaryMesh & patches
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
wordList names() const
A list of the zone names.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
A subset of mesh faces organised as a primitive patch.
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.
Foam::argList args(argc, argv)
bool found(const word &optName) const
Return true if the named option is found.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
forAllConstIters(mixture.phases(), phase)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.