Loading...
Searching...
No Matches
postProcess.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016 OpenFOAM Foundation
9 Copyright (C) 2018 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Global
28 postProcess
29
30Description
31 Execute application functionObjects to post-process existing results.
32
33 If the "dict" argument is specified the functionObjectList is constructed
34 from that dictionary otherwise the functionObjectList is constructed from
35 the "functions" sub-dictionary of "system/controlDict"
37 Multiple time-steps may be processed and the standard utility time
38 controls are provided.
39
40\*---------------------------------------------------------------------------*/
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44#ifndef CREATE_TIME
45 #define CREATE_TIME createTime.H
46#endif
47
48#ifndef CREATE_MESH
49 #define CREATE_MESH createMesh.H
50#endif
51
52#ifndef CREATE_FIELDS
53 #define CREATE_FIELDS createFields.H
54#endif
55
56#ifndef CREATE_CONTROL
57 #define CREATE_CONTROL createControl.H
58#endif
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62#define INCLUDE_FILE(X) INCLUDE_FILE2(X)
63#define INCLUDE_FILE2(X) #X
64
65// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66
68(
69 argList::postProcessOptionName,
70 "Execute functionObjects only"
71);
72
73if (argList::postProcess(argc, argv))
74{
76 #include "addRegionOption.H"
78
79 // Set functionObject post-processing mode
80 functionObject::postProcess = true;
81
82 #include "setRootCase.H"
83
84 if (args.found("list"))
85 {
86 functionObjectList::list();
87 return 0;
88 }
89
90 #include INCLUDE_FILE(CREATE_TIME)
92 #include INCLUDE_FILE(CREATE_MESH)
93
94 #ifndef NO_CONTROL
95 #include INCLUDE_FILE(CREATE_CONTROL)
96 #endif
97
98 // Externally stored dictionary for functionObjectList
99 // if not constructed from runTime
100 dictionary functionsDict;
101
102 HashSet<wordRe> selectedFields;
103
104 // Construct functionObjectList
105 autoPtr<functionObjectList> functionsPtr
106 (
107 functionObjectList::New(args, runTime, functionsDict, selectedFields)
108 );
109
110 forAll(timeDirs, timei)
111 {
112 runTime.setTime(timeDirs[timei], timei);
113
114 Info<< "Time = " << runTime.timeName() << endl;
115
116 switch (mesh.readUpdate())
117 {
118 case polyMesh::POINTS_MOVED:
119 {
120 functionsPtr->movePoints(mesh);
121 break;
122 }
123 case polyMesh::TOPO_CHANGE:
124 case polyMesh::TOPO_PATCH_CHANGE:
125 {
126 mapPolyMesh mpm(mesh);
127 functionsPtr->updateMesh(mpm);
128 break;
129 }
130 case polyMesh::UNCHANGED:
131 {
132 // No additional work
133 break;
134 }
135 default:
136 {
137 FatalErrorIn(args.executable())
138 << "Unhandled enumeration"
139 << abort(FatalError);
140 }
141 }
142
144
145 try
146 {
147 #include INCLUDE_FILE(CREATE_FIELDS)
148
149 #ifdef CREATE_FIELDS_2
150 #include INCLUDE_FILE(CREATE_FIELDS_2)
151 #endif
152
153 #ifdef CREATE_FIELDS_3
154 #include INCLUDE_FILE(CREATE_FIELDS_3)
155 #endif
156
157 functionsPtr->execute();
158
159 // Execute the functionObject 'end()' function for the last time
160 if (timei == timeDirs.size()-1)
161 {
162 functionsPtr->end();
163 }
164
165 // Report to output (avoid overwriting values from simulation)
166 profiling::print(Info);
167 }
168 catch (const Foam::IOerror& err)
169 {
170 Warning<< err << endl;
171 }
172
173 Info<< endl;
174 }
175
176 Info<< "End\n" << endl;
177
178 return 0;
179}
180
181
182// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183
184#undef INCLUDE_FILE
185#undef INCLUDE_FILE2
186
187#undef CREATE_MESH
188#undef CREATE_FIELDS
189#undef CREATE_CONTROL
190
191// ************************************************************************* //
Required Classes.
Report an I/O error.
Definition error.H:370
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Definition argList.C:389
bool throwing() const noexcept
Return the current exception throwing state (on or off).
Definition error.H:223
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options and also set the runTime to the first i...
dynamicFvMesh & mesh
engineTime & runTime
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition error.H:592
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Definition instantList.H:41
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299