regionToCell.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2012 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  //- Add usage string
74  static addToUsageTable usage_;
75 
76  //- Name of cellSet to keep to
77  const word setName_;
78 
79  //- Coordinate(s) that is inside connected region
80  const pointField insidePoints_;
81 
82  //- Number of layers to erode
83  const label nErode_;
84 
85 
86  // Private Member Functions
87 
88  //- Mark faces inbetween selected and unselected elements
89  void markRegionFaces
90  (
91  const boolList& selectedCell,
92  boolList& regionFace
93  ) const;
94 
95  //- Determine for every disconnected region in the mesh whether
96  // it contains a locationInMesh
97  boolList findRegions(const bool verbose, const regionSplit&) const;
98 
99  //- Unselect regions not containing a locationInMesh
100  void unselectOutsideRegions(boolList& selectedCell) const;
101 
102  //- Unselect one layer of cells from selectedCell
103  void shrinkRegions(boolList& selectedCell) const;
104 
105  //- Erode a given number of layers from selectedCell. Remove any
106  // region that gets disconnected that way.
107  void erode(boolList& selectedCell) const;
108 
109  void combine(topoSet& set, const bool add) const;
110 
111 
112 public:
113 
114  //- Runtime type information
115  TypeName("regionToCell");
116 
117  // Constructors
118 
119  //- Construct from components
121  (
122  const polyMesh& mesh,
123  const word& setName,
124  const pointField& insidePoints,
125  const label nErode
126  );
127 
128  //- Construct from dictionary
130  (
131  const polyMesh& mesh,
132  const dictionary& dict
133  );
134 
135  //- Construct from Istream
137  (
138  const polyMesh& mesh,
139  Istream&
140  );
141 
142 
143  //- Destructor
144  virtual ~regionToCell();
145 
146 
147  // Member Functions
149  virtual sourceType setType() const
150  {
151  return CELLSETSOURCE;
152  }
153 
154  virtual void applyToSet(const topoSetSource::setAction action, topoSet&)
155  const;
156 
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Definition: regionSplit.H:119
dictionary dict
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
virtual sourceType setType() const
Definition: regionToCell.H:148
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Definition: regionToCell.C:446
virtual ~regionToCell()
Destructor.
Definition: regionToCell.C:439
regionToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
Definition: regionToCell.C:390
Base class of a source for a topoSet.
Definition: topoSetSource.H:63
const polyMesh & mesh() const
A class for handling words, derived from string.
Definition: word.H:59
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:82
TypeName("regionToCell")
Runtime type information.
nErode
Definition: regionToCell.H:37
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
insidePoints((1 2 3))
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:61
Class with constructor to add usage string to table.
sourceType
Enumeration defining the types of sources.
Definition: topoSetSource.H:70
TopoSetSource. Select cells belonging to topological connected region (that contains given points) ...
Definition: regionToCell.H:65
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.