set.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 "set.H"
27 #include "polyMesh.H"
28 #include "pointSet.H"
29 #include "cellSet.H"
30 #include "faceSet.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  namespace zoneGenerators
38  {
41  }
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
48 (
49  const word& name,
50  const polyMesh& mesh,
51  const dictionary& dict
52 )
53 :
55  zoneType_(zoneTypesNames.read(dict.lookup("zoneType"))),
56  setName_(dict.lookupOrDefault("setName", zoneName_))
57 {}
58 
59 
60 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
61 
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
69 {
70  switch (zoneType_)
71  {
72  case zoneTypes::point:
73  {
74  return zoneSet
75  (
76  new pointZone
77  (
78  zoneName_,
79  pointSet(mesh_, setName_).toc(),
80  mesh_.pointZones(),
81  false,
82  false
83  )
84  );
85  }
86 
87  case zoneTypes::cell:
88  {
89  return zoneSet
90  (
91  new cellZone
92  (
93  zoneName_,
94  cellSet(mesh_, setName_).toc(),
95  mesh_.cellZones(),
96  false,
97  false
98  )
99  );
100  }
101 
102  case zoneTypes::face:
103  {
104  labelList faceIndices(faceSet(mesh_, setName_).toc());
105 
106  return zoneSet
107  (
108  new faceZone
109  (
110  zoneName_,
111  faceIndices,
112  mesh_.faceZones(),
113  false,
114  false
115  )
116  );
117  }
118  }
119 
120  return zoneSet();
121 }
122 
123 
124 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
A collection of cell labels.
Definition: cellSet.H:51
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
A list of face labels.
Definition: faceSet.H:51
Named list of face indices representing a sub-set of the mesh faces.
Definition: faceZone.H:66
A set of point labels.
Definition: pointSet.H:51
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 looks-up and returns a zoneSet containing point, and/or cell and/or faces zones...
Definition: lookup.H:139
A zoneGenerator which converts a set into the corresponding zone.
Definition: set.H:109
virtual zoneSet generate() const
Generate and return the zoneSet.
Definition: set.C:68
set(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: set.C:48
virtual ~set()
Destructor.
Definition: set.C:62
Zone container returned by zoneGenerator::generate.
Definition: zoneSet.H:94
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
defineTypeNameAndDebug(cylinderHeadPoints, 0)
addToRunTimeSelectionTable(zoneGenerator, cylinderHeadPoints, dictionary)
Namespace for OpenFOAM.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
const NamedEnum< zoneTypes, 3 > zoneTypesNames
Named enumeration defining the zone type names.
Definition: zoneSet.C:35
dictionary dict