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 Reads an OpenFOAM mesh and writes the boundaries in a surface format.
31 - foamToSurface [OPTION] \n
32 Reads an OpenFOAM mesh and writes the boundaries in a surface format.
34 \param -scale \<factor\>\n
35 Specify an alternative geometry scaling factor.
36 Eg, use \b 1000 to scale \em [m] to \em [mm].
41 \*---------------------------------------------------------------------------*/
44 #include "timeSelector.H"
48 #include "MeshedSurfaces.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 int main(int argc, char *argv[])
57 argList::noParallel();
58 argList::validArgs.append("outputFile.ext");
59 timeSelector::addOptions();
65 "geometry scaling factor - default is 1"
67 argList::addBoolOption
73 # include "setRootCase.H"
75 fileName exportName = args[1];
77 scalar scaleFactor = 0;
78 args.optionReadIfPresent<scalar>("scale", scaleFactor);
79 const bool doTriangulate = args.optionFound("tri");
81 fileName exportBase = exportName.lessExt();
82 word exportExt = exportName.ext();
84 if (!meshedSurface::canWriteType(exportExt, true))
89 # include "createTime.H"
90 instantList timeDirs = timeSelector::select0(runTime, args);
91 # include "createPolyMesh.H"
93 forAll(timeDirs, timeI)
95 runTime.setTime(timeDirs[timeI], timeI);
96 # include "getTimeIndex.H"
98 polyMesh::readUpdateState state = mesh.readUpdate();
100 if (timeI == 0 || state != polyMesh::UNCHANGED)
102 if (state == polyMesh::UNCHANGED)
104 exportName = exportBase + "." + exportExt;
109 exportBase + '_' + runTime.timeName() + "." + exportExt;
112 meshedSurface surf(mesh.boundaryMesh());
113 surf.scalePoints(scaleFactor);
115 Info<< "writing " << exportName;
118 Info<< " triangulated";
122 if (scaleFactor <= 0)
124 Info<< " without scaling" << endl;
128 Info<< " with scaling " << scaleFactor << endl;
130 surf.write(exportName);
136 Info<< "End\n" << endl;
141 // ************************************************************************* //