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/>.
25 Writes regions of triSurface to separate files.
27 \*---------------------------------------------------------------------------*/
30 #include "triSurface.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 int main(int argc, char *argv[])
41 "write surface mesh regions to separate files"
44 argList::noParallel();
45 argList::validArgs.append("input surfaceFile");
46 argList args(argc, argv);
48 const fileName surfName = args[1];
50 Info<< "Reading surf from " << surfName << " ..." << nl << endl;
52 fileName surfBase = surfName.lessExt();
54 word extension = surfName.ext();
56 triSurface surf(surfName);
58 Info<< "Writing regions to separate files ..."
62 const geometricSurfacePatchList& patches = surf.patches();
64 forAll(patches, patchI)
66 const geometricSurfacePatch& pp = patches[patchI];
68 word patchName = pp.name();
70 if (patchName.empty())
72 patchName = "patch" + Foam::name(patchI);
75 fileName outFile(surfBase + '_' + patchName + '.' + extension);
77 Info<< " Writing patch " << patchName << " to file " << outFile
81 // Collect faces of region
82 boolList includeMap(surf.size(), false);
86 const labelledTri& f = surf[faceI];
88 if (f.region() == patchI)
90 includeMap[faceI] = true;
108 subSurf.write(outFile);
111 Info<< "End\n" << endl;
117 // ************************************************************************* //