98 const scalar defaultConcaveAngle = 30;
122 scalar maxNonOrtho(
readScalar(snapDict.lookup(
"maxNonOrtho")));
124 scalar maxConcave(
readScalar(snapDict.lookup(
"maxConcave")));
126 scalar relMinVol(
readScalar(snapDict.lookup(
"minVol")));
128 const scalar minPyrVol = relMinVol*minCellVol;
130 scalar minArea(
readScalar(snapDict.lookup(
"minArea")));
132 if (maxNonOrtho < 180.0-SMALL)
134 Pout<<
"Checking non orthogonality" <<
endl;
136 label nOldSize = wrongFaces.
size();
140 Pout<<
"Detected " << wrongFaces.
size() - nOldSize
141 <<
" faces with non-orthogonality > " << maxNonOrtho <<
" degrees"
145 if (minPyrVol > -GREAT)
147 Pout<<
"Checking face pyramids" <<
endl;
149 label nOldSize = wrongFaces.
size();
151 Pout<<
"Detected additional " << wrongFaces.
size() - nOldSize
152 <<
" faces with illegal face pyramids" <<
endl;
155 if (maxConcave < 180.0-SMALL)
157 Pout<<
"Checking face angles" <<
endl;
159 label nOldSize = wrongFaces.
size();
161 Pout<<
"Detected additional " << wrongFaces.
size() - nOldSize
162 <<
" faces with concavity > " << maxConcave <<
" degrees"
166 if (minArea > -SMALL)
168 Pout<<
"Checking face areas" <<
endl;
170 label nOldSize = wrongFaces.
size();
174 forAll(magFaceAreas, faceI)
176 if (magFaceAreas[faceI] < minArea)
181 Pout<<
"Detected additional " << wrongFaces.
size() - nOldSize
182 <<
" faces with area < " << minArea <<
" m^2" <<
endl;
189 label mergePatchFaces
192 const scalar concaveSin,
193 const bool snapMeshDict,
202 labelListList allFaceSets(faceCombiner.getMergeSets(minCos, concaveSin));
206 Info<<
"Merging " << nFaceSets <<
" sets of faces." <<
endl;
227 faceCombiner.setRefinement(allFaceSets, meshMod);
230 map = meshMod.changeMesh(mesh,
false,
true);
236 if (map().hasMotionPoints())
256 checkSnapMesh(runTime, mesh, errorFaces);
268 label newMasterI = map().reverseFaceMap()[allFaceSets[setI][0]];
270 if (errorFaces.
found(newMasterI))
277 Info<<
"Detected " << nErrorSets
278 <<
" error faces on boundaries that have been merged."
279 <<
" These will be restored to their original faces."
287 label setI = iter.key();
289 faceList& setFaceVerts = allFaceSetsFaces[setI];
296 forAll(setFaceVerts[i], j)
298 label newVertI = setFaceVerts[i][j];
303 <<
"In set:" << setI <<
" old face labels:"
304 << allFaceSets[setI] <<
" new face vertices:"
305 << setFaceVerts[i] <<
" are unmapped vertices!"
320 label setI = iter.key();
322 const labelList& setFaces = allFaceSets[setI];
323 const faceList& setFaceVerts = allFaceSetsFaces[setI];
325 label newMasterI = map().reverseFaceMap()[setFaces[0]];
329 label own = mesh.
faceOwner()[newMasterI];
331 bool zoneFlip =
false;
340 Pout<<
"Restoring new master face " << newMasterI
341 <<
" to vertices " << setFaceVerts[0] <<
endl;
362 for (label i = 1; i < setFaces.
size(); i++)
364 Pout<<
"Restoring removed face " << setFaces[i]
365 <<
" with vertices " << setFaceVerts[i] <<
endl;
387 map = meshMod.changeMesh(mesh,
false,
true);
393 if (map().hasMotionPoints())
406 Info<<
"No faces merged ..." <<
endl;
415 label mergeEdges(
const scalar minCos,
polyMesh& mesh)
417 Info<<
"Merging all points on surface that" <<
nl
418 <<
"- are used by only two boundary faces and" <<
nl
419 <<
"- make an angle with a cosine of more than " << minCos
427 label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
431 Info<<
"Removing " << nRemove
432 <<
" straight edge points ..." <<
endl;
437 pointRemover.setRefinement(pointCanBeDeleted, meshMod);
446 if (map().hasMotionPoints())
458 Info<<
"No straight edges simplified and no points removed ..." <<
endl;
467 int main(
int argc,
char *argv[])
484 scalar concaveAngle = defaultConcaveAngle;
492 Info<<
"Merging all faces of a cell" <<
nl
493 <<
" - which are on the same patch" <<
nl
494 <<
" - which make an angle < " << featureAngle <<
" degrees"
496 <<
" (cos:" << minCos <<
')' <<
nl
497 <<
" - even when resulting face becomes concave by more than "
498 << concaveAngle <<
" degrees" <<
nl
499 <<
" (sin:" << concaveSin <<
')' <<
nl
508 label nChanged = mergePatchFaces
520 Info<<
"Merging all 'loose' points on surface edges"
521 <<
", regardless of the angle they make." <<
endl;
524 nChanged += mergeEdges(-1, mesh);
528 nChanged += mergeEdges(minCos, mesh);