zonesGenerator.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 "zonesGenerator.H"
27 #include "polyMesh.H"
28 #include "Time.H"
29 #include "IOdictionary.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
36 }
37 
38 
39 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
40 
41 Foam::IOobject Foam::zonesGenerator::io(const polyMesh& mesh) const
42 {
43  typeIOobject<IOdictionary> result
44  (
45  typeName,
46  mesh.time().constant(),
47  mesh,
50  );
51 
52  if (!result.headerOk())
53  {
54  result.readOpt() = IOobject::NO_READ;
55  }
56  else
57  {
58  result.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
59  }
60 
61  return result;
62 }
63 
64 
65 void Foam::zonesGenerator::generate()
66 {
68 }
69 
70 
71 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
72 
74 (
75  const polyMesh& mesh
76 )
77 :
79  <
80  polyMesh,
83  >
84  (
85  io(mesh),
86  mesh
87  ),
89 {
90  readHeaderOk(IOstream::ASCII, typeName);
91  generate();
92  addWatch();
93 }
94 
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
99 {
100  is >> *this;
101  zoneGeneratorList::read(*this, true);
102  return !is.bad();
103 }
104 
105 
107 {
108  dictionary::write(os, false);
109  return os.good();
110 }
111 
112 
114 {
115  if (regIOobject::read())
116  {
117  generate();
118  }
119 
120  return true;
121 }
122 
123 
125 {
127  return true;
128 }
129 
130 
132 {
133  // Zones are automatically distributed
134 }
135 
136 
138 {
139  // Regenerate zones following topology change
140  generate();
141 }
142 
143 
145 {
146  // Zones are automatically mapped but should be regenerated
147  generate();
148 }
149 
150 
151 // ************************************************************************* //
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:119
bool bad() const
Return true if stream is corrupted.
Definition: IOstream.H:351
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
static const word & constant()
Return constant name.
Definition: TimePaths.H:122
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:226
const Time & time() const
Return time.
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.
bool readHeaderOk(const IOstream::streamFormat defaultFormat, const word &typeName)
Read header, check readOpt flags and read data if necessary.
void addWatch()
Add file watch on object (if registered and READ_IF_MODIFIED)
Definition: regIOobject.C:259
virtual bool read()
Read object.
List of zoneGenerators.
void read(const dictionary &dict, const bool topLevel=false)
void generate()
Generate and register the zones.
void movePoints()
Update the zones following mesh point movement.
MeshObject zoneGeneratorList instantiated by polyMesh.
virtual bool movePoints()
Update for mesh motion.
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
zonesGenerator(const polyMesh &mesh)
Read construct from polyMesh.
virtual void mapMesh(const polyMeshMap &map)
Update from another mesh using the given map.
virtual void distribute(const polyDistributionMap &map)
Redistribute or update using the given distribution map.
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
virtual bool read()
Read the zonesGenerator dictionary if it has changed.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
defineTypeNameAndDebug(combustionModel, 0)