enrichedPatch.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 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::enrichedPatch
29 
30 Description
31  The enriched patch contains a double set of faces from the two
32  sides of the sliding interface before the cutting.
33 
34  The patch basically consists of two over-lapping sets of faces sitting
35  on a common point support, where every edge may be shared by more than
36  2 faces. The patch points are collected in a map. Additional
37  information needed for cutting is the point insertion into every edge
38  of master and slave.
39 
40  Note:
41  If new points are created during master-slave edge cutting, they
42  should be registered with the pointMap.
43 
44 SourceFiles
45  enrichedPatch.C
46  enrichedPatchCutFaces.C
47  enrichedPatchFaces.C
48  enrichedPatchPointMap.C
49  enrichedPatchPointMergeMap.C
50  enrichedPatchPointPoints.C
51 
52 \*---------------------------------------------------------------------------*/
53 
54 #ifndef Foam_enrichedPatch_H
55 #define Foam_enrichedPatch_H
56 
57 #include "Map.H"
58 #include "primitivePatch.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 
65 /*---------------------------------------------------------------------------*\
66  Class enrichedPatch Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class enrichedPatch
70 {
71  // Private Data
72 
73  //- Reference to master patch
74  const primitiveFacePatch& masterPatch_;
75 
76  //- Reference to slave patch
77  const primitiveFacePatch& slavePatch_;
78 
79  //- Map of points supporting patch faces
80  mutable Map<point> pointMap_;
81 
82  //- Has the point map been completed?
83  mutable bool pointMapComplete_;
84 
85  //- Map of point merges
86  mutable Map<label> pointMergeMap_;
87 
88  //- Slave point point hits
89  const labelList& slavePointPointHits_;
90 
91  //- Slave point edge hits
92  const labelList& slavePointEdgeHits_;
93 
94  //- Slave point face hits
95  const List<objectHit>& slavePointFaceHits_;
96 
97 
98  // Demand-driven private data
99 
100  //- Enriched patch
101  mutable std::unique_ptr<faceList> enrichedFacesPtr_;
102 
103  //- Mesh points
104  mutable std::unique_ptr<labelList> meshPointsPtr_;
105 
106  //- Local faces
107  mutable std::unique_ptr<faceList> localFacesPtr_;
108 
109  //- Local points
110  mutable std::unique_ptr<pointField> localPointsPtr_;
111 
112  //- Point-point addressing
113  mutable std::unique_ptr<labelListList> pointPointsPtr_;
114 
115  // Master point addressing
116  mutable std::unique_ptr<Map<labelList>> masterPointFacesPtr_;
117 
118 
119  // Cut faces and addressing
120 
121  //- Cut faces
122  mutable std::unique_ptr<faceList> cutFacesPtr_;
123 
124  //- Cut face master
125  // - the face on the master patch for internal faces
126  // - the creator face for boundary face
127  mutable std::unique_ptr<labelList> cutFaceMasterPtr_;
128 
129  //- Cut face slave
130  // - the face on the slave patch for internal faces
131  // - -1 for boundary face
132  mutable std::unique_ptr<labelList> cutFaceSlavePtr_;
133 
134 
135  // Private Member Functions
136 
137  //- No copy construct
138  enrichedPatch(const enrichedPatch&) = delete;
139 
140  //- No copy assignment
141  void operator=(const enrichedPatch&) = delete;
142 
143  // Creation of demand-driven private data
144 
145  //- Calculate point merge map
146  void calcPointMergeMap() const;
147 
148  //- Complete point map
149  void completePointMap() const;
150 
151  //- Calculate mesh points
152  void calcMeshPoints() const;
153 
154  //- Calculate local points
155  void calcLocalPoints() const;
156 
157  //- Calculate local faces
158  void calcLocalFaces() const;
159 
160  //- Calculate point-point addressing
161  void calcPointPoints() const;
162 
163  //- Calculate master point addressing
164  void calcMasterPointFaces() const;
165 
166  //- Calculate cut faces
167  void calcCutFaces() const;
168 
169  //- Clear cut faces
170  void clearCutFaces();
171 
172  //- Clear out demand-driven data
173  void clearOut();
174 
175 
176  // Static Data Members
177 
178  //- Estimated ratio of original-to-enriched face size
179  static const label enrichedFaceRatio_;
180 
181  //- Size of face on which the check is forced
182  static const label maxFaceSizeDebug_;
183 
184 
185 public:
186 
187  // Static data members
188  ClassName("enrichedPatch");
189 
190 
191  // Constructors
192 
193  //- Construct from components
195  (
196  const primitiveFacePatch& masterPatch,
197  const primitiveFacePatch& slavePatch,
198  const labelUList& slavePointPointHits,
199  // -1 or common point snapped to
200  const labelUList& slavePointEdgeHits,
201  // -1 or common edge snapped to
202  const UList<objectHit>& slavePointFaceHits
203  // master face snapped to
204  );
205 
206 
207  //- Destructor
208  ~enrichedPatch() = default;
209 
210 
211  // Member Functions
212 
213  // Access
214 
215  //- Return map of points
216  inline const Map<point>& pointMap() const;
217 
218  //- Return non-const access to point map to add points
219  inline Map<point>& pointMap();
220 
221  //- Return map of point merges
222  inline const Map<label>& pointMergeMap() const;
223 
224  //- Return map of point merges
225  inline Map<label>& pointMergeMap();
226 
227 
228  // Topological data
229 
230  //- Calculate enriched faces
231  void calcEnrichedFaces
232  (
233  const labelListList& pointsIntoMasterEdges,
234  const labelListList& pointsIntoSlaveEdges,
235  const pointField& projectedSlavePoints
236  );
237 
238  //- Return enriched faces
239  const faceList& enrichedFaces() const;
240 
241  //- Return mesh points
242  const labelList& meshPoints() const;
243 
244  //- Return local faces
245  const faceList& localFaces() const;
246 
247  //- Return local points
248  const pointField& localPoints() const;
249 
250  //- Return point-point addressing
251  const labelListList& pointPoints() const;
252 
253  //- Master point face addressing
254  const Map<labelList>& masterPointFaces() const;
255 
256 
257  // Cut faces
258 
259  //- Return list of cut faces
260  const faceList& cutFaces() const;
261 
262  //- Return cut face master list
263  const labelList& cutFaceMaster() const;
264 
265  //- Return cut face slave list
266  const labelList& cutFaceSlave() const;
267 
268 
269  //- Check if the patch is fully supported
270  bool checkSupport() const;
271 
272 
273  //- Debugging: dump graphical representation to obj format file
274  void writeOBJ(const fileName& fName) const;
275 };
276 
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 } // End namespace Foam
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 #include "enrichedPatchI.H"
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
void writeOBJ(const fileName &fName) const
Debugging: dump graphical representation to obj format file.
A class for handling file names.
Definition: fileName.H:72
~enrichedPatch()=default
Destructor.
const labelList & cutFaceMaster() const
Return cut face master list.
const faceList & cutFaces() const
Return list of cut faces.
const Map< labelList > & masterPointFaces() const
Master point face addressing.
bool checkSupport() const
Check if the patch is fully supported.
const faceList & enrichedFaces() const
Return enriched faces.
A list of faces which address into the list of points.
const labelList & cutFaceSlave() const
Return cut face slave list.
The enriched patch contains a double set of faces from the two sides of the sliding interface before ...
Definition: enrichedPatch.H:64
const Map< point > & pointMap() const
Return map of points.
ClassName("enrichedPatch")
const labelListList & pointPoints() const
Return point-point addressing.
const pointField & localPoints() const
Return local points.
void calcEnrichedFaces(const labelListList &pointsIntoMasterEdges, const labelListList &pointsIntoSlaveEdges, const pointField &projectedSlavePoints)
Calculate enriched faces.
const faceList & localFaces() const
Return local faces.
const labelList & meshPoints() const
Return mesh points.
const Map< label > & pointMergeMap() const
Return map of point merges.
Namespace for OpenFOAM.
A HashTable to objects of type <T> with a label key.