1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Reads an OpenFOAM mesh and writes a pro-STAR (v4) bnd/cel/vrt format.
32 - foamToStarMesh [OPTION] \n
33 Reads an OpenFOAM mesh and writes a pro-STAR (v4) bnd/cel/vrt format.
36 Suppress writing the @c .bnd file
38 @param -scale \<factor\>\n
39 Specify an alternative geometry scaling factor.
40 The default is @b 1000 (scale @em [m] to @em [mm]).
43 Extract the surface of the volume mesh only.
44 This can be useful, for example, for surface morphing in an external
48 Extract a triangulated surface.
49 The @b -surface options is implicitly selected.
53 The cellTable information available in the files
54 @c constant/cellTable and @c constant/polyMesh/cellTableId
55 will be used if available. Otherwise the cellZones are used when
56 creating the cellTable information.
59 Foam::cellTable, Foam::meshWriter and Foam::meshWriters::STARCD
61 \*---------------------------------------------------------------------------*/
64 #include "timeSelector.H"
67 #include "STARCDMeshWriter.H"
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 int main(int argc, char *argv[])
76 argList::noParallel();
77 timeSelector::addOptions();
79 argList::validOptions.insert("scale", "scale");
80 argList::validOptions.insert("noBnd", "");
81 argList::validOptions.insert("tri", "");
82 argList::validOptions.insert("surface", "");
84 # include "setRootCase.H"
85 # include "createTime.H"
87 instantList timeDirs = timeSelector::select0(runTime, args);
89 bool surfaceOnly = false;
90 if (args.optionFound("surface") || args.optionFound("tri"))
95 fileName exportName = meshWriter::defaultMeshName;
98 exportName = meshWriter::defaultSurfaceName;
101 if (args.optionFound("case"))
103 exportName += '-' + args.globalCaseName();
106 // default: rescale from [m] to [mm]
107 scalar scaleFactor = 1000;
108 if (args.optionReadIfPresent("scale", scaleFactor))
110 if (scaleFactor <= 0)
116 # include "createPolyMesh.H"
119 forAll(timeDirs, timeI)
121 runTime.setTime(timeDirs[timeI], timeI);
123 # include "getTimeIndex.H"
125 polyMesh::readUpdateState state = mesh.readUpdate();
127 if (!timeI || state != polyMesh::UNCHANGED)
129 meshWriters::STARCD writer(mesh, scaleFactor);
131 if (args.optionFound("noBnd"))
136 fileName meshName(exportName);
137 if (state != polyMesh::UNCHANGED)
139 meshName += '_' + runTime.timeName();
144 if (args.optionFound("tri"))
146 writer.writeSurface(meshName, true);
150 writer.writeSurface(meshName);
155 writer.write(meshName);
162 Info<< "End\n" << endl;
167 // ************************************************************************* //