regionsToCell.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2018 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::regionsToCell
28 
29 Description
30  TopoSetSource. Select cells belonging to topological connected region
31  (that contains given points)
32 
33  In dictionary input:
34 
35  // optional name of cellSet delimiting search
36  set c0;
37 
38  //- Number of cell layers to erode mesh to detect holes in the mesh
39  // Set to 0 if not used.
40  nErode 3;
41 
42  // points inside region to select
43  insidePoints ((1 2 3));
44 
45 
46 SourceFiles
47  regionsToCell.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef regionsToCell_H
52 #define regionsToCell_H
53 
54 #include "topoSetCellSource.H"
55 #include "boolList.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 // Forward declarations
63 class regionSplit;
64 
65 /*---------------------------------------------------------------------------*\
66  Class regionsToCell Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class regionsToCell
70 :
71  public topoSetCellSource
72 {
73 
74  // Private data
75 
76  //- Add usage string
77  static addToUsageTable usage_;
78 
79  //- Name of cellSet to keep to
80  const word setName_;
81 
82  //- Coordinate(s) that is inside connected region
83  const pointField insidePoints_;
84 
85  //- Number of layers to erode
86  const label nErode_;
87 
88 
89  // Private Member Functions
90 
91  //- Mark faces inbetween selected and unselected elements
92  void markRegionFaces
93  (
94  const boolList& selectedCell,
95  boolList& regionFace
96  ) const;
97 
98  //- Determine for every disconnected region in the mesh whether
99  // it contains a locationInMesh
100  boolList findRegions
101  (
102  const bool verbose,
103  const boolList& selectedCell,
104  const regionSplit& cellRegion
105  ) const;
106 
107  //- Unselect regions not containing a locationInMesh
108  void unselectOutsideRegions(boolList& selectedCell) const;
109 
110  //- Unselect one layer of cells from selectedCell
111  void shrinkRegions(boolList& selectedCell) const;
112 
113  //- Erode a given number of layers from selectedCell. Remove any
114  // region that gets disconnected that way.
115  void erode(boolList& selectedCell) const;
116 
117  void combine(topoSet& set, const bool add) const;
118 
119 
120 public:
121 
122  //- Runtime type information
123  TypeName("regionsToCell");
124 
125  // Constructors
126 
127  //- Construct from components
129  (
130  const polyMesh& mesh,
131  const word& setName,
132  const pointField& insidePoints,
133  const label nErode
134  );
135 
136  //- Construct from dictionary
137  regionsToCell(const polyMesh& mesh, const dictionary& dict);
138 
139  //- Construct from Istream
140  regionsToCell(const polyMesh& mesh, Istream& is);
141 
142 
143  //- Destructor
144  virtual ~regionsToCell() = default;
145 
146 
147  // Member Functions
148 
149  virtual void applyToSet
150  (
151  const topoSetSource::setAction action,
152  topoSet& set
153  ) const;
154 
155 };
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace Foam
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
Foam::regionsToCell::applyToSet
virtual void applyToSet(const topoSetSource::setAction action, topoSet &set) const
Apply specified action to the topoSet.
Definition: regionsToCell.C:463
boolList.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::combine
Definition: FaceCellWave.C:57
Foam::topoSetSource::setAction
setAction
Enumeration defining the valid actions.
Definition: topoSetSource.H:100
Foam::topoSetSource::verbose
bool verbose() const noexcept
Get output verbosity.
Definition: topoSetSource.H:348
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::regionsToCell::TypeName
TypeName("regionsToCell")
Runtime type information.
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::regionsToCell
TopoSetSource. Select cells belonging to topological connected region (that contains given points)
Definition: regionsToCell.H:68
Foam::regionSplit
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
Definition: regionSplit.H:140
Foam::topoSet
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:63
topoSetCellSource.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::regionsToCell::~regionsToCell
virtual ~regionsToCell()=default
Destructor.
nErode
nErode
Definition: regionsToCell.H:39
Foam::List< bool >
Foam::topoSetCellSource
The topoSetCellSource is a intermediate class for handling topoSet sources for selecting cells.
Definition: topoSetCellSource.H:54
Foam::topoSetSource::mesh
const polyMesh & mesh() const noexcept
Reference to the mesh.
Definition: topoSetSource.H:342
insidePoints
insidePoints((1 2 3))
Foam::regionsToCell::regionsToCell
regionsToCell(const polyMesh &mesh, const word &setName, const pointField &insidePoints, const label nErode)
Construct from components.
Definition: regionsToCell.C:415