cell_zoneGenerator.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) 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 "cell_zoneGenerator.H"
27 #include "polyMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  namespace zoneGenerators
35  {
38  (
40  cell,
42  );
43  }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const word& name,
52  const polyMesh& mesh,
53  const dictionary& dict
54 )
55 :
57  zoneGenerators_(mesh, dict)
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
62 
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
70 {
71  boolList selectedCells(mesh_.nCells(), false);
72 
73  forAll(zoneGenerators_, i)
74  {
75  zoneSet zs(zoneGenerators_[i].generate());
76 
77  if (zs.pValid())
78  {
79  const labelList& zonePoints = zs.pZone();
80 
81  forAll(zonePoints, pi)
82  {
83  const labelList& pCells = mesh_.pointCells()[zonePoints[pi]];
84 
85  forAll(pCells, pci)
86  {
87  selectedCells[pCells[pci]] = true;
88  }
89  }
90  }
91 
92  if (zs.cValid() && zs.cZone().name() != zoneName_)
93  {
94  const labelList& zoneCells = zs.cZone();
95 
96  forAll(zoneCells, zci)
97  {
98  selectedCells[zoneCells[zci]] = true;
99  }
100  }
101 
102  if (zs.fValid())
103  {
104  const labelList& zoneFaces = zs.fZone();
105 
106  const labelList& own = mesh_.faceOwner();
107  const labelList& nei = mesh_.faceNeighbour();
108 
109  forAll(zoneFaces, zfi)
110  {
111  const label facei = zoneFaces[zfi];
112 
113  selectedCells[own[facei]] = true;
114  if (mesh_.isInternalFace(facei))
115  {
116  selectedCells[nei[facei]] = true;
117  }
118  }
119  }
120  }
121 
122  moveUpdate_ = zoneGenerators_.moveUpdate();
123 
124  return zoneSet
125  (
126  new cellZone
127  (
128  zoneName_,
129  indices(selectedCells),
130  mesh_.cellZones(),
131  moveUpdate_,
132  true
133  )
134  );
135 }
136 
137 
138 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
const word & name() const
Return name.
Definition: Zone.H:171
Named list of cell indices representing a sub-set of the mesh.
Definition: cellZone.H:61
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:78
A class for handling words, derived from string.
Definition: word.H:63
Abstract base class for all zoneGenerators, providing runtime selection.
Definition: zoneGenerator.H:57
A zoneGenerator which converts the cell, face and point zones from a list of zoneGenerators into a ce...
virtual zoneSet generate() const
Generate and return the zoneSet.
cell(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual ~cell()
Destructor.
Zone container returned by zoneGenerator::generate.
Definition: zoneSet.H:94
const faceZone & fZone() const
Return a reference to the faceZone if allocated.
Definition: zoneSetI.H:230
const cellZone & cZone() const
Return a reference to the cellZone if allocated.
Definition: zoneSetI.H:223
bool pValid() const
Return true if the pointZone is allocated.
Definition: zoneSetI.H:167
const pointZone & pZone() const
Return a reference to the pointZone if allocated.
Definition: zoneSetI.H:216
bool fValid() const
Return true if the faceZone is allocated.
Definition: zoneSetI.H:181
bool cValid() const
Return true if the cellZone is allocated.
Definition: zoneSetI.H:174
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
defineTypeNameAndDebug(cylinderHeadPoints, 0)
addToRunTimeSelectionTable(zoneGenerator, cylinderHeadPoints, dictionary)
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict