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-2020 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  {
96  List<pointField> seedFacePoints;
97 
98  inline void transform(const transformer& tr)
99  {
100  forAll(seedFacePoints, regioni)
101  {
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  {
114  label nFaces;
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 initUpdateMesh(PstreamBuffers&) = 0;
152 
153  //- Update of the patch topology
154  virtual void updateMesh(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&,
199  labelList& faceMap,
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  //- Construct given the original patch and a map
249  (
250  const coupledPolyPatch& pp,
251  const polyBoundaryMesh& bm,
252  const label index,
253  const labelUList& mapAddressing,
254  const label newStart
255  );
256 
257 
258  //- Destructor
259  virtual ~coupledPolyPatch();
260 
261 
262  // Member Functions
263 
264  // Access
265 
266  //- Return true because this patch is coupled
267  virtual bool coupled() const
268  {
269  return true;
270  }
271 
272  //- Does this side own the patch ?
273  virtual bool owner() const = 0;
274 
275  //- Does the coupled side own the patch ?
276  virtual bool neighbour() const
277  {
278  return !owner();
279  }
280 
281  //- Return transformation between the coupled patches
282  virtual const transformer& transform() const = 0;
283 
284  //- Return the matching tolerance
285  scalar matchTolerance() const
286  {
287  return matchTolerance_;
288  }
289 
290 
291  //- Initialize ordering for primitivePatch. Does not
292  // refer to *this (except for name() and type() etc.)
293  virtual void initOrder
294  (
296  const primitivePatch&
297  ) const = 0;
298 
299  //- Return new ordering for primitivePatch.
300  // Ordering is -faceMap: for every face
301  // index of the new face -rotation:for every new face the clockwise
302  // shift of the original face. Return false if nothing changes
303  // (faceMap is identity, rotation is 0), true otherwise.
304  virtual bool order
305  (
307  const primitivePatch&,
308  labelList& faceMap,
309  labelList& rotation
310  ) const = 0;
311 
312  //- Calculate typical tolerance per face. Is currently max distance
313  // from face centre to any of the face vertices.
314  static scalarField calcFaceTol
315  (
316  const UList<face>& faces,
317  const pointField& points,
318  const pointField& faceCentres
319  );
320 
321  //- Write the polyPatch data as a dictionary
322  virtual void write(Ostream&) const;
323 
324 
325  // IOstream Operators
326 
328  friend Ostream& operator<<(Ostream&, const ownToNbrOrderData&);
331 };
332 
333 
338 
339 
340 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 
342 } // End namespace Foam
343 
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 
346 #endif
347 
348 // ************************************************************************* //
virtual void initMovePoints(PstreamBuffers &, const pointField &)=0
Initialise the patches for moving points.
label nPoints() const
Return number of points supporting patch faces.
dictionary dict
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 bool coupled() const
Return true because this patch is coupled.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
friend Ostream & operator<<(Ostream &, const ownToNbrOrderData &)
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
const word & name() const
Return name.
A class for handling file names.
Definition: fileName.H:79
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: transformer.H:83
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
coupledPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Data to pass from owner.initOrder to owner.order.
label nInternalEdges() const
Number of internal edges.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
scalar matchTolerance() const
Return the matching tolerance.
virtual const transformer & transform() const =0
Return transformation between the coupled patches.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void movePoints(PstreamBuffers &, const pointField &)=0
Correct patches after moving points.
virtual void initOrder(ownToNbrOrderData &ownToNbr, autoPtr< ownToNbrDebugOrderData > &ownToNbrDebugPtr, const primitivePatch &) const
Initialise ordering for the given primitivePatch. Fills the.
Data to pass from owner.initOrder to nbr.order if debugging.
A list of faces which address into the list of points.
friend Istream & operator>>(Istream &, ownToNbrOrderData &)
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
const scalar matchTolerance_
Local matching tolerance.
A class for handling words, derived from string.
Definition: word.H:59
Data to pass from owner.initOrder to nbr.order.
virtual bool owner() const =0
Does this side own the patch ?
const Field< PointType > & points() const
Return reference to global points.
virtual void initUpdateMesh(PstreamBuffers &)=0
Initialise the update of the patch topology.
autoPtr< ownToOwnOrderData > ownToOwnOrderDataPtr_
Data to pass from owner.initOrder to owner.order.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
label nEdges() const
Return number of edges in patch.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static scalarField calcFaceTol(const UList< face > &faces, const pointField &points, const pointField &faceCentres)
Calculate typical tolerance per face. Is currently max distance.
virtual void initCalcGeometry(PstreamBuffers &)=0
Initialise the calculation of the patch geometry.
virtual ~coupledPolyPatch()
Destructor.
TypeName("coupled")
Runtime type information.
label index() const
Return the index of this patch in the boundaryMesh.
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:303
virtual bool neighbour() const
Does the coupled side own the patch ?
vector transformPosition(const vector &v) const
Transform the given position.
Definition: transformerI.H:153
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
static const scalar defaultMatchTol_
Default matching tolerance.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
virtual void updateMesh(PstreamBuffers &)=0
Update of the patch topology.
static void writeOBJ(const fileName &, const primitivePatch &)
Write a patch in OBJ format.
Namespace for OpenFOAM.
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:284