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-2024 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  // Construct functionObjectList
121  autoPtr<functionObjectList> functionsPtr
122  (
123  functionObjectList::New(args, runTime)
124  );
125 
126  functionsPtr->execute();
127  }
128  catch (IOerror& err)
129  {
130  Warning<< err << endl;
131  }
132 
133  // Clear the objects owned by the mesh
134  mesh.objectRegistry::clear();
135 
136  Info<< endl;
137  }
138 
139  Info<< "End\n" << endl;
140 
141  return 0;
142 }
143 
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #undef INCLUDE_FILE
148 #undef INCLUDE_FILE2
149 
150 #undef CREATE_MESH
151 #undef CREATE_FIELDS
152 #undef CREATE_CONTROL
153 
154 // ************************************************************************* //
#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:257
wordList listAllConfigFiles(const fileName &configFilesPath)
Return the list of configuration files in.
Definition: dictionaryIO.C:415
messageStream Info
IOerror FatalIOError
static const char nl
Definition: Ostream.H:266
messageStream Warning
Foam::argList args(argc, argv)