regionProperties.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) 2012 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
27\*---------------------------------------------------------------------------*/
28
29#include "regionProperties.H"
30#include "IOdictionary.H"
31#include "Time.H"
32
33// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34
36:
37 regionProperties(runTime, IOobject::MUST_READ_IF_MODIFIED)
38{}
39
40
42(
43 const Time& runTime,
45)
46{
47 HashTable<wordList>& props = *this;
48
49 IOdictionary iodict
50 (
52 (
53 "regionProperties",
55 runTime.db(),
56 rOpt,
58 )
59 );
60
61 if
62 (
64 || iodict.size()
65 )
66 {
67 iodict.readEntry("regions", props);
68 }
69}
70
71
72// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73
75{
76 label n = 0;
77
78 const HashTable<wordList>& props = *this;
79
80 forAllConstIters(props, iter)
81 {
82 n += iter.val().size();
83 }
84
85 return n;
86}
87
88
90{
91 wordList list(this->count());
92
93 label n = 0;
94
95 const HashTable<wordList>& props = *this;
96
97 for (const word& grp : props.sortedToc())
98 {
99 for (const word& name : props[grp])
100 {
101 list[n] = name;
102 ++n;
103 }
104 }
105
106 return list;
107}
108
109
111{
112 wordList list(this->count());
113
114 label n = 0;
115
116 const HashTable<wordList>& props = *this;
117
118 forAllConstIters(props, iter)
119 {
120 for (const word& name : iter.val())
121 {
122 list[n] = name;
123 ++n;
124 }
125 }
126
127 Foam::sort(list);
128
129 return list;
130}
131
132
133// ************************************************************************* //
label n
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Definition: HashTable.C:137
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:500
readOption
Enumeration defining the read options.
Definition: IOobject.H:177
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:180
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
const Time & time() const noexcept
Return time registry.
Simple class to hold region information for coupled region simulations.
wordList sortedNames() const
The region names in sorted order.
wordList names() const
The region names. Sorted by region type.
label count() const
Total count of all region names.
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
void sort(UList< T > &list)
Sort the list.
Definition: UList.C:342
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Definition: stdFoam.H:278