foamToGMV.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 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 "argList.H"
36 #include "volFields.H"
37 #include "OFstream.H"
38 #include "instantList.H"
39 #include "IOobjectList.H"
40 #include "itoa.H"
41 #include "Cloud.H"
42 #include "passiveParticle.H"
43 
44 using namespace Foam;
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 
49 int main(int argc, char *argv[])
50 {
51  const label nTypes = 4;
52  const word fieldTypes[] =
53  {
54  "volScalarField",
55  "volVectorField",
56  "surfaceScalarField",
58  };
59 
60  #include "setRootCase.H"
61 
62  #include "createTime.H"
63  #include "createMeshNoChangers.H"
64 
66 
67  // get the available time-steps
68  instantList TimeList = runTime.times();
69  Info<< TimeList << endl;
70  label nTimes = TimeList.size();
71 
72  for (label n=1; n < nTimes; n++)
73  {
74  if (TimeList[n].value() > startTime)
75  {
76  Info<< "Time = " << TimeList[n].value() << nl;
77 
78  // Set Time
79  runTime.setTime(TimeList[n], n);
80  word CurTime = runTime.name();
81 
82  IOobjectList objects(mesh, runTime.name());
83 
84  #include "moveMesh.H"
85 
86  // set the filename of the GMV file
87  fileName gmvFileName = "plotGMV." + itoa(n);
88  OFstream gmvFile(args.rootPath()/args.caseName()/gmvFileName);
89 
90  #include "gmvOutputHeader.H"
91  #include "gmvOutput.H"
92  #include "gmvOutputTail.H"
93  }
94  }
95 
96  Info<< "\nEnd\n" << endl;
97 
98  return 0;
99 }
100 
101 
102 // ************************************************************************* //
label n
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:53
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Output to file stream.
Definition: OFstream.H:86
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
Definition: argListI.H:48
const fileName & rootPath() const
Return root path.
Definition: argListI.H:42
static const word prefix
The prefix to local: lagrangian.
Definition: cloud.H:63
A class for handling file names.
Definition: fileName.H:82
A class for handling words, derived from string.
Definition: word.H:62
int main(int argc, char *argv[])
Definition: financialFoam.C:44
Namespace for OpenFOAM.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
word itoa(const label n)
static const char nl
Definition: Ostream.H:260
scalar startTime(conversionProperties.lookup< scalar >("startTime"))
objects
Foam::argList args(argc, argv)