processorPolyPatch.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  Copyright (C) 2015 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::processorPolyPatch
29 
30 Description
31  Neighbour processor patch.
32 
33  Note: morph patch face ordering tries to do a geometric ordering.
34  (assumes faces coincident) Hence will have problems when cyclics
35  are present.
36 
37 SourceFiles
38  processorPolyPatch.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef Foam_processorPolyPatch_H
43 #define Foam_processorPolyPatch_H
44 
45 #include "coupledPolyPatch.H"
46 #include "polyBoundaryMesh.H"
47 #include "faceListFwd.H"
48 #include "polyMesh.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class processorPolyPatch Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 :
61  public coupledPolyPatch
62 {
63  // Private Data
64 
65  int myProcNo_;
66  int neighbProcNo_;
67 
68  //- Processor-neighbour patch face centres
69  vectorField neighbFaceCentres_;
70 
71  //- Processor-neighbour patch face areas
72  vectorField neighbFaceAreas_;
73 
74  //- Processor-neighbour patch neighbour cell centres
75  vectorField neighbFaceCellCentres_;
76 
77  //- Corresponding neighbouring local point label for every local point
78  // (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
79  mutable autoPtr<labelList> neighbPointsPtr_;
80 
81  //- Corresponding neighbouring local edge label for every local edge
82  // (so edges()[i] == neighb.edges()[neighbEdges_[i]])
83  mutable autoPtr<labelList> neighbEdgesPtr_;
84 
85 protected:
86 
87  // Protected constructors
88 
89  //- Construct from components with specified name
91  (
92  const word& name,
93  const label size,
94  const label start,
95  const label index,
96  const polyBoundaryMesh& bm,
97  const int myProcNo,
98  const int neighbProcNo,
99  const transformType transform = UNKNOWN, // transformation type
100  const word& patchType = typeName
101  );
102 
103 
104  // Protected Member functions
105 
106  //- Initialise the calculation of the patch geometry
108 
109  //- Calculate the patch geometry
111 
112  //- Calculate the patch geometry with externally
113  // provided geometry
114  virtual void calcGeometry
115  (
116  const primitivePatch& referPatch,
117  const pointField& thisCtrs,
118  const vectorField& thisAreas,
119  const pointField& thisCc,
120  const pointField& nbrCtrs,
121  const vectorField& nbrAreas,
122  const pointField& nbrCc
123  )
124  {
126  }
127 
128  //- Initialise the patches for moving points
130 
131  //- Correct patches after moving points
132  void movePoints(PstreamBuffers&, const pointField&);
133 
134  //- Initialise the update of the patch topology
135  virtual void initUpdateMesh(PstreamBuffers&);
136 
137  //- Update of the patch topology
138  virtual void updateMesh(PstreamBuffers&);
139 
140 
141 public:
142 
143  //- Runtime type information
144  TypeName("processor");
145 
146 
147  // Constructors
148 
149  //- Construct from components with automatically generated standard name
151  (
152  const label size,
153  const label start,
154  const label index,
155  const polyBoundaryMesh& bm,
156  const int myProcNo,
157  const int neighbProcNo,
158  const transformType transform = UNKNOWN, // transformation type
159  const word& patchType = typeName
160  );
161 
162  //- Construct from dictionary
164  (
165  const word& name,
166  const dictionary& dict,
167  const label index,
168  const polyBoundaryMesh&,
169  const word& patchType
170  );
171 
172  //- Construct as copy, resetting the boundary mesh
174 
175  //- Construct as given the original patch and resetting the
176  // face list and boundary mesh information
178  (
179  const processorPolyPatch& pp,
180  const polyBoundaryMesh& bm,
181  const label index,
182  const label newSize,
183  const label newStart
184  );
185 
186  //- Construct given the original patch and a map
188  (
189  const processorPolyPatch& pp,
190  const polyBoundaryMesh& bm,
191  const label index,
192  const labelUList& mapAddressing,
193  const label newStart
194  );
195 
196  //- Construct and return a clone, resetting the boundary mesh
197  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
198  {
199  return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
200  }
201 
202  //- Construct and return a clone, resetting the face list
203  // and boundary mesh
204  virtual autoPtr<polyPatch> clone
205  (
206  const polyBoundaryMesh& bm,
207  const label index,
208  const label newSize,
209  const label newStart
210  ) const
211  {
212  return autoPtr<polyPatch>
213  (
215  (
216  *this,
217  bm,
218  index,
219  newSize,
220  newStart
221  )
222  );
223  }
224 
225  //- Construct and return a clone, resetting the face list
226  // and boundary mesh
227  virtual autoPtr<polyPatch> clone
228  (
229  const polyBoundaryMesh& bm,
230  const label index,
231  const labelUList& mapAddressing,
232  const label newStart
233  ) const
234  {
235  return autoPtr<polyPatch>
236  (
238  (
239  *this,
240  bm,
241  index,
242  mapAddressing,
243  newStart
244  )
245  );
246  }
248 
249  //- Destructor
250  virtual ~processorPolyPatch();
251 
252 
253  // Static Functions
254 
255  //- Return the name of a processorPolyPatch ("procBoundary..")
256  //- constructed from the pair of processor IDs.
257  static word newName
258  (
259  const label myProcNo,
260  const label neighbProcNo
261  );
262 
263 
264  // Member Functions
265 
266  //- Return true only if this is a parallel run
267  virtual bool coupled() const
268  {
269  return UPstream::parRun();
270  }
271 
272  //- Return processor number
273  int myProcNo() const noexcept
274  {
275  return myProcNo_;
276  }
277 
278  //- Return neighbour processor number
279  int neighbProcNo() const noexcept
280  {
281  return neighbProcNo_;
282  }
283 
284  //- Does the processor own the patch ?
285  virtual bool owner() const
286  {
287  return (myProcNo_ < neighbProcNo_);
288  }
289 
290  //- Is the processor the patch neighbour ?
291  bool neighbour() const
292  {
293  return !owner();
294  }
295 
296  //- Return processor-neighbour patch face centres
297  const vectorField& neighbFaceCentres() const noexcept
298  {
299  return neighbFaceCentres_;
300  }
301 
302  //- Return processor-neighbour patch face areas
303  const vectorField& neighbFaceAreas() const noexcept
304  {
305  return neighbFaceAreas_;
306  }
307 
308  //- Return processor-neighbour patch neighbour cell centres
310  {
311  return neighbFaceCellCentres_;
312  }
313 
314  //- Return neighbour point labels. WIP.
315  const labelList& neighbPoints() const;
316 
317  //- Return neighbour edge labels. WIP.
318  const labelList& neighbEdges() const;
319 
320  //- Return message tag to use for communication
321  virtual int tag() const
322  {
323  return UPstream::msgType();
324  }
325 
326  //- Return communicator used for communication
327  virtual label comm() const
328  {
329  return boundaryMesh().mesh().comm();
330  }
331 
332  //- Transform a patch-based position from other side to this side
333  virtual void transformPosition(pointField& l) const
334  {}
335 
336  //- Transform a patch-based position from other side to this side
337  virtual void transformPosition(point&, const label facei) const
338  {}
339 
340  //- Initialize ordering for primitivePatch. Does not
341  // refer to *this (except for name() and type() etc.)
342  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
343 
344  //- Returns rotation.
345  // -1 : no match
346  // 0 : match
347  // >0 : match if rotated clockwise by this amount
348  static label matchFace
349  (
350  const face& localFace,
351  const pointField& localPts,
352  const face& masterFace,
353  const pointField& masterPts,
354  const bool sameOrientation,
355  const scalar absTolSqr,
356  scalar& matchDistSqr
357  );
359  //- Return new ordering for primitivePatch.
360  // Ordering is -faceMap: for every face
361  // index of the new face -rotation:for every new face the clockwise
362  // shift of the original face. Return false if nothing changes
363  // (faceMap is identity, rotation is 0), true otherwise.
364  virtual bool order
365  (
367  const primitivePatch&,
369  labelList& rotation
370  ) const;
371 
372 
373  //- Write the polyPatch data as a dictionary
374  virtual void write(Ostream&) const;
375 };
376 
377 
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379 
380 } // End namespace Foam
381 
382 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 
384 #endif
385 
386 // ************************************************************************* //
label comm() const noexcept
The communicator used for parallel communication.
Definition: polyMesh.H:700
dictionary dict
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
friend class polyBoundaryMesh
Definition: polyPatch.H:107
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:68
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 void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch ("procBoundary..") constructed from the pair of processor IDs...
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
const vectorField & neighbFaceCellCentres() const noexcept
Return processor-neighbour patch neighbour cell centres.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:1229
const vectorField & neighbFaceAreas() const noexcept
Return processor-neighbour patch face areas.
const vectorField & neighbFaceCentres() const noexcept
Return processor-neighbour patch face centres.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Neighbour processor patch.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
A list of faces which address into the list of points.
virtual label comm() const
Return communicator used for communication.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Definition: polyPatch.C:309
const polyMesh & mesh() const noexcept
Return the mesh reference.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual ~processorPolyPatch()
Destructor.
virtual int tag() const
Return message tag to use for communication.
virtual bool coupled() const
Return true only if this is a parallel run.
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
const word & name() const noexcept
The patch name.
bool neighbour() const
Is the processor the patch neighbour ?
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
TypeName("processor")
Runtime type information.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
static label matchFace(const face &localFace, const pointField &localPts, const face &masterFace, const pointField &masterPts, const bool sameOrientation, const scalar absTolSqr, scalar &matchDistSqr)
Returns rotation.
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
int neighbProcNo() const noexcept
Return neighbour processor number.
Forwards for various types of face lists.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
virtual transformType transform() const
Type of transform.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
label index() const noexcept
The index of this patch in the boundaryMesh.
List< label > labelList
A List of labels.
Definition: List.H:62
const labelList & neighbEdges() const
Return neighbour edge labels. WIP.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
int myProcNo() const noexcept
Return processor number.
processorPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const transformType transform=UNKNOWN, const word &patchType=typeName)
Construct from components with specified name.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
virtual bool owner() const
Does the processor own the patch ?