generatedZoneSet.C
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-2026 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 \*---------------------------------------------------------------------------*/
25 
26 #include "generatedZoneSet.H"
27 #include "lookup.H"
28 #include "polyMesh.H"
29 
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
34 {
35  zoneSet::operator=(zoneGenerator_->generate());
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 (
43  const word& name,
44  const polyMesh& mesh,
45  const dictionary& dict
46 )
47 :
48  regenerate_(false)
49 {
50  read(name, mesh, dict);
51 }
52 
53 
55 (
56  const word& name,
57  const zoneTypes& zoneType,
58  const polyMesh& mesh,
59  const dictionary& dict
60 )
61 :
62  regenerate_(false)
63 {
65 }
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
71 (
72  const word& name,
73  const polyMesh& mesh,
74  const dictionary& dict,
75  const bool onDemand
76 )
77 {
78  if (dict.isDict(name))
79  {
80  const dictionary& zgDict = dict.subDict(name);
81  zoneGenerator_ = zoneGenerator::New(name, mesh, zgDict);
82  regenerate_ = zgDict.lookupOrDefault<Switch>("regenerate", false);
83  }
84  else
85  {
86  Istream& zoneStream = dict.lookup(name);
87  const word zoneName(zoneStream);
88 
89  // If an empty keyword is present assume it is a zone name
90  // and add a zone lookup
91  dictionary zoneDict(name, dict);
92  zoneDict.add
93  (
95  (
96  "type",
98  zoneStream.lineNumber()
99  )
100  );
101 
102  zoneGenerator_ = new zoneGenerators::lookup(zoneName, mesh, zoneDict);
103  }
104 
105  if (!onDemand)
106  {
107  generate();
108  }
109 }
110 
111 
113 (
114  const word& name,
115  const zoneTypes& zoneType,
116  const polyMesh& mesh,
117  const dictionary& dict,
118  const bool onDemand
119 )
120 {
121  if (dict.isDict(name))
122  {
123  const dictionary& zgDict = dict.subDict(name);
124  zoneGenerator_ = zoneGenerator::New(name, zoneType, mesh, zgDict);
125  regenerate_ = zgDict.lookupOrDefault<Switch>("regenerate", false);
126  }
127  else
128  {
129  Istream& zoneStream = dict.lookup(name);
130  const word zoneName(zoneStream);
131 
132  // If an empty keyword is present assume it is a zone name
133  // and add a zone lookup
134  dictionary zoneDict(name, dict);
135  zoneDict.add
136  (
138  (
139  "type",
141  zoneStream.lineNumber()
142  )
143  );
144  zoneDict.add("zoneType", zoneTypesNames[zoneType]);
145 
146  zoneGenerator_ = new zoneGenerators::lookup(zoneName, mesh, zoneDict);
147  }
148 
149  if (!onDemand)
150  {
151  generate();
152  }
153 }
154 
155 
157 {
158  zoneGenerator_ = zg;
159  generate();
160 }
161 
162 
164 {
165  if (regenerate_)
166  {
167  generate();
168  }
169 
170  return regenerate_;
171 }
172 
173 
175 {
176  if (zoneGenerator_->moveUpdate())
177  {
178  generate();
179  }
180 
181  return true;
182 }
183 
184 
186 {
187  // generate zones following redistribution
188  generate();
189 }
190 
191 
193 {
194  // generate zones following topology change
195  generate();
196 }
197 
198 
200 {
201  // Zones are automatically mapped but should be generated
202  generate();
203 }
204 
205 
206 // ************************************************************************* //
label lineNumber() const
Return current stream line number.
Definition: IOstream.H:450
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
T lookupOrDefault(const word &, const T &) const
Find and return a T, if not found return the given default.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:732
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:778
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:1019
bool movePoints()
Update for mesh motion.
generatedZoneSet()
Construct null.
void read(const word &name, const polyMesh &mesh, const dictionary &dict, const bool onDemand=false)
Read from dictionary.
void generate()
Generate the zones and assign to the zoneSet.
void set(const autoPtr< zoneGenerator > &zg)
Set the zoneGenerator and generate the zoneSet.
void mapMesh(const polyMeshMap &map)
Update from another mesh using the given map.
void distribute(const polyDistributionMap &map)
Redistribute or update using the given distribution map.
void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
bool regenerate()
Regenerate the zones if the regenerate switch is set true.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
A class for handling words, derived from string.
Definition: word.H:63
static autoPtr< zoneGenerator > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Select constructed from name, mesh and dictionary.
Definition: zoneGenerator.C:66
void operator=(const zoneSet &)
Assignment transferring the temporary zones.
Definition: zoneSet.C:93
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
zoneTypes zoneType()
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
zoneTypes
Enumeration defining the zone types.
Definition: zoneSet.H:66
const NamedEnum< zoneTypes, 3 > zoneTypesNames
Named enumeration defining the zone type names.
Definition: zoneSet.C:35
dictionary dict