write.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 "write.H"
27 #include "Time.H"
28 #include "polyMesh.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  namespace zoneGenerators
36  {
39  }
40 }
41 
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 template<class ZoneListType>
46 void Foam::zoneGenerators::write::writeZoneType(const ZoneListType& zones) const
47 {
48  if
49  (
51  || (mesh_.time().writeTime() && zones.timeIndex() > timeIndex_)
52  )
53  {
55  {
56  zones.updateTimeInstance();
57  }
58 
59  zones.write();
60 
61  timeIndex_ = mesh_.time().timeIndex();
62  }
63 }
64 
65 
66 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
67 
69 (
70  const word& name,
71  const polyMesh& mesh,
72  const dictionary& dict
73 )
74 :
76  zoneType_
77  (
78  zoneTypesAllNames.lookupOrDefault("zoneType", dict, zoneTypesAll::all)
79  ),
80  timeIndex_(mesh.time().timeIndex())
81 {
82  moveUpdate_ = dict.lookupOrDefault("moveUpdate", true);
83 }
84 
85 
86 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
87 
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
95 {
96  if (zoneType_ == zoneTypesAll::point || zoneType_ == zoneTypesAll::all)
97  {
98  writeZoneType(mesh_.pointZones());
99  }
100 
101  if (zoneType_ == zoneTypesAll::cell || zoneType_ == zoneTypesAll::all)
102  {
103  writeZoneType(mesh_.cellZones());
104  }
105 
106  if (zoneType_ == zoneTypesAll::face || zoneType_ == zoneTypesAll::all)
107  {
108  writeZoneType(mesh_.faceZones());
109  }
110 
111  return zoneSet();
112 }
113 
114 
115 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
label timeIndex() const
Return current time index.
Definition: TimeStateI.H:28
bool writeTime() const
Return true if this is a write time.
Definition: TimeStateI.H:58
virtual label startTimeIndex() const
Return start time index.
Definition: Time.C:774
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Time & time() const
Return time.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A class for handling words, derived from string.
Definition: word.H:62
Abstract base class for all zoneGenerators, providing runtime selection.
Definition: zoneGenerator.H:57
bool moveUpdate_
Switch to update the zones if the mesh points are moved.
Definition: zoneGenerator.H:75
const polyMesh & mesh_
Reference to the polyMesh.
Definition: zoneGenerator.H:72
A zoneGenerator which writes all existing zones from the mesh.
Definition: write.H:109
virtual zoneSet generate() const
Generate and return the zoneSet.
Definition: write.C:94
write(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: write.C:69
virtual ~write()
Destructor.
Definition: write.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)
defineTypeNameAndDebug(cylinderHeadPoints, 0)
addToRunTimeSelectionTable(zoneGenerator, cylinderHeadPoints, dictionary)
Namespace for OpenFOAM.
zoneTypesAll
Enumeration defining the zone types with an option for all the types.
Definition: zoneSet.H:77
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
const NamedEnum< zoneTypesAll, 4 > zoneTypesAllNames
Named enumeration defining the zone type names.
Definition: zoneSet.C:43
label timeIndex
Definition: getTimeIndex.H:4
dictionary dict