lookup.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::zoneGenerators::lookup
26 
27 Description
28  A zoneGenerator which looks-up and returns a zoneSet containing point,
29  and/or cell and/or faces zones.
30 
31 Usage
32  \table
33  Property | Description | Required | Default value
34  type | Type: lookup | no | lookup
35  name | Name of the zone(s) | no | zoneGenerator name
36  zoneType | Type of zone | no | all the zone types
37  \endtable
38 
39  A full specification for the zoneGenerators::lookup requires the keyword
40  which is the name of the zoneGenerator, the type of the zoneGenerator,
41  i.e. \c lookup, the name and type of the zone to be looked-up, e.g.
42  \verbatim
43  <zoneGenerator name>
44  {
45  type lookup;
46  name box;
47  zoneType cell;
48  }
49  \endverbatim
50  However usually the name of the zoneGenerator can be chosen to match the
51  name of the zone to be looked-up so the name entry defaults to the
52  \c zoneGenerator keyword to make the specification simpler, e.g.
53  \verbatim
54  box
55  {
56  type lookup;
57  zoneType cell;
58  }
59  \endverbatim
60  To further simplify the specification of the \c lookup, given that it will
61  be commonly used in a zoneGenerator sequence, \c lookup is the default
62  type, so the box cellZone can be looked-up with the following simple
63  specification:
64  \verbatim
65  box
66  {
67  zoneType cell;
68  }
69  \endverbatim
70  If the \c zoneType is omitted the zoneSet returned by \c lookup will
71  contain each of the three zone types corresponding to the zone name that are
72  present in the lists of zones. Usually there will only be the one zone type
73  of the given name so the \c zoneType entry can often be omitted and this
74  form of default \c lookup can simply be specified as the name of
75  the zone only, e.g.
76  \verbatim
77  box;
78  \endverbatim
79  There is a special \c all zone of each type generated and cached
80  automatically by the corresponding zoneList which holds an identity map of
81  all the points, cells or faces and is returned by \c lookup using the
82  reserved zone name "all", e.g. to return the cellZone corresponding to all
83  the cells in the mesh use:
84  \verbatim
85  all
86  {
87  zoneType cell;
88  }
89  \endverbatim
90 
91 See also
92  zoneGenerator
93  zoneSet
94  zoneGeneratorList
95 
96 SourceFiles
97  lookup.C
98 
99 \*---------------------------------------------------------------------------*/
100 
101 #ifndef lookup_H
102 #define lookup_H
103 
104 #include "zoneGeneratorList.H"
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 namespace Foam
109 {
110 namespace zoneGenerators
111 {
112 
113 /*---------------------------------------------------------------------------*\
114  Class lookup Declaration
115 \*---------------------------------------------------------------------------*/
116 
117 class lookup
118 :
119  public zoneGenerator
120 {
121  // Private Data
122 
123  //- The type of zone to lookup (optional)
124  zoneTypesAll zoneType_;
125 
126 
127  // Private Member Functions
128 
129  //- Check if the zone with the given zoneName and type exists
130  // and return a reference otherwise error
131  template<class ZoneListType>
132  const typename ZoneListType::zoneType& lookupZone
133  (
134  const ZoneListType& zones,
135  const word& zoneName
136  ) const;
137 
138 
139 public:
140 
141  //- Runtime type information
142  TypeName("lookup");
143 
144 
145  // Constructors
146 
147  //- Construct from dictionary
148  lookup
149  (
150  const word& name,
151  const polyMesh& mesh,
152  const dictionary& dict
153  );
154 
155 
156  //- Destructor
157  virtual ~lookup();
158 
159 
160  // Member Functions
161 
162  virtual zoneSet generate() const;
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace zoneGenerators
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A class for handling words, derived from string.
Definition: word.H:62
const word & zoneName() const
const word & name() const
virtual zoneSet generate() const
Generate and return the zoneSet.
Definition: lookup.C:110
virtual ~lookup()
Destructor.
Definition: lookup.C:104
TypeName("lookup")
Runtime type information.
lookup(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: lookup.C:88
Zone container returned by zoneGenerator::generate.
Definition: zoneSet.H:94
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
zoneTypesAll
Enumeration defining the zone types with an option for all the types.
Definition: zoneSet.H:77
dictionary dict