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
68 
69  //- Point on axis of rotation for rotational cyclics
71 
72  // For translation
73 
74  //- Translation vector
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
87  (
88  const UList<face>&,
89  const pointField&
90  );
91 
92  //- Get f[0] for all faces
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.
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.
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  {
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  {
258  }
259 
260  //- Transform a patch-based position from other side to this side
261  virtual void transformPosition(point&, const label facei) const
262  {
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&,
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 // ************************************************************************* //
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:215
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
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 string.
Definition: word.H:59
Foam::oldCyclicPolyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: oldCyclicPolyPatch.C:1224
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::oldCyclicPolyPatch::movePoints
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Definition: oldCyclicPolyPatch.C:707
Foam::oldCyclicPolyPatch::rotationAxis_
vector rotationAxis_
Axis of rotation for rotational cyclics.
Definition: oldCyclicPolyPatch.H:66
Foam::oldCyclicPolyPatch::matchAnchors
bool matchAnchors(const bool report, const primitivePatch &, const labelList &, const pointField &, const labelList &, const faceList &, const labelList &, const scalarField &, labelList &faceMap, labelList &rotation) const
Given matched faces matches the anchor point. Sets faceMap,.
Definition: oldCyclicPolyPatch.C:435
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:85
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:260
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:51
Foam::oldCyclicPolyPatch::~oldCyclicPolyPatch
virtual ~oldCyclicPolyPatch()
Definition: oldCyclicPolyPatch.C:667
Foam::oldCyclicPolyPatch::getGeometricHalves
bool getGeometricHalves(const primitivePatch &, labelList &, labelList &) const
Find the two parts of the faces of pp using feature edges.
Definition: oldCyclicPolyPatch.C:113
Foam::oldCyclicPolyPatch::getCentresAndAnchors
void getCentresAndAnchors(const primitivePatch &, const faceList &half0Faces, const faceList &half1Faces, pointField &ppPoints, pointField &half0Ctrs, pointField &half1Ctrs, pointField &anchors0, scalarField &tols) const
Calculate geometric factors of the two halves.
Definition: oldCyclicPolyPatch.C:289
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:365
Foam::oldCyclicPolyPatch::rotationCentre_
point rotationCentre_
Point on axis of rotation for rotational cyclics.
Definition: oldCyclicPolyPatch.H:69
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::oldCyclicPolyPatch::transformPosition
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Definition: oldCyclicPolyPatch.H:254
Foam::coupledPolyPatch::UNKNOWN
@ UNKNOWN
Definition: coupledPolyPatch.H:59
Foam::oldCyclicPolyPatch::separationVector_
vector separationVector_
Translation vector.
Definition: oldCyclicPolyPatch.H:74
Foam::oldCyclicPolyPatch::featureCos_
scalar featureCos_
Morph:angle between normals of neighbouring faces.
Definition: oldCyclicPolyPatch.H:60
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
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: 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::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::oldCyclicPolyPatch
'old' style cyclic polyPatch with all faces in single patch. Does ordering but cannot be used to run....
Definition: oldCyclicPolyPatch.H:52
Foam::oldCyclicPolyPatch::calcGeometry
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: oldCyclicPolyPatch.C:692
Foam::oldCyclicPolyPatch::calcTransforms
void calcTransforms()
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:308
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::UList< face >
Foam::PrimitivePatch::calcFaceCentres
void calcFaceCentres() const
Calculate face centres.
Definition: PrimitivePatchMeshData.C:329
Foam::oldCyclicPolyPatch::getAnchorPoints
static pointField getAnchorPoints(const UList< face > &, const pointField &)
Get f[0] for all faces.
Definition: oldCyclicPolyPatch.C:68
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::oldCyclicPolyPatch::findMaxArea
static label findMaxArea(const pointField &, const faceList &)
Find amongst selected faces the one with the largest area.
Definition: oldCyclicPolyPatch.C:85
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::oldCyclicPolyPatch::getConsistentRotationFace
label getConsistentRotationFace(const pointField &faceCentres) const
For rotational cases, try to find a unique face on each side.
Definition: oldCyclicPolyPatch.C:517
Foam::oldCyclicPolyPatch::owner
virtual bool owner() const
Does this side own the patch ?
Definition: oldCyclicPolyPatch.H:247
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88
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:565