boundaryRegion.H
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) 2011 OpenFOAM Foundation
9  Copyright (C) 2024 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 Class
28  Foam::boundaryRegion
29 
30 Description
31  The boundaryRegion persistent data saved as a Map<dictionary>.
32 
33  The meshReader supports boundaryRegion information.
34 
35  The <tt>constant/boundaryRegion</tt> file is an \c IOMap<dictionary>
36  that is used to save the information persistently.
37  It contains the boundaryRegion information of the following form:
38 
39  \verbatim
40  (
41  INT
42  {
43  BoundaryType WORD;
44  Label WORD;
45  }
46  ...
47  )
48  \endverbatim
49 
50 SourceFiles
51  boundaryRegion.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef Foam_boundaryRegion_H
56 #define Foam_boundaryRegion_H
57 
58 #include "Map.H"
59 #include "dictionary.H"
60 #include "labelList.H"
61 #include "wordRes.H"
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 namespace Foam
66 {
67 
68 // Forward Declarations
69 class objectRegistry;
70 
71 /*---------------------------------------------------------------------------*\
72  Class boundaryRegion Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class boundaryRegion
76 :
77  public Map<dictionary>
78 {
79 public:
80 
81  //- No copy construct
82  boundaryRegion(const boundaryRegion&) = delete;
83 
84 
85  // Constructors
86 
87  //- Default construct
88  boundaryRegion() noexcept = default;
89 
90  //- Read construct from registry, name, instance
91  explicit boundaryRegion
92  (
93  const objectRegistry& obr,
94  const word& name = "boundaryRegion",
95  const fileName& instance = "constant"
96  );
97 
98 
99  //- Destructor
100  ~boundaryRegion() = default;
101 
102 
103  // Member Functions
104 
105  //- Add to the end, return index
106  label push_back(const dictionary& dict);
107 
108  //- The max table index, -1 if empty
109  label maxIndex() const;
110 
111  //- The index corresponding to entry with 'Label' of given name,
112  //- or -1 if not found
113  label findIndex(const word& name) const;
114 
115  //- The 'Label' name corresponding to id,
116  //- or boundaryRegion_ID if not otherwise defined
117  word name(const label id) const;
118 
119  //- Return the extracted Map of (id => name)
120  Map<word> names() const;
121 
122  //- Return the extracted Map of (id => names) selected by patterns
123  Map<word> names(const wordRes& patterns) const;
124 
125  //- Return the extracted Map of (id => type)
126  Map<word> boundaryTypes() const;
127 
128  //- Return BoundaryType corresponding to patch 'name',
129  //- "patch" if not found
130  word boundaryType(const word& name) const;
131 
132 
133  //- Read constant/boundaryRegion
134  void readDict
135  (
136  const objectRegistry& obr,
137  const word& name = "boundaryRegion",
138  const fileName& instance = "constant"
139  );
140 
141  //- Write constant/boundaryRegion for later reuse
142  void writeDict
143  (
144  const objectRegistry& obr,
145  const word& name = "boundaryRegion",
146  const fileName& instance = "constant"
147  ) const;
148 
149 
150  // Member Operators
151 
152  //- Copy assignment
153  void operator=(const boundaryRegion&);
154 
155  //- Assign from Map<dictionary>
156  void operator=(const Map<dictionary>&);
157 
158 
159  // Friend Functions
160 
161  //- Rename regions
162  // each dictionary entry is a single word:
163  // \verbatim
164  // newPatchName originalName;
165  // \endverbatim
166  void rename(const dictionary&);
167 
168 
169  // Housekeeping
170 
171  //- Add to the end, return index
172  label append(const dictionary& dict) { return push_back(dict); }
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #endif
183 
184 // ************************************************************************* //
dictionary dict
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
label findIndex(const word &name) const
The index corresponding to entry with &#39;Label&#39; of given name, or -1 if not found.
void rename(const dictionary &)
Rename regions.
Map< word > boundaryTypes() const
Return the extracted Map of (id => type)
A class for handling words, derived from Foam::string.
Definition: word.H:63
boundaryRegion() noexcept=default
Default construct.
Map< word > names() const
Return the extracted Map of (id => name)
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
label append(const dictionary &dict)
Add to the end, return index.
const direction noexcept
Definition: Scalar.H:258
label push_back(const dictionary &dict)
Add to the end, return index.
word boundaryType(const word &name) const
Return BoundaryType corresponding to patch &#39;name&#39;, "patch" if not found.
void operator=(const boundaryRegion &)
Copy assignment.
~boundaryRegion()=default
Destructor.
void readDict(const objectRegistry &obr, const word &name="boundaryRegion", const fileName &instance="constant")
Read constant/boundaryRegion.
label maxIndex() const
The max table index, -1 if empty.
Registry of regIOobjects.
The boundaryRegion persistent data saved as a Map<dictionary>.
word name(const label id) const
The &#39;Label&#39; name corresponding to id, or boundaryRegion_ID if not otherwise defined.
void writeDict(const objectRegistry &obr, const word &name="boundaryRegion", const fileName &instance="constant") const
Write constant/boundaryRegion for later reuse.
Namespace for OpenFOAM.
A HashTable to objects of type <T> with a label key.