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 | 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::oldCyclicPolyPatch
26 
27 Description
28  'old' style cyclic polyPatch with all faces in single patch. Does ordering
29  but cannot be used to run. Writes 'type cyclic' so foamUpgradeCyclics
30  can be run afterwards.
31  Used to get cyclics from mesh converters that assume cyclics in single
32  patch (e.g. fluent3DMeshToFoam)
33 
34 SourceFiles
35  oldCyclicPolyPatch.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef oldCyclicPolyPatch_H
40 #define oldCyclicPolyPatch_H
41 
42 #include "coupledPolyPatch.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class oldCyclicPolyPatch Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 :
55  public coupledPolyPatch
56 {
57  // Private data
58 
59  //- Morph:angle between normals of neighbouring faces.
60  // Used to split cyclic into halves.
61  scalar featureCos_;
62 
63 
64  // For rotation
65 
66  //- Axis of rotation for rotational cyclics
67  vector rotationAxis_;
68 
69  //- Point on axis of rotation for rotational cyclics
70  point rotationCentre_;
71 
72  // For translation
73 
74  //- Translation vector
75  vector separationVector_;
76 
77 
78  // Private member functions
79 
80  //- Find amongst selected faces the one with the largest area
81  static label findMaxArea(const pointField&, const faceList&);
82 
83  void calcTransforms();
84 
85  //- Calculate face centres
86  static pointField calcFaceCentres
87  (
88  const UList<face>&,
89  const pointField&
90  );
91 
92  //- Get f[0] for all faces
93  static pointField getAnchorPoints
94  (
95  const UList<face>&,
96  const pointField&
97  );
98 
99  // Face ordering
100 
101  //- Find the two parts of the faces of pp using feature edges.
102  // Returns true if successfull.
103  bool getGeometricHalves
104  (
105  const primitivePatch&,
106  labelList&,
107  labelList&
108  ) const;
109 
110  //- Calculate geometric factors of the two halves.
111  void getCentresAndAnchors
112  (
113  const primitivePatch&,
114  const faceList& half0Faces,
115  const faceList& half1Faces,
116 
117  pointField& ppPoints,
118  pointField& half0Ctrs,
119  pointField& half1Ctrs,
120  pointField& anchors0,
121  scalarField& tols
122  ) const;
123 
124  //- Given matched faces matches the anchor point. Sets faceMap,
125  // rotation. Returns true if all matched.
126  bool matchAnchors
127  (
128  const bool report,
129  const primitivePatch&,
130  const labelList&,
131  const pointField&,
132  const labelList&,
133  const faceList&,
134  const labelList&,
135  const scalarField&,
136 
138  labelList& rotation
139  ) const;
140 
141  //- For rotational cases, try to find a unique face on each side
142  // of the cyclic.
143  label getConsistentRotationFace
144  (
145  const pointField& faceCentres
146  ) const;
147 
148 
149 protected:
150 
151  // Protected Member functions
152 
153  //- Initialise the calculation of the patch geometry
154  virtual void initGeometry(PstreamBuffers&);
155 
156  //- Calculate the patch geometry
157  virtual void calcGeometry(PstreamBuffers&);
158 
159  //- Initialise the patches for moving points
160  virtual void initMovePoints(PstreamBuffers&, const pointField&);
161 
162  //- Correct patches after moving points
163  virtual void movePoints(PstreamBuffers&, const pointField&);
164 
165  //- Initialise the update of the patch topology
166  virtual void initUpdateMesh(PstreamBuffers&);
167 
168  //- Update of the patch topology
169  virtual void updateMesh(PstreamBuffers&);
170 
171 public:
172 
173  //- Runtime type information
174  TypeName("oldCyclic");
175 
176 
177  // Constructors
178 
179  //- Construct from components
181  (
182  const word& name,
183  const label size,
184  const label start,
185  const label index,
186  const polyBoundaryMesh& bm,
187  const word& patchType,
189  );
190 
191  //- Construct from dictionary
193  (
194  const word& name,
195  const dictionary& dict,
196  const label index,
197  const polyBoundaryMesh& bm,
198  const word& patchType
199  );
200 
201  //- Construct as copy, resetting the boundary mesh
203 
204  //- Construct given the original patch and resetting the
205  // face list and boundary mesh information
207  (
208  const oldCyclicPolyPatch& pp,
209  const polyBoundaryMesh& bm,
210  const label index,
211  const label newSize,
212  const label newStart
213  );
214 
215  //- Construct and return a clone, resetting the boundary mesh
216  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
217  {
218  return autoPtr<polyPatch>(new oldCyclicPolyPatch(*this, bm));
219  }
220 
221  //- Construct and return a clone, resetting the face list
222  // and boundary mesh
224  (
225  const polyBoundaryMesh& bm,
226  const label index,
227  const label newSize,
228  const label newStart
229  ) const
230  {
231  return autoPtr<polyPatch>
232  (
233  new oldCyclicPolyPatch(*this, bm, index, newSize, newStart)
234  );
235  }
236 
237 
238  // Destructor
239 
240  virtual ~oldCyclicPolyPatch();
241 
242 
243  // Member Functions
244 
245  // Access
246 
247  //- Does this side own the patch ?
248  virtual bool owner() const
249  {
250  notImplemented("oldCyclicPolyPatch::owner()");
251  return true;
252  }
253 
254  //- Transform a patch-based position from other side to this side
255  virtual void transformPosition(pointField& l) const
256  {
257  notImplemented("transformPosition(pointField&)");
258  }
259 
260  //- Transform a patch-based position from other side to this side
261  virtual void transformPosition(point&, const label facei) const
262  {
263  notImplemented("transformPosition(point&, const label)");
264  }
265 
266  //- Calculate the patch geometry
267  virtual void calcGeometry
268  (
269  const primitivePatch& referPatch,
270  const pointField& thisCtrs,
271  const vectorField& thisAreas,
272  const pointField& thisCc,
273  const pointField& nbrCtrs,
274  const vectorField& nbrAreas,
275  const pointField& nbrCc
276  );
277 
278  //- Initialize ordering for primitivePatch. Does not
279  // refer to *this (except for name() and type() etc.)
280  virtual void initOrder
281  (
283  const primitivePatch&
284  ) const;
285 
286  //- Return new ordering for primitivePatch.
287  // Ordering is -faceMap: for every face
288  // index of the new face -rotation:for every new face the clockwise
289  // shift of the original face. Return false if nothing changes
290  // (faceMap is identity, rotation is 0), true otherwise.
291  virtual bool order
292  (
294  const primitivePatch&,
295  labelList& faceMap,
296  labelList& rotation
297  ) const;
298 
299  //- Write the polyPatch data as a dictionary
300  virtual void write(Ostream&) const;
301 };
302 
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 } // End namespace Foam
307 
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 
310 #endif
311 
312 // ************************************************************************* //
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
const word & name() const
Return name.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
label index() const
Return the index of this patch in the boundaryMesh.
A class for handling words, derived from string.
Definition: word.H:59
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
virtual bool owner() const
Does this side own the patch ?
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:284
dictionary dict
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Foam::polyBoundaryMesh.
A list of faces which address into the list of points.
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:300
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
virtual transformType transform() const
Type of transform.
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
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.
TypeName("oldCyclic")
Runtime type information.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
&#39;old&#39; style cyclic polyPatch with all faces in single patch. Does ordering but cannot be used to run...
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.