foamCalcApp.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  foamCalc
26 
27 Description
28  Generic wrapper for calculating a quantity at each time.
29 
30  Split into four phases:
31  1. Intialise
32  2. Pre-time calculation loop
33  3. Calculation loop
34  4. Post-calculation loop
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "timeSelector.H"
39 #include "calcType.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 int main(int argc, char *argv[])
44 {
46  #include "addRegionOption.H"
48  (
49  "noWrite",
50  "suppress writing results"
51  );
52  #include "addDictOption.H"
53 
54  if (argc < 2)
55  {
57  << "No utility has been supplied" << nl
58  << exit(FatalError);
59  }
60 
61  const word utilityName = argv[1];
62 
64  (
65  calcType::New(utilityName)
66  );
67 
68  utility().tryInit();
69 
70  #include "setRootCase.H"
71  #include "createTime.H"
73  #include "createNamedMesh.H"
74 
75  utility().tryPreCalc(args, runTime, mesh);
76 
77  forAll(timeDirs, timeI)
78  {
79  runTime.setTime(timeDirs[timeI], timeI);
80 
81  Foam::Info<< "Time = " << runTime.timeName() << Foam::endl;
82 
83  mesh.readUpdate();
84 
85  utility().tryCalc(args, runTime, mesh);
86 
88  }
89 
90  utility().tryPostCalc(args, runTime, mesh);
91 
92  Info<< "End\n" << endl;
93 
94  return 0;
95 }
96 
97 
98 // ************************************************************************* //
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::argList::addBoolOption
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:98
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
addDictOption.H
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
addRegionOption.H
main
int main(int argc, char *argv[])
Definition: postCalc.C:54
Foam::FatalError
error FatalError
createNamedMesh.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
calcType.H
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
setRootCase.H
timeDirs
static instantList timeDirs
Definition: globalFoam.H:44
Foam::timeSelector::addOptions
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
Definition: timeSelector.C:114
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
timeSelector.H
createTime.H
Foam::timeSelector::select0
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
Definition: timeSelector.C:253
args
Foam::argList args(argc, argv)