1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Converts .msh file generated by the Adventure system.
27 Note: the .msh format does not contain any boundary information. It is
28 purely a description of the internal mesh.
30 Can read both linear-tet format (i.e. 4 verts per tet) and linear-hex
31 format (8 verts per hex) (if provided with the -hex option)
32 (Note: will bomb out if not supplied with the correct option for the
35 Not extensively tested.
37 \*---------------------------------------------------------------------------*/
40 #include "objectRegistry.H"
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.optionFound("hex");
67 fileName mshFile(args.additionalArgs()[0]);
68 IFstream mshStream(mshFile);
75 Info<< "Trying to read " << nCells << " hexes." << endl << endl;
79 Info<< "Trying to read " << nCells << " tets." << endl << endl;
82 cellShapeList cells(nCells);
84 const cellModel& tet = *(cellModeller::lookup("tet"));
85 const cellModel& hex = *(cellModeller::lookup("hex"));
87 labelList tetPoints(4);
88 labelList hexPoints(8);
92 for (label cellI = 0; cellI < nCells; cellI++)
94 for (label cp = 0; cp < 8; cp++)
96 mshStream >> hexPoints[cp];
98 cells[cellI] = cellShape(hex, hexPoints);
103 for (label cellI = 0; cellI < nCells; cellI++)
105 for (label cp = 0; cp < 4; cp++)
107 mshStream >> tetPoints[cp];
109 cells[cellI] = cellShape(tet, tetPoints);
116 mshStream >> nPoints;
118 Info<< "Trying to read " << nPoints << " points." << endl << endl;
120 pointField points(nPoints);
123 for (label pointI = 0; pointI < nPoints; pointI++)
127 mshStream >> x >> y >> z;
129 points[pointI] = point(x, y, z);
137 polyMesh::defaultRegion,
151 Info<< "Writing mesh ..." << endl;
156 Info<< "End\n" << endl;
162 // ************************************************************************* //