foamList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 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 Application
25  foamList
26 
27 Description
28  Print the table of contents of selectable switches, classes etc. in the
29  OpenFOAM libraries
30 
31 Usage
32  \b foamList [OPTION]
33 
34  Options:
35  - \par -switches
36  Print the DebugSwitches, InfoSwitches and OptimisationSwitches
37 
38  - \par -registeredSwitches
39  Print the registered DebugSwitches, InfoSwitches and
40  OptimisationSwitches supporting run-time modification
41 
42  - \par -unset
43  print switches declared in libraries but not set in etc/controlDict
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #include "argList.H"
48 #include "dictionary.H"
49 #include "simpleObjectRegistry.H"
50 #include "IFstream.H"
51 #include "IOobject.H"
52 #include "HashSet.H"
53 #include "etcFiles.H"
54 #include "fvPatchField.H"
55 #include "functionObject.H"
56 #include "fvOption.H"
59 
60 using namespace Foam;
61 
62 void listSwitches
63 (
64  const wordList& debugSwitches,
65  const wordList& infoSwitches,
66  const wordList& optSwitches,
67  const bool unset
68 )
69 {
70  if (unset)
71  {
72  fileNameList controlDictFiles = findEtcFiles("controlDict", true);
74  forAllReverse(controlDictFiles, cdfi)
75  {
76  controlDict.merge(dictionary(IFstream(controlDictFiles[cdfi])()));
77  }
78 
79  wordHashSet controlDictDebug
80  (
81  controlDict.subDict("DebugSwitches").sortedToc()
82  );
83 
84  wordHashSet controlDictInfo
85  (
86  controlDict.subDict("InfoSwitches").sortedToc()
87  );
88 
89  wordHashSet controlDictOpt
90  (
91  controlDict.subDict("OptimisationSwitches").sortedToc()
92  );
93 
94 
96 
97  wordHashSet hashset;
98  hashset = debugSwitches;
99  hashset -= controlDictDebug;
100  Info<< "Unset DebugSwitches" << hashset.sortedToc() << endl;
101 
102  hashset = infoSwitches;
103  hashset -= controlDictInfo;
104  Info<< "Unset InfoSwitches" << hashset.sortedToc() << endl;
105 
106  hashset = optSwitches;
107  hashset -= controlDictOpt;
108  Info<< "Unset OptimisationSwitches" << hashset.sortedToc() << endl;
109  }
110  else
111  {
113  Info<< "DebugSwitches" << debugSwitches << endl;
114  Info<< "InfoSwitches" << infoSwitches << endl;
115  Info<< "OptimisationSwitches" << optSwitches << endl;
116  }
117 }
118 
119 
120 void listSwitches(const argList& args)
121 {
122  if (args.optionFound("registeredSwitches"))
123  {
124  listSwitches
125  (
126  debug::debugObjects().sortedToc(),
127  debug::infoObjects().sortedToc(),
128  debug::optimisationObjects().sortedToc(),
129  args.optionFound("unset")
130  );
131  }
132  else
133  {
134  listSwitches
135  (
136  debug::debugSwitches().sortedToc(),
137  debug::infoSwitches().sortedToc(),
138  debug::optimisationSwitches().sortedToc(),
139  args.optionFound("unset")
140  );
141  }
142 }
143 
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 int main(int argc, char *argv[])
148 {
151  (
152  "switches",
153  "List switches declared in libraries but not set in etc/controlDict"
154  );
156  (
157  "registeredSwitches",
158  "List switches registered for run-time modification"
159  );
161  (
162  "unset",
163  "List switches declared in libraries but not set in etc/controlDict"
164  );
166  (
167  "scalarBCs",
168  "List scalar field boundary conditions (fvPatchField<scalar>)"
169  );
171  (
172  "vectorBCs",
173  "List vector field boundary conditions (fvPatchField<vector>)"
174  );
176  (
177  "functionObjects",
178  "List functionObjects"
179  );
181  (
182  "fvOptions",
183  "List fvOptions"
184  );
186  (
187  "incompressibleTurbulenceModels",
188  "List incompressible turbulenceModels"
189  );
191  (
192  "compressibleTurbulenceModels",
193  "List compressible turbulenceModels"
194  );
195 
196  argList args(argc, argv);
197 
198  if (!args.options().size())
199  {
200  args.printUsage();
201  return 0;
202  }
203 
204  if
205  (
206  args.optionFound("switches")
207  || args.optionFound("registeredSwitches")
208  )
209  {
210  listSwitches(args);
211  }
212 
213  if (args.optionFound("scalarBCs"))
214  {
215  Info<< "scalarBCs"
217  << endl;
218  }
219 
220  if (args.optionFound("vectorBCs"))
221  {
222  Info<< "vectorBCs"
224  << endl;
225  }
226 
227  if (args.optionFound("functionObjects"))
228  {
229  Info<< "functionObjects"
230  << functionObject::dictionaryConstructorTablePtr_->sortedToc()
231  << endl;
232  }
233 
234  if (args.optionFound("fvOptions"))
235  {
236  Info<< "fvOptions"
237  << fv::option::dictionaryConstructorTablePtr_->sortedToc()
238  << endl;
239  }
240 
241  if (args.optionFound("incompressibleTurbulenceModels"))
242  {
243  Info<< "Turbulence models"
244  << incompressible::turbulenceModel::
245  dictionaryConstructorTablePtr_->sortedToc()
246  << endl;
247 
248  Info<< "RAS models"
249  << incompressible::RASModel::
250  dictionaryConstructorTablePtr_->sortedToc()
251  << endl;
252 
253  Info<< "LES models"
254  << incompressible::LESModel::
255  dictionaryConstructorTablePtr_->sortedToc()
256  << endl;
257  }
258 
259  if (args.optionFound("compressibleTurbulenceModels"))
260  {
261  Info<< "Turbulence models"
262  << compressible::turbulenceModel::
263  dictionaryConstructorTablePtr_->sortedToc()
264  << endl;
265 
266  Info<< "RAS models"
267  << compressible::RASModel::
268  dictionaryConstructorTablePtr_->sortedToc()
269  << endl;
270 
271  Info<< "LES models"
272  << compressible::LESModel::
273  dictionaryConstructorTablePtr_->sortedToc()
274  << endl;
275  }
276 
277 
278  return 0;
279 }
280 
281 
282 // ************************************************************************* //
A HashTable with keys but without contents.
Definition: HashSet.H:59
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
Definition: IOobjectI.H:98
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:633
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: UList.H:440
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
static void noParallel()
Remove the parallel options.
Definition: argList.C:146
simpleObjectRegistry & debugObjects()
Get access to registered debug switch objects.
Definition: debug.C:313
const Foam::HashTable< string > & options() const
Return options.
Definition: argListI.H:90
simpleObjectRegistry & optimisationObjects()
Get access to registered optimisation switch objects.
Definition: debug.C:335
fileNameList findEtcFiles(const fileName &, bool mandatory=false, bool findFirst=false)
Search for files from user/group/shipped directories.
Definition: etcFiles.C:119
wordList sortedToc() const
Return the sorted table of contents.
Definition: dictionary.C:713
bool optionFound(const word &opt) const
Return true if the named option is found.
Definition: argListI.H:108
Functions to search &#39;etc&#39; directories for configuration files etc.
dictionary & infoSwitches()
The InfoSwitches sub-dictionary in the central controlDict.
Definition: debug.C:154
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:102
simpleObjectRegistry & infoObjects()
Get access to registered info switch objects.
Definition: debug.C:324
Input from file stream.
Definition: IFstream.H:81
List< Key > sortedToc() const
Return the table of contents as a sorted list.
Definition: HashTable.C:213
messageStream Info
bool merge(const dictionary &)
Merge entries from the given dictionary.
Definition: dictionary.C:1013
dictionary & optimisationSwitches()
The OptimisationSwitches sub-dictionary in the central controlDict.
Definition: debug.C:160
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Definition: argList.C:83
dictionary & debugSwitches()
The DebugSwitches sub-dictionary in the central controlDict.
Definition: debug.C:148
void printUsage() const
Print usage.
Definition: argList.C:1033
Foam::argList args(argc, argv)
Namespace for OpenFOAM.