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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::slidingInterface
28 
29 Description
30  Sliding interface mesh modifier. Given two face zones, couple the
31  master and slave side using a cutting procedure.
32 
33  The coupled faces are collected into the "coupled" zone and can become
34  either internal or placed into a master and slave coupled zone. The
35  remaining faces (uncovered master or slave) are placed into the master
36  and slave patch.
37 
38  The definition of the sliding interface can be either integral or partial.
39  Integral interface implies that the slave side completely covers
40  the master (i.e. no faces are uncovered); partial interface
41  implies that the uncovered part of master/slave face zone should
42  become boundary faces.
43 
44 SourceFiles
45  slidingInterface.C
46  coupleSlidingInterface.C
47  decoupleSlidingInterface.C
48  slidingInterfaceProjectPoints.C
49  slidingInterfaceAttachedAddressing.C
50  slidingInterfaceClearCouple.C
51 
52 \*---------------------------------------------------------------------------*/
53 
54 #ifndef slidingInterface_H
55 #define slidingInterface_H
56 
57 #include "polyMeshModifier.H"
58 #include "primitiveFacePatch.H"
59 #include "polyPatchID.H"
60 #include "ZoneIDs.H"
61 #include "intersection.H"
62 #include "Pair.H"
63 #include "objectHit.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 /*---------------------------------------------------------------------------*\
71  Class slidingInterface Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 class slidingInterface
75 :
76  public polyMeshModifier
77 {
78 public:
79 
80  // Public enumerations
81 
82  //- Type of match
83  enum typeOfMatch
84  {
86  PARTIAL
87  };
88 
89  //- Names for the types of matches
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 conjunction 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  //- No copy construct
215  slidingInterface(const slidingInterface&) = delete;
216 
217  //- No copy assignment
218  void operator=(const slidingInterface&) = delete;
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  virtual ~slidingInterface();
345 
346 
347  // Member Functions
348 
349  //- Return master face zone ID
350  const faceZoneID& masterFaceZoneID() const;
351 
352  //- Return slave face zone ID
353  const faceZoneID& slaveFaceZoneID() const;
354 
355  //- Return true if attached
356  bool attached() const
357  {
358  return attached_;
359  }
360 
361  //- Check for topology change
362  virtual bool changeTopology() const;
363 
364  //- Insert the layer addition/removal instructions
365  // into the topological change
366  virtual void setRefinement(polyTopoChange&) const;
367 
368  //- Modify motion points to comply with the topological change
369  virtual void modifyMotionPoints(pointField& motionPoints) const;
370 
371  //- Force recalculation of locally stored data on topological change
372  virtual void updateMesh(const mapPolyMesh&);
373 
374  //- Return projected points for a slave patch
375  const pointField& pointProjection() const;
376 
377  //- Set the tolerances from the values in a dictionary
378  void setTolerances(const dictionary&, bool report=false);
379 
380  //- Write
381  virtual void write(Ostream&) const;
382 
383  //- Write dictionary
384  virtual void writeDict(Ostream&) const;
385 };
386 
387 
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 
390 } // End namespace Foam
391 
392 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
393 
394 #endif
395 
396 // ************************************************************************* //
ref
rDeltaT ref()
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:70
Foam::Enum< typeOfMatch >
intersection.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::slidingInterface::setRefinement
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Definition: slidingInterface.C:375
Foam::slidingInterface::slaveFaceZoneID
const faceZoneID & slaveFaceZoneID() const
Return slave face zone ID.
Definition: slidingInterface.C:328
Foam::intersection::VISIBLE
Definition: intersection.H:76
Foam::slidingInterface::typeOfMatch
typeOfMatch
Type of match.
Definition: slidingInterface.H:82
Foam::slidingInterface::PARTIAL
Definition: slidingInterface.H:85
Foam::polyTopoChanger
List of mesh modifiers defining the mesh dynamics.
Definition: polyTopoChanger.H:67
Foam::polyTopoChange
Direct mesh changes based on v1.3 polyTopoChange syntax.
Definition: polyTopoChange.H:100
primitiveFacePatch.H
Foam::Map< label >
Foam::polyMeshModifier::index
label index() const
Return the index of this modifier.
Definition: polyMeshModifier.H:159
Pair.H
ZoneIDs.H
Foam::slidingInterface
Sliding interface mesh modifier. Given two face zones, couple the master and slave side using a cutti...
Definition: slidingInterface.H:73
Foam::DynamicID< faceZoneMesh >
Foam::slidingInterface::setTolerances
void setTolerances(const dictionary &, bool report=false)
Set the tolerances from the values in a dictionary.
Definition: slidingInterface.C:681
polyPatchID.H
Foam::slidingInterface::attached
bool attached() const
Return true if attached.
Definition: slidingInterface.H:355
Foam::slidingInterface::~slidingInterface
virtual ~slidingInterface()
Destructor.
Definition: slidingInterface.C:307
Foam::slidingInterface::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Definition: slidingInterface.C:639
objectHit.H
Foam::label
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:62
Foam::Field< vector >
Foam::intersection::algorithm
algorithm
Definition: intersection.H:72
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::polyMeshModifier
Virtual base class for mesh modifiers.
Definition: polyMeshModifier.H:71
Foam::slidingInterface::TypeName
TypeName("slidingInterface")
Runtime type information.
Foam::polyMeshModifier::name
const word & name() const
Return name of this modifier.
Definition: polyMeshModifier.H:153
Foam::slidingInterface::modifyMotionPoints
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
Definition: slidingInterface.C:408
Foam::List< label >
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:160
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::slidingInterface::masterFaceZoneID
const faceZoneID & masterFaceZoneID() const
Return master face zone ID.
Definition: slidingInterface.C:322
Foam::slidingInterface::writeDict
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: slidingInterface.C:763
Foam::slidingInterface::INTEGRAL
Definition: slidingInterface.H:84
Foam::slidingInterface::typeOfMatchNames
static const Enum< typeOfMatch > typeOfMatchNames
Names for the types of matches.
Definition: slidingInterface.H:89
Foam::slidingInterface::write
virtual void write(Ostream &) const
Write.
Definition: slidingInterface.C:739
Foam::slidingInterface::pointProjection
const pointField & pointProjection() const
Return projected points for a slave patch.
Definition: slidingInterface.C:671
Foam::slidingInterface::changeTopology
virtual bool changeTopology() const
Check for topology change.
Definition: slidingInterface.C:334
polyMeshModifier.H