78 const scalar concaveSin,
88 labelListList allFaceSets(faceCombiner.getMergeSets(minCos, concaveSin));
92 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
endl;
113 faceCombiner.setRefinement(allFaceSets, meshMod);
116 map = meshMod.changeMesh(
mesh,
false,
true);
119 mesh.updateMesh(map());
122 if (map().hasMotionPoints())
124 mesh.movePoints(map().preMotionPoints());
142 motionSmoother::checkMesh(
false,
mesh, *qualDictPtr, errorFaces);
146 mesh.checkFacePyramids(
false, -SMALL, &errorFaces);
154 label newMasterI = map().reverseFaceMap()[allFaceSets[seti][0]];
156 if (errorFaces.
found(newMasterI))
163 Info<<
"Detected " << nErrorSets
164 <<
" error faces on boundaries that have been merged."
165 <<
" These will be restored to their original faces."
171 for (
const label seti : errorSets)
173 faceList& setFaceVerts = allFaceSetsFaces[seti];
180 forAll(setFaceVerts[i], j)
182 label newVertI = setFaceVerts[i][j];
187 <<
"In set:" << seti <<
" old face labels:"
188 << allFaceSets[seti] <<
" new face vertices:"
189 << setFaceVerts[i] <<
" are unmapped vertices!"
190 <<
abort(FatalError);
202 for (
const label seti : errorSets)
204 const labelList& setFaces = allFaceSets[seti];
205 const faceList& setFaceVerts = allFaceSetsFaces[seti];
207 label newMasterI = map().reverseFaceMap()[setFaces[0]];
211 label own =
mesh.faceOwner()[newMasterI];
212 label
zoneID =
mesh.faceZones().whichZone(newMasterI);
213 bool zoneFlip =
false;
219 label
patchID =
mesh.boundaryMesh().whichPatch(newMasterI);
221 Pout<<
"Restoring new master face " << newMasterI
222 <<
" to vertices " << setFaceVerts[0] <<
endl;
243 for (label i = 1; i < setFaces.
size(); ++i)
245 Pout<<
"Restoring removed face " << setFaces[i]
246 <<
" with vertices " << setFaceVerts[i] <<
endl;
268 map = meshMod.changeMesh(
mesh,
false,
true);
271 mesh.updateMesh(map());
274 if (map().hasMotionPoints())
276 mesh.movePoints(map().preMotionPoints());
287 Info<<
"No faces merged ..." <<
endl;
298 Info<<
"Merging all points on surface that" <<
nl
299 <<
"- are used by only two boundary faces and" <<
nl
300 <<
"- make an angle with a cosine of more than " << minCos
308 label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
312 Info<<
"Removing " << nRemove
313 <<
" straight edge points ..." <<
endl;
318 pointRemover.setRefinement(pointCanBeDeleted, meshMod);
324 mesh.updateMesh(map());
327 if (map().hasMotionPoints())
329 mesh.movePoints(map().preMotionPoints());
339 Info<<
"No straight edges simplified and no points removed ..." <<
endl;
347int main(
int argc,
char *argv[])
351 "Checks for multiple patch faces on the same cell and combines them."
365 "Specify concave angle [0..180] (default: 30 degrees)"
367 argList::addBoolOption
370 "Read user-defined mesh quality criteria from system/meshQualityDict"
373 argList::noFunctionObjects();
379 const word oldInstance =
mesh.pointsInstance();
381 const scalar featureAngle =
args.
get<scalar>(1);
390 const bool overwrite =
args.
found(
"overwrite");
391 const bool meshQuality =
args.
found(
"meshQuality");
393 Info<<
"Merging all faces of a cell" <<
nl
394 <<
" - which are on the same patch" <<
nl
395 <<
" - which make an angle < " << featureAngle <<
" degrees"
397 <<
" (cos:" << minCos <<
')' <<
nl
398 <<
" - even when resulting face becomes concave by more than "
399 << concaveAngle <<
" degrees" <<
nl
400 <<
" (sin:" << concaveSin <<
')' <<
nl
406 Info<<
"Enabling user-defined geometry checks." <<
nl <<
endl;
415 mesh.time().system(),
433 label nChanged = mergePatchFaces
445 Info<<
"Merging all 'loose' points on surface edges, "
446 <<
"regardless of the angle they make." <<
endl;
449 nChanged += mergeEdges(-1,
mesh);
453 nChanged += mergeEdges(minCos,
mesh);
460 mesh.setInstance(oldInstance);
466 topoSet::removeFiles(
mesh);
467 processorMeshes::removeFiles(
mesh);
Inter-processor communication reduction functions.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
bool found(const Key &key) const
Return true if hashed entry is found in table.
label size() const noexcept
The number of elements in table.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
T get(const label index) const
Get a value from the argument at index.
bool found(const word &optName) const
Return true if the named option is found.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Combines boundary faces into single face. The faces get the patch of the first face ('the master')
A subset of mesh faces organised as a primitive patch.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
const boolList & flipMap() const noexcept
Return face flip map.
A face addition data class. A face can be inflated either from a point or from another face and can e...
Mesh consisting of general polyhedral cells.
Class describing modification of a face.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Removes selected points from mesh and updates faces using these points.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelIOList & zoneID
void inplaceRenumber(const labelUList &oldToNew, IntListType &lists)
Inplace renumber the values (not the indices) of a list of lists.
dimensionedScalar sin(const dimensionedScalar &ds)
messageStream Info
Information stream (stdout output on master, null elsewhere)
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensionedScalar cos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.