processorCyclicPolyPatch.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-2016 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::processorCyclicPolyPatch
28 
29 Description
30  Neighbour processor patch.
31 
32  Note: morph patch face ordering is geometric.
33 
34 SourceFiles
35  processorCyclicPolyPatch.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_processorCyclicPolyPatch_H
40 #define Foam_processorCyclicPolyPatch_H
41 
42 #include "processorPolyPatch.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class processorCyclicPolyPatch Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 :
55  public processorPolyPatch
56 {
57  // Private Data
58 
59  //- Name of originating patch
60  const word referPatchName_;
61 
62  //- Message tag to use for communication
63  mutable int tag_;
64 
65  //- Index of originating patch
66  mutable label referPatchID_;
67 
68 
69 protected:
70 
71  // Protected Member functions
72 
73  //- Initialise the calculation of the patch geometry
75 
76  //- Calculate the patch geometry
78 
79  //- Calculate the patch geometry with externally
80  // provided geometry
81  virtual void calcGeometry
82  (
84  const pointField& thisCtrs,
85  const vectorField& thisAreas,
86  const pointField& thisCc,
87  const pointField& nbrCtrs,
88  const vectorField& nbrAreas,
89  const pointField& nbrCc
90  )
91  {
93  }
94 
95  //- Initialise the patches for moving points
97 
98  //- Correct patches after moving points
99  void movePoints(PstreamBuffers&, const pointField&);
100 
101  //- Initialise the update of the patch topology
102  virtual void initUpdateMesh(PstreamBuffers&);
103 
104  //- Update of the patch topology
105  virtual void updateMesh(PstreamBuffers&);
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("processorCyclic");
112 
113 
114  // Constructors
115 
116  //- Construct from components
118  (
119  const label size,
120  const label start,
121  const label index,
122  const polyBoundaryMesh& bm,
123  const int myProcNo,
124  const int neighbProcNo,
125  const word& referPatchName,
127  const word& patchType = typeName
128  );
129 
130  //- Construct from dictionary
132  (
133  const word& name,
134  const dictionary& dict,
135  const label index,
136  const polyBoundaryMesh&,
137  const word& patchType
138  );
139 
140  //- Construct as copy, resetting the boundary mesh
142  (
144  const polyBoundaryMesh&
145  );
146 
147  //- Construct as given the original patch and resetting the
148  // face list and boundary mesh information
150  (
152  const polyBoundaryMesh& bm,
153  const label index,
154  const label newSize,
155  const label newStart
156  );
157 
158  //- Construct as given the original patch and resetting the
159  // face list, boundary mesh information and referPatch
161  (
163  const polyBoundaryMesh& bm,
164  const label index,
165  const label newSize,
166  const label newStart,
167  const word& referPatchName
168  );
169 
170  //- Construct given the original patch and a map
172  (
174  const polyBoundaryMesh& bm,
175  const label index,
176  const labelUList& mapAddressing,
177  const label newStart
178  );
179 
180 
181  //- Construct and return a clone, resetting the boundary mesh
182  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
183  {
184  return autoPtr<polyPatch>(new processorCyclicPolyPatch(*this, bm));
185  }
186 
187  //- Construct and return a clone, resetting the face list
188  // and boundary mesh
189  virtual autoPtr<polyPatch> clone
190  (
191  const polyBoundaryMesh& bm,
192  const label index,
193  const label newSize,
194  const label newStart
195  ) const
196  {
197  return autoPtr<polyPatch>
198  (
200  (
201  *this,
202  bm,
203  index,
204  newSize,
205  newStart
206  )
207  );
208  }
209 
210  //- Construct and return a clone, resetting the face list
211  // and boundary mesh
212  virtual autoPtr<polyPatch> clone
213  (
214  const polyBoundaryMesh& bm,
215  const label index,
216  const label newSize,
217  const label newStart,
218  const word& referPatchName
219  ) const
220  {
221  return autoPtr<polyPatch>
222  (
224  (
225  *this,
226  bm,
228  newSize,
229  newStart,
231  )
232  );
233  }
234 
235  //- Construct and return a clone, resetting the face list
236  // and boundary mesh
237  virtual autoPtr<polyPatch> clone
238  (
239  const polyBoundaryMesh& bm,
240  const label index,
241  const labelUList& mapAddressing,
242  const label newStart
243  ) const
244  {
245  return autoPtr<polyPatch>
246  (
248  (
249  *this,
250  bm,
251  index,
252  mapAddressing,
253  newStart
254  )
255  );
256  }
257 
258 
259  // Destructor
260  virtual ~processorCyclicPolyPatch() = default;
261 
262 
263  // Static Functions
264 
265  //- Return the name of a processorCyclicPolyPatch constructed from
266  //- the cyclicPolyPatch name and the pair of processor IDs.
267  static word newName
268  (
269  const word& cyclicPolyPatchName,
270  const label myProcNo,
271  const label neighbProcNo
272  );
273 
274  //- Return the indices of a processorCyclicPolyPatchs
275  // constructed from the given cyclicPolyPatch
276  static labelList patchIDs
277  (
278  const word& cyclicPolyPatchName,
279  const polyBoundaryMesh& bm
280  );
282 
283  // Member Functions
284 
285  //- Return name of originating cyclicPolyPatch patch
286  const word& referPatchName() const
287  {
288  return referPatchName_;
289  }
290 
291  //- The referring patchID.
292  //- Searches for referPatchName() on the first call.
293  virtual label referPatchID() const;
294 
295  //- The referred coupled patch
296  const coupledPolyPatch& referPatch() const
297  {
298  const polyPatch& pp = this->boundaryMesh()[referPatchID()];
299  return refCast<const coupledPolyPatch>(pp);
300  }
301 
302  //- Return message tag to use for communication
303  virtual int tag() const;
304 
305  //- Does this side own the patch ?
306  virtual bool owner() const
307  {
308  return referPatch().owner();
309  }
310 
311  //- Type of transform
312  virtual transformType transform() const
313  {
314  return referPatch().transform();
315  }
316 
317  //- Type of transform
318  // This is currently only for use when collapsing generated
319  // meshes that can have zero area faces.
320  virtual transformType& transform()
321  {
322  return const_cast<coupledPolyPatch&>(referPatch()).transform();
323  }
324 
325  //- Transform a patch-based position from other side to this side
326  virtual void transformPosition(pointField& l) const
327  {
329  }
330 
331  //- Transform a patch-based position from other side to this side
332  virtual void transformPosition(point& l, const label facei) const
333  {
334  referPatch().transformPosition(l, facei);
335  }
337  //- Are the planes separated.
338  virtual bool separated() const
339  {
340  return referPatch().separated();
341  }
342 
343  //- If the planes are separated the separation vector.
344  virtual const vectorField& separation() const
345  {
346  return referPatch().separation();
347  }
348 
349  //- Are the cyclic planes parallel.
350  virtual bool parallel() const
351  {
352  return referPatch().parallel();
353  }
354 
355  //- Return face transformation tensor.
356  virtual const tensorField& forwardT() const
357  {
358  return referPatch().forwardT();
359  }
360 
361  //- Return neighbour-cell transformation tensor.
362  virtual const tensorField& reverseT() const
363  {
364  return referPatch().reverseT();
365  }
366 
367  //- Are faces collocated. Either size 0,1 or length of patch
368  virtual const boolList& collocated() const
369  {
370  return referPatch().collocated();
371  }
373 
374  //- Initialize ordering for primitivePatch. Does not
375  // refer to *this (except for name() and type() etc.)
376  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
377 
378  //- Return new ordering for primitivePatch.
379  // Ordering is -faceMap: for every face
380  // index of the new face -rotation:for every new face the clockwise
381  // shift of the original face. Return false if nothing changes
382  // (faceMap is identity, rotation is 0), true otherwise.
383  virtual bool order
384  (
386  const primitivePatch&,
388  labelList& rotation
389  ) const;
390 
392  //- Write the polyPatch data as a dictionary
393  virtual void write(Ostream&) const;
394 };
395 
396 
397 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
398 
399 } // End namespace Foam
400 
401 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
402 
403 #endif
404 
405 // ************************************************************************* //
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
dictionary dict
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
virtual bool owner() const
Does this side own the patch ?
virtual bool separated() const
Are the planes separated.
friend class polyBoundaryMesh
Definition: polyPatch.H:107
coupledPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType, const transformType transform)
Construct from components.
virtual bool parallel() const
Are the cyclic planes parallel.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
label start() const noexcept
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:441
virtual bool separated() const
Are the planes separated.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
virtual const vectorField & separation() const
If the planes are separated the separation vector.
virtual ~processorCyclicPolyPatch()=default
virtual const tensorField & forwardT() const
Return face transformation tensor.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Neighbour processor patch.
const coupledPolyPatch & referPatch() const
The referred coupled patch.
virtual bool parallel() const
Are the cyclic planes parallel.
A list of faces which address into the list of points.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
virtual const vectorField & separation() const
If the planes are separated the separation vector.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Definition: polyPatch.C:309
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
virtual const boolList & collocated() const
Are faces collocated. Either size 0,1 or length of patch.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool owner() const =0
Does this side own the patch ?
virtual label referPatchID() const
The referring patchID. Searches for referPatchName() on the first call.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
virtual transformType transform() const
Type of transform.
const word & name() const noexcept
The patch name.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual const boolList & collocated() const
Are faces collocated. Either size 0,1 or length of patch.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
int neighbProcNo() const noexcept
Return neighbour processor number.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
vector point
Point is a vector.
Definition: point.H:37
virtual void transformPosition(pointField &) const =0
Transform a patch-based position from other side to this side.
TypeName("processorCyclic")
Runtime type information.
static labelList patchIDs(const word &cyclicPolyPatchName, const polyBoundaryMesh &bm)
Return the indices of a processorCyclicPolyPatchs.
const word & referPatchName() const
Return name of originating cyclicPolyPatch patch.
processorCyclicPolyPatch(const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const word &referPatchName, const transformType transform=UNKNOWN, const word &patchType=typeName)
Construct from components.
virtual transformType transform() const
Type of transform.
virtual int tag() const
Return message tag to use for communication.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
label index() const noexcept
The index of this patch in the boundaryMesh.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
static word newName(const word &cyclicPolyPatchName, const label myProcNo, const label neighbProcNo)
Return the name of a processorCyclicPolyPatch constructed from the cyclicPolyPatch name and the pair ...
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
int myProcNo() const noexcept
Return processor number.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.