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-2023 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  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 initTopoChange(PstreamBuffers&);
116 
117  //- Update of the patch topology
118  virtual void topoChange(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 and return a clone, resetting the boundary mesh
166  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
167  {
168  return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
169  }
170 
171  //- Construct and return a clone, resetting the face list
172  // and boundary mesh
173  virtual autoPtr<polyPatch> clone
174  (
175  const polyBoundaryMesh& bm,
176  const label index,
177  const label newSize,
178  const label newStart
179  ) const
180  {
181  return autoPtr<polyPatch>
182  (
184  (
185  *this,
186  bm,
187  index,
188  newSize,
189  newStart
190  )
191  );
192  }
193 
194 
195  //- Destructor
196  virtual ~processorPolyPatch();
197 
198 
199  // Member Functions
200 
201  //- Return true only if this is a parallel run
202  virtual bool coupled() const
203  {
204  if (Pstream::parRun())
205  {
206  return true;
207  }
208  else
209  {
210  return false;
211  }
212  }
213 
214  //- Return processor number
215  int myProcNo() const
216  {
217  return myProcNo_;
218  }
219 
220  //- Return neighbour processor number
221  int neighbProcNo() const
222  {
223  return neighbProcNo_;
224  }
225 
226  //- Does the processor own the patch ?
227  virtual bool owner() const
228  {
229  return (myProcNo_ < neighbProcNo_);
230  }
231 
232  //- Is the processor the patch neighbour ?
233  bool neighbour() const
234  {
235  return !owner();
236  }
237 
238  //- Return the name of a processorPolyPatch
239  // constructed from the processor IDs
240  static word newName
241  (
242  const label myProcNo,
243  const label neighbProcNo
244  );
245 
246  //- Return processor-neighbour patch face centres
247  const vectorField& neighbFaceCentres() const
248  {
249  return neighbFaceCentres_;
250  }
251 
252  //- Return processor-neighbour patch face areas
253  const vectorField& neighbFaceAreas() const
254  {
255  return neighbFaceAreas_;
256  }
257 
258  //- Return processor-neighbour patch neighbour cell centres
259  const vectorField& neighbFaceCellCentres() const
260  {
261  return neighbFaceCellCentres_;
262  }
263 
264  //- Return neighbour point labels. WIP.
265  const labelList& nbrPoints() const;
266 
267  //- Return neighbour edge labels. WIP.
268  const labelList& nbrEdges() const;
269 
270  //- Return message tag to use for communication
271  virtual int tag() const
272  {
273  return Pstream::msgType();
274  }
275 
276  //- Return communicator used for communication
277  virtual label comm() const
278  {
279  return boundaryMesh().mesh().comm();
280  }
281 
282  //- Return null transform between processor patches
283  virtual const transformer& transform() const
284  {
285  return transformer::null;
286  }
287 
288  //- Initialise ordering for primitivePatch. Does not
289  // refer to *this (except for name() and type() etc.)
290  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
291 
292  //- Return new ordering for primitivePatch.
293  // Ordering is -faceMap: for every face
294  // index of the new face -rotation:for every new face the clockwise
295  // shift of the original face. Return false if nothing changes
296  // (faceMap is identity, rotation is 0), true otherwise.
297  virtual bool order
298  (
300  const primitivePatch&,
302  labelList& rotation
303  ) const;
304 
305 
306  //- Write the polyPatch data as a dictionary
307  virtual void write(Ostream&) const;
308 };
309 
310 
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 
313 } // End namespace Foam
314 
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 
317 #endif
318 
319 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of faces which address into the list of points.
autoPtr< PrimitivePatch< FaceList, PointField > > clone() const
Construct and return a clone.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Foam::polyBoundaryMesh.
const polyMesh & mesh() const
Return the mesh reference.
label comm() const
Return communicator used for parallel communication.
Definition: polyMesh.C:1581
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:280
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:270
Neighbour processor patch.
int myProcNo() const
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 word &patchType=typeName)
Construct from components with specified name.
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.
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.
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:128
A class for handling words, derived from string.
Definition: word.H:62
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