point_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) 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 "point_zoneGenerator.H"
27 #include "polyMesh.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  namespace zoneGenerators
35  {
38  (
40  point,
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 selectedPoints(mesh_.nPoints(), false);
72 
73  forAll(zoneGenerators_, i)
74  {
75  zoneSet zs(zoneGenerators_[i].generate());
76 
77  if (zs.pValid() && zs.pZone().name() != zoneName_)
78  {
79  const labelList& zonePoints = zs.pZone();
80 
81  forAll(zonePoints, zpi)
82  {
83  selectedPoints[zonePoints[zpi]] = true;
84  }
85  }
86 
87  if (zs.cValid())
88  {
89  const labelList& zoneCells = zs.cZone();
90 
91  forAll(zoneCells, zci)
92  {
93  const labelList& cellFaces = mesh_.cells()[zoneCells[zci]];
94 
95  forAll(cellFaces, cFacei)
96  {
97  const face& f = mesh_.faces()[cellFaces[cFacei]];
98 
99  forAll(f, fp)
100  {
101  selectedPoints[f[fp]] = true;
102  }
103  }
104  }
105  }
106 
107  if (zs.fValid())
108  {
109  const labelList& zoneFaces = zs.fZone();
110 
111  forAll(zoneFaces, zfi)
112  {
113  const face& f = mesh_.faces()[zoneFaces[zfi]];
114 
115  forAll(f, fp)
116  {
117  selectedPoints[f[fp]] = true;
118  }
119  }
120  }
121  }
122 
123  moveUpdate_ = zoneGenerators_.moveUpdate();
124 
125  return zoneSet
126  (
127  new pointZone
128  (
129  zoneName_,
130  indices(selectedPoints),
131  mesh_.pointZones(),
132  moveUpdate_,
133  true
134  )
135  );
136 }
137 
138 
139 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Macros for easy insertion into run-time selection tables.
const word & name() const
Return name.
Definition: Zone.H:171
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Named list of point indices representing a sub-set of the mesh faces.
Definition: pointZone.H:60
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
A zoneGenerator which converts the point, cell and face zones from a list of zoneGenerators into a fa...
A zoneGenerator which converts the point, cell and face zones from a list of zoneGenerators into a po...
virtual zoneSet generate() const
Generate and return the zoneSet.
point(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
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.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
labelList f(nPoints)
dictionary dict