coupledPolyPatch.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::coupledPolyPatch
26 
27 Description
28  The coupledPolyPatch is an abstract base class for patches that couple
29  regions of the computational domain e.g. cyclic and processor-processor
30  links.
31 
32 SourceFiles
33  coupledPolyPatch.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef coupledPolyPatch_H
38 #define coupledPolyPatch_H
39 
40 #include "polyPatch.H"
41 #include "transformer.H"
42 #include "diagTensorField.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class coupledPolyPatch Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class coupledPolyPatch
54 :
55  public polyPatch
56 {
57 private:
58 
59  // Private Member Functions
60 
61  //- Walk the given primitive patch. Starts at the given seed face and
62  // point within that face. Traverses through the next available
63  // manifold edge to an as yet unvisited face. Stores the order in
64  // which faces are visited and the point/edge through which they are
65  // first walked into. Direction reverses the order in which face-edges
66  // are considered. For two conformal patches, with the same seed face
67  // and point, the maps are guaranteed to match. They can therefore be
68  // used for ordering purposes. This can also be used to identify
69  // contiguous regions of the patch.
70  bool walk
71  (
72  const primitivePatch& pp,
73  const bool direction,
74  const label seedFacei,
75  const label seedFacePointi,
77  labelList& facePointMap,
78  label& mapFacei,
80  ) const;
81 
82 
83 protected:
84 
85  // Protected Classes
86 
87  //- Data to pass from owner.initOrder to owner.order
88  struct ownToOwnOrderData
89  {
91  };
92 
93  //- Data to pass from owner.initOrder to nbr.order
94  struct ownToNbrOrderData
95  {
97 
98  inline void transform(const transformer& tr)
99  {
100  forAll(seedFacePoints, regioni)
101  {
102  tr.transformPosition
103  (
104  seedFacePoints[regioni],
105  seedFacePoints[regioni]
106  );
107  }
108  }
109  };
110 
111  //- Data to pass from owner.initOrder to nbr.order if debugging
113  {
118 
119  inline void transform(const transformer& tr)
120  {}
121  };
122 
123 
124  // Protected Data
125 
126  //- Default matching tolerance
127  static const scalar defaultMatchTol_;
128 
129  //- Local matching tolerance
130  const scalar matchTolerance_;
131 
132  //- Data to pass from owner.initOrder to owner.order
134 
135 
136  // Protected Member Functions
137 
138  //- Initialise the calculation of the patch geometry
139  virtual void initCalcGeometry(PstreamBuffers&) = 0;
140 
141  //- Calculate the patch geometry
142  virtual void calcGeometry(PstreamBuffers&) = 0;
143 
144  //- Initialise the patches for moving points
145  virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0;
146 
147  //- Correct patches after moving points
148  virtual void movePoints(PstreamBuffers&, const pointField&) = 0;
149 
150  //- Initialise the update of the patch topology
151  virtual void initTopoChange(PstreamBuffers&) = 0;
152 
153  //- Update of the patch topology
154  virtual void topoChange(PstreamBuffers&) = 0;
155 
156  //- Write a patch in OBJ format
157  static void writeOBJ
158  (
159  const fileName&,
160  const primitivePatch&
161  );
162 
163  //- Write lines between two lists of points in OBJ format
164  static void writeOBJ
165  (
166  const fileName&,
167  const pointField&,
168  const pointField&
169  );
170 
171  //- Write a set of paths in OBJ format
172  static void writeOBJ
173  (
174  const fileName&,
175  const pointField&,
176  const labelListList&
177  );
178 
179  //- Initialise ordering for the given primitivePatch. Fills the
180  // referenced data structures, but leaves transferring them to the
181  // opposite patch to the caller.
182  virtual void initOrder
183  (
184  ownToNbrOrderData& ownToNbr,
185  autoPtr<ownToNbrDebugOrderData>& ownToNbrDebugPtr,
186  const primitivePatch&
187  ) const;
188 
189  //- Return new ordering for the given primitivePatch.
190  // Ordering is -faceMap: for every face
191  // index of the new face -rotation:for every new face the clockwise
192  // shift of the original face. Return false if nothing changes
193  // (faceMap is identity, rotation is 0), true otherwise.
194  virtual bool order
195  (
196  const ownToNbrOrderData& ownToNbr,
197  const autoPtr<ownToNbrDebugOrderData>& ownToNbrDebugPtr,
198  const primitivePatch&,
200  labelList& rotation
201  ) const;
202 
203 
204 public:
205 
206  //- Runtime type information
207  TypeName("coupled");
208 
209 
210  // Constructors
211 
212  //- Construct from components
214  (
215  const word& name,
216  const label size,
217  const label start,
218  const label index,
219  const polyBoundaryMesh& bm,
220  const word& patchType
221  );
222 
223  //- Construct from dictionary
225  (
226  const word& name,
227  const dictionary& dict,
228  const label index,
229  const polyBoundaryMesh& bm,
230  const word& patchType
231  );
232 
233  //- Construct as copy, resetting the boundary mesh
235 
236  //- Construct given the original patch and resetting the
237  // face list and boundary mesh information
239  (
240  const coupledPolyPatch& pp,
241  const polyBoundaryMesh& bm,
242  const label index,
243  const label newSize,
244  const label newStart
245  );
246 
247 
248  //- Destructor
249  virtual ~coupledPolyPatch();
250 
251 
252  // Member Functions
253 
254  // Access
255 
256  //- Return true because this patch is coupled
257  virtual bool coupled() const
258  {
259  return true;
260  }
261 
262  //- Does this side own the patch ?
263  virtual bool owner() const = 0;
264 
265  //- Does the coupled side own the patch ?
266  virtual bool neighbour() const
267  {
268  return !owner();
269  }
270 
271  //- Return transformation between the coupled patches
272  virtual const transformer& transform() const = 0;
273 
274  //- Return the matching tolerance
275  scalar matchTolerance() const
276  {
277  return matchTolerance_;
278  }
279 
280 
281  //- Initialise ordering for primitivePatch. Does not
282  // refer to *this (except for name() and type() etc.)
283  virtual void initOrder
284  (
286  const primitivePatch&
287  ) const = 0;
288 
289  //- Return new ordering for primitivePatch.
290  // Ordering is -faceMap: for every face
291  // index of the new face -rotation:for every new face the clockwise
292  // shift of the original face. Return false if nothing changes
293  // (faceMap is identity, rotation is 0), true otherwise.
294  virtual bool order
295  (
297  const primitivePatch&,
299  labelList& rotation
300  ) const = 0;
301 
302  //- Calculate typical tolerance per face. Is currently max distance
303  // from face centre to any of the face vertices.
304  static scalarField calcFaceTol
305  (
306  const UList<face>& faces,
307  const pointField& points,
308  const pointField& faceCentres
309  );
310 
311  //- Write the polyPatch data as a dictionary
312  virtual void write(Ostream&) const;
313 
314 
315  // IOstream Operators
316 
321 };
322 
323 
328 
329 
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
331 
332 } // End namespace Foam
333 
334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
335 
336 #endif
337 
338 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
const Field< PointType > & points() const
Return reference to global points.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:74
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual void topoChange(PstreamBuffers &)=0
Update of the patch topology.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
scalar matchTolerance() const
Return the matching tolerance.
virtual void initMovePoints(PstreamBuffers &, const pointField &)=0
Initialise the patches for moving points.
virtual bool coupled() const
Return true because this patch is coupled.
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
friend Ostream & operator<<(Ostream &, const ownToNbrOrderData &)
static const scalar defaultMatchTol_
Default matching tolerance.
coupledPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
virtual bool order(const ownToNbrOrderData &ownToNbr, const autoPtr< ownToNbrDebugOrderData > &ownToNbrDebugPtr, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for the given primitivePatch.
virtual void movePoints(PstreamBuffers &, const pointField &)=0
Correct patches after moving points.
virtual bool owner() const =0
Does this side own the patch ?
TypeName("coupled")
Runtime type information.
virtual void initTopoChange(PstreamBuffers &)=0
Initialise the update of the patch topology.
virtual void initCalcGeometry(PstreamBuffers &)=0
Initialise the calculation of the patch geometry.
virtual const transformer & transform() const =0
Return transformation between the coupled patches.
autoPtr< ownToOwnOrderData > ownToOwnOrderDataPtr_
Data to pass from owner.initOrder to owner.order.
static void writeOBJ(const fileName &, const primitivePatch &)
Write a patch in OBJ format.
friend Istream & operator>>(Istream &, ownToNbrOrderData &)
static scalarField calcFaceTol(const UList< face > &faces, const pointField &points, const pointField &faceCentres)
Calculate typical tolerance per face. Is currently max distance.
const scalar matchTolerance_
Local matching tolerance.
virtual bool neighbour() const
Does the coupled side own the patch ?
virtual void initOrder(ownToNbrOrderData &ownToNbr, autoPtr< ownToNbrDebugOrderData > &ownToNbrDebugPtr, const primitivePatch &) const
Initialise ordering for the given primitivePatch. Fills the.
virtual ~coupledPolyPatch()
Destructor.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Foam::polyBoundaryMesh.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:280
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:276
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
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
Istream & operator>>(Istream &, pistonPointEdgeData &)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
uint8_t direction
Definition: direction.H:45
dictionary dict
Data to pass from owner.initOrder to nbr.order if debugging.
Data to pass from owner.initOrder to nbr.order.
void transform(const transformer &tr)
Data to pass from owner.initOrder to owner.order.