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-2021 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()[nbrPoints_[i]])
76  mutable autoPtr<labelList> nbrPointsPtr_;
77 
78  //- Corresponding neighbouring local edge label for every local edge
79  // (so edges()[i] == neighb.edges()[nbrEdges_[i]])
80  mutable autoPtr<labelList> nbrEdgesPtr_;
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 word& patchType = typeName
97  );
98 
99 
100  // Protected Member functions
101 
102  //- Initialise the calculation of the patch geometry
104 
105  //- Calculate the patch geometry
107 
108  //- Initialise the patches for moving points
110 
111  //- Correct patches after moving points
112  void movePoints(PstreamBuffers&, const pointField&);
113 
114  //- Initialise the update of the patch topology
115  virtual void initUpdateMesh(PstreamBuffers&);
116 
117  //- Update of the patch topology
118  virtual void updateMesh(PstreamBuffers&);
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("processor");
125 
126 
127  // Constructors
128 
129  //- Construct from components with automatically generated standard name
131  (
132  const label size,
133  const label start,
134  const label index,
135  const polyBoundaryMesh& bm,
136  const int myProcNo,
137  const int neighbProcNo,
138  const word& patchType = typeName
139  );
140 
141  //- Construct from dictionary
143  (
144  const word& name,
145  const dictionary& dict,
146  const label index,
147  const polyBoundaryMesh&,
148  const word& patchType
149  );
150 
151  //- Construct as copy, resetting the boundary mesh
153 
154  //- Construct as given the original patch and resetting the
155  // face list and boundary mesh information
157  (
158  const processorPolyPatch& pp,
159  const polyBoundaryMesh& bm,
160  const label index,
161  const label newSize,
162  const label newStart
163  );
164 
165  //- Construct given the original patch and a map
167  (
168  const processorPolyPatch& pp,
169  const polyBoundaryMesh& bm,
170  const label index,
171  const labelUList& mapAddressing,
172  const label newStart
173  );
174 
175  //- Construct and return a clone, resetting the boundary mesh
176  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
177  {
178  return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
179  }
180 
181  //- Construct and return a clone, resetting the face list
182  // and boundary mesh
184  (
185  const polyBoundaryMesh& bm,
186  const label index,
187  const label newSize,
188  const label newStart
189  ) const
190  {
191  return autoPtr<polyPatch>
192  (
194  (
195  *this,
196  bm,
197  index,
198  newSize,
199  newStart
200  )
201  );
202  }
203 
204  //- Construct and return a clone, resetting the face list
205  // and boundary mesh
207  (
208  const polyBoundaryMesh& bm,
209  const label index,
210  const labelUList& mapAddressing,
211  const label newStart
212  ) const
213  {
214  return autoPtr<polyPatch>
215  (
217  (
218  *this,
219  bm,
220  index,
221  mapAddressing,
222  newStart
223  )
224  );
225  }
226 
227 
228  //- Destructor
229  virtual ~processorPolyPatch();
230 
231 
232  // Member Functions
233 
234  //- Return true only if this is a parallel run
235  virtual bool coupled() const
236  {
237  if (Pstream::parRun())
238  {
239  return true;
240  }
241  else
242  {
243  return false;
244  }
245  }
246 
247  //- Return processor number
248  int myProcNo() const
249  {
250  return myProcNo_;
251  }
252 
253  //- Return neighbour processor number
254  int neighbProcNo() const
255  {
256  return neighbProcNo_;
257  }
258 
259  //- Does the processor own the patch ?
260  virtual bool owner() const
261  {
262  return (myProcNo_ < neighbProcNo_);
263  }
264 
265  //- Is the processor the patch neighbour ?
266  bool neighbour() const
267  {
268  return !owner();
269  }
270 
271  //- Return the name of a processorPolyPatch
272  // constructed from the processor IDs
273  static word newName
274  (
275  const label myProcNo,
276  const label neighbProcNo
277  );
278 
279  //- Return processor-neighbbour patch face centres
280  const vectorField& neighbFaceCentres() const
281  {
282  return neighbFaceCentres_;
283  }
284 
285  //- Return processor-neighbbour patch face areas
286  const vectorField& neighbFaceAreas() const
287  {
288  return neighbFaceAreas_;
289  }
290 
291  //- Return processor-neighbbour patch neighbour cell centres
292  const vectorField& neighbFaceCellCentres() const
293  {
294  return neighbFaceCellCentres_;
295  }
296 
297  //- Return neighbour point labels. WIP.
298  const labelList& nbrPoints() const;
299 
300  //- Return neighbour edge labels. WIP.
301  const labelList& nbrEdges() const;
302 
303  //- Return message tag to use for communication
304  virtual int tag() const
305  {
306  return Pstream::msgType();
307  }
308 
309  //- Return communicator used for communication
310  virtual label comm() const
311  {
312  return boundaryMesh().mesh().comm();
313  }
314 
315  //- Return null transform between processor patches
316  virtual const transformer& transform() const
317  {
318  return transformer::null;
319  }
320 
321  //- Initialise ordering for primitivePatch. Does not
322  // refer to *this (except for name() and type() etc.)
323  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
324 
325  //- Return new ordering for primitivePatch.
326  // Ordering is -faceMap: for every face
327  // index of the new face -rotation:for every new face the clockwise
328  // shift of the original face. Return false if nothing changes
329  // (faceMap is identity, rotation is 0), true otherwise.
330  virtual bool order
331  (
333  const primitivePatch&,
335  labelList& rotation
336  ) const;
337 
338 
339  //- Write the polyPatch data as a dictionary
340  virtual void write(Ostream&) const;
341 };
342 
343 
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
345 
346 } // End namespace Foam
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 #endif
351 
352 // ************************************************************************* //
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
const labelList & nbrPoints() const
Return neighbour point labels. WIP.
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space...
Definition: transformer.H:83
const labelList & nbrEdges() const
Return neighbour edge labels. WIP.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:291
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
static const transformer null
Null transformer.
Definition: transformer.H:128
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
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
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.
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:54
TypeName("processor")
Runtime type information.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual const transformer & transform() const
Return null transform between processor patches.
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
const vectorField & neighbFaceCellCentres() const
Return processor-neighbbour patch neighbour cell centres.
processorPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const word &patchType=typeName)
Construct from components with specified name.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
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.
Namespace for OpenFOAM.
virtual bool owner() const
Does the processor own the patch ?