66 const scalar concaveSin,
76 labelListList allFaceSets(faceCombiner.getMergeSets(minCos, concaveSin));
80 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
endl;
101 faceCombiner.setRefinement(allFaceSets, meshMod);
104 map = meshMod.changeMesh(mesh,
true);
117 if (qualDictPtr.
valid())
131 label newMasterI = map().reverseFaceMap()[allFaceSets[setI][0]];
133 if (errorFaces.
found(newMasterI))
140 Info<<
"Detected " << nErrorSets
141 <<
" error faces on boundaries that have been merged."
142 <<
" These will be restored to their original faces."
150 label setI = iter.key();
152 faceList& setFaceVerts = allFaceSetsFaces[setI];
159 forAll(setFaceVerts[i], j)
161 label newVertI = setFaceVerts[i][j];
166 <<
"In set:" << setI <<
" old face labels:"
167 << allFaceSets[setI] <<
" new face vertices:"
168 << setFaceVerts[i] <<
" are unmapped vertices!"
183 label setI = iter.key();
185 const labelList& setFaces = allFaceSets[setI];
186 const faceList& setFaceVerts = allFaceSetsFaces[setI];
188 label newMasterI = map().reverseFaceMap()[setFaces[0]];
195 Pout<<
"Restoring new master face " << newMasterI
196 <<
" to vertices " << setFaceVerts[0] <<
endl;
210 for (
label i = 1; i < setFaces.
size(); i++)
212 Pout<<
"Restoring removed face " << setFaces[i]
213 <<
" with vertices " << setFaceVerts[i] <<
endl;
228 map = meshMod.changeMesh(mesh,
true);
236 Info<<
"No faces merged ..." <<
endl;
247 Info<<
"Merging all points on surface that" <<
nl
248 <<
"- are used by only two boundary faces and" <<
nl
249 <<
"- make an angle with a cosine of more than " << minCos
257 label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
261 Info<<
"Removing " << nRemove
262 <<
" straight edge points ..." <<
endl;
267 pointRemover.setRefinement(pointCanBeDeleted, meshMod);
277 Info<<
"No straight edges simplified and no points removed ..." <<
endl;
285 int main(
int argc,
char *argv[])
294 "specify concave angle [0..180] (default: 30 degrees)"
299 "read user-defined mesh quality criterions from system/meshQualityDict"
308 const scalar minCos =
Foam::cos(featureAngle);
312 const scalar concaveAngle =
314 const scalar concaveSin =
Foam::sin(concaveAngle);
319 Info<<
"Merging all faces of a cell" <<
nl
320 <<
" - which are on the same patch" <<
nl
321 <<
" - which make an angle < " <<
radToDeg(featureAngle)
323 <<
" (cos:" << minCos <<
')' <<
nl
324 <<
" - even when resulting face becomes concave by more than "
326 <<
" (sin:" << concaveSin <<
')' <<
nl
332 Info<<
"Enabling user-defined geometry checks." <<
nl <<
endl;
359 label nChanged = mergePatchFaces
369 if (qualDict.
valid())
371 Info<<
"Merging all 'loose' points on surface edges, "
372 <<
"regardless of the angle they make." <<
endl;
375 nChanged += mergeEdges(-1, mesh);
379 nChanged += mergeEdges(minCos, mesh);
389 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.
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.
const Time & time() const
Return time.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Mesh consisting of general polyhedral cells.
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.
Direct mesh changes based on v1.3 polyTopoChange syntax.
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[])
Functions for checking mesh topology and geometry.
bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet &wrongFaces)
Check (subset of mesh including baffles) with mesh settings in dict.
bool checkFacePyramids(const bool report, const scalar minPyrVol, const polyMesh &, const vectorField &cellCentres, const pointField &p, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet *)
Check face pyramid volumes.
scalar radToDeg(const scalar rad)
Convert radians to degrees.
scalar degToRad(const scalar deg)
Convert degrees to radians.
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)
Foam::argList args(argc, argv)