cyclicPolyPatch.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::cyclicPolyPatch
26 
27 Description
28  Cyclic plane patch.
29 
30  Note: morph patch face ordering uses geometric matching so with the
31  following restrictions:
32  -coupled patches should be flat planes.
33  -no rotation in patch plane
34 
35  Uses coupledPolyPatch::calcFaceTol to calculate
36  tolerance per face which might need tweaking.
37 
38  Switch on 'cyclicPolyPatch' debug flag to write .obj files to show
39  the matching.
40 
41 SourceFiles
42  cyclicPolyPatch.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef cyclicPolyPatch_H
47 #define cyclicPolyPatch_H
48 
49 #include "coupledPolyPatch.H"
50 #include "cyclicTransform.H"
51 #include "edgeList.H"
52 #include "polyBoundaryMesh.H"
53 #include "diagTensorField.H"
54 #include "coupleGroupIdentifier.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class cyclicPolyPatch Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class cyclicPolyPatch
66 :
67  public coupledPolyPatch,
68  public cyclicTransform
69 {
70  // Private Classes
71 
72  //- Data to pass from owner.initOrder to nbr.order
73  struct ownToNbrCyclicOrderData
74  {
75  point ctr;
76  vector area;
77  };
78 
79 
80  // Private Data
81 
82  //- Name of cyclic neighbour patch
83  mutable word nbrPatchName_;
84 
85  //- Optional patchGroup to find neighbour patch
86  const coupleGroupIdentifier coupleGroup_;
87 
88  //- Index of cyclic neighbour patch
89  mutable label nbrPatchID_;
90 
91  //- List of edges formed from connected points. e[0] is the point on
92  // this patch, e[1] the corresponding point on the cyclic neighbour.
93  mutable edgeList* coupledPointsPtr_;
94 
95  //- List of connected edges. e[0] is the edge on this patch,
96  // e[1] the corresponding edge on the cyclic neigbour
97  mutable edgeList* coupledEdgesPtr_;
98 
99  //- Data to pass from owner.initOrder to nbr.order
100  mutable autoPtr<ownToNbrOrderData> ownToNbrOrderDataPtr_;
101 
102  //- Data to pass from owner.initOrder to nbr.order
103  mutable autoPtr<ownToNbrCyclicOrderData> ownToNbrCyclicOrderDataPtr_;
104 
105  //- Data to pass from owner.initOrder to nbr.order if debugging
106  mutable autoPtr<ownToNbrDebugOrderData> ownToNbrDebugOrderDataPtr_;
107 
108 
109 protected:
110 
111  // Protected Member functions
112 
113  //- Initialise the calculation of the patch geometry
114  virtual void initCalcGeometry(PstreamBuffers&);
115 
116  //- Initialise the calculation of the patch geometry
117  virtual void initCalcGeometry
118  (
119  const primitivePatch& referPatch,
120  pointField& nbrCtrs,
121  vectorField& nbrAreas,
122  pointField& nbrCc
123  );
124 
125  //- Calculate the patch geometry
126  virtual void calcGeometry(PstreamBuffers&);
127 
128  //- Initialise the patches for moving points
129  virtual void initMovePoints(PstreamBuffers&, const pointField&);
130 
131  //- Correct patches after moving points
132  virtual void movePoints(PstreamBuffers&, const pointField&);
133 
134  //- Initialise the update of the patch topology
135  virtual void initUpdateMesh(PstreamBuffers&);
136 
137  //- Update of the patch topology
138  virtual void updateMesh(PstreamBuffers&);
139 
140 public:
141 
142  //- Declare friendship with processorCyclicPolyPatch
143  friend class processorCyclicPolyPatch;
144 
145 
146  //- Runtime type information
147  TypeName("cyclic");
148 
149 
150  // Constructors
151 
152  //- Construct from components
154  (
155  const word& name,
156  const label size,
157  const label start,
158  const label index,
159  const polyBoundaryMesh& bm,
160  const word& patchType
161  );
162 
163  //- Construct from components
165  (
166  const word& name,
167  const label size,
168  const label start,
169  const label index,
170  const polyBoundaryMesh& bm,
171  const word& patchType,
172  const word& nbrPatchName
173  );
174 
175  //- Construct from dictionary
177  (
178  const word& name,
179  const dictionary& dict,
180  const label index,
181  const polyBoundaryMesh& bm,
182  const word& patchType
183  );
184 
185  //- Construct as copy, resetting the boundary mesh
187 
188  //- Construct given the original patch and resetting the
189  // face list and boundary mesh information
191  (
192  const cyclicPolyPatch& pp,
193  const polyBoundaryMesh& bm,
194  const label index,
195  const label newSize,
196  const label newStart,
197  const word& nbrPatchName
198  );
199 
200  //- Construct given the original patch and a map
202  (
203  const cyclicPolyPatch& pp,
204  const polyBoundaryMesh& bm,
205  const label index,
206  const labelUList& mapAddressing,
207  const label newStart
208  );
209 
210  //- Construct and return a clone, resetting the boundary mesh
211  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
212  {
213  return autoPtr<polyPatch>(new cyclicPolyPatch(*this, bm));
214  }
215 
216  //- Construct and return a clone, resetting the face list
217  // and boundary mesh
219  (
220  const polyBoundaryMesh& bm,
221  const label index,
222  const label newSize,
223  const label newStart
224  ) const
225  {
226  return autoPtr<polyPatch>
227  (
228  new cyclicPolyPatch
229  (
230  *this,
231  bm,
232  index,
233  newSize,
234  newStart,
235  nbrPatchName_
236  )
237  );
238  }
239 
240  //- Construct and return a clone, resetting the face list
241  // and boundary mesh
243  (
244  const polyBoundaryMesh& bm,
245  const label index,
246  const labelUList& mapAddressing,
247  const label newStart
248  ) const
249  {
250  return autoPtr<polyPatch>
251  (
252  new cyclicPolyPatch(*this, bm, index, mapAddressing, newStart)
253  );
254  }
255 
256 
257  //- Destructor
258  virtual ~cyclicPolyPatch();
259 
260 
261  // Member Functions
262 
263  //- Neighbour patch name
264  const word& nbrPatchName() const;
265 
266  //- Neighbour patchID
267  virtual label nbrPatchID() const;
269  virtual bool owner() const
270  {
271  return index() < nbrPatchID();
272  }
274  virtual bool neighbour() const
275  {
276  return !owner();
277  }
279  const cyclicPolyPatch& nbrPatch() const
280  {
281  const polyPatch& pp = this->boundaryMesh()[nbrPatchID()];
282  return refCast<const cyclicPolyPatch>(pp);
283  }
284 
285  //- Return connected points (from patch local to neighbour patch local)
286  // Demand driven calculation. Does primitivePatch::clearOut after
287  // calculation!
288  const edgeList& coupledPoints() const;
289 
290  //- Return connected edges (from patch local to neighbour patch local).
291  // Demand driven calculation. Does primitivePatch::clearOut after
292  // calculation!
293  const edgeList& coupledEdges() const;
294 
295  //- Return transformation between the coupled patches
296  virtual const transformer& transform() const
297  {
299  }
300 
301  //- For a given patch face index, return the corresponding index of the
302  // face on the neighbour
303  label transformGlobalFace(const label facei) const
304  {
305  label offset = facei - start();
306  label neiStart = nbrPatch().start();
307 
308  if (offset >= 0 && offset < size())
309  {
310  return neiStart + offset;
311  }
312  else
313  {
315  << "Face " << facei << " not in patch " << name()
316  << exit(FatalError);
317  return -1;
318  }
319  }
320 
321  //- Initialize ordering for primitivePatch. Does not
322  // refer to *this (except for name() and type() etc.)
323  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
324 
325  //- Return new ordering for primitivePatch.
326  // Ordering is -faceMap: for every face
327  // index of the new face -rotation:for every new face the clockwise
328  // shift of the original face. Return false if nothing changes
329  // (faceMap is identity, rotation is 0), true otherwise.
330  virtual bool order
331  (
333  const primitivePatch&,
335  labelList& rotation
336  ) const;
337 
338  //- Write the polyPatch data as a dictionary
339  virtual void write(Ostream&) const;
340 };
341 
342 
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 
345 } // End namespace Foam
346 
347 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
348 
349 #endif
350 
351 // ************************************************************************* //
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
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
const word & name() const
Return name.
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: transformer.H:83
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const edgeList & coupledPoints() const
Return connected points (from patch local to neighbour patch local)
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:278
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
const word & nbrPatchName() const
Neighbour patch name.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
cyclicPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
virtual const transformer & transform() const
Return transformation between the coupled patches.
const cyclicPolyPatch & nbrPatch() const
virtual autoPtr< PrimitivePatch< FaceList, PointField > > clone() const
Construct and return a clone.
const edgeList & coupledEdges() const
Return connected edges (from patch local to neighbour patch local).
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
A list of faces which address into the list of points.
virtual bool owner() const
Does this side own the patch ?
TypeName("cyclic")
Runtime type information.
A class for handling words, derived from string.
Definition: word.H:59
Cyclic plane patch.
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
const transformer & transform() const
Return transformation between the coupled patches.
Encapsulates using patchGroups to specify coupled patch.
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
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual bool neighbour() const
Does the coupled side own the patch ?
virtual ~cyclicPolyPatch()
Destructor.
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 void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Cyclic plane tranformation.
label transformGlobalFace(const label facei) const
For a given patch face index, return the corresponding index of the.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
virtual void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
virtual label nbrPatchID() const
Neighbour patchID.
Namespace for OpenFOAM.