regionToCell.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) 2011-2024 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::regionToCell
26 
27 Description
28  TopoSetSource. Select cells belonging to topological connected region
29  (that contains given points)
30 
31  In dictionary input:
32 
33  // optional name of cellSet delimiting search
34  set c0;
35 
36  //- Number of cell layers to erode mesh to detect holes in the mesh
37  // Set to 0 if not used.
38  nErode 3;
39 
40  // points inside region to select
41  insidePoints ((1 2 3));
42 
43 
44 SourceFiles
45  regionToCell.C
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef regionToCell_H
50 #define regionToCell_H
51 
52 #include "topoSetSource.H"
53 #include "boolList.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 class regionSplit;
61 
62 /*---------------------------------------------------------------------------*\
63  Class regionToCell Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class regionToCell
67 :
68  public topoSetSource
69 {
70  // Private Data
71 
72  //- Name of cellSet to keep to
73  const word setName_;
74 
75  //- Coordinate(s) that is inside connected region
76  const List<point> insidePoints_;
77 
78  //- Number of layers to erode
79  const label nErode_;
80 
81 
82  // Private Member Functions
83 
84  //- Mark faces in between selected and unselected elements
85  void markRegionFaces
86  (
87  const boolList& selectedCell,
88  boolList& regionFace
89  ) const;
90 
91  //- Determine for every disconnected region in the mesh whether
92  // it contains a insidePoint
93  boolList findRegions(const bool verbose, const regionSplit&) const;
94 
95  //- Deselect regions not containing a insidePoint
96  void unselectOutsideRegions(boolList& selectedCell) const;
97 
98  //- Deselect one layer of cells from selectedCell
99  void shrinkRegions(boolList& selectedCell) const;
100 
101  //- Erode a given number of layers from selectedCell. Remove any
102  // region that gets disconnected that way.
103  void erode(boolList& selectedCell) const;
104 
105  void combine(topoSet& set, const bool add) const;
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("regionToCell");
112 
113 
114  // Constructors
115 
116  //- Construct from components
118  (
119  const polyMesh& mesh,
120  const word& setName,
121  const pointField& insidePoints,
122  const label nErode
123  );
124 
125  //- Construct from dictionary
127  (
128  const polyMesh& mesh,
129  const dictionary& dict
130  );
131 
132 
133  //- Destructor
134  virtual ~regionToCell();
135 
136 
137  // Member Functions
138 
139  virtual sourceType setType() const
140  {
141  return CELLSETSOURCE;
142  }
143 
144  virtual void applyToSet
145  (
146  const topoSetSource::setAction action,
147  topoSet&
148  ) const;
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #endif
159 
160 // ************************************************************************* //
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
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Definition: regionSplit.H:118
TopoSetSource. Select cells belonging to topological connected region (that contains given points)
Definition: regionToCell.H:68
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: regionToCell.C:410
TypeName("regionToCell")
Runtime type information.
virtual sourceType setType() const
Definition: regionToCell.H:138
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
Definition: regionToCell.C:369
virtual ~regionToCell()
Destructor.
Definition: regionToCell.C:403
Base class of a source for a topoSet.
Definition: topoSetSource.H:64
sourceType
Enumeration defining the types of sources.
Definition: topoSetSource.H:71
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:83
const polyMesh & mesh() const
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:65
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
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
nErode
Definition: regionToCell.H:37
insidePoints((1 2 3))
dictionary dict