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 -------------------------------------------------------------------------------
10 License
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 
26 Application
27  foamListRegions
28 
29 Group
30  grpPostProcessingUtilities
31 
32 Description
33  List regions from constant/regionProperties.
34 
35 Usage
36  \b foamListRegions [OPTION]
37 
38 Note
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 
48 using namespace Foam;
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 int main(int argc, char *argv[])
53 {
55  (
56  "List regions from constant/regionProperties"
57  );
58 
62  argList::noFunctionObjects(); // Never use function objects
63  // No profiling since there is no time loop
64 
65  // Arguments are optional (non-mandatory)
67  argList::addArgument("regionType ... regionType");
68 
69  #include "setRootCase.H"
70 
71  // Silent version of "createTime.H", without libraries
73  (
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 // ************************************************************************* //
Foam::argList::noBanner
static void noBanner()
Definition: argList.C:434
runTime
engineTime & runTime
Definition: createEngineTime.H:13
rp
regionProperties rp(runTime)
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
regionProperties.H
Foam::List::resize
void resize(const label len)
Definition: ListI.H:132
Foam::argList::addNote
static void addNote(const string &note)
Definition: argList.C:405
Foam::InfoErr
messageStream InfoErr
Foam::HashSet
A HashTable with keys but without contents that is similar to std::unordered_set.
Definition: HashSet.H:73
Foam::Time::controlDictName
static word controlDictName
Definition: Time.H:222
Foam::argList::noMandatoryArgs
static void noMandatoryArgs()
Definition: argList.C:422
regionNames
wordList regionNames
Definition: getAllRegionOptions.H:31
Foam::argList::addArgument
static void addArgument(const string &argName, const string &usage="")
Definition: argList.C:294
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Definition: argList.C:466
Foam::argList::noJobInfo
static void noJobInfo()
Definition: argList.C:486
Foam::Info
messageStream Info
argList.H
Foam::regionProperties
Simple class to hold region information for coupled region simulations.
Definition: regionProperties.H:56
Foam
Definition: atmBoundaryLayer.C:26
Foam::HashTable::sortedToc
List< Key > sortedToc() const
Definition: HashTable.C:129
Time.H
setRootCase.H
Foam::argList::size
label size() const noexcept
Definition: argListI.H:139
Foam::nl
constexpr char nl
Definition: Ostream.H:424
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::HashSet::insert
bool insert(const Key &key)
Definition: HashSet.H:191
Foam::argList::noParallel
static void noParallel()
Definition: argList.C:503
Foam::HashTable::found
bool found(const Key &key) const
Definition: HashTableI.H:93
args
Foam::argList args(argc, argv)