foamToGMV.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-2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Application
27 foamToGMV
28
29Group
30 grpPostProcessingUtilities
31
32Description
33 Translate OpenFOAM output to GMV readable files.
34
35 A free post-processor with available binaries from
36 http://www-xdiv.lanl.gov/XCM/gmv/
37
38\*---------------------------------------------------------------------------*/
39
40#include "fvCFD.H"
41#include "OFstream.H"
42#include "instantList.H"
43#include "IOobjectList.H"
44#include "itoa.H"
45#include "Cloud.H"
46#include "passiveParticle.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50int main(int argc, char *argv[])
51{
52 argList::addNote
53 (
54 "Translate OpenFOAM output to GMV readable files"
55 );
56
57 const wordList fieldTypes
58 ({
59 "volScalarField",
60 "volVectorField",
61 "surfaceScalarField",
62 cloud::prefix
63 });
64
65 #include "setRootCase.H"
66 #include "createTime.H"
67 #include "createNamedMesh.H"
69
70 // get the available time-steps
71 instantList TimeList = runTime.times();
72 Info<< TimeList << endl;
73 label nTimes = TimeList.size();
74
75 for (label n=1; n < nTimes; n++)
76 {
77 if (TimeList[n].value() > startTime)
78 {
79 Info<< "Time = " << TimeList[n].value() << nl;
80
81 // Set Time
82 runTime.setTime(TimeList[n], n);
83 word CurTime = runTime.timeName();
84
85 IOobjectList objects(mesh, runTime.timeName());
86
87 #include "moveMesh.H"
88
89 // set the filename of the GMV file
90 fileName gmvFileName = "plotGMV." + itoa(n);
91 OFstream gmvFile(args.rootPath()/args.caseName()/gmvFileName);
92
93 #include "gmvOutputHeader.H"
94 #include "gmvOutput.H"
95 #include "gmvOutputTail.H"
96 }
97 }
98
99 Info<< "\nEnd\n" << endl;
100
101 return 0;
102}
103
104
105// ************************************************************************* //
label n
Foam::label startTime
const fileName & rootPath() const noexcept
Return root path.
Definition: argListI.H:63
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:69
dynamicFvMesh & mesh
engineTime & runTime
Required Variables.
List< word > wordList
A List of words.
Definition: fileName.H:63
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
List< instant > instantList
List of instants.
Definition: instantList.H:47
word itoa(const label n)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)