polyCellSetI.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) 2021-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 \*---------------------------------------------------------------------------*/
25 
26 #include "polyMesh.H"
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
32 {
33  return selectionType_;
34 }
35 
36 
38 {
39  return cellSetName_;
40 }
41 
42 
44 {
45  if (selectionType_ == selectionTypes::all)
46  {
47  return identityMap(mesh_.nCells());
48  }
49  else if (selectionType_ == selectionTypes::cellZone)
50  {
51  return mesh_.cellZones()[cellSetName_];
52  }
53  else
54  {
55  return cells_;
56  }
57 }
58 
59 
61 {
62  if (selectionType_ == selectionTypes::all)
63  {
64  return mesh_.nCells();
65  }
66  else
67  {
68  return cells().size();
69  }
70 }
71 
72 
73 inline bool Foam::polyCellSet::all() const
74 {
75  return selectionType_ == selectionTypes::all;
76 }
77 
78 
80 {
81  if (selectionType_ == selectionTypes::all)
82  {
83  return i;
84  }
85  else if (selectionType_ == selectionTypes::cellZone)
86  {
87  return mesh_.cellZones()[cellSetName_][i];
88  }
89  else
90  {
91  return cells_[i];
92  }
93 }
94 
95 
96 // ************************************************************************* //
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
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
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
label nCells() const
Return the number of cells in the set.
Definition: polyCellSetI.H:60
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
A class for handling words, derived from string.
Definition: word.H:62
const cellShapeList & cells
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
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104