postProcess.H
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) 2016-2018 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 Global
25  postProcess
26 
27 Description
28  Execute application functionObjects to post-process existing results.
29 
30  If the "dict" argument is specified the functionObjectList is constructed
31  from that dictionary otherwise the functionObjectList is constructed from
32  the "functions" sub-dictionary of "system/controlDict"
33 
34  Multiple time-steps may be processed and the standard utility time
35  controls are provided.
36 
37 \*---------------------------------------------------------------------------*/
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 #ifndef CREATE_TIME
42  #define CREATE_TIME createTime.H
43 #endif
44 
45 #ifndef CREATE_MESH
46  #define CREATE_MESH createMesh.H
47 #endif
48 
49 #ifndef CREATE_FIELDS
50  #define CREATE_FIELDS createFields.H
51 #endif
52 
53 #ifndef CREATE_CONTROL
54  #define CREATE_CONTROL createControl.H
55 #endif
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 #define INCLUDE_FILE(X) INCLUDE_FILE2(X)
60 #define INCLUDE_FILE2(X) #X
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
65 (
66  argList::postProcessOptionName,
67  "Execute functionObjects only"
68 );
69 
70 if (argList::postProcess(argc, argv))
71 {
73  #include "addRegionOption.H"
75 
76  // Set functionObject post-processing mode
77  functionObject::postProcess = true;
78 
79  #include "setRootCase.H"
80 
81  if (args.optionFound("list"))
82  {
83  functionObjectList::list();
84  return 0;
85  }
86 
87  #include INCLUDE_FILE(CREATE_TIME)
89  #include INCLUDE_FILE(CREATE_MESH)
90 
91  #ifndef NO_CONTROL
92  #include INCLUDE_FILE(CREATE_CONTROL)
93  #endif
94 
95  forAll(timeDirs, timei)
96  {
97  runTime.setTime(timeDirs[timei], timei);
98 
99  Info<< "Time = " << runTime.timeName() << endl;
100 
102 
103  try
104  {
105  #include INCLUDE_FILE(CREATE_FIELDS)
106 
107  #ifdef CREATE_FIELDS_2
108  #include INCLUDE_FILE(CREATE_FIELDS_2)
109  #endif
110 
111  #ifdef CREATE_FIELDS_3
112  #include INCLUDE_FILE(CREATE_FIELDS_3)
113  #endif
114 
115  // Externally stored dictionary for functionObjectList
116  // if not constructed from runTime
117  dictionary functionsControlDict("controlDict");
118 
119  HashSet<word> selectedFields;
120 
121  // Construct functionObjectList
122  autoPtr<functionObjectList> functionsPtr
123  (
125  (
126  args,
127  runTime,
128  functionsControlDict,
129  selectedFields
130  )
131  );
132 
133  functionsPtr->execute();
134  }
135  catch (IOerror& err)
136  {
137  Warning<< err << endl;
138  }
139 
140  // Clear the objects owned by the mesh
141  mesh.objectRegistry::clear();
142 
143  Info<< endl;
144  }
145 
146  Info<< "End\n" << endl;
147 
148  return 0;
149 }
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #undef INCLUDE_FILE
155 #undef INCLUDE_FILE2
156 
157 #undef CREATE_MESH
158 #undef CREATE_FIELDS
159 #undef CREATE_CONTROL
160 
161 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
dynamicFvMesh & mesh
static instantList timeDirs
Definition: globalFoam.H:44
void throwExceptions()
Definition: error.H:122
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
Definition: timeSelector.C:252
messageStream Warning
messageStream Info
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:117
Foam::argList args(argc, argv)
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
Definition: timeSelector.C:114
IOerror FatalIOError