1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Patches surface according to feature angle. Like autoPatch.
30 \*---------------------------------------------------------------------------*/
33 #include "triSurface.H"
35 #include "surfaceFeatures.H"
36 #include "treeBoundBox.H"
37 #include "meshTools.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 int main(int argc, char *argv[])
48 argList::noParallel();
49 argList::validArgs.append("input surfaceFile");
50 argList::validArgs.append("output surfaceFile");
51 argList::validArgs.append("includedAngle [0..180]");
52 argList args(argc, argv);
54 const fileName inFileName = args[1];
55 const fileName outFileName = args[2];
56 const scalar includedAngle = args.argRead<scalar>(3);
58 Info<< "Surface : " << inFileName << nl << endl;
64 Info<< "Reading : " << inFileName << endl;
65 triSurface surf(inFileName);
67 Info<< "Read surface:" << endl;
68 surf.writeStats(Info);
73 // Construct features from surface&featureangle
74 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76 Info<< "Constructing feature set from included angle " << includedAngle
79 surfaceFeatures set(surf, includedAngle);
82 << "Feature set:" << nl
83 << " feature points : " << set.featurePoints().size() << nl
84 << " feature edges : " << set.featureEdges().size() << nl
86 << " region edges : " << set.nRegionEdges() << nl
87 << " external edges : " << set.nExternalEdges() << nl
88 << " internal edges : " << set.nInternalEdges() << nl
91 // Get per-edge status.
92 boolList borderEdge(surf.nEdges(), false);
93 forAll(set.featureEdges(), i)
95 borderEdge[set.featureEdges()[i]] = true;
98 labelList faceRegion(surf.size());
99 label nRegions = surf.markZones(borderEdge, faceRegion);
101 // Reregion triangles.
104 surf[i].region() = faceRegion[i];
107 // Create some patches
108 surf.patches().setSize(nRegions);
110 forAll(surf.patches(), patchI)
112 surf.patches()[patchI].name() = "patch" + Foam::name(patchI);
113 surf.patches()[patchI].geometricType() = "empty";
117 Info<< "Writing : " << outFileName << endl;
118 surf.write(outFileName, true);
120 Info<< "End\n" << endl;
126 // ************************************************************************* //