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);
122 if (map().hasMotionPoints())
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!" 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]];
213 bool zoneFlip =
false;
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);
274 if (map().hasMotionPoints())
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);
327 if (map().hasMotionPoints())
339 Info<<
"No straight edges simplified and no points removed ..." <<
endl;
347 int 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)" 370 "Read user-defined mesh quality criteria from system/meshQualityDict" 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;
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);
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces, const bool dryRun=false)
Check mesh with mesh settings in dict. Collects incorrect faces.
void clearOut()
Clear all geometry and addressing.
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.
Inter-processor communication reduction functions.
Class describing modification of a face.
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.
bool found(const Key &key) const
Same as contains()
Unit conversion functions.
constexpr char nl
The newline '\n' character (0x0a)
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.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Ignore writing from objectRegistry::writeObject()
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
const Time & time() const
Return the top-level database.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
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.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A face addition data class. A face can be inflated either from a point or from another face and can e...
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#define forAll(list, i)
Loop across all elements in list.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
bool checkFacePyramids(const pointField &points, const vectorField &ctrs, const bool report, const bool detailedReport, const scalar minPyrVol, labelHashSet *setPtr) const
Check face pyramid volume.
label size() const noexcept
The number of elements in table.
Combines boundary faces into single face. The faces get the patch of the first face ('the master') ...
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.
dimensionedScalar cos(const dimensionedScalar &ds)
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
const word & system() const noexcept
Return system name.
virtual const labelList & faceOwner() const
Return face owner.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
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.
dimensionedScalar sin(const dimensionedScalar &ds)
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.
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.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Direct mesh changes based on v1.3 polyTopoChange syntax.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
const boolList & flipMap() const noexcept
Return face flip map.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Removes selected points from mesh and updates faces using these points.
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
Foam::argList args(argc, argv)
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Defines the attributes of an object for which implicit objectRegistry management is supported...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
bool found(const word &optName) const
Return true if the named option is found.