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-2026 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-neighbour patch face centres
66  vectorField neighbFaceCentres_;
67 
68  //- Processor-neighbour patch face areas
69  vectorField neighbFaceAreas_;
70 
71  //- Processor-neighbour 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  );
97 
98 
99  // Protected Member functions
100 
101  //- Initialise the calculation of the patch geometry
103 
104  //- Calculate the patch geometry
106 
107  //- Initialise the patches for moving points
109 
110  //- Correct patches after moving points
111  void movePoints(PstreamBuffers&, const pointField&);
112 
113  //- Initialise the update of the patch topology
114  virtual void initTopoChange(PstreamBuffers&);
115 
116  //- Update of the patch topology
117  virtual void topoChange(PstreamBuffers&);
118 
119 
120 public:
121 
122  //- Runtime type information
123  TypeName("processor");
124 
125 
126  // Constructors
127 
128  //- Construct from components with automatically generated standard name
130  (
131  const label size,
132  const label start,
133  const label index,
134  const polyBoundaryMesh& bm,
135  const int myProcNo,
136  const int neighbProcNo
137  );
138 
139  //- Construct from dictionary
141  (
142  const word& name,
143  const dictionary& dict,
144  const label index,
145  const polyBoundaryMesh&
146  );
147 
148  //- Construct as copy, resetting the boundary mesh
150 
151  //- Construct as given the original patch and resetting the
152  // face list and boundary mesh information
154  (
155  const processorPolyPatch& pp,
156  const polyBoundaryMesh& bm,
157  const label index,
158  const label newSize,
159  const label newStart
160  );
161 
162  //- Construct and return a clone, resetting the boundary mesh
163  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
164  {
165  return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
166  }
167 
168  //- Construct and return a clone, resetting the face list
169  // and boundary mesh
170  virtual autoPtr<polyPatch> clone
171  (
172  const polyBoundaryMesh& bm,
173  const label index,
174  const label newSize,
175  const label newStart
176  ) const
177  {
178  return autoPtr<polyPatch>
179  (
181  (
182  *this,
183  bm,
184  index,
185  newSize,
186  newStart
187  )
188  );
189  }
190 
191 
192  //- Destructor
193  virtual ~processorPolyPatch();
194 
195 
196  // Member Functions
197 
198  //- Return true as this patch is a constraint type
199  virtual bool constraint() const
200  {
201  return true;
202  }
203 
204  //- Return true only if this is a parallel run
205  virtual bool coupled() const
206  {
207  if (Pstream::parRun())
208  {
209  return true;
210  }
211  else
212  {
213  return false;
214  }
215  }
216 
217  //- Return processor number
218  int myProcNo() const
219  {
220  return myProcNo_;
221  }
222 
223  //- Return neighbour processor number
224  int neighbProcNo() const
225  {
226  return neighbProcNo_;
227  }
228 
229  //- Does the processor own the patch ?
230  virtual bool owner() const
231  {
232  return (myProcNo_ < neighbProcNo_);
233  }
234 
235  //- Is the processor the patch neighbour ?
236  bool neighbour() const
237  {
238  return !owner();
239  }
240 
241  //- Return the name of a processorPolyPatch
242  // constructed from the processor IDs
243  static word newName
244  (
245  const label myProcNo,
246  const label neighbProcNo
247  );
248 
249  //- Return processor-neighbour patch face centres
250  const vectorField& neighbFaceCentres() const
251  {
252  return neighbFaceCentres_;
253  }
254 
255  //- Return processor-neighbour patch face areas
256  const vectorField& neighbFaceAreas() const
257  {
258  return neighbFaceAreas_;
259  }
260 
261  //- Return processor-neighbour patch neighbour cell centres
262  const vectorField& neighbFaceCellCentres() const
263  {
264  return neighbFaceCellCentres_;
265  }
266 
267  //- Return neighbour point labels. WIP.
268  const labelList& nbrPoints() const;
269 
270  //- Return neighbour edge labels. WIP.
271  const labelList& nbrEdges() const;
272 
273  //- Return message tag to use for communication
274  virtual int tag() const
275  {
276  return Pstream::msgType();
277  }
278 
279  //- Return communicator used for communication
280  virtual label comm() const
281  {
282  return mesh().comm();
283  }
284 
285  //- Return null transform between processor patches
286  virtual const transformer& transform() const
287  {
288  return transformer::null;
289  }
290 
291  //- Initialise ordering for primitivePatch. Does not
292  // refer to *this (except for name() and type() etc.)
293  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
294 
295  //- Return new ordering for primitivePatch.
296  // Ordering is -faceMap: for every face
297  // index of the new face -rotation:for every new face the clockwise
298  // shift of the original face. Return false if nothing changes
299  // (faceMap is identity, rotation is 0), true otherwise.
300  virtual bool order
301  (
303  const primitivePatch&,
305  labelList& rotation
306  ) const;
307 
308 
309  //- Write the polyPatch data as a dictionary
310  virtual void write(Ostream&) const;
311 };
312 
313 
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 
316 } // End namespace Foam
317 
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319 
320 #endif
321 
322 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
autoPtr< PrimitivePatch< SubList< face >, const pointField & > > clone() const
Construct and return a clone.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:476
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Foam::polyBoundaryMesh.
label comm() const
Return communicator used for parallel communication.
Definition: polyMesh.C:1490
const polyMesh & mesh() const
Return mesh reference.
Definition: polyPatch.C:221
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:277
Neighbour processor patch.
int myProcNo() const
Return processor number.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
virtual bool owner() const
Does the processor own the patch ?
virtual bool coupled() const
Return true only if this is a parallel run.
int neighbProcNo() const
Return neighbour processor number.
virtual ~processorPolyPatch()
Destructor.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
virtual const transformer & transform() const
Return null transform between processor patches.
const vectorField & neighbFaceCentres() const
Return processor-neighbour patch face centres.
virtual bool constraint() const
Return true as this patch is a constraint type.
const labelList & nbrPoints() const
Return neighbour point labels. WIP.
const labelList & nbrEdges() const
Return neighbour edge labels. WIP.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch.
virtual label comm() const
Return communicator used for communication.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
processorPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo)
Construct from components with specified name.
bool neighbour() const
Is the processor the patch neighbour ?
virtual int tag() const
Return message tag to use for communication.
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
TypeName("processor")
Runtime type information.
const vectorField & neighbFaceAreas() const
Return processor-neighbour patch face areas.
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
const vectorField & neighbFaceCellCentres() const
Return processor-neighbour patch neighbour cell centres.
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
static const transformer null
Null transformer.
Definition: transformer.H:127
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
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
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
dictionary dict