oldCyclicPolyPatch.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::oldCyclicPolyPatch
28 
29 Description
30  'old' style cyclic polyPatch with all faces in single patch. Does ordering
31  but cannot be used to run. Writes 'type cyclic' so foamUpgradeCyclics
32  can be run afterwards.
33  Used to get cyclics from mesh converters that assume cyclics in single
34  patch (e.g. fluent3DMeshToFoam)
35 
36 SourceFiles
37  oldCyclicPolyPatch.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef oldCyclicPolyPatch_H
42 #define oldCyclicPolyPatch_H
43 
44 #include "coupledPolyPatch.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class oldCyclicPolyPatch Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 :
57  public coupledPolyPatch
58 {
59  // Private data
60 
61  //- Morph:angle between normals of neighbouring faces.
62  // Used to split cyclic into halves.
63  scalar featureCos_;
64 
65 
66  // For rotation
67 
68  //- Axis of rotation for rotational cyclics
69  vector rotationAxis_;
70 
71  //- Point on axis of rotation for rotational cyclics
72  point rotationCentre_;
73 
74  // For translation
75 
76  //- Translation vector
77  vector separationVector_;
78 
79 
80  // Private member functions
81 
82  //- Find amongst selected faces the one with the largest area
83  static label findMaxArea(const pointField&, const faceList&);
84 
85  void calcTransforms();
86 
87  //- Calculate face centres
88  static pointField calcFaceCentres
89  (
90  const UList<face>&,
91  const pointField&
92  );
93 
94  //- Get f[0] for all faces
95  static pointField getAnchorPoints
96  (
97  const UList<face>&,
98  const pointField&
99  );
100 
101  // Face ordering
102 
103  //- Find the two parts of the faces of pp using feature edges.
104  // Returns true if successful.
105  bool getGeometricHalves
106  (
107  const primitivePatch&,
108  labelList&,
109  labelList&
110  ) const;
111 
112  //- Calculate geometric factors of the two halves.
113  void getCentresAndAnchors
114  (
115  const primitivePatch&,
116  const faceList& half0Faces,
117  const faceList& half1Faces,
118 
119  pointField& ppPoints,
120  pointField& half0Ctrs,
121  pointField& half1Ctrs,
122  pointField& anchors0,
123  scalarField& tols
124  ) const;
125 
126  //- Given matched faces matches the anchor point. Sets faceMap,
127  // rotation. Returns true if all matched.
128  bool matchAnchors
129  (
130  const bool report,
131  const primitivePatch&,
132  const labelList&,
133  const pointField&,
134  const labelList&,
135  const faceList&,
136  const labelList&,
137  const scalarField&,
138 
140  labelList& rotation
141  ) const;
142 
143  //- For rotational cases, try to find a unique face on each side
144  // of the cyclic.
145  label getConsistentRotationFace
146  (
147  const pointField& faceCentres
148  ) const;
149 
150 
151 protected:
152 
153  // Protected Member functions
154 
155  //- Initialise the calculation of the patch geometry
156  virtual void initGeometry(PstreamBuffers&);
157 
158  //- Calculate the patch geometry
159  virtual void calcGeometry(PstreamBuffers&);
160 
161  //- Initialise the patches for moving points
162  virtual void initMovePoints(PstreamBuffers&, const pointField&);
163 
164  //- Correct patches after moving points
165  virtual void movePoints(PstreamBuffers&, const pointField&);
166 
167  //- Initialise the update of the patch topology
168  virtual void initUpdateMesh(PstreamBuffers&);
169 
170  //- Update of the patch topology
171  virtual void updateMesh(PstreamBuffers&);
172 
173 public:
174 
175  //- Runtime type information
176  TypeName("oldCyclic");
177 
178 
179  // Constructors
180 
181  //- Construct from components
183  (
184  const word& name,
185  const label size,
186  const label start,
187  const label index,
188  const polyBoundaryMesh& bm,
189  const word& patchType,
191  );
192 
193  //- Construct from dictionary
195  (
196  const word& name,
197  const dictionary& dict,
198  const label index,
199  const polyBoundaryMesh& bm,
200  const word& patchType
201  );
202 
203  //- Construct as copy, resetting the boundary mesh
205 
206  //- Construct given the original patch and resetting the
207  // face list and boundary mesh information
209  (
210  const oldCyclicPolyPatch& pp,
211  const polyBoundaryMesh& bm,
212  const label index,
213  const label newSize,
214  const label newStart
215  );
216 
217  //- Construct and return a clone, resetting the boundary mesh
218  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
219  {
220  return autoPtr<polyPatch>(new oldCyclicPolyPatch(*this, bm));
221  }
222 
223  //- Construct and return a clone, resetting the face list
224  // and boundary mesh
226  (
227  const polyBoundaryMesh& bm,
228  const label index,
229  const label newSize,
230  const label newStart
231  ) const
232  {
233  return autoPtr<polyPatch>
234  (
235  new oldCyclicPolyPatch(*this, bm, index, newSize, newStart)
236  );
237  }
238 
239 
240  // Destructor
241 
242  virtual ~oldCyclicPolyPatch();
243 
244 
245  // Member Functions
246 
247  // Access
248 
249  //- Does this side own the patch ?
250  virtual bool owner() const
251  {
253  return true;
254  }
255 
256  //- Transform a patch-based position from other side to this side
257  virtual void transformPosition(pointField& l) const
258  {
260  }
261 
262  //- Transform a patch-based position from other side to this side
263  virtual void transformPosition(point&, const label facei) const
264  {
266  }
267 
268  //- Calculate the patch geometry
269  virtual void calcGeometry
270  (
271  const primitivePatch& referPatch,
272  const pointField& thisCtrs,
273  const vectorField& thisAreas,
274  const pointField& thisCc,
275  const pointField& nbrCtrs,
276  const vectorField& nbrAreas,
277  const pointField& nbrCc
278  );
279 
280  //- Initialize ordering for primitivePatch. Does not
281  // refer to *this (except for name() and type() etc.)
282  virtual void initOrder
283  (
285  const primitivePatch&
286  ) const;
287 
288  //- Return new ordering for primitivePatch.
289  // Ordering is -faceMap: for every face
290  // index of the new face -rotation:for every new face the clockwise
291  // shift of the original face. Return false if nothing changes
292  // (faceMap is identity, rotation is 0), true otherwise.
293  virtual bool order
294  (
296  const primitivePatch&,
298  labelList& rotation
299  ) const;
300 
301  //- Write the polyPatch data as a dictionary
302  virtual void write(Ostream&) const;
303 };
304 
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 } // End namespace Foam
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 #endif
313 
314 // ************************************************************************* //
Foam::oldCyclicPolyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: oldCyclicPolyPatch.C:722
Foam::oldCyclicPolyPatch::clone
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: oldCyclicPolyPatch.H:217
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
Foam::oldCyclicPolyPatch::initGeometry
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: oldCyclicPolyPatch.C:673
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::oldCyclicPolyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: oldCyclicPolyPatch.C:1224
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::oldCyclicPolyPatch::movePoints
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Definition: oldCyclicPolyPatch.C:707
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:88
Foam::oldCyclicPolyPatch::TypeName
TypeName("oldCyclic")
Runtime type information.
Foam::oldCyclicPolyPatch::transformPosition
virtual void transformPosition(point &, const label facei) const
Transform a patch-based position from other side to this side.
Definition: oldCyclicPolyPatch.H:262
Foam::oldCyclicPolyPatch::initMovePoints
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: oldCyclicPolyPatch.C:697
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:54
Foam::oldCyclicPolyPatch::~oldCyclicPolyPatch
virtual ~oldCyclicPolyPatch()
Definition: oldCyclicPolyPatch.C:667
Foam::oldCyclicPolyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: oldCyclicPolyPatch.C:741
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
coupledPolyPatch.H
Foam::Field< vector >
Foam::oldCyclicPolyPatch::transformPosition
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Definition: oldCyclicPolyPatch.H:256
Foam::coupledPolyPatch::UNKNOWN
Definition: coupledPolyPatch.H:62
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::oldCyclicPolyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: oldCyclicPolyPatch.C:729
Foam::oldCyclicPolyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: oldCyclicPolyPatch.C:716
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchIdentifier::index
label index() const noexcept
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:147
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:361
Foam::coupledPolyPatch::transform
virtual transformType transform() const
Type of transform.
Definition: coupledPolyPatch.H:263
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::oldCyclicPolyPatch
'old' style cyclic polyPatch with all faces in single patch. Does ordering but cannot be used to run....
Definition: oldCyclicPolyPatch.H:54
Foam::oldCyclicPolyPatch::calcGeometry
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: oldCyclicPolyPatch.C:692
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:321
Foam::Vector< scalar >
Foam::List< face >
Foam::UList< face >
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::coupledPolyPatch::transformType
transformType
Definition: coupledPolyPatch.H:60
Foam::oldCyclicPolyPatch::owner
virtual bool owner() const
Does this side own the patch ?
Definition: oldCyclicPolyPatch.H:249
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79
Foam::oldCyclicPolyPatch::oldCyclicPolyPatch
oldCyclicPolyPatch(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: oldCyclicPolyPatch.C:567