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 processorCyclicPolyPatch_H
40 #define 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();
261 
262 
263  // Member functions
264 
265  //- Return name of originating cyclicPolyPatch patch
266  const word& referPatchName() const
267  {
268  return referPatchName_;
269  }
270 
271  //- Return the name of a processorCyclicPolyPatch
272  // constructed from cyclicPolyPatch name and the processor IDs
273  static word newName
274  (
275  const word& cyclicPolyPatchName,
276  const label myProcNo,
277  const label neighbProcNo
278  );
279 
280  //- Return the indices of a processorCyclicPolyPatchs
281  // constructed from the given cyclicPolyPatch
282  static labelList patchIDs
283  (
284  const word& cyclicPolyPatchName,
285  const polyBoundaryMesh& bm
286  );
287 
288  //- Referring patchID.
289  label referPatchID() const
290  {
291  if (referPatchID_ == -1)
292  {
293  referPatchID_ = this->boundaryMesh().findPatchID
294  (
295  referPatchName_
296  );
297  if (referPatchID_ == -1)
298  {
300  << "Illegal referPatch name " << referPatchName_
301  << endl << "Valid patch names are "
302  << this->boundaryMesh().names()
303  << exit(FatalError);
304  }
305  }
306  return referPatchID_;
307  }
308 
309  const coupledPolyPatch& referPatch() const
310  {
311  const polyPatch& pp = this->boundaryMesh()[referPatchID()];
312  return refCast<const coupledPolyPatch>(pp);
313  }
314 
315  //- Return message tag to use for communication
316  virtual int tag() const;
317 
318  //- Does this side own the patch ?
319  virtual bool owner() const
320  {
321  return referPatch().owner();
322  }
323 
324  //- Type of transform
325  virtual transformType transform() const
326  {
327  return referPatch().transform();
328  }
329 
330  //- Type of transform
331  // This is currently only for use when collapsing generated
332  // meshes that can have zero area faces.
333  virtual transformType& transform()
334  {
335  return const_cast<coupledPolyPatch&>(referPatch()).transform();
336  }
337 
338  //- Transform a patch-based position from other side to this side
339  virtual void transformPosition(pointField& l) const
340  {
342  }
343 
344  //- Transform a patch-based position from other side to this side
345  virtual void transformPosition(point& l, const label facei) const
346  {
347  referPatch().transformPosition(l, facei);
348  }
349 
350  //- Are the planes separated.
351  virtual bool separated() const
352  {
353  return referPatch().separated();
354  }
355 
356  //- If the planes are separated the separation vector.
357  virtual const vectorField& separation() const
358  {
359  return referPatch().separation();
360  }
361 
362  //- Are the cyclic planes parallel.
363  virtual bool parallel() const
364  {
365  return referPatch().parallel();
366  }
367 
368  //- Return face transformation tensor.
369  virtual const tensorField& forwardT() const
370  {
371  return referPatch().forwardT();
372  }
373 
374  //- Return neighbour-cell transformation tensor.
375  virtual const tensorField& reverseT() const
376  {
377  return referPatch().reverseT();
378  }
379 
380  //- Are faces collocated. Either size 0,1 or length of patch
381  virtual const boolList& collocated() const
382  {
383  return referPatch().collocated();
384  }
385 
386 
387  //- Initialize ordering for primitivePatch. Does not
388  // refer to *this (except for name() and type() etc.)
389  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
390 
391  //- Return new ordering for primitivePatch.
392  // Ordering is -faceMap: for every face
393  // index of the new face -rotation:for every new face the clockwise
394  // shift of the original face. Return false if nothing changes
395  // (faceMap is identity, rotation is 0), true otherwise.
396  virtual bool order
397  (
399  const primitivePatch&,
401  labelList& rotation
402  ) const;
404 
405  //- Write the polyPatch data as a dictionary
406  virtual void write(Ostream&) const;
407 };
408 
409 
410 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
412 } // End namespace Foam
413 
414 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
415 
416 #endif
417 
418 // ************************************************************************* //
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
label referPatchID() const
Referring patchID.
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
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.
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
label start() const noexcept
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:441
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
virtual bool separated() const
Are the planes separated.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
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 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
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:310
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
wordList names() const
Return a list of patch names.
virtual bool owner() const =0
Does this side own the patch ?
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:55
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
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.
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.
Field< vector > vectorField
Specialisation of Field<T> for vector.
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.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:666
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.