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"
92  #include INCLUDE_FILE(CREATE_MESH)
93 
94  #ifndef NO_CONTROL
95  #include INCLUDE_FILE(CREATE_CONTROL)
96  #endif
97 
98  forAll(timeDirs, timei)
99  {
100  runTime.setTime(timeDirs[timei], timei);
101 
102  Info<< "Time = " << runTime.userTimeName() << endl;
103 
104  mesh.readUpdate();
105 
107 
108  try
109  {
110  #include INCLUDE_FILE(CREATE_FIELDS)
111 
112  #ifdef CREATE_FIELDS_2
113  #include INCLUDE_FILE(CREATE_FIELDS_2)
114  #endif
115 
116  #ifdef CREATE_FIELDS_3
117  #include INCLUDE_FILE(CREATE_FIELDS_3)
118  #endif
119 
120  // Externally stored dictionary for functionObjectList
121  // if not constructed from runTime
122  dictionary functionsControlDict("controlDict");
123 
124  // Construct functionObjectList
125  autoPtr<functionObjectList> functionsPtr
126  (
128  (
129  args,
130  runTime,
131  functionsControlDict
132  )
133  );
134 
135  functionsPtr->execute();
136  }
137  catch (IOerror& err)
138  {
139  Warning<< err << endl;
140  }
141 
142  // Clear the objects owned by the mesh
143  mesh.objectRegistry::clear();
144 
145  Info<< endl;
146  }
147 
148  Info<< "End\n" << endl;
149 
150  return 0;
151 }
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #undef INCLUDE_FILE
157 #undef INCLUDE_FILE2
158 
159 #undef CREATE_MESH
160 #undef CREATE_FIELDS
161 #undef CREATE_CONTROL
162 
163 // ************************************************************************* //
#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:413
messageStream Info
IOerror FatalIOError
static const char nl
Definition: Ostream.H:260
messageStream Warning
Foam::argList args(argc, argv)