70 const scalar concaveSin,
80 labelListList allFaceSets(faceCombiner.getMergeSets(minCos, concaveSin));
84 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
endl;
105 faceCombiner.setRefinement(allFaceSets, meshMod);
108 map = meshMod.changeMesh(mesh,
false,
true);
114 if (map().hasMotionPoints())
132 if (qualDictPtr.
valid())
146 label newMasterI = map().reverseFaceMap()[allFaceSets[setI][0]];
148 if (errorFaces.
found(newMasterI))
155 Info<<
"Detected " << nErrorSets
156 <<
" error faces on boundaries that have been merged."
157 <<
" These will be restored to their original faces."
165 label setI = iter.key();
167 faceList& setFaceVerts = allFaceSetsFaces[setI];
174 forAll(setFaceVerts[i], j)
176 label newVertI = setFaceVerts[i][j];
181 <<
"In set:" << setI <<
" old face labels:"
182 << allFaceSets[setI] <<
" new face vertices:"
183 << setFaceVerts[i] <<
" are unmapped vertices!"
198 label setI = iter.key();
200 const labelList& setFaces = allFaceSets[setI];
201 const faceList& setFaceVerts = allFaceSetsFaces[setI];
203 label newMasterI = map().reverseFaceMap()[setFaces[0]];
209 bool zoneFlip =
false;
217 Pout<<
"Restoring new master face " << newMasterI
218 <<
" to vertices " << setFaceVerts[0] <<
endl;
239 for (
label i = 1; i < setFaces.
size(); i++)
241 Pout<<
"Restoring removed face " << setFaces[i]
242 <<
" with vertices " << setFaceVerts[i] <<
endl;
264 map = meshMod.changeMesh(mesh,
false,
true);
270 if (map().hasMotionPoints())
283 Info<<
"No faces merged ..." <<
endl;
294 Info<<
"Merging all points on surface that" <<
nl
295 <<
"- are used by only two boundary faces and" <<
nl
296 <<
"- make an angle with a cosine of more than " << minCos
304 label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
308 Info<<
"Removing " << nRemove
309 <<
" straight edge points ..." <<
endl;
314 pointRemover.setRefinement(pointCanBeDeleted, meshMod);
323 if (map().hasMotionPoints())
335 Info<<
"No straight edges simplified and no points removed ..." <<
endl;
343 int main(
int argc,
char *argv[])
352 "specify concave angle [0..180] (default: 30 degrees)"
357 "read user-defined mesh quality criterions from system/meshQualityDict"
365 const scalar featureAngle =
args.
argRead<scalar>(1);
376 Info<<
"Merging all faces of a cell" <<
nl
377 <<
" - which are on the same patch" <<
nl
378 <<
" - which make an angle < " << featureAngle <<
" degrees"
380 <<
" (cos:" << minCos <<
')' <<
nl
381 <<
" - even when resulting face becomes concave by more than "
382 << concaveAngle <<
" degrees" <<
nl
383 <<
" (sin:" << concaveSin <<
')' <<
nl
389 Info<<
"Enabling user-defined geometry checks." <<
nl <<
endl;
416 label nChanged = mergePatchFaces
426 if (qualDict.
valid())
428 Info<<
"Merging all 'loose' points on surface edges, "
429 <<
"regardless of the angle they make." <<
endl;
432 nChanged += mergeEdges(-1, mesh);
436 nChanged += mergeEdges(minCos, mesh);
446 Info<<
"Writing morphed mesh to time " << runTime.
name() <<
endl;
Inter-processor communication reduction functions.
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
bool insert(const Key &key)
Insert a new entry.
label size() const
Return number of elements in table.
bool found(const Key &) const
Return true if hashedEntry is found in table.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void size(const label)
Override size to be inconsistent with allocated storage.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
static const word & system()
Return system name.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A List with indirect addressing.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
T argRead(const label index) const
Read a value from the argument at index.
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
Combines boundary faces into single face. The faces get the patch of the first face ('the master')
const word & name() const
Return const reference to name.
A subset of mesh faces organised as a primitive patch.
const boolList & flipMap() const
Return face flip map.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces)
Check mesh with mesh settings in dict. Collects incorrect faces.
const Time & time() const
Return time.
A face addition data class. A face can be inflated either from a point or from another face and can e...
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Mesh consisting of general polyhedral cells.
const meshFaceZones & faceZones() const
Return face zones.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
const fileName & pointsInstance() const
Return the current instance directory for points.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
void setInstance(const fileName &)
Set the instance for mesh files.
void clearOut()
Clear all geometry and addressing unnecessary for CFD.
virtual void setPoints(const pointField &)
Reset the points.
Class describing modification of a face.
Direct mesh changes based on v1.3 polyTopoChange syntax.
bool checkFacePyramids(const bool report=false, const scalar minPyrVol=-small, labelHashSet *setPtr=nullptr) const
Check face pyramid volume.
virtual bool write(const bool write=true) const
Write using setting from DB.
Removes selected points from mesh and updates faces using these points.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
dimensionedScalar sin(const dimensionedScalar &ds)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
prefixOSstream Pout(cout, "Pout")
dimensionedScalar cos(const dimensionedScalar &ds)
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Foam::argList args(argc, argv)
Unit conversion functions.