vtkUnstructuredToFoam.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Application
28 vtkUnstructuredToFoam
29
30Group
31 grpMeshConversionUtilities
32
33Description
34 Convert legacy VTK file (ascii) containing an unstructured grid
35 to an OpenFOAM mesh without boundary information.
36
37Note
38 The .vtk format does not contain any boundary information.
39 It is purely a description of the internal mesh.
40 Not extensively tested.
41
42\*---------------------------------------------------------------------------*/
43
44#include "argList.H"
45#include "Time.H"
46#include "polyMesh.H"
47#include "IFstream.H"
49
50using namespace Foam;
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54
55int main(int argc, char *argv[])
56{
57 argList::addNote
58 (
59 "Convert legacy VTK file (ascii) containing an unstructured grid"
60 " to an OpenFOAM mesh without boundary information"
61 );
62
63 argList::noParallel();
64 argList::addArgument("vtk-file", "The input legacy ascii vtk file");
65
66 #include "setRootCase.H"
67 #include "createTime.H"
68
69 IFstream mshStream(args.get<fileName>(1));
70
71 vtkUnstructuredReader reader(runTime, mshStream);
72
74 (
76 (
77 polyMesh::defaultRegion,
78 runTime.constant(),
80 ),
81 std::move(reader.points()),
82 reader.cells(),
84 wordList(),
85 wordList(),
86 "defaultFaces",
87 polyPatch::typeName,
88 wordList()
89 );
90
91 // Set the precision of the points data to 10
92 IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
93
94 Info<< "Writing mesh ..." << endl;
95
96 mesh.removeFiles();
97 mesh.write();
98
99 Info<< "End\n" << endl;
100
101 return 0;
102}
103
104
105// ************************************************************************* //
Y[inertIndex] max(0.0)
Input from file stream, using an ISstream.
Definition: IFstream.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:278
A class for handling file names.
Definition: fileName.H:76
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Reader for vtk UNSTRUCTURED_GRID legacy files. Supports single CELLS, POINTS etc. entry only.
dynamicFvMesh & mesh
engineTime & runTime
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
Foam::argList args(argc, argv)