foamListRegions.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2017-2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Application
27 foamListRegions
28
29Group
30 grpPostProcessingUtilities
31
32Description
33 List regions from constant/regionProperties.
34
35Usage
36 \b foamListRegions [OPTION]
37
38Note
39 The OpenFOAM banner information is suppressed so that the output can be
40 piped into another command.
41
42\*---------------------------------------------------------------------------*/
43
44#include "argList.H"
45#include "Time.H"
46#include "regionProperties.H"
47
48using namespace Foam;
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52int main(int argc, char *argv[])
53{
54 argList::addNote
55 (
56 "List regions from constant/regionProperties"
57 );
58
59 argList::noBanner();
60 argList::noParallel();
61 argList::noJobInfo();
62 argList::noFunctionObjects(); // Never use function objects
63 // No profiling since there is no time loop
64
65 // Arguments are optional (non-mandatory)
66 argList::noMandatoryArgs();
67 argList::addArgument("regionType ... regionType");
68
69 #include "setRootCase.H"
70
71 // Silent version of "createTime.H", without libraries
73 (
74 Time::controlDictName,
75 args,
76 false, // no enableFunctionObjects
77 false // no enableLibs
78 );
79
81
82 // We now handle checking args and general sanity etc.
83 wordList regionTypes;
84
85 if (args.size() > 1)
86 {
87 regionTypes.resize(args.size()-1);
88
89 // No duplicates
90 wordHashSet uniq;
91
92 label nTypes = 0;
93 for (label argi = 1; argi < args.size(); ++argi)
94 {
95 regionTypes[nTypes] = args[argi];
96
97 const word& regType = regionTypes[nTypes];
98
99 if (uniq.insert(regType))
100 {
101 if (rp.found(regType))
102 {
103 ++nTypes;
104 }
105 else
106 {
107 InfoErr<< "No region-type: " << regType << nl;
108 }
109 }
110 }
111
112 regionTypes.resize(nTypes);
113 }
114 else
115 {
116 regionTypes = rp.sortedToc();
117 }
118
119
120 for (const word& regionType : regionTypes)
121 {
122 const wordList& regionNames = rp[regionType];
123
124 for (const word& regionName : regionNames)
125 {
126 Info<< regionName << nl;
127 }
128 }
129
130 return 0;
131}
132
133
134// ************************************************************************* //
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Definition: HashSet.H:191
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
label size() const noexcept
The number of arguments.
Definition: argListI.H:146
Simple class to hold region information for coupled region simulations.
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
regionProperties rp(runTime)
Foam::word regionName(Foam::polyMesh::defaultRegion)
wordList regionNames
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
messageStream InfoErr
Information stream (stderr output on master, null elsewhere)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)