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 | 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 Application
25  foamToGMV
26 
27 Description
28  Translates foam output to GMV readable files.
29 
30  A free post-processor with available binaries from
31  http://www-xdiv.lanl.gov/XCM/gmv/
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #include "fvCFD.H"
36 #include "OFstream.H"
37 #include "instantList.H"
38 #include "IOobjectList.H"
39 #include "itoa.H"
40 #include "Cloud.H"
41 #include "passiveParticle.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 
46 int main(int argc, char *argv[])
47 {
48  const label nTypes = 4;
49  const word fieldTypes[] =
50  {
51  "volScalarField",
52  "volVectorField",
53  "surfaceScalarField",
54  cloud::prefix
55  };
56 
57  #include "setRootCase.H"
58 
59  #include "createTime.H"
60  #include "createMesh.H"
61 
63 
64  // get the available time-steps
65  instantList TimeList = runTime.times();
66  Info<< TimeList << endl;
67  label nTimes = TimeList.size();
68 
69  for (label n=1; n < nTimes; n++)
70  {
71  if (TimeList[n].value() > startTime)
72  {
73  Info<< "Time = " << TimeList[n].value() << nl;
74 
75  // Set Time
76  runTime.setTime(TimeList[n], n);
77  word CurTime = runTime.timeName();
78 
79  IOobjectList objects(mesh, runTime.timeName());
80 
81  #include "moveMesh.H"
82 
83  // set the filename of the GMV file
84  fileName gmvFileName = "plotGMV." + itoa(n);
85  OFstream gmvFile(args.rootPath()/args.caseName()/gmvFileName);
86 
87  #include "gmvOutputHeader.H"
88  #include "gmvOutput.H"
89  #include "gmvOutputTail.H"
90  }
91  }
92 
93  Info<< "\nEnd\n" << endl;
94 
95  return 0;
96 }
97 
98 
99 // ************************************************************************* //
100 
List< instant > instantList
List of instants.
Definition: instantList.H:42
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word itoa(const label n)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
const fileName & rootPath() const
Return root path.
Definition: argListI.H:36
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:42
dynamicFvMesh & mesh
static const char nl
Definition: Ostream.H:262
messageStream Info
label n
Foam::argList args(argc, argv)
Foam::label startTime