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) 2011-2016 OpenFOAM Foundation
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 
55 #include "polyMeshModifier.H"
56 #include "primitiveFacePatch.H"
57 #include "polyPatchID.H"
58 #include "ZoneIDs.H"
59 #include "intersection.H"
60 #include "Pair.H"
61 #include "objectHit.H"
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 namespace Foam
66 {
67 
68 /*---------------------------------------------------------------------------*\
69  Class slidingInterface Declaration
70 \*---------------------------------------------------------------------------*/
71 
72 class slidingInterface
73 :
74  public polyMeshModifier
75 {
76 public:
77 
78  // Public enumerations
79 
80  //- Type of match
81  enum typeOfMatch
82  {
84  PARTIAL
85  };
86 
87  //- Direction names
89 
90 private:
91 
92  // Private data
93 
94  //- Master face zone ID
95  faceZoneID masterFaceZoneID_;
96 
97  //- Slave face zone ID
98  faceZoneID slaveFaceZoneID_;
99 
100  //- Cut point zone ID
101  pointZoneID cutPointZoneID_;
102 
103  //- Cut face zone ID
104  faceZoneID cutFaceZoneID_;
105 
106  //- Master patch ID
107  polyPatchID masterPatchID_;
108 
109  //- Slave patch ID
110  polyPatchID slavePatchID_;
111 
112  //- Type of match
113  const typeOfMatch matchType_;
114 
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_;
119 
120  //- State of the modifier
121  mutable Switch attached_;
122 
123  //- Point projection algorithm
124  intersection::algorithm projectionAlgo_;
125 
126  //- Trigger topological change
127  mutable bool trigger_;
128 
129  // Tolerances. Initialised to static ones below.
130 
131  //- Point merge tolerance
132  scalar pointMergeTol_;
133 
134  //- Edge merge tolerance
135  scalar edgeMergeTol_;
136 
137  //- Estimated number of faces an edge goes through
138  label nFacesPerSlaveEdge_;
139 
140  //- Edge-face interaction escape limit
141  label edgeFaceEscapeLimit_;
142 
143  //- Integral match point adjustment tolerance
144  scalar integralAdjTol_;
145 
146  //- Edge intersection master catch fraction
147  scalar edgeMasterCatchFraction_;
148 
149  //- Edge intersection co-planar tolerance
150  scalar edgeCoPlanarTol_;
151 
152  //- Edge end cut-off tolerance
153  scalar edgeEndCutoffTol_;
154 
155 
156  // Private addressing data.
157 
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
160  // this will be -1
161  mutable labelList* cutFaceMasterPtr_;
162 
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
165  // this will be -1
166  mutable labelList* cutFaceSlavePtr_;
167 
168  //- Master zone faceCells
169  mutable labelList* masterFaceCellsPtr_;
170 
171  //- Slave zone faceCells
172  mutable labelList* slaveFaceCellsPtr_;
173 
174  //- Master stick-out faces
175  mutable labelList* masterStickOutFacesPtr_;
176 
177  //- Slave stick-out faces
178  mutable labelList* slaveStickOutFacesPtr_;
179 
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_;
184 
185  //- Cut edge pairs
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_;
189 
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_;
193 
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_;
197 
198  //- Slave face hit. The index of master face hit by the
199  // slave point in projection.
200  mutable List<objectHit>* slavePointFaceHitsPtr_;
201 
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_;
205 
206  //- Projected slave points
207  mutable pointField* projectedSlavePointsPtr_;
208 
209 
210  // Private Member Functions
211 
212  //- Disallow default bitwise copy construct
214 
215  //- Disallow default bitwise assignment
216  void operator=(const slidingInterface&);
217 
218  //- Clear out
219  void clearOut() const;
220 
221 
222  //- Check validity of construction data
223  void checkDefinition();
224 
225  //- Calculate attached addressing
226  void calcAttachedAddressing() const;
227 
228  //- Calculate decoupled zone face-cell addressing
229  void renumberAttachedAddressing(const mapPolyMesh&) const;
230 
231  //- Clear attached addressing
232  void clearAttachedAddressing() const;
233 
234 
235  // Topological changes
236 
237  //- Master faceCells
238  const labelList& masterFaceCells() const;
239 
240  //- Slave faceCells
241  const labelList& slaveFaceCells() const;
242 
243  //- Master stick-out faces
244  const labelList& masterStickOutFaces() const;
245 
246  //- Slave stick-out faces
247  const labelList& slaveStickOutFaces() const;
248 
249  //- Retired point map
250  const Map<label>& retiredPointMap() const;
251 
252  //- Cut point edge pair map
253  const Map<Pair<edge>>& cutPointEdgePairMap() const;
254 
255  //- Clear addressing
256  void clearAddressing() const;
257 
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;
262 
263  //- Couple sliding interface
264  void coupleInterface(polyTopoChange& ref) const;
265 
266  //- Clear projection
267  void clearPointProjection() const;
268 
269  //- Clear old couple
270  void clearCouple(polyTopoChange& ref) const;
271 
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
275  // original state
276  void decoupleInterface(polyTopoChange& ref) const;
277 
278 
279  // Static data members
280 
281  //- Point merge tolerance
282  static const scalar pointMergeTolDefault_;
283 
284  //- Edge merge tolerance
285  static const scalar edgeMergeTolDefault_;
286 
287  //- Estimated number of faces an edge goes through
288  static const label nFacesPerSlaveEdgeDefault_;
289 
290  //- Edge-face interaction escape limit
291  static const label edgeFaceEscapeLimitDefault_;
292 
293  //- Integral match point adjustment tolerance
294  static const scalar integralAdjTolDefault_;
295 
296  //- Edge intersection master catch fraction
297  static const scalar edgeMasterCatchFractionDefault_;
298 
299  //- Edge intersection co-planar tolerance
300  static const scalar edgeCoPlanarTolDefault_;
301 
302  //- Edge end cut-off tolerance
303  static const scalar edgeEndCutoffTolDefault_;
304 
305 
306 public:
307 
308  //- Runtime type information
309  TypeName("slidingInterface");
310 
311 
312  // Constructors
313 
314  //- Construct from components
316  (
317  const word& name,
318  const label index,
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,
329  );
330 
331  //- Construct from dictionary
333  (
334  const word& name,
335  const dictionary& dict,
336  const label index,
337  const polyTopoChanger& mme
338  );
339 
340 
341  //- Destructor
342  virtual ~slidingInterface();
343 
344 
345  // Member Functions
346 
347  //- Return master face zone ID
348  const faceZoneID& masterFaceZoneID() const;
349 
350  //- Return slave face zone ID
351  const faceZoneID& slaveFaceZoneID() const;
352 
353  //- Return true if attached
354  bool attached() const
355  {
356  return attached_;
357  }
358 
359  //- Check for topology change
360  virtual bool changeTopology() const;
361 
362  //- Insert the layer addition/removal instructions
363  // into the topological change
364  virtual void setRefinement(polyTopoChange&) const;
365 
366  //- Modify motion points to comply with the topological change
367  virtual void modifyMotionPoints(pointField& motionPoints) const;
368 
369  //- Force recalculation of locally stored data on topological change
370  virtual void updateMesh(const mapPolyMesh&);
371 
372  //- Return projected points for a slave patch
373  const pointField& pointProjection() const;
374 
375  //- Set the tolerances from the values in a dictionary
376  void setTolerances(const dictionary&, bool report=false);
377 
378  //- Write
379  virtual void write(Ostream&) const;
380 
381  //- Write dictionary
382  virtual void writeDict(Ostream&) const;
383 };
384 
385 
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 
388 } // End namespace Foam
389 
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391 
392 #endif
393 
394 // ************************************************************************* //
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
bool attached() const
Return true if attached.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
const word & name() const
Return name of this modifier.
virtual bool changeTopology() const
Check for topology change.
const faceZoneID & slaveFaceZoneID() const
Return slave face zone ID.
label index() const
Return the index of this modifier.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual void write(Ostream &) const
Write.
const faceZoneID & masterFaceZoneID() const
Return master face zone ID.
virtual void writeDict(Ostream &) const
Write dictionary.
List of mesh modifiers defining the mesh dynamics.
A class for handling words, derived from string.
Definition: word.H:59
TypeName("slidingInterface")
Runtime type information.
Virtual base class for mesh modifiers.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Sliding interface mesh modifier. Given two face zones, couple the master and slave side using a cutti...
const pointField & pointProjection() const
Return projected points for a slave patch.
static const NamedEnum< typeOfMatch, 2 > typeOfMatchNames_
Direction names.
typeOfMatch
Type of match.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Direct mesh changes based on v1.3 polyTopoChange syntax.
rDeltaT ref()
void setTolerances(const dictionary &, bool report=false)
Set the tolerances from the values in a dictionary.
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
virtual ~slidingInterface()
Destructor.
Namespace for OpenFOAM.