1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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
26 Reads .msh format generated by the Adventure system.
28 Note: the .msh format does not contain any boundary information. It is
29 purely a description of the internal mesh.
31 Can read both linear-tet format (i.e. 4 verts per tet) and linear-hex
32 format (8 verts per hex) (if provided with the -hex option)
33 (Note: will bomb out if not supplied with the correct option for the
36 Not extensively tested.
38 \*---------------------------------------------------------------------------*/
44 #include "polyPatch.H"
46 #include "cellModeller.H"
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 int main(int argc, char *argv[])
58 argList::noParallel();
59 argList::validArgs.append(".msh file");
60 argList::validOptions.insert("hex", "");
62 # include "setRootCase.H"
63 # include "createTime.H"
65 bool readHex(args.options().found("hex"));
67 fileName mshFile(args.additionalArgs()[0]);
69 IFstream mshStream(mshFile);
77 Info<< "Trying to read " << nCells << " hexes." << endl << endl;
81 Info<< "Trying to read " << nCells << " tets." << endl << endl;
84 cellShapeList cells(nCells);
86 const cellModel& tet = *(cellModeller::lookup("tet"));
87 const cellModel& hex = *(cellModeller::lookup("hex"));
89 labelList tetPoints(4);
90 labelList hexPoints(8);
94 for (label cellI = 0; cellI < nCells; cellI++)
96 for (label cp = 0; cp < 8; cp++)
98 mshStream >> hexPoints[cp];
100 cells[cellI] = cellShape(hex, hexPoints);
105 for (label cellI = 0; cellI < nCells; cellI++)
107 for (label cp = 0; cp < 4; cp++)
109 mshStream >> tetPoints[cp];
111 cells[cellI] = cellShape(tet, tetPoints);
118 mshStream >> nPoints;
120 Info<< "Trying to read " << nPoints << " points." << endl << endl;
122 pointField points(nPoints);
125 for (label pointI = 0; pointI < nPoints; pointI++)
129 mshStream >> x >> y >> z;
131 points[pointI] = point(x, y, z);
139 polyMesh::defaultRegion,
153 Info<< "Writing mesh ..." << endl;
158 Info<< "End\n" << endl;
164 // ************************************************************************* //