/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 3.2
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
foam-extend is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see .
Description
Converts neutral file format as written by Netgen v4.4.
Example:
9
1.000000 1.000000 1.000000
0.000000 1.000000 1.000000
0.000000 0.000000 1.000000
1.000000 0.000000 1.000000
0.000000 1.000000 0.000000
1.000000 1.000000 0.000000
1.000000 0.000000 0.000000
0.000000 0.000000 0.000000
0.500000 0.500000 0.500000
12
1 7 8 9 3
1 5 9 6 8
1 5 9 2 1
1 4 9 7 6
1 7 8 6 9
1 4 6 1 9
1 5 9 8 2
1 4 1 2 9
1 1 6 5 9
1 2 3 4 9
1 8 9 3 2
1 4 9 3 7
12
1 1 2 4
1 3 4 2
2 5 6 8
2 7 8 6
3 1 4 6
3 7 6 4
5 2 1 5
5 6 5 1
5 3 2 8
5 5 8 2
6 4 3 7
6 8 7 3
NOTE:
- reverse order of boundary faces using geometric test.
(not very space efficient)
- order of tet vertices only tested on one file.
- all patch/cell/vertex numbers offset by one.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "objectRegistry.H"
#include "foamTime.H"
#include "polyMesh.H"
#include "IFstream.H"
#include "polyPatch.H"
#include "cellModeller.H"
#include "triFace.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::validArgs.append("Neutral file");
# include "setRootCase.H"
# include "createTime.H"
fileName neuFile(args.additionalArgs()[0]);
IFstream str(neuFile);
//
// Read nodes.
//
label nNodes(readLabel(str));
Info<< "nNodes:" << nNodes << endl;
pointField points(nNodes);
forAll(points, pointI)
{
scalar x,y,z;
str >> x >> y >> z;
points[pointI] = point(x, y, z);
}
label nTets(readLabel(str));
Info<< "nTets:" << nTets << endl;
const cellModel& tet = *(cellModeller::lookup("tet"));
cellShapeList cells(nTets);
labelList tetPoints(4);
forAll(cells, cellI)
{
label domain(readLabel(str));
if (domain != 1)
{
WarningIn(args.executable())
<< "Cannot handle multiple domains"
<< nl << "Ignoring domain " << domain << " setting on line "
<< str.lineNumber() << endl;
}
tetPoints[1] = readLabel(str) - 1;
tetPoints[0] = readLabel(str) - 1;
tetPoints[2] = readLabel(str) - 1;
tetPoints[3] = readLabel(str) - 1;
cells[cellI] = cellShape(tet, tetPoints);
}
label nFaces(readLabel(str));
Info<< "nFaces:" << nFaces << endl;
// Unsorted boundary faces
faceList boundaryFaces(nFaces);
// For each boundary faces the Foam patchID
labelList boundaryPatch(nFaces, -1);
// Max patch.
label maxPatch = 0;
// Boundary faces as three vertices
HashTable