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-2021 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 
71  // Private Data
72 
73 
74  //- Name of cellSet to keep to
75  const word setName_;
76 
77  //- Coordinate(s) that is inside connected region
78  const pointField insidePoints_;
79 
80  //- Number of layers to erode
81  const label nErode_;
82 
83 
84  // Private Member Functions
85 
86  //- Mark faces in between selected and unselected elements
87  void markRegionFaces
88  (
89  const boolList& selectedCell,
90  boolList& regionFace
91  ) const;
92 
93  //- Determine for every disconnected region in the mesh whether
94  // it contains a insidePoint
95  boolList findRegions(const bool verbose, const regionSplit&) const;
96 
97  //- Deselect regions not containing a insidePoint
98  void unselectOutsideRegions(boolList& selectedCell) const;
99 
100  //- Deselect one layer of cells from selectedCell
101  void shrinkRegions(boolList& selectedCell) const;
102 
103  //- Erode a given number of layers from selectedCell. Remove any
104  // region that gets disconnected that way.
105  void erode(boolList& selectedCell) const;
106 
107  void combine(topoSet& set, const bool add) const;
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeName("regionToCell");
114 
115  // Constructors
116 
117  //- Construct from components
119  (
120  const polyMesh& mesh,
121  const word& setName,
122  const pointField& insidePoints,
123  const label nErode
124  );
125 
126  //- Construct from dictionary
128  (
129  const polyMesh& mesh,
130  const dictionary& dict
131  );
132 
133 
134  //- Destructor
135  virtual ~regionToCell();
136 
137 
138  // Member Functions
139 
140  virtual sourceType setType() const
141  {
142  return CELLSETSOURCE;
143  }
144 
145  virtual void applyToSet(const topoSetSource::setAction action, topoSet&)
146  const;
147 
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #endif
158 
159 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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:139
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