1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::slidingInterface
29 Sliding interface mesh modifier. Given two face zones, couple the
30 master and slave side using a cutting procedure.
32 The coupled faces are collected into the "coupled" zone and can become
33 either internal or placed into a master and slave coupled zone. The
34 remaining faces (uncovered master or slave) are placed into the master
37 The definition of the sliding interface can be either integral or partial.
38 Integral interface implies that the slave side completely covers
39 the master (i.e. no faces are uncovered); partial interface
40 implies that the uncovered part of master/slave face zone should
41 become boundary faces.
44 Hrvoje Jasak, Nabla Ltd. and Wikki Ltd. All rights reserved.
45 Copyright Hrvoje Jasak
49 coupleSlidingInterface.C
50 decoupleSlidingInterface.C
51 slidingInterfaceProjectPoints.C
52 slidingInterfaceAttachedAddressing.C
53 slidingInterfaceClearCouple.C
54 writeSlidingInterfaceVTK.C
56 \*---------------------------------------------------------------------------*/
58 #ifndef slidingInterface_H
59 #define slidingInterface_H
61 #include "polyMeshModifier.H"
62 #include "primitiveFacePatch.H"
63 #include "polyPatchID.H"
65 #include "intersection.H"
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 // Forward declaration of classes
76 /*---------------------------------------------------------------------------*\
77 Class slidingInterface Declaration
78 \*---------------------------------------------------------------------------*/
80 class slidingInterface
82 public polyMeshModifier
86 // Public enumerations
96 static const NamedEnum<typeOfMatch, 2> typeOfMatchNames_;
103 //- Master face zone ID
104 faceZoneID masterFaceZoneID_;
106 //- Slave face zone ID
107 faceZoneID slaveFaceZoneID_;
109 //- Cut point zone ID
110 pointZoneID cutPointZoneID_;
113 faceZoneID cutFaceZoneID_;
116 polyPatchID masterPatchID_;
119 polyPatchID slavePatchID_;
122 const typeOfMatch matchType_;
124 //- Couple-decouple operation.
125 // If the interface is coupled, decouple it and vice versa.
126 // Used in conjuction with automatic mesh motion
127 mutable Switch coupleDecouple_;
129 //- State of the modifier
130 mutable Switch attached_;
132 //- Point projection algorithm
133 intersection::algorithm projectionAlgo_;
135 //- Trigger topological change
136 mutable bool trigger_;
139 // Private addressing data.
141 //- Cut face master face. Gives the index of face in master patch
142 // the cut face has been created from. For a slave-only face
144 mutable labelList* cutFaceMasterPtr_;
146 //- Cut face slave face. Gives the index of face in slave patch
147 // the cut face has been created from. For a master-only face
149 mutable labelList* cutFaceSlavePtr_;
151 //- Master zone faceCells
152 mutable labelList* masterFaceCellsPtr_;
154 //- Slave zone faceCells
155 mutable labelList* slaveFaceCellsPtr_;
157 //- Master stick-out faces
158 mutable labelList* masterStickOutFacesPtr_;
160 //- Slave stick-out faces
161 mutable labelList* slaveStickOutFacesPtr_;
163 //- Retired point mapping.
164 // For every retired slave side point, gives the label of the
165 // master point that replaces it
166 mutable Map<label>* retiredPointMapPtr_;
169 // For cut points created by intersection two edges,
170 // store the master-slave edge pair used in creation
171 mutable Map<Pair<edge> >* cutPointEdgePairMapPtr_;
173 //- Slave point hit. The index of master point hit by the
174 // slave point in projection. For no point hit, set to -1
175 mutable labelList* slavePointPointHitsPtr_;
177 //- Slave edge hit. The index of master edge hit by the
178 // slave point in projection. For point or no edge hit, set to -1
179 mutable labelList* slavePointEdgeHitsPtr_;
181 //- Slave face hit. The index of master face hit by the
182 // slave point in projection.
183 mutable List<objectHit>* slavePointFaceHitsPtr_;
185 //- Master point edge hit. The index of slave edge hit by
186 // a master point. For no hit set to -1
187 mutable labelList* masterPointEdgeHitsPtr_;
189 //- Projected slave points
190 mutable pointField* projectedSlavePointsPtr_;
193 // Private Member Functions
195 //- Disallow default bitwise copy construct
196 slidingInterface(const slidingInterface&);
198 //- Disallow default bitwise assignment
199 void operator=(const slidingInterface&);
202 void clearOut() const;
205 //- Check validity of construction data
206 void checkDefinition() const;
208 //- Calculate attached addressing
209 void calcAttachedAddressing() const;
211 //- Calculate decoupled zone face-cell addressing
212 void renumberAttachedAddressing(const mapPolyMesh&) const;
214 //- Clear attached addressing
215 void clearAttachedAddressing() const;
218 // Topological changes
221 const labelList& masterFaceCells() const;
224 const labelList& slaveFaceCells() const;
226 //- Master stick-out faces
227 const labelList& masterStickOutFaces() const;
229 //- Slave stick-out faces
230 const labelList& slaveStickOutFaces() const;
232 //- Retired point map
233 const Map<label>& retiredPointMap() const;
235 //- Cut point edge pair map
236 const Map<Pair<edge> >& cutPointEdgePairMap() const;
239 void clearAddressing() const;
241 //- Project slave points and compare with the current projection.
242 // If the projection has changed, the sliding interface
243 // changes topologically
244 bool projectPoints() const;
246 //- Couple sliding interface
247 void coupleInterface(polyTopoChange& ref) const;
250 void clearPointProjection() const;
253 void clearCouple(polyTopoChange& ref) const;
255 //- Decouple interface (returns it to decoupled state)
256 // Note: this should not be used in normal operation of the
257 // sliding mesh, but only to return the mesh to its
259 void decoupleInterface(polyTopoChange& ref) const;
262 // Static data members
264 //- Point merge tolerance
265 static const scalar pointMergeTol_;
267 //- Edge merge tolerance
268 static const scalar edgeMergeTol_;
270 //- Estimated number of faces an edge goes through
271 static const label nFacesPerSlaveEdge_;
273 //- Edge-face interaction escape limit
274 static const label edgeFaceEscapeLimit_;
276 //- Integral match point adjustment tolerance
277 static const scalar integralAdjTol_;
279 //- Edge intersection master catch fraction
280 static const scalar edgeMasterCatchFraction_;
282 //- Edge intersection co-planar tolerance
283 static const scalar edgeCoPlanarTol_;
285 //- Edge end cut-off tolerance
286 static const scalar edgeEndCutoffTol_;
291 //- Runtime type information
292 TypeName("slidingInterface");
297 //- Construct from components
302 const polyTopoChanger& mme,
303 const word& masterFaceZoneName,
304 const word& slaveFaceZoneName,
305 const word& cutPointZoneName,
306 const word& cutFaceZoneName,
307 const word& masterPatchName,
308 const word& slavePatchName,
309 const typeOfMatch tom,
310 const bool coupleDecouple,
311 const intersection::algorithm algo
314 //- Construct from dictionary
318 const dictionary& dict,
320 const polyTopoChanger& mme
326 virtual ~slidingInterface();
331 //- Return master face zone ID
332 const faceZoneID& masterFaceZoneID() const;
334 //- Return slave face zone ID
335 const faceZoneID& slaveFaceZoneID() const;
337 //- Return cut point zone ID
338 const pointZoneID& cutPointZoneID() const;
340 //- Return cut face zone ID
341 const faceZoneID& cutFaceZoneID() const;
343 //- Return true if attached
344 bool attached() const
349 //- Check for topology change
350 virtual bool changeTopology() const;
352 //- Insert the layer addition/removal instructions
353 // into the topological change
354 virtual void setRefinement(polyTopoChange&) const;
356 //- Modify motion points to comply with the topological change
357 virtual void modifyMotionPoints(pointField& motionPoints) const;
359 //- Force recalculation of locally stored data on topological change
360 virtual void updateMesh(const mapPolyMesh&);
362 //- Return projected points for a slave patch
363 const pointField& pointProjection() const;
367 virtual void write(Ostream&) const;
370 virtual void writeDict(Ostream&) const;
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376 } // End namespace Foam
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
382 // ************************************************************************* //