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 processorPolyPatch_H
43 #define 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
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
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  }
247 
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  if (Pstream::parRun())
259  {
260  return true;
261  }
262  else
263  {
264  return false;
265  }
266  }
267 
268  //- Return processor number
269  int myProcNo() const
270  {
271  return myProcNo_;
272  }
273 
274  //- Return neighbour processor number
275  int neighbProcNo() const
276  {
277  return neighbProcNo_;
278  }
279 
280  //- Does the processor own the patch ?
281  virtual bool owner() const
282  {
283  return (myProcNo_ < neighbProcNo_);
284  }
285 
286  //- Is the processor the patch neighbour ?
287  bool neighbour() const
288  {
289  return !owner();
290  }
291 
292  //- Return the name of a processorPolyPatch
293  // constructed from the processor IDs
294  static word newName
295  (
296  const label myProcNo,
297  const label neighbProcNo
298  );
299 
300  //- Return processor-neighbour patch face centres
301  const vectorField& neighbFaceCentres() const
302  {
303  return neighbFaceCentres_;
304  }
305 
306  //- Return processor-neighbour patch face areas
307  const vectorField& neighbFaceAreas() const
308  {
309  return neighbFaceAreas_;
310  }
311 
312  //- Return processor-neighbour patch neighbour cell centres
313  const vectorField& neighbFaceCellCentres() const
314  {
315  return neighbFaceCellCentres_;
316  }
317 
318  //- Return neighbour point labels. WIP.
319  const labelList& neighbPoints() const;
320 
321  //- Return neighbour edge labels. WIP.
322  const labelList& neighbEdges() const;
323 
324  //- Return message tag to use for communication
325  virtual int tag() const
326  {
327  return Pstream::msgType();
328  }
329 
330  //- Return communicator used for communication
331  virtual label comm() const
332  {
333  return boundaryMesh().mesh().comm();
334  }
335 
336  //- Transform a patch-based position from other side to this side
337  virtual void transformPosition(pointField& l) const
338  {}
339 
340  //- Transform a patch-based position from other side to this side
341  virtual void transformPosition(point&, const label facei) const
342  {}
343 
344  //- Initialize ordering for primitivePatch. Does not
345  // refer to *this (except for name() and type() etc.)
346  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
347 
348  //- Returns rotation.
349  // -1 : no match
350  // 0 : match
351  // >0 : match if rotated clockwise by this amount
352  static label matchFace
353  (
354  const face& localFace,
355  const pointField& localPts,
356  const face& masterFace,
357  const pointField& masterPts,
358  const bool sameOrientation,
359  const scalar absTolSqr,
360  scalar& matchDistSqr
361  );
362 
363  //- Return new ordering for primitivePatch.
364  // Ordering is -faceMap: for every face
365  // index of the new face -rotation:for every new face the clockwise
366  // shift of the original face. Return false if nothing changes
367  // (faceMap is identity, rotation is 0), true otherwise.
368  virtual bool order
369  (
371  const primitivePatch&,
373  labelList& rotation
374  ) const;
375 
376 
377  //- Write the polyPatch data as a dictionary
378  virtual void write(Ostream&) const;
379 };
380 
381 
382 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 
384 } // End namespace Foam
385 
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 
388 #endif
389 
390 // ************************************************************************* //
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::processorPolyPatch::initMovePoints
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: processorPolyPatch.C:339
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:88
Foam::processorPolyPatch::neighbProcNo
int neighbProcNo() const
Return neighbour processor number.
Definition: processorPolyPatch.H:274
Foam::processorPolyPatch::neighbEdges
const labelList & neighbEdges() const
Return neighbour edge labels. WIP.
Definition: processorPolyPatch.C:540
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:54
polyMesh.H
Foam::processorPolyPatch::calcGeometry
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: processorPolyPatch.C:222
Foam::processorPolyPatch::neighbFaceAreas
const vectorField & neighbFaceAreas() const
Return processor-neighbour patch face areas.
Definition: processorPolyPatch.H:306
Foam::polyMesh::comm
label comm() const noexcept
Return communicator used for parallel communication.
Definition: polyMesh.C:1313
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::processorPolyPatch::matchFace
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.
Definition: processorPolyPatch.C:637
Foam::processorPolyPatch::neighbFaceCellCentres
const vectorField & neighbFaceCellCentres() const
Return processor-neighbour patch neighbour cell centres.
Definition: processorPolyPatch.H:312
coupledPolyPatch.H
Foam::polyBoundaryMesh::mesh
const polyMesh & mesh() const noexcept
Return the mesh reference.
Definition: polyBoundaryMesh.H:152
Foam::Field< vector >
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:315
Foam::processorPolyPatch::clone
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: processorPolyPatch.H:196
Foam::processorPolyPatch::initGeometry
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: processorPolyPatch.C:198
Foam::coupledPolyPatch::UNKNOWN
Definition: coupledPolyPatch.H:62
Foam::processorPolyPatch
Neighbour processor patch.
Definition: processorPolyPatch.H:58
Foam::processorPolyPatch::coupled
virtual bool coupled() const
Return true only if this is a parallel run.
Definition: processorPolyPatch.H:255
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::processorPolyPatch::owner
virtual bool owner() const
Does the processor own the patch ?
Definition: processorPolyPatch.H:280
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::processorPolyPatch::neighbFaceCentres
const vectorField & neighbFaceCentres() const
Return processor-neighbour patch face centres.
Definition: processorPolyPatch.H:300
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchIdentifier::index
label index() const noexcept
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:147
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:361
Foam::coupledPolyPatch::transform
virtual transformType transform() const
Type of transform.
Definition: coupledPolyPatch.H:263
Foam::processorPolyPatch::movePoints
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Definition: processorPolyPatch.C:350
Foam::processorPolyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: processorPolyPatch.C:359
Foam::processorPolyPatch::tag
virtual int tag() const
Return message tag to use for communication.
Definition: processorPolyPatch.H:324
Foam::processorPolyPatch::processorPolyPatch
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.
Definition: processorPolyPatch.C:53
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::processorPolyPatch::neighbPoints
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
Definition: processorPolyPatch.C:528
Foam::processorPolyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: processorPolyPatch.C:1135
Foam::UPstream::msgType
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:540
Foam::processorPolyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: processorPolyPatch.C:553
Foam::Vector< scalar >
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::List< label >
Foam::processorPolyPatch::newName
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch.
Definition: processorPolyPatch.C:185
Foam::processorPolyPatch::comm
virtual label comm() const
Return communicator used for communication.
Definition: processorPolyPatch.H:330
Foam::UList< label >
Foam::processorPolyPatch::transformPosition
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Definition: processorPolyPatch.H:336
polyBoundaryMesh.H
Foam::processorPolyPatch::transformPosition
virtual void transformPosition(point &, const label facei) const
Transform a patch-based position from other side to this side.
Definition: processorPolyPatch.H:340
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::processorPolyPatch::myProcNo
int myProcNo() const
Return processor number.
Definition: processorPolyPatch.H:268
Foam::processorPolyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: processorPolyPatch.C:416
faceListFwd.H
Forwards for various types of face lists.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::processorPolyPatch::~processorPolyPatch
virtual ~processorPolyPatch()
Destructor.
Definition: processorPolyPatch.C:175
Foam::coupledPolyPatch::transformType
transformType
Definition: coupledPolyPatch.H:60
Foam::processorPolyPatch::neighbour
bool neighbour() const
Is the processor the patch neighbour ?
Definition: processorPolyPatch.H:286
Foam::processorPolyPatch::TypeName
TypeName("processor")
Runtime type information.
Foam::processorPolyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: processorPolyPatch.C:743
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79