slidingInterface.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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 conjunction 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  //- Clear out
213  void clearOut() const;
214 
215 
216  //- Check validity of construction data
217  void checkDefinition();
218 
219  //- Calculate attached addressing
220  void calcAttachedAddressing() const;
221 
222  //- Calculate decoupled zone face-cell addressing
223  void renumberAttachedAddressing(const polyTopoChangeMap&) const;
224 
225  //- Clear attached addressing
226  void clearAttachedAddressing() const;
227 
228 
229  // Topological changes
230 
231  //- Master faceCells
232  const labelList& masterFaceCells() const;
233 
234  //- Slave faceCells
235  const labelList& slaveFaceCells() const;
236 
237  //- Master stick-out faces
238  const labelList& masterStickOutFaces() const;
239 
240  //- Slave stick-out faces
241  const labelList& slaveStickOutFaces() const;
242 
243  //- Retired point map
244  const Map<label>& retiredPointMap() const;
245 
246  //- Cut point edge pair map
247  const Map<Pair<edge>>& cutPointEdgePairMap() const;
248 
249  //- Clear addressing
250  void clearAddressing() const;
251 
252  //- Project slave points and compare with the current projection.
253  // If the projection has changed, the sliding interface
254  // changes topologically
255  bool projectPoints() const;
256 
257  //- Couple sliding interface
258  void coupleInterface(polyTopoChange& ref) const;
259 
260  //- Clear projection
261  void clearPointProjection() const;
262 
263  //- Clear old couple
264  void clearCouple(polyTopoChange& ref) const;
265 
266  //- Decouple interface (returns it to decoupled state)
267  // Note: this should not be used in normal operation of the
268  // sliding mesh, but only to return the mesh to its
269  // original state
270  void decoupleInterface(polyTopoChange& ref) const;
271 
272 
273  // Static Data Members
274 
275  //- Point merge tolerance
276  static const scalar pointMergeTolDefault_;
277 
278  //- Edge merge tolerance
279  static const scalar edgeMergeTolDefault_;
280 
281  //- Estimated number of faces an edge goes through
282  static const label nFacesPerSlaveEdgeDefault_;
283 
284  //- Edge-face interaction escape limit
285  static const label edgeFaceEscapeLimitDefault_;
286 
287  //- Integral match point adjustment tolerance
288  static const scalar integralAdjTolDefault_;
289 
290  //- Edge intersection master catch fraction
291  static const scalar edgeMasterCatchFractionDefault_;
292 
293  //- Edge intersection co-planar tolerance
294  static const scalar edgeCoPlanarTolDefault_;
295 
296  //- Edge end cut-off tolerance
297  static const scalar edgeEndCutoffTolDefault_;
298 
299 
300 public:
301 
302  //- Runtime type information
303  TypeName("slidingInterface");
304 
305 
306  // Constructors
307 
308  //- Construct from components
310  (
311  const word& name,
312  const label index,
313  const polyTopoChanger& mme,
314  const word& masterFaceZoneName,
315  const word& slaveFaceZoneName,
316  const word& cutPointZoneName,
317  const word& cutFaceZoneName,
318  const word& masterPatchName,
319  const word& slavePatchName,
320  const typeOfMatch tom,
321  const bool coupleDecouple = false,
322  const intersection::algorithm algo =
324  );
325 
326  //- Construct from dictionary
328  (
329  const word& name,
330  const dictionary& dict,
331  const label index,
332  const polyTopoChanger& mme
333  );
334 
335  //- Disallow default bitwise copy construction
336  slidingInterface(const slidingInterface&) = delete;
337 
338 
339  //- Destructor
340  virtual ~slidingInterface();
341 
342 
343  // Member Functions
344 
345  //- Return master face zone ID
346  const faceZoneID& masterFaceZoneID() const;
347 
348  //- Return slave face zone ID
349  const faceZoneID& slaveFaceZoneID() const;
350 
351  //- Return true if attached
352  bool attached() const
353  {
354  return attached_;
355  }
356 
357  //- Check for topology change
358  virtual bool changeTopology() const;
359 
360  //- Insert the layer addition/removal instructions
361  // into the topological change
362  virtual void setRefinement(polyTopoChange&) const;
363 
364  //- Modify motion points to comply with the topological change
365  virtual void modifyMotionPoints(pointField& motionPoints) const;
366 
367  //- Force recalculation of locally stored data on topological change
368  virtual void topoChange(const polyTopoChangeMap&);
369 
370  //- Return projected points for a slave patch
371  const pointField& pointProjection() const;
372 
373  //- Set the tolerances from the values in a dictionary
374  void setTolerances(const dictionary&, bool report=false);
375 
376  //- Write
377  virtual void write(Ostream&) const;
378 
379  //- Write dictionary
380  virtual void writeDict(Ostream&) const;
381 
382 
383  // Member Operators
384 
385  //- Disallow default bitwise assignment
386  void operator=(const slidingInterface&) = delete;
387 };
388 
389 
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391 
392 } // End namespace Foam
393 
394 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
395 
396 #endif
397 
398 // ************************************************************************* //
dictionary dict
const faceZoneID & slaveFaceZoneID() const
Return slave face zone ID.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
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/any.
Definition: Switch.H:60
virtual void write(Ostream &) const
Write.
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
const pointField & pointProjection() const
Return projected points for a slave patch.
List of mesh modifiers defining the mesh dynamics.
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
TypeName("slidingInterface")
Runtime type information.
slidingInterface(const word &name, const label index, const polyTopoChanger &mme, const word &masterFaceZoneName, const word &slaveFaceZoneName, const word &cutPointZoneName, const word &cutFaceZoneName, const word &masterPatchName, const word &slavePatchName, const typeOfMatch tom, const bool coupleDecouple=false, const intersection::algorithm algo=intersection::algorithm::visible)
Construct from components.
Virtual base class for mesh modifiers.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Sliding interface mesh modifier. Given two face zones, couple the master and slave side using a cutti...
static const NamedEnum< typeOfMatch, 2 > typeOfMatchNames_
Direction names.
typeOfMatch
Type of match.
Direct mesh changes based on v1.3 polyTopoChange syntax.
virtual void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
void operator=(const slidingInterface &)=delete
Disallow default bitwise assignment.
const word & name() const
Return name of this modifier.
const faceZoneID & masterFaceZoneID() const
Return master face zone ID.
void setTolerances(const dictionary &, bool report=false)
Set the tolerances from the values in a dictionary.
label index() const
Return the index of this modifier.
rDeltaT ref()
bool attached() const
Return true if attached.
virtual ~slidingInterface()
Destructor.
virtual void writeDict(Ostream &) const
Write dictionary.
virtual bool changeTopology() const
Check for topology change.
Namespace for OpenFOAM.