holeToFace.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) 2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::holeToFace
28
29Description
30 A topoSetFaceSource to select a set of faces that closes a hole i.e.
31 disconnects zones (specified by locations) from one another.
32
33 Algorithm roughly according to
34 "A 3D-Hole Closing Algorithm", Zouina Aktouf et al
35
36 \heading Dictionary parameters
37 \table
38 Property | Description | Required | Default
39 points | Per zone the list of points | yes |
40 faceSet | Optional blocked faces | no | <empty>
41 cellSet | Optional subset of cells to operate in | no | <empty>
42 erode | Perform some cleanup on set | no | no
43 \endtable
44
45 Limited to max 31 zones.
46
47SourceFiles
48 holeToFace.C
49
50\*---------------------------------------------------------------------------*/
51
52#ifndef holeToFace_H
53#define holeToFace_H
54
55#include "topoSetFaceSource.H"
56#include "bitSet.H"
57#include "mapDistribute.H"
58
59// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60
61namespace Foam
62{
63
64/*---------------------------------------------------------------------------*\
65 Class holeToFace Declaration
66\*---------------------------------------------------------------------------*/
67
68class holeToFace
69:
70 public topoSetFaceSource
71{
72 // Private data
73
74 //- Add usage string
75 static addToUsageTable usage_;
76
77 //- Per 'zone' the set of points
78 List<pointField> zonePoints_;
79
80 //- Names of faceSets specifying blockage
81 wordList blockedFaceNames_;
82
83 //- Names of cellSets specifying blockage
84 wordList blockedCellNames_;
85
86 //- Erode set
87 bool erode_;
88
89
90 // Private Member Functions
91
92 // Helper functions
93
94 //- Expand pointField into list of pointFields
95 static List<pointField> expand(const pointField& pts);
96
97 //- Write .obj file with selected faces
98 void writeFaces
99 (
100 const word& name,
101 const bitSet& faceFld
102 ) const;
103
104
105 //- Calculate topological distance from seedFaces. Do not cross
106 // blocked cells/faces
107 void calculateDistance
108 (
109 const labelList& seedFaces,
110 const bitSet& isBlockedCell,
111 const bitSet& isBlockedFace,
112 labelList& cellDist,
113 labelList& faceDist
114 ) const;
115
116 //- Calculate faces on outside of hole cells. Ignore blocked faces
117 // (isSurfaceFace) and faces reachable from more than one location
118 bitSet frontFaces
119 (
120 const bitSet& isSurfaceFace,
121 const List<unsigned int>& locationFaces,
122 const bitSet& isHoleCell
123 ) const;
124
125 //- Overall driver to find minimum set of faces to close the path
126 // between zones
127 bitSet findClosure
128 (
129 const bitSet& isSurfaceFace, // intersected faces
130 const bitSet& isCandidateHoleCell, // starting blockage
131 const labelListList& locationCells // cells per zone
132 ) const;
133
134 //- WIP. Remove excess faces. Not parallel consistent.
135 bitSet erodeSet
136 (
137 const bitSet& isSurfaceFace,
138 const bitSet& isSetFace
139 ) const;
140
141
142public:
143
144 //- Runtime type information
145 TypeName("holeToFace");
146
147 // Constructors
148
149 //- Construct from components
151 (
152 const polyMesh& mesh,
153 const List<pointField>& zonePoints,
154 const wordList& blockedFaceNames,
155 const wordList& blockedCellNames,
156 const bool erode
157 );
158
159 //- Construct from dictionary
160 holeToFace(const polyMesh& mesh, const dictionary& dict);
161
162 //- Construct from Istream
163 holeToFace(const polyMesh& mesh, Istream& is);
164
165
166 //- Destructor
167 virtual ~holeToFace() = default;
168
170 // Member Functions
171
172 virtual void applyToSet
173 (
174 const topoSetSource::setAction action,
175 topoSet&
176 ) const;
177
178 //- Optional direct use to generate a faceSet
179 void combine
180 (
181 topoSet& set,
182 const bitSet& isBlockedFace,
183 const bitSet& isActiveCell,
184 const bool add
185 ) const;
186
187 //- Optional direct use to generate the set of faces and the method to
188 // get data from nearby blocked faces. Gets provided with the
189 // - set of points per 'zone'
190 // - set of blocked faces
191 // - global numbering for these blocked faces
192 // Returns
193 // - the set of faces to disconnect zones from one
194 // another (closureFaces)
195 // - a nullptr or the maps from closureFaces to nearest blocked face
196 // (mapDistribute and closureToBlocked). Note: closureToBlocked
197 // (index into the map) can contain -1 if no nearby valid blocked
198 // face could be found (from an edge-face-edge walk)
200 (
201 const polyMesh& mesh,
202 const List<pointField>& zonePoints,
203 const labelList& blockedFaces,
204 const globalIndex& globalBlockedFaces,
205 const bool erode,
206 labelList& closureFaces,
207 labelList& closureToBlocked
208 );
209};
210
211
212// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213
214} // End namespace Foam
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218#endif
219
220// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
A topoSetFaceSource to select a set of faces that closes a hole i.e. disconnects zones (specified by ...
Definition: holeToFace.H:95
virtual void applyToSet(const topoSetSource::setAction action, topoSet &) const
Apply specified action to the topoSet.
Definition: holeToFace.C:1142
static autoPtr< mapDistribute > calcClosure(const polyMesh &mesh, const List< pointField > &zonePoints, const labelList &blockedFaces, const globalIndex &globalBlockedFaces, const bool erode, labelList &closureFaces, labelList &closureToBlocked)
Optional direct use to generate the set of faces and the method to.
Definition: holeToFace.C:1194
virtual ~holeToFace()=default
Destructor.
TypeName("holeToFace")
Runtime type information.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
The topoSetFaceSource is a intermediate class for handling topoSet sources for selecting faces.
Class with constructor to add usage string to table.
setAction
Enumeration defining various actions.
const polyMesh & mesh() const noexcept
Reference to the mesh.
General set of labels of mesh quantity (points, cells, faces).
Definition: topoSet.H:67
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73