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-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 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:"
82  (
83  functionEntries::includeFuncEntry::functionObjectDictPath
84  )
85  << endl;
86  return 0;
87  }
88 
89  #include "createTime.H"
91  #include INCLUDE_FILE(CREATE_MESH)
92 
93  #ifndef NO_CONTROL
94  #include INCLUDE_FILE(CREATE_CONTROL)
95  #endif
96 
97  forAll(timeDirs, timei)
98  {
99  runTime.setTime(timeDirs[timei], timei);
100 
101  Info<< "Time = " << runTime.userTimeName() << endl;
102 
103  mesh.readUpdate();
104 
106 
107  try
108  {
109  #include INCLUDE_FILE(CREATE_FIELDS)
110 
111  #ifdef CREATE_FIELDS_2
112  #include INCLUDE_FILE(CREATE_FIELDS_2)
113  #endif
114 
115  #ifdef CREATE_FIELDS_3
116  #include INCLUDE_FILE(CREATE_FIELDS_3)
117  #endif
118 
119  // Externally stored dictionary for functionObjectList
120  // if not constructed from runTime
121  dictionary functionsControlDict("controlDict");
122 
123  // Construct functionObjectList
124  autoPtr<functionObjectList> functionsPtr
125  (
127  (
128  args,
129  runTime,
130  functionsControlDict
131  )
132  );
133 
134  functionsPtr->execute();
135  }
136  catch (IOerror& err)
137  {
138  Warning<< err << endl;
139  }
140 
141  // Clear the objects owned by the mesh
142  mesh.objectRegistry::clear();
143 
144  Info<< endl;
145  }
146 
147  Info<< "End\n" << endl;
148 
149  return 0;
150 }
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #undef INCLUDE_FILE
156 #undef INCLUDE_FILE2
157 
158 #undef CREATE_MESH
159 #undef CREATE_FIELDS
160 #undef CREATE_CONTROL
161 
162 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:118
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:114
void throwExceptions()
Definition: error.H:115
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:252
static instantList timeDirs
Definition: globalFoam.H:44
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
wordList listAllConfigFiles(const fileName &configFilesPath)
Return the list of configuration files in.
Definition: dictionaryIO.C:406
messageStream Info
IOerror FatalIOError
static const char nl
Definition: Ostream.H:260
messageStream Warning
Foam::argList args(argc, argv)