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 Miscellaneous information about surface meshes
31 - surfaceMeshInfo surfaceFile [OPTION]
34 Report area for each face.
36 \param -scale \<scale\> \n
37 Specify a scaling factor when reading files.
40 Write output in XML format.
43 The filename extensions are used to determine the file format type.
45 The XML-like output can be useful for extraction with other tools,
46 but either output format can be easily extracted with a simple sed
49 surfaceMeshInfo surfaceFile -areas | \
50 sed -ne '/areas/,/:/{ /:/!p }'
52 surfaceMeshInfo surfaceFile -areas -xml | \
53 sed -ne '/<areas/,/</{ /</!p }'
56 \*---------------------------------------------------------------------------*/
59 #include "timeSelector.H"
62 #include "UnsortedMeshedSurfaces.H"
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 int main(int argc, char *argv[])
74 "information about surface meshes"
78 argList::noParallel();
79 argList::validArgs.append("surfaceFile");
85 "geometry scaling factor - default is 1"
87 argList::addBoolOption
90 "display area of each face"
92 argList::addBoolOption
95 "write output in XML format"
98 argList args(argc, argv);
99 Time runTime(args.rootPath(), args.caseName());
101 const fileName importName = args[1];
103 // check that reading is supported
104 if (!UnsortedMeshedSurface<face>::canRead(importName, true))
109 const bool writeXML = args.optionFound("xml");
110 const bool writeAreas = args.optionFound("areas");
113 // use UnsortedMeshedSurface, not MeshedSurface to maintain ordering
114 UnsortedMeshedSurface<face> surf(importName);
117 if (args.optionReadIfPresent("scale", scaling) && scaling > 0)
119 Info<< " -scale " << scaling << endl;
120 surf.scalePoints(scaling);
123 scalar areaTotal = 0;
127 Info<<"<?xml version='1.0' encoding='utf-8'?>" << nl
128 <<"<surfaceMeshInfo>" << nl
129 << "<npoints>" << surf.nPoints() << "</npoints>" << nl
130 << "<nfaces>" << surf.size() << "</nfaces>" << nl;
134 Info<<"<areas size='" << surf.size() << "'>" << nl;
139 Info<< "nPoints : " << surf.nPoints() << nl
140 << "nFaces : " << surf.size() << nl;
144 Info<< "areas : " << nl;
150 const scalar fArea(surf[faceI].mag(surf.points()));
163 Info<<"</areas>" << nl;
166 Info<< "<area>" << areaTotal << "</area>" << nl
167 << "</surfaceMeshInfo>" << nl;
171 Info<< "area : " << areaTotal << nl;
177 // ************************************************************************* //