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 -------------------------------------------------------------------------------
11 License
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  (
51  IOobject
52  (
53  "regionProperties",
54  runTime.time().constant(),
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 
74 Foam::label Foam::regionProperties::count() const
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 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::regionProperties::count
label count() const
Total count of all region names.
Definition: regionProperties.C:74
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
regionProperties.H
Foam::regionProperties::names
wordList names() const
The region names. Sorted by region type.
Definition: regionProperties.C:89
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::sort
void sort(UList< T > &a)
Definition: UList.C:261
Foam::dictionary::readEntry
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Definition: dictionaryTemplates.C:302
Foam::regionProperties
Simple class to hold region information for coupled region simulations.
Definition: regionProperties.H:60
Foam::HashTable::sortedToc
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Definition: HashTable.C:136
Foam::HashTable< wordList >
IOdictionary.H
Time.H
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::List< word >
Foam::regionProperties::sortedNames
wordList sortedNames() const
The region names in sorted order.
Definition: regionProperties.C:110
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:186
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::IOobject::readOption
readOption
Enumeration defining the read options.
Definition: IOobject.H:183
Foam::regionProperties::regionProperties
regionProperties(const Time &runTime)
Construct from Time.
Definition: regionProperties.C:35
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
Foam::objectRegistry::time
const Time & time() const noexcept
Return time registry.
Definition: objectRegistry.H:178
Foam::IOobject::MUST_READ
Definition: IOobject.H:185
Foam::IOobject::db
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:487