cyclicPolyPatch.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 | Copyright (C) 2011-2015 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 "edgeList.H"
51 #include "polyBoundaryMesh.H"
52 #include "diagTensorField.H"
53 #include "coupleGroupIdentifier.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class cyclicPolyPatch Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class cyclicPolyPatch
65 :
66  public coupledPolyPatch
67 {
68  // Private data
69 
70  //- Name of other half
71  mutable word neighbPatchName_;
72 
73  //- Optional patchGroup to find neighbPatch
75 
76  //- Index of other half
77  mutable label neighbPatchID_;
78 
79  // For rotation
80 
81  //- Axis of rotation for rotational cyclics
83 
84  //- Point on axis of rotation for rotational cyclics
86 
87  // For translation
88 
89  //- Translation vector
91 
92 
93  //- List of edges formed from connected points. e[0] is the point on
94  // the first half of the patch, e[1] the corresponding point on the
95  // second half.
96  mutable edgeList* coupledPointsPtr_;
97 
98  //- List of connected edges. e[0] is the edge on the first half of the
99  // patch, e[1] the corresponding edge on the second half.
100  mutable edgeList* coupledEdgesPtr_;
101 
102  //- Temporary storage of owner side patch during ordering.
104 
105 
106  // Private Member Functions
107 
108  //- Find amongst selected faces the one with the largest area
109  static label findMaxArea(const pointField&, const faceList&);
110 
111  void calcTransforms
112  (
113  const primitivePatch& half0,
114  const pointField& half0Ctrs,
115  const vectorField& half0Areas,
116  const pointField& half1Ctrs,
117  const vectorField& half1Areas
118  );
119 
120  // Face ordering
121 
122  // Given a split of faces into left and right half calculate the
123  // centres and anchor points. Transform the left points so they
124  // align with the right ones
126  (
127  const primitivePatch& pp0,
128  const primitivePatch& pp1,
129 
130  pointField& half0Ctrs,
131  pointField& half1Ctrs,
132  pointField& anchors0,
133  scalarField& tols
134  ) const;
135 
136  //- Return normal of face at max distance from rotation axis
138 
139 
140 protected:
141 
142  // Protected Member functions
143 
144  //- Recalculate the transformation tensors
145  virtual void calcTransforms();
146 
147  //- Initialise the calculation of the patch geometry
148  virtual void initGeometry(PstreamBuffers&);
149 
150  //- Initialise the calculation of the patch geometry
151  virtual void initGeometry
152  (
153  const primitivePatch& referPatch,
154  pointField& nbrCtrs,
155  vectorField& nbrAreas,
156  pointField& nbrCc
157  );
158 
159  //- Calculate the patch geometry
160  virtual void calcGeometry(PstreamBuffers&);
161 
162  //- Calculate the patch geometry
163  virtual void calcGeometry
164  (
165  const primitivePatch& referPatch,
166  const pointField& thisCtrs,
167  const vectorField& thisAreas,
168  const pointField& thisCc,
169  const pointField& nbrCtrs,
170  const vectorField& nbrAreas,
171  const pointField& nbrCc
172  );
173 
174  //- Initialise the patches for moving points
175  virtual void initMovePoints(PstreamBuffers&, const pointField&);
176 
177  //- Correct patches after moving points
178  virtual void movePoints(PstreamBuffers&, const pointField&);
179 
180  //- Initialise the update of the patch topology
181  virtual void initUpdateMesh(PstreamBuffers&);
182 
183  //- Update of the patch topology
184  virtual void updateMesh(PstreamBuffers&);
185 
186 public:
187 
188  //- Declare friendship with processorCyclicPolyPatch
189  friend class processorCyclicPolyPatch;
190 
191 
192  //- Runtime type information
193  TypeName("cyclic");
194 
195 
196  // Constructors
197 
198  //- Construct from components
200  (
201  const word& name,
202  const label size,
203  const label start,
204  const label index,
205  const polyBoundaryMesh& bm,
206  const word& patchType,
208  );
209 
210  //- Construct from components
212  (
213  const word& name,
214  const label size,
215  const label start,
216  const label index,
217  const polyBoundaryMesh& bm,
218  const word& neighbPatchName,
219  const transformType transform, // transformation type
220  const vector& rotationAxis, // for rotation only
221  const point& rotationCentre, // for rotation only
222  const vector& separationVector // for translation only
223  );
224 
225  //- Construct from dictionary
227  (
228  const word& name,
229  const dictionary& dict,
230  const label index,
231  const polyBoundaryMesh& bm,
232  const word& patchType
233  );
234 
235  //- Construct as copy, resetting the boundary mesh
237 
238  //- Construct given the original patch and resetting the
239  // face list and boundary mesh information
241  (
242  const cyclicPolyPatch& pp,
243  const polyBoundaryMesh& bm,
244  const label index,
245  const label newSize,
246  const label newStart,
247  const word& neighbPatchName
248  );
249 
250  //- Construct given the original patch and a map
252  (
253  const cyclicPolyPatch& pp,
254  const polyBoundaryMesh& bm,
255  const label index,
256  const labelUList& mapAddressing,
257  const label newStart
258  );
259 
260  //- Construct and return a clone, resetting the boundary mesh
261  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
262  {
263  return autoPtr<polyPatch>(new cyclicPolyPatch(*this, bm));
264  }
265 
266  //- Construct and return a clone, resetting the face list
267  // and boundary mesh
269  (
270  const polyBoundaryMesh& bm,
271  const label index,
272  const label newSize,
273  const label newStart
274  ) const
275  {
276  return autoPtr<polyPatch>
277  (
278  new cyclicPolyPatch
279  (
280  *this,
281  bm,
282  index,
283  newSize,
284  newStart,
286  )
287  );
288  }
289 
290  //- Construct and return a clone, resetting the face list
291  // and boundary mesh
293  (
294  const polyBoundaryMesh& bm,
295  const label index,
296  const labelUList& mapAddressing,
297  const label newStart
298  ) const
299  {
300  return autoPtr<polyPatch>
301  (
302  new cyclicPolyPatch(*this, bm, index, mapAddressing, newStart)
303  );
304  }
305 
306 
307  //- Destructor
308  virtual ~cyclicPolyPatch();
309 
310 
311  // Member Functions
312 
313  //- Neighbour patch name
314  const word& neighbPatchName() const;
315 
316  //- Neighbour patchID
317  virtual label neighbPatchID() const;
318 
319  virtual bool owner() const
320  {
321  return index() < neighbPatchID();
322  }
323 
324  virtual bool neighbour() const
325  {
326  return !owner();
327  }
328 
329  const cyclicPolyPatch& neighbPatch() const
330  {
331  const polyPatch& pp = this->boundaryMesh()[neighbPatchID()];
332  return refCast<const cyclicPolyPatch>(pp);
333  }
334 
335  //- Return connected points (from patch local to neighbour patch local)
336  // Demand driven calculation. Does primitivePatch::clearOut after
337  // calculation!
338  const edgeList& coupledPoints() const;
339 
340  //- Return connected edges (from patch local to neighbour patch local).
341  // Demand driven calculation. Does primitivePatch::clearOut after
342  // calculation!
343  const edgeList& coupledEdges() const;
344 
345  //- Transform a patch-based position from other side to this side
346  virtual void transformPosition(pointField& l) const;
347 
348  //- Transform a patch-based position from other side to this side
349  virtual void transformPosition(point&, const label facei) const;
350 
351 
352  // Transformation
353 
354  label transformGlobalFace(const label facei) const
355  {
356  label offset = facei-start();
357  label neighbStart = neighbPatch().start();
358 
359  if (offset >= 0 && offset < size())
360  {
361  return neighbStart+offset;
362  }
363  else
364  {
366  << "Face " << facei << " not in patch " << name()
367  << exit(FatalError);
368  return -1;
369  }
370  }
371 
372  //- Axis of rotation for rotational cyclics
373  const vector& rotationAxis() const
374  {
375  return rotationAxis_;
376  }
377 
378  //- Point on axis of rotation for rotational cyclics
379  const point& rotationCentre() const
380  {
381  return rotationCentre_;
382  }
383 
384  //- Translation vector for translational cyclics
385  const vector& separationVector() const
386  {
387  return separationVector_;
388  }
389 
390 
391  //- Initialize ordering for primitivePatch. Does not
392  // refer to *this (except for name() and type() etc.)
393  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
394 
395  //- Return new ordering for primitivePatch.
396  // Ordering is -faceMap: for every face
397  // index of the new face -rotation:for every new face the clockwise
398  // shift of the original face. Return false if nothing changes
399  // (faceMap is identity, rotation is 0), true otherwise.
400  virtual bool order
401  (
403  const primitivePatch&,
405  labelList& rotation
406  ) const;
407 
408 
409  //- Write the polyPatch data as a dictionary
410  virtual void write(Ostream&) const;
411 };
412 
413 
414 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
415 
416 } // End namespace Foam
417 
418 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
419 
420 #endif
421 
422 // ************************************************************************* //
Foam::coupleGroupIdentifier
Encapsulates using patchGroups to specify coupled patch.
Definition: coupleGroupIdentifier.H:62
Foam::cyclicPolyPatch::findMaxArea
static label findMaxArea(const pointField &, const faceList &)
Find amongst selected faces the one with the largest area.
Definition: cyclicPolyPatch.C:53
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
Foam::cyclicPolyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: cyclicPolyPatch.C:1004
Foam::cyclicPolyPatch::initMovePoints
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: cyclicPolyPatch.C:978
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::processorCyclicPolyPatch
Neighbour processor patch.
Definition: processorCyclicPolyPatch.H:50
Foam::cyclicPolyPatch::transformGlobalFace
label transformGlobalFace(const label facei) const
Definition: cyclicPolyPatch.H:353
Foam::cyclicPolyPatch
Cyclic plane patch.
Definition: cyclicPolyPatch.H:63
Foam::cyclicPolyPatch::rotationAxis
const vector & rotationAxis() const
Axis of rotation for rotational cyclics.
Definition: cyclicPolyPatch.H:372
Foam::cyclicPolyPatch::initGeometry
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: cyclicPolyPatch.C:924
Foam::cyclicPolyPatch::neighbPatch
const cyclicPolyPatch & neighbPatch() const
Definition: cyclicPolyPatch.H:328
Foam::cyclicPolyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: cyclicPolyPatch.C:1255
coupleGroupIdentifier.H
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:85
Foam::cyclicPolyPatch::separationVector_
vector separationVector_
Translation vector.
Definition: cyclicPolyPatch.H:89
Foam::cyclicPolyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: cyclicPolyPatch.C:998
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:51
Foam::cyclicPolyPatch::rotationCentre
const point & rotationCentre() const
Point on axis of rotation for rotational cyclics.
Definition: cyclicPolyPatch.H:378
Foam::cyclicPolyPatch::coupledEdgesPtr_
edgeList * coupledEdgesPtr_
List of connected edges. e[0] is the edge on the first half of the.
Definition: cyclicPolyPatch.H:99
diagTensorField.H
Foam::cyclicPolyPatch::coupledPoints
const edgeList & coupledPoints() const
Return connected points (from patch local to neighbour patch local)
Definition: cyclicPolyPatch.C:1012
Foam::cyclicPolyPatch::rotationAxis_
vector rotationAxis_
Axis of rotation for rotational cyclics.
Definition: cyclicPolyPatch.H:81
coupledPolyPatch.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:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:302
Foam::cyclicPolyPatch::rotationCentre_
point rotationCentre_
Point on axis of rotation for rotational cyclics.
Definition: cyclicPolyPatch.H:84
Foam::cyclicPolyPatch::calcGeometry
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: cyclicPolyPatch.C:962
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::coupledPolyPatch::UNKNOWN
@ UNKNOWN
Definition: coupledPolyPatch.H:59
Foam::cyclicPolyPatch::clone
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: cyclicPolyPatch.H:260
Foam::cyclicPolyPatch::getCentresAndAnchors
void getCentresAndAnchors(const primitivePatch &pp0, const primitivePatch &pp1, pointField &half0Ctrs, pointField &half1Ctrs, pointField &anchors0, scalarField &tols) const
Definition: cyclicPolyPatch.C:390
Foam::cyclicPolyPatch::coupledEdges
const edgeList & coupledEdges() const
Return connected edges (from patch local to neighbour patch local).
Definition: cyclicPolyPatch.C:1093
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::cyclicPolyPatch::owner
virtual bool owner() const
Does this side own the patch ?
Definition: cyclicPolyPatch.H:318
Foam::cyclicPolyPatch::coupledPointsPtr_
edgeList * coupledPointsPtr_
List of edges formed from connected points. e[0] is the point on.
Definition: cyclicPolyPatch.H:95
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
edgeList.H
Foam::cyclicPolyPatch::transformPosition
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Definition: cyclicPolyPatch.C:854
Foam::cyclicPolyPatch::TypeName
TypeName("cyclic")
Runtime type information.
Foam::cyclicPolyPatch::~cyclicPolyPatch
virtual ~cyclicPolyPatch()
Destructor.
Definition: cyclicPolyPatch.C:797
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::coupledPolyPatch::transform
virtual transformType transform() const
Type of transform.
Definition: coupledPolyPatch.H:256
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::cyclicPolyPatch::coupleGroup_
const coupleGroupIdentifier coupleGroup_
Optional patchGroup to find neighbPatch.
Definition: cyclicPolyPatch.H:73
Foam::cyclicPolyPatch::movePoints
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Definition: cyclicPolyPatch.C:988
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::cyclicPolyPatch::findFaceMaxRadius
vector findFaceMaxRadius(const pointField &faceCentres) const
Return normal of face at max distance from rotation axis.
Definition: cyclicPolyPatch.C:567
Foam::cyclicPolyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: cyclicPolyPatch.C:1233
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:308
Foam::cyclicPolyPatch::neighbPatchID_
label neighbPatchID_
Index of other half.
Definition: cyclicPolyPatch.H:76
Foam::cyclicPolyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: cyclicPolyPatch.C:1445
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::cyclicPolyPatch::neighbPatchName_
word neighbPatchName_
Name of other half.
Definition: cyclicPolyPatch.H:70
Foam::UList
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::cyclicPolyPatch::calcTransforms
virtual void calcTransforms()
Recalculate the transformation tensors.
Definition: cyclicPolyPatch.C:75
polyBoundaryMesh.H
Foam::cyclicPolyPatch::ownerPatchPtr_
autoPtr< primitivePatch > ownerPatchPtr_
Temporary storage of owner side patch during ordering.
Definition: cyclicPolyPatch.H:102
Foam::cyclicPolyPatch::neighbour
virtual bool neighbour() const
Does the coupled side own the patch ?
Definition: cyclicPolyPatch.H:323
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::coupledPolyPatch::transformType
transformType
Definition: coupledPolyPatch.H:57
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109
Foam::cyclicPolyPatch::neighbPatchID
virtual label neighbPatchID() const
Neighbour patchID.
Definition: cyclicPolyPatch.C:819
Foam::cyclicPolyPatch::neighbPatchName
const word & neighbPatchName() const
Neighbour patch name.
Definition: cyclicPolyPatch.C:806
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::cyclicPolyPatch::separationVector
const vector & separationVector() const
Translation vector for translational cyclics.
Definition: cyclicPolyPatch.H:384
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88
Foam::cyclicPolyPatch::cyclicPolyPatch
cyclicPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType, const transformType transform=UNKNOWN)
Construct from components.
Definition: cyclicPolyPatch.C:595