booleanSurface.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2015 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::booleanSurface
29
30Description
31 Surface-surface intersection. Given two surfaces construct combined surface.
32
33 Called 'boolean' since the volume of resulting surface will encompass
34 the volumes of the original surface according to some boolean operation:
35 - all which is in surface1 AND in surface2 (intersection)
36 - all which is in surface1 AND NOT in surface2 (surface1 minus surface2)
37 - all which is in surface1 OR in surface2 (union)
38
39 Algorithm:
40 -# find edge-surface intersection. Class 'surfaceIntersection'.
41 -# combine intersection with both surfaces. Class 'intersectedSurface'.
42 -# subset surfaces upto intersection. The 'side' of the surface to
43 include is based on the faces that can be reached from a
44 user-supplied face index.
45 -# merge surfaces. Only the points on the intersection are shared.
46
47SourceFiles
48 booleanSurface.C
49
50\*---------------------------------------------------------------------------*/
51
52#ifndef booleanSurface_H
53#define booleanSurface_H
54
55#include "triSurface.H"
56#include "surfaceIntersection.H"
57#include "typeInfo.H"
58
59// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60
61namespace Foam
62{
63
64// Forward declaration of classes
65class triSurfaceSearch;
66class intersectedSurface;
67
68/*---------------------------------------------------------------------------*\
69 Class booleanSurface Declaration
70\*---------------------------------------------------------------------------*/
73:
74 public triSurface
75{
76 // Data types
77
78 //- Enumeration listing the status of a face (visible/invisible from
79 // outside)
80 enum sideStat
81 {
82 UNVISITED,
83 OUTSIDE,
84 INSIDE
85 };
86
87
88 // Private data
89
90 //- From new to old face + surface:
91 // >0 : to face on surface1
92 // <0 : to face on surface2. Negate and offset by one to get
93 // face2 (e.g. face2I = -faceMap[]-1)
94 labelList faceMap_;
95
96
97 // Private Member Functions
98
99 //- Check whether subset of faces (from markZones) reaches up to
100 // the intersection.
101 static void checkIncluded
102 (
103 const intersectedSurface& surf,
104 const labelList& faceZone,
105 const label includedFace
106 );
107
108 //- Get label in elems of elem.
109 static label index(const labelList& elems, const label elem);
110
111 //- Find index of edge e in subset edgeLabels.
112 static label findEdge
113 (
114 const edgeList& edges,
115 const labelList& edgeLabels,
116 const edge& e
117 );
118
119 //- Get index of face in zoneI whose faceCentre is nearest farAwayPoint
120 static label findNearest
121 (
122 const triSurface& surf,
123 const labelList& faceZone,
124 const label zoneI
125 );
126
127 //- Generate combined patchList (returned). Sets patchMap to map from
128 // surf region numbers into combined patchList
129 static geometricSurfacePatchList mergePatches
130 (
131 const triSurface& surf1,
132 const triSurface& surf2,
133 labelList& patchMap2
134 );
135
136 //- On edgeI, coming from face prevFace, determines visibility/side of
137 // all the other faces using the edge.
138 static void propagateEdgeSide
139 (
140 const triSurface& surf,
141 const label prevVert0,
142 const label prevFacei,
143 const label prevState,
144 const label edgeI,
145 labelList& side
146 );
147
148 //- Given in/outside status of face determines status for all
149 // neighbouring faces.
150 static void propagateSide
151 (
152 const triSurface& surf,
153 const label prevState,
154 const label facei,
155 labelList& side
156 );
157
158
159public:
161 ClassName("booleanSurface");
162
163
164 // Data types
165
166 //- Enumeration listing the possible volume operator types
167 enum booleanOpType
169 UNION, // Union of volumes
170 INTERSECTION, // Intersection of volumes
171 DIFFERENCE, // Difference of volumes
172 ALL // Special: does not subset combined
173 // surface. (Produces multiply connected surface)
174 };
175
176 // Static data
179
180
181
182 // Constructors
183
184 //- Construct null
186
187 //- Construct from surfaces and face labels to keep.
188 // Walks from provided seed faces without crossing intersection line
189 // to determine faces to keep.
191 (
192 const triSurface& surf1,
193 const triSurface& surf2,
194 const surfaceIntersection& inter,
195 const label includeFace1,
196 const label includeFace2
197 );
198
199 //- Construct from surfaces and operation. Surfaces need to be closed
200 // for this to make any sense since uses inside/outside to determine
201 // which part of combined surface to include.
203 (
204 const triSurface& surf1,
205 const triSurface& surf2,
206 const surfaceIntersection& inter,
207 const label booleanOp
208 );
209
210
211 // Member Functions
212
213 //- New to old face map. >0: surface 1 face label. <0: surface 2. Negate
214 // and subtract 1 to get face label on surface 2.
215 const labelList& faceMap() const
216 {
217 return faceMap_;
218 }
220 bool from1(const label facei) const
221 {
222 return faceMap_[facei] >= 0;
223 }
225 bool surf1Face(const label facei) const
226 {
227 if (!from1(facei))
228 {
230 << "face " << facei << " not from surface 1"
231 << abort(FatalError);
232 }
233 return faceMap_[facei];
234 }
236 bool surf2Face(const label facei) const
237 {
238 if (from1(facei))
239 {
241 << "face " << facei << " not from surface 2"
242 << abort(FatalError);
243 }
244 return -faceMap_[facei]-1;
245 }
246};
247
248
249// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250
251} // End namespace Foam
252
253// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254
255#endif
256
257// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
Surface-surface intersection. Given two surfaces construct combined surface.
const labelList & faceMap() const
New to old face map. >0: surface 1 face label. <0: surface 2. Negate.
bool surf2Face(const label facei) const
static const Enum< booleanOpType > booleanOpTypeNames
bool surf1Face(const label facei) const
booleanSurface()
Construct null.
booleanOpType
Enumeration listing the possible volume operator types.
ClassName("booleanSurface")
bool from1(const label facei) const
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:67
Given triSurface and intersection creates the intersected (properly triangulated) surface....
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
Triangulated surface description with patch information.
Definition: triSurface.H:79
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition: className.H:67
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
volScalarField & e
Definition: createFields.H:11