102 using namespace Foam;
106 void insertDuplicateMerge
118 forAll(duplicates, bFacei)
120 label otherFacei = duplicates[bFacei];
122 if (otherFacei != -1 && otherFacei > bFacei)
126 label face0 = boundaryFaces[bFacei];
127 label face1 = boundaryFaces[otherFacei];
129 label own0 = faceOwner[face0];
130 label own1 = faceOwner[face1];
135 label zoneID = faceZones.
whichZone(face0);
136 bool zoneFlip =
false;
140 const faceZone& fZone = faceZones[zoneID];
164 label zoneID = faceZones.
whichZone(face1);
165 bool zoneFlip =
false;
169 const faceZone& fZone = faceZones[zoneID];
221 faceIDs[sz++] =
pp.start()+ppi;
225 if (faceIDs.size() != sz)
247 forAll(duplicates, bFacei)
249 if (duplicates[bFacei] != -1)
251 label facei = boundaryFaces[bFacei];
254 if (isA<processorPolyPatch>(
patches[patchi]))
257 <<
"Duplicate face " << facei
258 <<
" is on a processorPolyPatch." 259 <<
"This is not allowed." <<
nl 277 forAll(duplicates, bFacei)
279 label otherFacei = duplicates[bFacei];
281 if (otherFacei != -1 && otherFacei > bFacei)
283 duplicateSet.insert(boundaryFaces[bFacei]);
284 duplicateSet.insert(boundaryFaces[otherFacei]);
289 <<
" duplicate faces to faceSet " << duplicateSet.objectPath()
291 duplicateSet.
write();
298 int main(
int argc,
char *argv[])
302 "Detect faces that share points (baffles).\n" 303 "Merge them or duplicate the points." 312 "Specify a dictionary to read actions from" 317 "Find baffles only, but do not merge or split them" 322 "Topologically split duplicate surfaces" 334 const bool readDict =
args.
found(
"dict");
336 const bool overwrite =
args.
found(
"overwrite");
337 const bool detectOnly =
args.
found(
"detectOnly");
339 if (readDict && (
split || detectOnly))
342 <<
"Use of dictionary for settings not compatible with" 343 <<
" using command line arguments for \"split\"" 367 Info<<
"Detecting baffles on " << detectPatchIDs.
size()
379 Info<<
"Merge baffles on " << mergePatchIDs.
size()
391 Info<<
"Split baffles on " << splitPatchIDs.
size()
414 if (detectPatchIDs.
size())
416 findBaffles(
mesh, patchFaces(
mesh, detectPatchIDs));
465 if (mergePatchIDs.
size())
467 Info<<
"Merging duplicate faces" <<
nl <<
endl;
472 const labelList boundaryFaces(patchFaces(
mesh, mergePatchIDs));
478 insertDuplicateMerge(
mesh, boundaryFaces, duplicates, meshMod);
492 if (map().hasMotionPoints())
509 if (newToOld.size() != oldPatchNames.size())
512 forAll(oldPatchNames, patchi)
514 if (!newToOld.found(patchi))
517 <<
" at position " << patchi
534 if (splitPatchIDs.
size())
536 Info<<
"Topologically splitting duplicate surfaces" 537 <<
", i.e. duplicating points internal to duplicate surfaces" 546 sz +=
patches[splitPatchIDs[i]].nPoints();
556 label pointi =
mp[mpi];
557 if (isCandidate.set(pointi))
559 candidates.
append(pointi);
576 pointDuplicator.setRefinement(
regionSide, meshMod);
590 if (map().hasMotionPoints())
606 const labelList& pointMap = map().pointMap();
614 label oldPointi = pointMap[pointi];
616 nDupPerPoint[oldPointi]++;
618 if (nDupPerPoint[oldPointi] > 1)
620 dupPoints.insert(map().reversePointMap()[oldPointi]);
621 dupPoints.insert(pointi);
626 <<
" duplicated points to pointSet " 627 << dupPoints.objectPath() <<
nl <<
endl;
Class containing data for face removal.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
Ostream & indent(Ostream &os)
Indent stream.
wordList ReadFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh >> &fields, const bool syncPar=true, const bool readOldTime=false)
Read Geometric fields of templated type.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Class describing modification of a face.
label nPoints() const noexcept
Number of mesh points.
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.
const word & name() const noexcept
Return the object name.
labelHashSet patchSet(const UList< wordRe > &select, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
constexpr char nl
The newline '\n' character (0x0a)
const word dictName("faMeshDefinition")
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
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.
Field reading functions for post-processing utilities.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
autoPtr< mapPolyMesh > changeMesh(polyMesh &mesh, const labelUList &patchMap, const bool inflate, const bool syncParallel=true, const bool orderCells=false, const bool orderPoints=false)
Inplace changes mesh without change of patches.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#define forAll(list, i)
Loop across all elements in list.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
Determines the 'side' for every face and connected to a singly-connected (through edges) region of fa...
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
const fileName & pointsInstance() const
Return the current instance directory for points.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
wordList names() const
Return a list of patch names.
label size() const noexcept
The number of entries in the list.
virtual const labelList & faceOwner() const
Return face owner.
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.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
void append(const T &val)
Copy append an element to the end of this list.
virtual const faceList & faces() const
Return raw faces.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
errorManip< error > abort(error &err)
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh...
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.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
static bool split(const std::string &line, std::string &key, std::string &val)
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Direct mesh changes based on v1.3 polyTopoChange syntax.
const polyBoundaryMesh & patches
const boolList & flipMap() const noexcept
Return face flip map.
static labelList findDuplicateFaces(const primitiveMesh &, const labelList &)
Helper routine to find baffles (two boundary faces using the.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
A patch is a list of labels that address the faces in the global face list.
label nBoundaryFaces() const noexcept
Number of boundary faces (== nFaces - nInternalFaces)
Foam::argList args(argc, argv)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
const dimensionedScalar mp
Proton mass.
bool found(const word &optName) const
Return true if the named option is found.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
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...
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
label whichFace(const label meshFaceID) const
The local index of the given mesh face, -1 if not in the zone.
static constexpr const zero Zero
Global zero (0)