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-2022 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_MESH
42  #define CREATE_MESH createMesh.H
43 #endif
44 
45 #ifndef CREATE_FIELDS
46  #define CREATE_FIELDS createFields.H
47 #endif
48 
49 #ifndef CREATE_CONTROL
50  #define CREATE_CONTROL createControl.H
51 #endif
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 #define INCLUDE_FILE(X) INCLUDE_FILE2(X)
56 #define INCLUDE_FILE2(X) #X
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
61 (
62  argList::postProcessOptionName,
63  "Execute functionObjects only"
64 );
65 
66 if (argList::postProcess(argc, argv))
67 {
69  #include "addRegionOption.H"
71 
72  // Set functionObject post-processing mode
73  functionObject::postProcess = true;
74 
75  #include "setRootCase.H"
76 
77  if (args.optionFound("list"))
78  {
79  Info<< nl
80  << "Available configured functionObjects:"
81  << functionObjectList::list()
82  << endl;
83  return 0;
84  }
85 
86  #include "createTime.H"
88  #include INCLUDE_FILE(CREATE_MESH)
89 
90  #ifndef NO_CONTROL
91  #include INCLUDE_FILE(CREATE_CONTROL)
92  #endif
93 
94  forAll(timeDirs, timei)
95  {
96  runTime.setTime(timeDirs[timei], timei);
97 
98  Info<< "Time = " << runTime.userTimeName() << endl;
99 
100  mesh.readUpdate();
101 
103 
104  try
105  {
106  #include INCLUDE_FILE(CREATE_FIELDS)
107 
108  #ifdef CREATE_FIELDS_2
109  #include INCLUDE_FILE(CREATE_FIELDS_2)
110  #endif
111 
112  #ifdef CREATE_FIELDS_3
113  #include INCLUDE_FILE(CREATE_FIELDS_3)
114  #endif
115 
116  // Externally stored dictionary for functionObjectList
117  // if not constructed from runTime
118  dictionary functionsControlDict("controlDict");
119 
120  // Construct functionObjectList
121  autoPtr<functionObjectList> functionsPtr
122  (
124  (
125  args,
126  runTime,
127  functionsControlDict
128  )
129  );
130 
131  functionsPtr->execute();
132  }
133  catch (IOerror& err)
134  {
135  Warning<< err << endl;
136  }
137 
138  // Clear the objects owned by the mesh
139  mesh.objectRegistry::clear();
140 
141  Info<< endl;
142  }
143 
144  Info<< "End\n" << endl;
145 
146  return 0;
147 }
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #undef INCLUDE_FILE
153 #undef INCLUDE_FILE2
154 
155 #undef CREATE_MESH
156 #undef CREATE_FIELDS
157 #undef CREATE_CONTROL
158 
159 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
fvMesh & mesh
static instantList timeDirs
Definition: globalFoam.H:44
void throwExceptions()
Definition: error.H:115
static const char nl
Definition: Ostream.H:260
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:118
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