initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / slidingInterface / slidingInterface.H
blob376c969e38edde1d82de0387b79719ab3c294e9a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::slidingInterface
28 Description
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
35     and slave patch.
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.
43 SourceFiles
44     slidingInterface.C
45     coupleSlidingInterface.C
46     decoupleSlidingInterface.C
47     slidingInterfaceProjectPoints.C
48     slidingInterfaceAttachedAddressing.C
49     slidingInterfaceClearCouple.C
51 \*---------------------------------------------------------------------------*/
53 #ifndef slidingInterface_H
54 #define slidingInterface_H
56 #include "polyMeshModifier.H"
57 #include "primitiveFacePatch.H"
58 #include "polyPatchID.H"
59 #include "ZoneIDs.H"
60 #include "intersection.H"
61 #include "Pair.H"
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 namespace Foam
68 // Forward declaration of classes
69 class objectHit;
71 /*---------------------------------------------------------------------------*\
72                       Class slidingInterface Declaration
73 \*---------------------------------------------------------------------------*/
75 class slidingInterface
77     public polyMeshModifier
79 public:
81     // Public enumerations
83         //- Type of match
84         enum typeOfMatch
85         {
86             INTEGRAL,
87             PARTIAL
88         };
90         //- Direction names
91         static const NamedEnum<typeOfMatch, 2> typeOfMatchNames_;
93 private:
95     // Private data
97         //- Master face zone ID
98         faceZoneID masterFaceZoneID_;
100         //- Slave face zone ID
101         faceZoneID slaveFaceZoneID_;
103         //- Cut point zone ID
104         pointZoneID cutPointZoneID_;
106         //- Cut face zone ID
107         faceZoneID cutFaceZoneID_;
109         //- Master patch ID
110         polyPatchID masterPatchID_;
112         //- Slave patch ID
113         polyPatchID slavePatchID_;
115         //- Type of match
116         const typeOfMatch matchType_;
118         //- Couple-decouple operation.
119         //  If the interface is coupled, decouple it and vice versa.
120         //  Used in conjuction with automatic mesh motion
121         mutable Switch coupleDecouple_;
123         //- State of the modifier
124         mutable Switch attached_;
126         //- Point projection algorithm
127         intersection::algorithm projectionAlgo_;
129         //- Trigger topological change
130         mutable bool trigger_;
133         // Private addressing data.
135             //- Cut face master face.  Gives the index of face in master patch
136             //  the cut face has been created from.  For a slave-only face
137             //  this will be -1
138             mutable labelList* cutFaceMasterPtr_;
140             //- Cut face slave face.  Gives the index of face in slave patch
141             //  the cut face has been created from.  For a master-only face
142             //  this will be -1
143             mutable labelList* cutFaceSlavePtr_;
145             //- Master zone faceCells
146             mutable labelList* masterFaceCellsPtr_;
148             //- Slave zone faceCells
149             mutable labelList* slaveFaceCellsPtr_;
151             //- Master stick-out faces
152             mutable labelList* masterStickOutFacesPtr_;
154             //- Slave stick-out faces
155             mutable labelList* slaveStickOutFacesPtr_;
157             //- Retired point mapping.
158             //  For every retired slave side point, gives the label of the
159             //  master point that replaces it
160             mutable Map<label>* retiredPointMapPtr_;
162             //- Cut edge pairs
163             //  For cut points created by intersection two edges,
164             //  store the master-slave edge pair used in creation
165             mutable Map<Pair<edge> >* cutPointEdgePairMapPtr_;
167             //- Slave point hit.  The index of master point hit by the
168             //  slave point in projection.  For no point hit, set to -1
169             mutable labelList* slavePointPointHitsPtr_;
171             //- Slave edge hit.  The index of master edge hit by the
172             //  slave point in projection.  For point or no edge  hit, set to -1
173             mutable labelList* slavePointEdgeHitsPtr_;
175             //- Slave face hit.  The index of master face hit by the
176             //  slave point in projection.
177             mutable List<objectHit>* slavePointFaceHitsPtr_;
179             //- Master point edge hit.  The index of slave edge hit by
180             //  a master point.  For no hit set to -1
181             mutable labelList* masterPointEdgeHitsPtr_;
183             //- Projected slave points
184             mutable pointField* projectedSlavePointsPtr_;
187     // Private Member Functions
189         //- Disallow default bitwise copy construct
190         slidingInterface(const slidingInterface&);
192         //- Disallow default bitwise assignment
193         void operator=(const slidingInterface&);
195         //- Clear out
196         void clearOut() const;
199         //- Check validity of construction data
200         void checkDefinition();
202         //- Calculate attached addressing
203         void calcAttachedAddressing() const;
205         //- Calculate decoupled zone face-cell addressing
206         void renumberAttachedAddressing(const mapPolyMesh&) const;
208         //- Clear attached addressing
209         void clearAttachedAddressing() const;
212         // Topological changes
214             //- Master faceCells
215             const labelList& masterFaceCells() const;
217             //- Slave faceCells
218             const labelList& slaveFaceCells() const;
220             //- Master stick-out faces
221             const labelList& masterStickOutFaces() const;
223             //- Slave stick-out faces
224             const labelList& slaveStickOutFaces() const;
226             //- Retired point map
227             const Map<label>& retiredPointMap() const;
229             //- Cut point edge pair map
230             const Map<Pair<edge> >& cutPointEdgePairMap() const;
232              //- Clear addressing
233              void clearAddressing() const;
235             //- Project slave points and compare with the current projection.
236             //  If the projection has changed, the sliding interface
237             //  changes topologically
238             bool projectPoints() const;
240             //- Couple sliding interface
241             void coupleInterface(polyTopoChange& ref) const;
243             //- Clear projection
244             void clearPointProjection() const;
246             //- Clear old couple
247             void clearCouple(polyTopoChange& ref) const;
249             //- Decouple interface (returns it to decoupled state)
250             //  Note: this should not be used in normal operation of the
251             //  sliding mesh, but only to return the mesh to its
252             //  original state
253             void decoupleInterface(polyTopoChange& ref) const;
256     // Static data members
258         //- Point merge tolerance
259         static const scalar pointMergeTol_;
261         //- Edge merge tolerance
262         static const scalar edgeMergeTol_;
264         //- Estimated number of faces an edge goes through
265         static const label nFacesPerSlaveEdge_;
267         //- Edge-face interaction escape limit
268         static const label edgeFaceEscapeLimit_;
270         //- Integral match point adjustment tolerance
271         static const scalar integralAdjTol_;
273         //- Edge intersection master catch fraction
274         static const scalar edgeMasterCatchFraction_;
276         //- Edge intersection co-planar tolerance
277         static const scalar edgeCoPlanarTol_;
279         //- Edge end cut-off tolerance
280         static const scalar edgeEndCutoffTol_;
283 public:
285     //- Runtime type information
286     TypeName("slidingInterface");
289     // Constructors
291         //- Construct from components
292         slidingInterface
293         (
294             const word& name,
295             const label index,
296             const polyTopoChanger& mme,
297             const word& masterFaceZoneName,
298             const word& slaveFaceZoneName,
299             const word& cutPointZoneName,
300             const word& cutFaceZoneName,
301             const word& masterPatchName,
302             const word& slavePatchName,
303             const typeOfMatch tom,
304             const bool coupleDecouple = false,
305             const intersection::algorithm algo = intersection::VISIBLE
306         );
308         //- Construct from dictionary
309         slidingInterface
310         (
311             const word& name,
312             const dictionary& dict,
313             const label index,
314             const polyTopoChanger& mme
315         );
318     // Destructor
320         virtual ~slidingInterface();
323     // Member Functions
325         //- Return master face zone ID
326         const faceZoneID& masterFaceZoneID() const;
328         //- Return slave face zone ID
329         const faceZoneID& slaveFaceZoneID() const;
331         //- Return true if attached
332         bool attached() const
333         {
334             return attached_;
335         }
337         //- Check for topology change
338         virtual bool changeTopology() const;
340         //- Insert the layer addition/removal instructions
341         //  into the topological change
342         virtual void setRefinement(polyTopoChange&) const;
344         //- Modify motion points to comply with the topological change
345         virtual void modifyMotionPoints(pointField& motionPoints) const;
347         //- Force recalculation of locally stored data on topological change
348         virtual void updateMesh(const mapPolyMesh&);
350         //- Return projected points for a slave patch
351         const pointField& pointProjection() const;
354         //- Write
355         virtual void write(Ostream&) const;
357         //- Write dictionary
358         virtual void writeDict(Ostream&) const;
362 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 } // End namespace Foam
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368 #endif
370 // ************************************************************************* //