87 void insertDuplicateMerge
101 label otherFacei = duplicates[bFacei];
103 if (otherFacei != -1 && otherFacei > bFacei)
107 label face0 = boundaryFaces[bFacei];
108 label face1 = boundaryFaces[otherFacei];
110 label own0 = faceOwner[face0];
111 label own1 = faceOwner[face1];
116 label zoneID = faceZones.
whichZone(face0);
117 bool zoneFlip =
false;
121 const faceZone& fZone = faceZones[zoneID];
145 label zoneID = faceZones.
whichZone(face1);
146 bool zoneFlip =
false;
150 const faceZone& fZone = faceZones[zoneID];
202 faceIDs[sz++] =
pp.start()+ppi;
206 if (faceIDs.size() != sz)
228 forAll(duplicates, bFacei)
230 if (duplicates[bFacei] != -1)
232 label facei = boundaryFaces[bFacei];
235 if (isA<processorPolyPatch>(
patches[patchi]))
238 <<
"Duplicate face " << facei
239 <<
" is on a processorPolyPatch." 240 <<
"This is not allowed." <<
nl 258 forAll(duplicates, bFacei)
260 label otherFacei = duplicates[bFacei];
262 if (otherFacei != -1 && otherFacei > bFacei)
264 duplicateSet.insert(boundaryFaces[bFacei]);
265 duplicateSet.insert(boundaryFaces[otherFacei]);
270 <<
" duplicate faces to faceSet " << duplicateSet.objectPath()
272 duplicateSet.
write();
279 int main(
int argc,
char *argv[])
283 "Detect faces that share points (baffles).\n" 284 "Merge them or duplicate the points." 293 "Specify a dictionary to read actions from" 298 "Find baffles only, but do not merge or split them" 303 "Topologically split duplicate surfaces" 315 const bool readDict =
args.
found(
"dict");
317 const bool overwrite =
args.
found(
"overwrite");
318 const bool detectOnly =
args.
found(
"detectOnly");
320 if (readDict && (
split || detectOnly))
323 <<
"Use of dictionary for settings not compatible with" 324 <<
" using command line arguments for \"split\"" 348 Info<<
"Detecting baffles on " << detectPatchIDs.
size()
360 Info<<
"Merge baffles on " << mergePatchIDs.
size()
372 Info<<
"Split baffles on " << splitPatchIDs.
size()
395 if (detectPatchIDs.
size())
397 findBaffles(
mesh, patchFaces(
mesh, detectPatchIDs));
446 if (mergePatchIDs.
size())
448 Info<<
"Merging duplicate faces" <<
nl <<
endl;
453 const labelList boundaryFaces(patchFaces(
mesh, mergePatchIDs));
459 insertDuplicateMerge(
mesh, boundaryFaces, duplicates, meshMod);
473 if (map().hasMotionPoints())
487 if (splitPatchIDs.
size())
489 Info<<
"Topologically splitting duplicate surfaces" 490 <<
", i.e. duplicating points internal to duplicate surfaces" 499 sz +=
patches[splitPatchIDs[i]].nPoints();
509 label pointi =
mp[mpi];
510 if (isCandidate.set(pointi))
512 candidates.
append(pointi);
529 pointDuplicator.setRefinement(
regionSide, meshMod);
543 if (map().hasMotionPoints())
559 const labelList& pointMap = map().pointMap();
567 label oldPointi = pointMap[pointi];
569 nDupPerPoint[oldPointi]++;
571 if (nDupPerPoint[oldPointi] > 1)
573 dupPoints.insert(map().reversePointMap()[oldPointi]);
574 dupPoints.insert(pointi);
579 <<
" duplicated points to pointSet " 580 << dupPoints.objectPath() <<
nl <<
endl;
const labelList patchIDs(pbm.indices(polyPatchNames, true))
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.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
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.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
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.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
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.
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.
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...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
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.
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 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.
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)
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())
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
static constexpr const zero Zero
Global zero (0)