All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2023 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 nbrPatchIndex_;
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 neighbour
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 initTopoChange(PstreamBuffers&);
136 
137  //- Update of the patch topology
138  virtual void topoChange(PstreamBuffers&);
139 
140  //- Reset the patch name
141  virtual void rename(const wordList& newNames);
142 
143  //- Reset the patch index
144  virtual void reorder(const labelUList& newToOldIndex);
145 
146 
147 public:
148 
149  //- Declare friendship with processorCyclicPolyPatch
150  friend class processorCyclicPolyPatch;
151 
152 
153  //- Runtime type information
154  TypeName("cyclic");
155 
156 
157  // Constructors
158 
159  //- Construct from components
161  (
162  const word& name,
163  const label size,
164  const label start,
165  const label index,
166  const polyBoundaryMesh& bm,
167  const word& patchType
168  );
169 
170  //- Construct from components
172  (
173  const word& name,
174  const label size,
175  const label start,
176  const label index,
177  const polyBoundaryMesh& bm,
178  const word& patchType,
179  const word& nbrPatchName,
181  );
182 
183  //- Construct from dictionary
185  (
186  const word& name,
187  const dictionary& dict,
188  const label index,
189  const polyBoundaryMesh& bm,
190  const word& patchType,
191  const bool cyclicTransformDefaultIsNone=false
192  );
193 
194  //- Construct as copy, resetting the boundary mesh
196 
197  //- Construct given the original patch and resetting the
198  // face list and boundary mesh information
200  (
201  const cyclicPolyPatch& pp,
202  const polyBoundaryMesh& bm,
203  const label index,
204  const label newSize,
205  const label newStart,
206  const word& nbrPatchName
207  );
208 
209  //- Construct and return a clone, resetting the boundary mesh
210  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
211  {
212  return autoPtr<polyPatch>(new cyclicPolyPatch(*this, bm));
213  }
214 
215  //- Construct and return a clone, resetting the face list
216  // and boundary mesh
217  virtual autoPtr<polyPatch> clone
218  (
219  const polyBoundaryMesh& bm,
220  const label index,
221  const label newSize,
222  const label newStart
223  ) const
224  {
225  return autoPtr<polyPatch>
226  (
227  new cyclicPolyPatch
228  (
229  *this,
230  bm,
231  index,
232  newSize,
233  newStart,
234  nbrPatchName_
235  )
236  );
237  }
238 
239 
240  //- Destructor
241  virtual ~cyclicPolyPatch();
242 
243 
244  // Member Functions
245 
246  //- Neighbour patch name
247  const word& nbrPatchName() const;
248 
249  //- Neighbour patchID
250  virtual label nbrPatchIndex() const;
251 
252  virtual bool owner() const
253  {
254  return index() < nbrPatchIndex();
255  }
256 
257  virtual bool neighbour() const
258  {
259  return !owner();
260  }
261 
262  const cyclicPolyPatch& nbrPatch() const
263  {
264  const polyPatch& pp = this->boundaryMesh()[nbrPatchIndex()];
265  return refCast<const cyclicPolyPatch>(pp);
266  }
267 
268  //- Return connected points (from patch local to neighbour patch local)
269  // Demand driven calculation. Does primitivePatch::clearOut after
270  // calculation!
271  const edgeList& coupledPoints() const;
272 
273  //- Return connected edges (from patch local to neighbour patch local).
274  // Demand driven calculation. Does primitivePatch::clearOut after
275  // calculation!
276  const edgeList& coupledEdges() const;
277 
278  //- Return transformation between the coupled patches
279  virtual const transformer& transform() const
280  {
282  }
283 
284  //- For a given patch face index, return the corresponding index of the
285  // face on the neighbour
286  label transformGlobalFace(const label facei) const
287  {
288  label offset = facei - start();
289  label neiStart = nbrPatch().start();
290 
291  if (offset >= 0 && offset < size())
292  {
293  return neiStart + offset;
294  }
295  else
296  {
298  << "Face " << facei << " not in patch " << name()
299  << exit(FatalError);
300  return -1;
301  }
302  }
303 
304  //- Initialise ordering for primitivePatch. Does not
305  // refer to *this (except for name() and type() etc.)
306  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
307 
308  //- Return new ordering for primitivePatch.
309  // Ordering is -faceMap: for every face
310  // index of the new face -rotation:for every new face the clockwise
311  // shift of the original face. Return false if nothing changes
312  // (faceMap is identity, rotation is 0), true otherwise.
313  virtual bool order
314  (
316  const primitivePatch&,
318  labelList& rotation
319  ) const;
320 
321  //- Write the polyPatch data as a dictionary
322  virtual void write(Ostream&) const;
323 };
324 
325 
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
327 
328 } // End namespace Foam
329 
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
331 
332 #endif
333 
334 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
autoPtr< PrimitivePatch< SubList< face >, const pointField & > > clone() const
Construct and return a clone.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
Encapsulates using patchGroups to specify coupled patch.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Cyclic plane patch.
const cyclicPolyPatch & nbrPatch() const
cyclicPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
virtual void rename(const wordList &newNames)
Reset the patch name.
virtual bool owner() const
Does this side own the patch ?
const edgeList & coupledEdges() const
Return connected edges (from patch local to neighbour patch local).
const word & nbrPatchName() const
Neighbour patch name.
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
const edgeList & coupledPoints() const
Return connected points (from patch local to neighbour patch local)
virtual void reorder(const labelUList &newToOldIndex)
Reset the patch index.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
virtual void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
virtual const transformer & transform() const
Return transformation between the coupled patches.
virtual label nbrPatchIndex() const
Neighbour patchID.
label transformGlobalFace(const label facei) const
For a given patch face index, return the corresponding index of the.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
TypeName("cyclic")
Runtime type information.
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
virtual ~cyclicPolyPatch()
Destructor.
virtual bool neighbour() const
Does the coupled side own the patch ?
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
Cyclic plane transformation.
const transformer & transform() const
Return transformation between the coupled patches.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Foam::polyBoundaryMesh.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:280
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:270
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
error FatalError
void offset(label &lst, const label o)
dictionary dict