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 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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const word& name,
35  const polyMesh& mesh,
36  const dictionary& dict
37 )
38 {
39  read(name, mesh, dict);
40 }
41 
42 
44 (
45  const word& name,
46  const zoneTypes& zoneType,
47  const polyMesh& mesh,
48  const dictionary& dict
49 )
50 {
51  read(name, zoneType, mesh, dict);
52 }
53 
54 
55 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
56 
58 (
59  const word& name,
60  const polyMesh& mesh,
61  const dictionary& dict
62 )
63 {
64  if (dict.isDict(name))
65  {
66  zoneGenerator_ = zoneGenerator::New(name, mesh, dict.subDict(name));
67  }
68  else
69  {
70  Istream& zoneStream = dict.lookup(name);
71  const word zoneName(zoneStream);
72 
73  // If an empty keyword is present assume it is a zone name
74  // and add a zone lookup
75  dictionary zoneDict(name, dict);
76  zoneDict.add
77  (
79  (
80  "type",
81  zoneGenerators::lookup::typeName,
82  zoneStream.lineNumber()
83  )
84  );
85 
86  zoneGenerator_ = new zoneGenerators::lookup(zoneName, mesh, zoneDict);
87  }
88 
89  zoneSet::operator=(zoneGenerator_->generate());
90 }
91 
92 
94 (
95  const word& name,
96  const zoneTypes& zoneType,
97  const polyMesh& mesh,
98  const dictionary& dict
99 )
100 {
101  if (dict.isDict(name))
102  {
103  zoneGenerator_ = zoneGenerator::New
104  (
105  name,
106  zoneType,
107  mesh,
108  dict.subDict(name));
109  }
110  else
111  {
112  Istream& zoneStream = dict.lookup(name);
113  const word zoneName(zoneStream);
114 
115  // If an empty keyword is present assume it is a zone name
116  // and add a zone lookup
117  dictionary zoneDict(name, dict);
118  zoneDict.add
119  (
121  (
122  "type",
123  zoneGenerators::lookup::typeName,
124  zoneStream.lineNumber()
125  )
126  );
127  zoneDict.add("zoneType", zoneTypesNames[zoneType]);
128 
129  zoneGenerator_ = new zoneGenerators::lookup(zoneName, mesh, zoneDict);
130  }
131 
132  zoneSet::operator=(zoneGenerator_->generate());
133 }
134 
135 
137 {
138  zoneGenerator_ = zg;
139  zoneSet::operator=(zoneGenerator_->generate());
140 }
141 
142 
144 {
145  if (zoneGenerator_->moveUpdate())
146  {
147  zoneSet::operator=(zoneGenerator_->generate());
148  }
149 
150  return true;
151 }
152 
153 
155 {
156  // Regenerate zones following redistribution
157  zoneSet::operator=(zoneGenerator_->generate());
158 }
159 
160 
162 {
163  // Regenerate zones following topology change
164  zoneSet::operator=(zoneGenerator_->generate());
165 }
166 
167 
169 {
170  // Zones are automatically mapped but should be regenerated
171  zoneSet::operator=(zoneGenerator_->generate());
172 }
173 
174 
175 // ************************************************************************* //
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
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
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:740
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Definition: dictionary.C:803
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:849
bool add(entry *, bool mergeEntry=false)
Add a new entry.
Definition: dictionary.C:1020
bool movePoints()
Update for mesh motion.
void read(const word &name, const polyMesh &mesh, const dictionary &dict)
Read from dictionary.
generatedZoneSet()
Construct null.
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.
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:80
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:62
static autoPtr< zoneGenerator > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Select constructed from name, mesh and dictionary.
Definition: zoneGenerator.C:66
A zoneGenerator which looks-up and returns a zoneSet containing point, and/or cell and/or faces zones...
Definition: lookup.H:139
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)
bool read(const char *, int32_t &)
Definition: int32IO.C:85
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