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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Description
25  Converts ascii .vtk (legacy format) file generated by vtk/paraview.
26 
27  Note: the .vtk format does not contain any boundary information. It is
28  purely a description of the internal mesh.
29 
30  Not extensively tested.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #include "argList.H"
35 #include "Time.H"
36 #include "polyMesh.H"
37 #include "IFstream.H"
38 #include "vtkUnstructuredReader.H"
39 
40 using namespace Foam;
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 
45 int main(int argc, char *argv[])
46 {
48  argList::validArgs.append(".vtk ascii file");
49 
50  #include "setRootCase.H"
51  #include "createTime.H"
52 
53  IFstream mshStream(args[1]);
54 
55  vtkUnstructuredReader reader(runTime, mshStream);
56 
58  (
59  IOobject
60  (
62  runTime.constant(),
63  runTime
64  ),
65  xferMove(reader.points()),
66  reader.cells(),
67  faceListList(0),
68  wordList(0),
69  wordList(0),
70  "defaultFaces",
71  polyPatch::typeName,
72  wordList(0)
73  );
74 
75  Info<< "Writing mesh ..." << endl;
76 
77  mesh.write();
78 
79 
80  Info<< "End\n" << endl;
81 
82  return 0;
83 }
84 
85 
86 // ************************************************************************* //
List< faceList > faceListList
Definition: faceListFwd.H:45
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:306
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static void noParallel()
Remove the parallel options.
Definition: argList.C:146
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:154
Reader for vtk unstructured_grid legacy files. Supports single CELLS, POINTS etc. entry only...
dynamicFvMesh & mesh
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
Input from file stream.
Definition: IFstream.H:81
List< word > wordList
A List of words.
Definition: fileName.H:54
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
virtual bool write() const
Write mesh using IO settings from time.
Definition: fvMesh.C:870
Namespace for OpenFOAM.