cuttingSurfaceBase.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) 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::cuttingSurfaceBase
28 
29 Description
30  Base for creating a MeshedSurface by performing some type of cell
31  cutting/intersection.
32 
33  No attempt at resolving degenerate cases.
34  Since the cut faces can be quite ugly, they will often be triangulated.
35 
36 SourceFiles
37  cuttingSurfaceBase.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef cuttingSurfaceBase_H
42 #define cuttingSurfaceBase_H
43 
44 #include "bitSet.H"
45 #include "faceList.H"
46 #include "MeshedSurface.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declarations
54 class primitiveMesh;
55 
56 /*---------------------------------------------------------------------------*\
57  Class cuttingSurfaceBase Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 :
62  public MeshedSurface<face>
63 {
64 protected:
65 
66  //- Typedef for convenience
68 
69 
70  // Protected Data
71 
72  //- List of the cells cut
74 
75 
76  // Protected Member Functions
77 
78  //- Walk cell cuts to create faces
79  //
80  // \tparam EdgeOrientIntersect
81  // Parameter (edge&), returns bool.
82  // Orient edge for a consistent positive gradient.
83  // Checks for edge intersection (true|false).
84  //
85  // \tparam EdgeAlphaIntersect
86  // Parameter (const edge&), returns scalar.
87  // Determine alpha [0-1] for an intersecting edge.
88  // No guarantees when used with non-intersecting edges.
89  //
90  // \param cellCuts [in] The cells to walk.
91  template<class EdgeOrientIntersect, class EdgeAlphaIntersect>
92  void walkCellCuts
93  (
94  const primitiveMesh& mesh,
95  const bitSet& cellCuts,
96  const EdgeOrientIntersect& edgeOrientIntersect,
97  const EdgeAlphaIntersect& edgeAlphaIntersect,
98  const bool triangulate,
99  label nFaceCuts = 0
100  );
101 
102 
103  //- Cut mesh, restricted to a list of cells
104  virtual void performCut
105  (
106  const primitiveMesh& mesh,
107  const bool triangulate,
108  const labelUList& cellIdLabels
109  );
110 
111  //- Cut mesh, restricted to a list of cells
112  virtual void performCut
113  (
114  const primitiveMesh& mesh,
115  const bool triangulate,
116  const bitSet& cellSelectionMask = bitSet()
117  );
118 
119  //- Cut mesh, restricted to a list of cells
120  // Reclaim memory for cellSelectionMask
121  virtual void performCut
122  (
123  const primitiveMesh& mesh,
124  const bool triangulate,
125  bitSet&& cellSelectionMask
126  ) = 0;
127 
128  //- Remap action on triangulation or cleanup
129  virtual void remapFaces(const labelUList& faceMap);
130 
131 
132  //- Check and warn if bounding boxes do not intersect
133  static void checkOverlap
134  (
135  const word callerName,
136  const boundBox& meshBounds,
137  const boundBox& userBounds
138  );
139 
140 
141  //- Define cell selection from bounding-box and zones.
142  //
143  // \param userBounds Optionally user-specified bounding box
144  // \param zoneNames Optionally user-specified zone names
145  // \param meshBounds [out] The effective mesh bounds after applying
146  // the user-specified zone names
147  //
148  // \return A set of nCells size with the selected cells or an empty
149  // set if no bounding-box or zones were specified.
150  static bitSet cellSelection
151  (
152  const polyMesh& mesh,
153  const boundBox& userBounds,
154  const wordRes& zoneNames,
155  boundBox& meshBounds
156  );
157 
158  //- Define cell selection from bounding-box and zones.
159  //
160  // \param userBounds Optionally user-specified bounding box
161  // \param zoneNames Optionally user-specified zone names
162  // \param callerName The caller name for warnings
163  // \param warn Check and warn if the bounding box does not
164  // overlap with the mesh (or submesh)
165  //
166  // \return A set of nCells size with the selected cells or an empty
167  // set if no bounding-box or zones were specified.
168  static bitSet cellSelection
169  (
170  const polyMesh& mesh,
171  const boundBox& userBounds,
172  const wordRes& zoneNames,
173  const word callerName,
174  const bool warn
175  );
176 
177 
178 public:
179 
180  //- Debug information
181  static int debug;
182 
183 
184  // Constructors
185 
186  //- Construct null
188 
189 
190  //- Destructors
191  virtual ~cuttingSurfaceBase() = default;
192 
193 
194  // Member Functions
195 
196  //- The mesh cells cut
197  const labelList& meshCells() const
198  {
199  return meshCells_;
200  }
201 
202  //- The mesh cells cut
204  {
205  return meshCells_;
206  }
207 
208  //- Have any cells been cut?
209  bool cut() const
210  {
211  return meshCells_.size();
212  }
213 
214 
215  // Member Operators
216 
217  //- Copy assignment
218  void operator=(const cuttingSurfaceBase& rhs);
219 };
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 } // End namespace Foam
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #ifdef NoRepository
229 #endif
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 #endif
234 
235 // ************************************************************************* //
Foam::cuttingSurfaceBase::meshCells
labelList & meshCells()
The mesh cells cut.
Definition: cuttingSurfaceBase.H:202
Foam::cuttingSurfaceBase::meshCells
const labelList & meshCells() const
The mesh cells cut.
Definition: cuttingSurfaceBase.H:196
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:94
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:64
Foam::MeshedSurface< face >::triangulate
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
Definition: MeshedSurface.C:864
Foam::cuttingSurfaceBase::cuttingSurfaceBase
cuttingSurfaceBase()
Construct null.
Definition: cuttingSurfaceBase.C:40
Foam::cuttingSurfaceBase::checkOverlap
static void checkOverlap(const word callerName, const boundBox &meshBounds, const boundBox &userBounds)
Check and warn if bounding boxes do not intersect.
Definition: cuttingSurfaceBaseSelection.C:34
Foam::cuttingSurfaceBase::cellSelection
static bitSet cellSelection(const polyMesh &mesh, const boundBox &userBounds, const wordRes &zoneNames, boundBox &meshBounds)
Define cell selection from bounding-box and zones.
Definition: cuttingSurfaceBaseSelection.C:53
faceList.H
bitSet.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::cuttingSurfaceBase::cut
bool cut() const
Have any cells been cut?
Definition: cuttingSurfaceBase.H:208
Foam::label
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:62
Foam::cuttingSurfaceBase::remapFaces
virtual void remapFaces(const labelUList &faceMap)
Remap action on triangulation or cleanup.
Definition: cuttingSurfaceBase.C:79
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cuttingSurfaceBase::walkCellCuts
void walkCellCuts(const primitiveMesh &mesh, const bitSet &cellCuts, const EdgeOrientIntersect &edgeOrientIntersect, const EdgeAlphaIntersect &edgeAlphaIntersect, const bool triangulate, label nFaceCuts=0)
Walk cell cuts to create faces.
Definition: cuttingSurfaceBaseTemplates.C:36
cuttingSurfaceBaseTemplates.C
Foam::List< label >
Foam::cuttingSurfaceBase::debug
static int debug
Debug information.
Definition: cuttingSurfaceBase.H:180
Foam::UList< label >
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
Foam::cuttingSurfaceBase
Base for creating a MeshedSurface by performing some type of cell cutting/intersection.
Definition: cuttingSurfaceBase.H:59
Foam::cuttingSurfaceBase::operator=
void operator=(const cuttingSurfaceBase &rhs)
Copy assignment.
Definition: cuttingSurfaceBase.C:97
Foam::cuttingSurfaceBase::~cuttingSurfaceBase
virtual ~cuttingSurfaceBase()=default
Destructors.
Foam::MeshedSurface
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: triSurfaceTools.H:80
Foam::cuttingSurfaceBase::MeshStorage
MeshedSurface< face > MeshStorage
Typedef for convenience.
Definition: cuttingSurfaceBase.H:66
Foam::cuttingSurfaceBase::performCut
virtual void performCut(const primitiveMesh &mesh, const bool triangulate, const labelUList &cellIdLabels)
Cut mesh, restricted to a list of cells.
Definition: cuttingSurfaceBase.C:60
Foam::cuttingSurfaceBase::meshCells_
labelList meshCells_
List of the cells cut.
Definition: cuttingSurfaceBase.H:72
MeshedSurface.H
Foam::cellCuts
Description of cuts across cells.
Definition: cellCuts.H:110
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78