FreeFOAM The Cross-Platform CFD Toolkit
slidingInterface.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::slidingInterface
26 
27 Description
28  Sliding interface mesh modifier. Given two face zones, couple the
29  master and slave side using a cutting procedure.
30 
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
34  and slave patch.
35 
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.
41 
42 SourceFiles
43  slidingInterface.C
44  coupleSlidingInterface.C
45  decoupleSlidingInterface.C
46  slidingInterfaceProjectPoints.C
47  slidingInterfaceAttachedAddressing.C
48  slidingInterfaceClearCouple.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef slidingInterface_H
53 #define slidingInterface_H
54 
57 #include <OpenFOAM/polyPatchID.H>
58 #include <OpenFOAM/ZoneIDs.H>
59 #include <OpenFOAM/intersection.H>
60 #include <OpenFOAM/Pair.H>
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 // Forward declaration of classes
68 class objectHit;
69 
70 /*---------------------------------------------------------------------------*\
71  Class slidingInterface Declaration
72 \*---------------------------------------------------------------------------*/
73 
75 :
76  public polyMeshModifier
77 {
78 public:
79 
80  // Public enumerations
81 
82  //- Type of match
84  {
87  };
88 
89  //- Direction names
91 
92 private:
93 
94  // Private data
95 
96  //- Master face zone ID
97  faceZoneID masterFaceZoneID_;
98 
99  //- Slave face zone ID
100  faceZoneID slaveFaceZoneID_;
101 
102  //- Cut point zone ID
103  pointZoneID cutPointZoneID_;
104 
105  //- Cut face zone ID
106  faceZoneID cutFaceZoneID_;
107 
108  //- Master patch ID
109  polyPatchID masterPatchID_;
110 
111  //- Slave patch ID
112  polyPatchID slavePatchID_;
113 
114  //- Type of match
115  const typeOfMatch matchType_;
116 
117  //- Couple-decouple operation.
118  // If the interface is coupled, decouple it and vice versa.
119  // Used in conjuction with automatic mesh motion
120  mutable Switch coupleDecouple_;
121 
122  //- State of the modifier
123  mutable Switch attached_;
124 
125  //- Point projection algorithm
126  intersection::algorithm projectionAlgo_;
127 
128  //- Trigger topological change
129  mutable bool trigger_;
130 
131  // Tolerances. Initialised to static ones below.
132 
133  //- Point merge tolerance
134  scalar pointMergeTol_;
135 
136  //- Edge merge tolerance
137  scalar edgeMergeTol_;
138 
139  //- Estimated number of faces an edge goes through
140  label nFacesPerSlaveEdge_;
141 
142  //- Edge-face interaction escape limit
143  label edgeFaceEscapeLimit_;
144 
145  //- Integral match point adjustment tolerance
146  scalar integralAdjTol_;
147 
148  //- Edge intersection master catch fraction
149  scalar edgeMasterCatchFraction_;
150 
151  //- Edge intersection co-planar tolerance
152  scalar edgeCoPlanarTol_;
153 
154  //- Edge end cut-off tolerance
155  scalar edgeEndCutoffTol_;
156 
157 
158  // Private addressing data.
159 
160  //- Cut face master face. Gives the index of face in master patch
161  // the cut face has been created from. For a slave-only face
162  // this will be -1
163  mutable labelList* cutFaceMasterPtr_;
164 
165  //- Cut face slave face. Gives the index of face in slave patch
166  // the cut face has been created from. For a master-only face
167  // this will be -1
168  mutable labelList* cutFaceSlavePtr_;
169 
170  //- Master zone faceCells
171  mutable labelList* masterFaceCellsPtr_;
172 
173  //- Slave zone faceCells
174  mutable labelList* slaveFaceCellsPtr_;
175 
176  //- Master stick-out faces
177  mutable labelList* masterStickOutFacesPtr_;
178 
179  //- Slave stick-out faces
180  mutable labelList* slaveStickOutFacesPtr_;
181 
182  //- Retired point mapping.
183  // For every retired slave side point, gives the label of the
184  // master point that replaces it
185  mutable Map<label>* retiredPointMapPtr_;
186 
187  //- Cut edge pairs
188  // For cut points created by intersection two edges,
189  // store the master-slave edge pair used in creation
190  mutable Map<Pair<edge> >* cutPointEdgePairMapPtr_;
191 
192  //- Slave point hit. The index of master point hit by the
193  // slave point in projection. For no point hit, set to -1
194  mutable labelList* slavePointPointHitsPtr_;
195 
196  //- Slave edge hit. The index of master edge hit by the
197  // slave point in projection. For point or no edge hit, set to -1
198  mutable labelList* slavePointEdgeHitsPtr_;
199 
200  //- Slave face hit. The index of master face hit by the
201  // slave point in projection.
202  mutable List<objectHit>* slavePointFaceHitsPtr_;
203 
204  //- Master point edge hit. The index of slave edge hit by
205  // a master point. For no hit set to -1
206  mutable labelList* masterPointEdgeHitsPtr_;
207 
208  //- Projected slave points
209  mutable pointField* projectedSlavePointsPtr_;
210 
211 
212  // Private Member Functions
213 
214  //- Disallow default bitwise copy construct
216 
217  //- Disallow default bitwise assignment
218  void operator=(const slidingInterface&);
219 
220  //- Clear out
221  void clearOut() const;
222 
223 
224  //- Check validity of construction data
225  void checkDefinition();
226 
227  //- Calculate attached addressing
228  void calcAttachedAddressing() const;
229 
230  //- Calculate decoupled zone face-cell addressing
231  void renumberAttachedAddressing(const mapPolyMesh&) const;
232 
233  //- Clear attached addressing
234  void clearAttachedAddressing() const;
235 
236 
237  // Topological changes
238 
239  //- Master faceCells
240  const labelList& masterFaceCells() const;
241 
242  //- Slave faceCells
243  const labelList& slaveFaceCells() const;
244 
245  //- Master stick-out faces
246  const labelList& masterStickOutFaces() const;
247 
248  //- Slave stick-out faces
249  const labelList& slaveStickOutFaces() const;
250 
251  //- Retired point map
252  const Map<label>& retiredPointMap() const;
253 
254  //- Cut point edge pair map
255  const Map<Pair<edge> >& cutPointEdgePairMap() const;
256 
257  //- Clear addressing
258  void clearAddressing() const;
259 
260  //- Project slave points and compare with the current projection.
261  // If the projection has changed, the sliding interface
262  // changes topologically
263  bool projectPoints() const;
264 
265  //- Couple sliding interface
266  void coupleInterface(polyTopoChange& ref) const;
267 
268  //- Clear projection
269  void clearPointProjection() const;
270 
271  //- Clear old couple
272  void clearCouple(polyTopoChange& ref) const;
273 
274  //- Decouple interface (returns it to decoupled state)
275  // Note: this should not be used in normal operation of the
276  // sliding mesh, but only to return the mesh to its
277  // original state
278  void decoupleInterface(polyTopoChange& ref) const;
279 
280 
281  // Static data members
282 
283  //- Point merge tolerance
284  static const scalar pointMergeTolDefault_;
285 
286  //- Edge merge tolerance
287  static const scalar edgeMergeTolDefault_;
288 
289  //- Estimated number of faces an edge goes through
290  static const label nFacesPerSlaveEdgeDefault_;
291 
292  //- Edge-face interaction escape limit
293  static const label edgeFaceEscapeLimitDefault_;
294 
295  //- Integral match point adjustment tolerance
296  static const scalar integralAdjTolDefault_;
297 
298  //- Edge intersection master catch fraction
299  static const scalar edgeMasterCatchFractionDefault_;
300 
301  //- Edge intersection co-planar tolerance
302  static const scalar edgeCoPlanarTolDefault_;
303 
304  //- Edge end cut-off tolerance
305  static const scalar edgeEndCutoffTolDefault_;
306 
307 
308 public:
309 
310  //- Runtime type information
311  TypeName("slidingInterface");
312 
313 
314  // Constructors
315 
316  //- Construct from components
318  (
319  const word& name,
320  const label index,
321  const polyTopoChanger& mme,
322  const word& masterFaceZoneName,
323  const word& slaveFaceZoneName,
324  const word& cutPointZoneName,
325  const word& cutFaceZoneName,
326  const word& masterPatchName,
327  const word& slavePatchName,
328  const typeOfMatch tom,
329  const bool coupleDecouple = false,
331  );
332 
333  //- Construct from dictionary
335  (
336  const word& name,
337  const dictionary& dict,
338  const label index,
339  const polyTopoChanger& mme
340  );
341 
342 
343  // Destructor
344 
345  virtual ~slidingInterface();
346 
347 
348  // Member Functions
349 
350  //- Return master face zone ID
351  const faceZoneID& masterFaceZoneID() const;
352 
353  //- Return slave face zone ID
354  const faceZoneID& slaveFaceZoneID() const;
355 
356  //- Return true if attached
357  bool attached() const
358  {
359  return attached_;
360  }
361 
362  //- Check for topology change
363  virtual bool changeTopology() const;
364 
365  //- Insert the layer addition/removal instructions
366  // into the topological change
367  virtual void setRefinement(polyTopoChange&) const;
368 
369  //- Modify motion points to comply with the topological change
370  virtual void modifyMotionPoints(pointField& motionPoints) const;
371 
372  //- Force recalculation of locally stored data on topological change
373  virtual void updateMesh(const mapPolyMesh&);
374 
375  //- Return projected points for a slave patch
376  const pointField& pointProjection() const;
377 
378  //- Set the tolerances from the values in a dictionary
379  void setTolerances(const dictionary&, bool report=false);
380 
381  //- Write
382  virtual void write(Ostream&) const;
383 
384  //- Write dictionary
385  virtual void writeDict(Ostream&) const;
386 };
387 
388 
389 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
390 
391 } // End namespace Foam
392 
393 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394 
395 #endif
396 
397 // ************************ vim: set sw=4 sts=4 et: ************************ //