All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
polyCellSet.H
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) 2022-2023 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 Class
25  Foam::polyCellSet
26 
27 Description
28  General run-time selected cell set selection class for polyMesh
29 
30  Currently supports cell selection from:
31  - a set of points
32  - a cellSet
33  - a cellZone
34  - all of the cells.
35 
36 Usage
37  Examples:
38  \verbatim
39  // Select all cells
40  select all;
41 
42  // Select the cells within the given cellSet
43  select cellSet; // Optional
44  cellSet rotor;
45 
46  // Select the cells within the given cellZone
47  select cellZone; // Optional
48  cellZone rotor;
49 
50  // Select the cells containing a list of points
51  select points; // Optional
52  points
53  (
54  (2.25 0.5 0)
55  (2.75 0.5 0)
56  );
57  \endverbatim
58 
59 SourceFiles
60  polyCellSet.C
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #ifndef polyCellSet_H
65 #define polyCellSet_H
66 
67 #include "cellSet.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
74 class polyMesh;
75 class polyMeshMap;
76 class polyDistributionMap;
77 
78 /*---------------------------------------------------------------------------*\
79  Class polyCellSet Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 class polyCellSet
83 {
84 public:
85 
86  // Public data
87 
88  //- Enumeration for selection mode types
89  enum class selectionTypes
90  {
91  points,
92  cellSet,
93  cellZone,
94  all
95  };
96 
97  //- Word list of selection type names
99 
100 
101 private:
102 
103  // Private data
104 
105  //- Reference to the mesh
106  const polyMesh& mesh_;
107 
108  //- Cell selection type
109  selectionTypes selectionType_;
110 
111  //- Optional name of cell set or zone
112  word cellSetName_;
113 
114  //- Optional list of points
115  List<point> points_;
116 
117  //- Set of selected cells (not used for all or cellZone)
118  mutable labelList cells_;
119 
120 
121  // Private functions
122 
123  //- Set the cells
124  void setCells();
125 
126  //- Return the identity map of length len
127  labelUList identityMap(const label len) const;
128 
129 
130 public:
131 
132  // Constructors
133 
134  //- Construct from mesh. Will select all.
135  polyCellSet(const polyMesh& mesh);
136 
137  //- Construct from mesh and dictionary
138  polyCellSet(const polyMesh& mesh, const dictionary& dict);
139 
140 
141  //- Destructor
142  ~polyCellSet();
143 
144 
145  // Member Functions
146 
147  // Access
148 
149  //- Return const access to the cell selection type
150  inline const selectionTypes& selectionType() const;
151 
152  //- Return const access to the name of cellSet
153  inline const word& cellSetName() const;
154 
155  //- Return const access to the cell set
156  inline labelUList cells() const;
157 
158  //- Return the number of cells in the set
159  inline label nCells() const;
160 
161  //- Return true if the set comprises all the cells
162  inline bool all() const;
163 
164  //- Return the cell index corresponding to the cell set index
165  inline label celli(const label i) const;
166 
167 
168  // Mesh changes
169 
170  //- Update for mesh motion
171  void movePoints();
172 
173  //- Update topology using the given map
174  void topoChange(const polyTopoChangeMap&);
175 
176  //- Update from another mesh using the given map
177  void mapMesh(const polyMeshMap&);
178 
179  //- Redistribute or update using the given distribution map
180  void distribute(const polyDistributionMap&);
181 
182 
183  // IO
184 
185  //- Read coefficients dictionary
186  bool read(const dictionary& dict);
187 };
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #include "polyCellSetI.H"
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 #endif
201 
202 // ************************************************************************* //
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
General run-time selected cell set selection class for polyMesh.
Definition: polyCellSet.H:82
polyCellSet(const polyMesh &mesh)
Construct from mesh. Will select all.
Definition: polyCellSet.C:148
const word & cellSetName() const
Return const access to the name of cellSet.
Definition: polyCellSetI.H:37
label celli(const label i) const
Return the cell index corresponding to the cell set index.
Definition: polyCellSetI.H:79
~polyCellSet()
Destructor.
Definition: polyCellSet.C:168
void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: polyCellSet.C:183
void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: polyCellSet.C:195
void movePoints()
Update for mesh motion.
Definition: polyCellSet.C:174
bool read(const dictionary &dict)
Read coefficients dictionary.
Definition: polyCellSet.C:201
bool all() const
Return true if the set comprises all the cells.
Definition: polyCellSetI.H:73
labelUList cells() const
Return const access to the cell set.
Definition: polyCellSetI.H:43
void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: polyCellSet.C:189
label nCells() const
Return the number of cells in the set.
Definition: polyCellSetI.H:60
static const NamedEnum< selectionTypes, 4 > selectionTypeNames
Word list of selection type names.
Definition: polyCellSet.H:97
const selectionTypes & selectionType() const
Return const access to the cell selection type.
Definition: polyCellSetI.H:31
selectionTypes
Enumeration for selection mode types.
Definition: polyCellSet.H:89
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.
A class for handling words, derived from string.
Definition: word.H:62
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
dictionary dict