postCalc.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  postCalc
26 
27 Description
28  Generic wrapper for calculating a quantity at each time
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "calc.H"
33 #include "timeSelector.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  void tryCalc(const argList& args, const Time& runTime, const fvMesh& mesh)
40  {
42 
43  try
44  {
45  calc(args, runTime, mesh);
46  }
47  catch(IOerror& err)
48  {
49  Warning<< err << endl;
50  }
51  }
52 }
53 
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 int main(int argc, char *argv[])
58 {
60  #include "addRegionOption.H"
62  (
63  "noWrite",
64  "suppress writing results"
65  );
66  #include "addDictOption.H"
67 
68  #include "setRootCase.H"
69  #include "createTime.H"
71  #include "createNamedMesh.H"
72 
73  forAll(timeDirs, timeI)
74  {
75  runTime.setTime(timeDirs[timeI], timeI);
76 
77  Foam::Info<< "Time = " << runTime.timeName() << Foam::endl;
78 
79  mesh.readUpdate();
80 
81  Foam::tryCalc(args, runTime, mesh);
82 
84  }
85 
86  return 0;
87 }
88 
89 
90 // ************************************************************************* //
void calc(const argList &args, const Time &runTime, const fvMesh &mesh)
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Function prototype for all simple post-processing functions e.g. calcDivPhi, calcMagU etc...
void throwExceptions()
Definition: error.H:122
messageStream Info
dynamicFvMesh & mesh
Report an I/O error.
Definition: error.H:196
Namespace for OpenFOAM.
messageStream Warning
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOerror FatalIOError
void tryCalc(const argList &args, const Time &runTime, const fvMesh &mesh)
Definition: postCalc.C:36
#define forAll(list, i)
Definition: UList.H:421
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:83
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:102
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
Definition: fvMesh.C:500
Foam::argList args(argc, argv)
static instantList timeDirs
Definition: globalFoam.H:44
int main(int argc, char *argv[])
Definition: postCalc.C:54
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
Definition: timeSelector.C:114
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
Definition: timeSelector.C:253