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  // Member functions
254 
255  //- Return true only if this is a parallel run
256  virtual bool coupled() const
257  {
258  return UPstream::parRun();
259  }
260 
261  //- Return processor number
262  int myProcNo() const noexcept
263  {
264  return myProcNo_;
265  }
266 
267  //- Return neighbour processor number
268  int neighbProcNo() const noexcept
269  {
270  return neighbProcNo_;
271  }
272 
273  //- Does the processor own the patch ?
274  virtual bool owner() const
275  {
276  return (myProcNo_ < neighbProcNo_);
277  }
278 
279  //- Is the processor the patch neighbour ?
280  bool neighbour() const
281  {
282  return !owner();
283  }
284 
285  //- Return the name of a processorPolyPatch
286  // constructed from the processor IDs
287  static word newName
288  (
289  const label myProcNo,
290  const label neighbProcNo
291  );
292 
293  //- Return processor-neighbour patch face centres
294  const vectorField& neighbFaceCentres() const noexcept
295  {
296  return neighbFaceCentres_;
297  }
298 
299  //- Return processor-neighbour patch face areas
300  const vectorField& neighbFaceAreas() const noexcept
301  {
302  return neighbFaceAreas_;
303  }
304 
305  //- Return processor-neighbour patch neighbour cell centres
307  {
308  return neighbFaceCellCentres_;
309  }
310 
311  //- Return neighbour point labels. WIP.
312  const labelList& neighbPoints() const;
314  //- Return neighbour edge labels. WIP.
315  const labelList& neighbEdges() const;
316 
317  //- Return message tag to use for communication
318  virtual int tag() const
319  {
320  return UPstream::msgType();
321  }
322 
323  //- Return communicator used for communication
324  virtual label comm() const
325  {
326  return boundaryMesh().mesh().comm();
327  }
328 
329  //- Transform a patch-based position from other side to this side
330  virtual void transformPosition(pointField& l) const
331  {}
332 
333  //- Transform a patch-based position from other side to this side
334  virtual void transformPosition(point&, const label facei) const
335  {}
336 
337  //- Initialize ordering for primitivePatch. Does not
338  // refer to *this (except for name() and type() etc.)
339  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
340 
341  //- Returns rotation.
342  // -1 : no match
343  // 0 : match
344  // >0 : match if rotated clockwise by this amount
345  static label matchFace
346  (
347  const face& localFace,
348  const pointField& localPts,
349  const face& masterFace,
350  const pointField& masterPts,
351  const bool sameOrientation,
352  const scalar absTolSqr,
353  scalar& matchDistSqr
354  );
355 
356  //- Return new ordering for primitivePatch.
357  // Ordering is -faceMap: for every face
358  // index of the new face -rotation:for every new face the clockwise
359  // shift of the original face. Return false if nothing changes
360  // (faceMap is identity, rotation is 0), true otherwise.
361  virtual bool order
362  (
366  labelList& rotation
367  ) const;
368 
369 
370  //- Write the polyPatch data as a dictionary
371  virtual void write(Ostream&) const;
372 };
373 
374 
375 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376 
377 } // End namespace Foam
378 
379 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380 
381 #endif
382 
383 // ************************************************************************* //
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:120
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.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1004
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:1184
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:310
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
label comm() const noexcept
Return communicator used for parallel communication.
Definition: polyMesh.C:1318
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:55
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.
const labelList & neighbEdges() const
Return neighbour edge labels. WIP.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:666
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 ?