1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
16 cfMesh is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
25 Reads the specified surface and writes it in the fms format.
27 \*---------------------------------------------------------------------------*/
33 #include "triSurfaceChecks.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 int main(int argc, char *argv[])
42 argList::noParallel();
43 argList::validArgs.clear();
44 argList::validArgs.append("input surface file");
45 argList args(argc, argv);
47 const fileName inFileName(args.args()[1]);
49 triSurf surf(inFileName);
54 triSurfaceChecks::calculateBoundingBox(surf, bb);
55 Info << "\nNumber of points " << surf.nPoints() << endl;
56 Info << "Number of triangles " << surf.size() << endl;
57 Info << "Number of patches " << surf.patches().size() << endl;
58 Info << "Number of feature edges " << surf.nFeatureEdges() << endl;
59 Info << "Bounding box " << bb << nl << nl << endl;
61 const scalar distTol = SMALL * bb.mag();
63 //- calculate manifolds
64 const label nManifolds = triSurfaceChecks::checkSurfaceManifolds(surf);
69 Info << "\nSurface mesh consists of " << nManifolds
70 << " manifolds!!" << endl;
71 Info << "You cannot mesh geometries consisting of more than"
72 << " one domain, and it must not contain baffles"
73 << " in the domain which shall be meshed." << endl;
77 Info << "\nSurface mesh consists of a single manifold." << endl;
80 //- find open boundary edges
81 if( triSurfaceChecks::checkForHoles(surf) )
85 Info << "\nSurface mesh has open boundaries!!" << endl;
86 Info << "This indicates that there may be some holes in the surface"
87 << " mesh. Holes in the mesh must be smaller than the specified"
88 << " cell size at this location. In addition, please avoid"
89 << " using the automatic refinement procedure."
90 << " Please avoid using the minCellSize option." << endl;
94 Info << "No open edges found in the surface mesh." << endl;
97 //- find non-manifold edges
98 if( triSurfaceChecks::checkForNonManifoldEdges(surf) )
102 Info << "\nSurface mesh has non-manifold edges!!" << endl;
103 Info << "This indicates that the surface mesh consists of multiple"
104 << " domains and/or baffles. Please make sure that they are not"
105 << " in the domain which shall be meshed." << endl;
109 Info << "Surface does not have any non-manifold edges." << endl;
112 //- check the number of disconnected parts
113 if( triSurfaceChecks::checkDisconnectedParts(surf) > 1 )
117 Info << "\nSurface mesh consists of disconnected parts!!" << endl;
118 Info << "This is not a problem if there exists a region surrounding"
119 << " all other regions! In other case, the mesher will generate"
120 << " the mesh in the domains with most cells." << endl;
124 Info << "Surface mesh consists of a single region." << endl;
127 //- find triangles with small angles
128 if( triSurfaceChecks::checkAngles(surf, "smallAngles", 1.0) )
132 Info << "\nSurface mesh has some bad-quality triangles with"
133 << " angles smaller than 1.0 deg!!" << endl;
134 Info << "This may cause problems to the automatic refinement"
135 << " procedure. Please avoid using the minCellSize option."
140 Info << "No sliver triangles found." << endl;
143 //- find self-intersections in the surface mesh
146 triSurfaceChecks::checkSelfIntersections
156 Info << "\nFound self-intersecting parts in the surface mesh!!" << endl;
157 Info << "This causes problems to the automatic refinement procedure"
158 << " Please avoid using the minCellSize option."
159 << " It can also cause problems to the boundary layer"
160 << " generation procedure." << endl;
164 Info << "No self-intersections found." << endl;
167 //- find overlaps in the surface mesh
170 triSurfaceChecks::checkOverlaps
181 Info << "\nFound overlapping parts in the surface mesh!!" << endl;
182 Info << "This causes problems to the automatic refinement procedure."
183 << " Please avoid using the minCellSize option." << endl;
186 //- check for existence of collocated points
189 triSurfaceChecks::checkCollocatedPoints
199 Info << "\nFound collocated points in the surface mesh!!" << endl;
200 Info << "This causes problems to the automatic refinement procedure."
201 << " Please avoid using the minCellSize option." << endl;
208 Info << "\nFound " << nFailed
209 << " checks indicating potential problems." << endl;
210 Info << "However, it does not mean that you cannot generate"
211 << " a valid mesh.\n" << endl;
213 surf.writeSurface(inFileName);
217 Info << "\nSurface passes all checks.\n" << endl;
220 Info << "End\n" << endl;
226 // ************************************************************************* //