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