86 for (
const label patchi : indices)
90 if (isType<emptyPolyPatch>(pp))
99 indices[
count] = patchi;
103 indices.resize(
count);
111 int 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." 129 "excludeProcPatches",
130 "Exclude processor patches" 136 "Specify single or multiple faceZones to extract\n" 137 "Eg, 'cells' or '( slice \"mfp-.*\" )'" 143 "Specify single patch or multiple patches to extract.\n" 144 "Eg, 'top' or '( front \".*back\" )'" 150 "Specify single patch or multiple patches to exclude from writing." 151 " Eg, 'outlet' or '( inlet \".*Wall\" )'",
160 if (!userOutFileName.has_ext())
163 <<
"Missing extension on output name " << userOutFileName
167 Info<<
"Extracting surface from boundaryMesh ..." <<
nl <<
nl;
169 const bool includeProcPatches =
175 if (includeProcPatches)
177 Info<<
"Including all processor patches." <<
nl <<
endl;
181 Info<<
"Excluding all processor patches." <<
nl <<
endl;
184 wordRes includePatches, excludePatches;
198 if (selectedFaceZones.size())
217 if (timeDirs.
size() == 1)
219 outFileName = userOutFileName;
226 Info<<
" ... no mesh change." <<
nl;
233 const auto dot = userOutFileName.rfind(
'.');
236 userOutFileName.substr(0,
dot) +
"_" 238 + userOutFileName.
ext();
255 (includePatches.
size() || excludePatches.
size())
256 ? getSelectedPatches(
bMesh, includePatches, excludePatches)
266 if (selectedFaceZones.size())
268 faceZoneIds = fzm.
indices(selectedFaceZones);
270 Info<<
"Additionally extracting faceZones " 271 << fzm.
names(selectedFaceZones) <<
nl;
289 patchSize.insert(pp.
name(), pp.size());
294 for (
const label zonei : faceZoneIds)
297 zoneSize.insert(pp.
name(), pp.
size());
310 compactZoneID.insert(iter.key(), compactZoneID.size());
315 compactZoneID.insert(iter.key(), compactZoneID.size());
326 label patchi =
bMesh.findPatchID(iter.key());
329 patchToCompactZone[patchi] = iter.val();
334 faceZoneToCompactZone[zoneI] = iter.val();
349 compactZones.
append(patchToCompactZone[pp.
index()]);
353 for (
const label zonei : faceZoneIds)
359 compactZones.
append(faceZoneToCompactZone[pp.
index()]);
378 allBoundary.meshPoints(),
379 allBoundary.meshPointMap(),
415 gatheredPoints.clear();
417 faceList allFaces = ListListOps::combine<faceList>
422 gatheredFaces.clear();
424 labelList allZones = ListListOps::combine<labelList>
429 gatheredZones.clear();
437 Info<<
"surfZone " << *iter
438 <<
" : " << surfZones[*iter].name()
464 Info<<
"Writing merged surface to " << globalCasePath <<
endl;
466 sortedFace.
write(globalCasePath);
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
static void mapCombineGather(const List< commsStruct > &comms, Container &values, const CombineOp &cop, const int tag, const label comm)
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.
fileName path() const
Return 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.
constexpr char nl
The newline '\n' character (0x0a)
Object access operator or list access operator.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
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.
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)
Number of this process (starting from masterNo() = 0)
bool processorCase() const noexcept
Return 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 processes in communicator.
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) is 1 for serial run.
vectorField pointField
pointField is a vectorField.
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for 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)
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.
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...
const word & name() const noexcept
The patch name.
label index() const noexcept
The index of this zone in the zone list.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time 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 (not the indices) of 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)
Am I the master rank.
label start() const
Return start label of this patch in the polyMesh face list.
const polyBoundaryMesh & patches
const word & name() const noexcept
The zone name.
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.
label index() const noexcept
The index of this patch in the boundaryMesh.
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.
forAllConstIters(mixture.phases(), phase)
fileName globalPath() const
Return global path for the case.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.