1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Foam::slidingInterface
28 Sliding interface mesh modifier. Given two face zones, couple the
29 master and slave side using a cutting procedure.
31 The coupled faces are collected into the "coupled" zone and can become
32 either internal or placed into a master and slave coupled zone. The
33 remaining faces (uncovered master or slave) are placed into the master
36 The definition of the sliding interface can be either integral or partial.
37 Integral interface implies that the slave side completely covers
38 the master (i.e. no faces are uncovered); partial interface
39 implies that the uncovered part of master/slave face zone should
40 become boundary faces.
44 coupleSlidingInterface.C
45 decoupleSlidingInterface.C
46 slidingInterfaceProjectPoints.C
47 slidingInterfaceAttachedAddressing.C
48 slidingInterfaceClearCouple.C
50 \*---------------------------------------------------------------------------*/
52 #ifndef slidingInterface_H
53 #define slidingInterface_H
55 #include "polyMeshModifier.H"
56 #include "primitiveFacePatch.H"
57 #include "polyPatchID.H"
59 #include "intersection.H"
61 #include "objectHit.H"
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 /*---------------------------------------------------------------------------*\
69 Class slidingInterface Declaration
70 \*---------------------------------------------------------------------------*/
72 class slidingInterface
74 public polyMeshModifier
78 // Public enumerations
88 static const NamedEnum<typeOfMatch, 2> typeOfMatchNames_;
94 //- Master face zone ID
95 faceZoneID masterFaceZoneID_;
97 //- Slave face zone ID
98 faceZoneID slaveFaceZoneID_;
100 //- Cut point zone ID
101 pointZoneID cutPointZoneID_;
104 faceZoneID cutFaceZoneID_;
107 polyPatchID masterPatchID_;
110 polyPatchID slavePatchID_;
113 const typeOfMatch matchType_;
115 //- Couple-decouple operation.
116 // If the interface is coupled, decouple it and vice versa.
117 // Used in conjuction with automatic mesh motion
118 mutable Switch coupleDecouple_;
120 //- State of the modifier
121 mutable Switch attached_;
123 //- Point projection algorithm
124 intersection::algorithm projectionAlgo_;
126 //- Trigger topological change
127 mutable bool trigger_;
129 // Tolerances. Initialised to static ones below.
131 //- Point merge tolerance
132 scalar pointMergeTol_;
134 //- Edge merge tolerance
135 scalar edgeMergeTol_;
137 //- Estimated number of faces an edge goes through
138 label nFacesPerSlaveEdge_;
140 //- Edge-face interaction escape limit
141 label edgeFaceEscapeLimit_;
143 //- Integral match point adjustment tolerance
144 scalar integralAdjTol_;
146 //- Edge intersection master catch fraction
147 scalar edgeMasterCatchFraction_;
149 //- Edge intersection co-planar tolerance
150 scalar edgeCoPlanarTol_;
152 //- Edge end cut-off tolerance
153 scalar edgeEndCutoffTol_;
156 // Private addressing data.
158 //- Cut face master face. Gives the index of face in master patch
159 // the cut face has been created from. For a slave-only face
161 mutable labelList* cutFaceMasterPtr_;
163 //- Cut face slave face. Gives the index of face in slave patch
164 // the cut face has been created from. For a master-only face
166 mutable labelList* cutFaceSlavePtr_;
168 //- Master zone faceCells
169 mutable labelList* masterFaceCellsPtr_;
171 //- Slave zone faceCells
172 mutable labelList* slaveFaceCellsPtr_;
174 //- Master stick-out faces
175 mutable labelList* masterStickOutFacesPtr_;
177 //- Slave stick-out faces
178 mutable labelList* slaveStickOutFacesPtr_;
180 //- Retired point mapping.
181 // For every retired slave side point, gives the label of the
182 // master point that replaces it
183 mutable Map<label>* retiredPointMapPtr_;
186 // For cut points created by intersection two edges,
187 // store the master-slave edge pair used in creation
188 mutable Map<Pair<edge> >* cutPointEdgePairMapPtr_;
190 //- Slave point hit. The index of master point hit by the
191 // slave point in projection. For no point hit, set to -1
192 mutable labelList* slavePointPointHitsPtr_;
194 //- Slave edge hit. The index of master edge hit by the
195 // slave point in projection. For point or no edge hit, set to -1
196 mutable labelList* slavePointEdgeHitsPtr_;
198 //- Slave face hit. The index of master face hit by the
199 // slave point in projection.
200 mutable List<objectHit>* slavePointFaceHitsPtr_;
202 //- Master point edge hit. The index of slave edge hit by
203 // a master point. For no hit set to -1
204 mutable labelList* masterPointEdgeHitsPtr_;
206 //- Projected slave points
207 mutable pointField* projectedSlavePointsPtr_;
210 // Private Member Functions
212 //- Disallow default bitwise copy construct
213 slidingInterface(const slidingInterface&);
215 //- Disallow default bitwise assignment
216 void operator=(const slidingInterface&);
219 void clearOut() const;
222 //- Check validity of construction data
223 void checkDefinition();
225 //- Calculate attached addressing
226 void calcAttachedAddressing() const;
228 //- Calculate decoupled zone face-cell addressing
229 void renumberAttachedAddressing(const mapPolyMesh&) const;
231 //- Clear attached addressing
232 void clearAttachedAddressing() const;
235 // Topological changes
238 const labelList& masterFaceCells() const;
241 const labelList& slaveFaceCells() const;
243 //- Master stick-out faces
244 const labelList& masterStickOutFaces() const;
246 //- Slave stick-out faces
247 const labelList& slaveStickOutFaces() const;
249 //- Retired point map
250 const Map<label>& retiredPointMap() const;
252 //- Cut point edge pair map
253 const Map<Pair<edge> >& cutPointEdgePairMap() const;
256 void clearAddressing() const;
258 //- Project slave points and compare with the current projection.
259 // If the projection has changed, the sliding interface
260 // changes topologically
261 bool projectPoints() const;
263 //- Couple sliding interface
264 void coupleInterface(polyTopoChange& ref) const;
267 void clearPointProjection() const;
270 void clearCouple(polyTopoChange& ref) const;
272 //- Decouple interface (returns it to decoupled state)
273 // Note: this should not be used in normal operation of the
274 // sliding mesh, but only to return the mesh to its
276 void decoupleInterface(polyTopoChange& ref) const;
279 // Static data members
281 //- Point merge tolerance
282 static const scalar pointMergeTolDefault_;
284 //- Edge merge tolerance
285 static const scalar edgeMergeTolDefault_;
287 //- Estimated number of faces an edge goes through
288 static const label nFacesPerSlaveEdgeDefault_;
290 //- Edge-face interaction escape limit
291 static const label edgeFaceEscapeLimitDefault_;
293 //- Integral match point adjustment tolerance
294 static const scalar integralAdjTolDefault_;
296 //- Edge intersection master catch fraction
297 static const scalar edgeMasterCatchFractionDefault_;
299 //- Edge intersection co-planar tolerance
300 static const scalar edgeCoPlanarTolDefault_;
302 //- Edge end cut-off tolerance
303 static const scalar edgeEndCutoffTolDefault_;
308 //- Runtime type information
309 TypeName("slidingInterface");
314 //- Construct from components
319 const polyTopoChanger& mme,
320 const word& masterFaceZoneName,
321 const word& slaveFaceZoneName,
322 const word& cutPointZoneName,
323 const word& cutFaceZoneName,
324 const word& masterPatchName,
325 const word& slavePatchName,
326 const typeOfMatch tom,
327 const bool coupleDecouple = false,
328 const intersection::algorithm algo = intersection::VISIBLE
331 //- Construct from dictionary
335 const dictionary& dict,
337 const polyTopoChanger& mme
342 virtual ~slidingInterface();
347 //- Return master face zone ID
348 const faceZoneID& masterFaceZoneID() const;
350 //- Return slave face zone ID
351 const faceZoneID& slaveFaceZoneID() const;
353 //- Return true if attached
354 bool attached() const
359 //- Check for topology change
360 virtual bool changeTopology() const;
362 //- Insert the layer addition/removal instructions
363 // into the topological change
364 virtual void setRefinement(polyTopoChange&) const;
366 //- Modify motion points to comply with the topological change
367 virtual void modifyMotionPoints(pointField& motionPoints) const;
369 //- Force recalculation of locally stored data on topological change
370 virtual void updateMesh(const mapPolyMesh&);
372 //- Return projected points for a slave patch
373 const pointField& pointProjection() const;
375 //- Set the tolerances from the values in a dictionary
376 void setTolerances(const dictionary&, bool report=false);
379 virtual void write(Ostream&) const;
382 virtual void writeDict(Ostream&) const;
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
388 } // End namespace Foam
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394 // ************************************************************************* //