processorFaPatch.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2019-2022 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::processorFaPatch
29 
30 Description
31  Processor patch.
32 
33 Author
34  Zeljko Tukovic, FMENA
35  Hrvoje Jasak, Wikki Ltd.
36 
37 SourceFiles
38  processorFaPatch.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef Foam_processorFaPatch_H
43 #define Foam_processorFaPatch_H
44 
45 #include "coupledFaPatch.H"
46 #include "processorLduInterface.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class processorFaPatch Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class processorFaPatch
58 :
59  public coupledFaPatch,
61 {
62  // Private Data
63 
64  //- My processor number
65  int myProcNo_;
66 
67  //- Neighbour processor number
68  int neighbProcNo_;
69 
70  //- Processor-neighbour patch edge centres
71  vectorField neighbEdgeCentres_;
72 
73  //- Processor-neighbour patch edge lengths
74  vectorField neighbEdgeLengths_;
75 
76  //- Processor-neighbour patch neighbour face centres
77  vectorField neighbEdgeFaceCentres_;
78 
79  //- Corresponding neighbouring local point label for every local point
80  // (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
81  mutable autoPtr<labelList> neighbPointsPtr_;
82 
83  //- The set of labels of the processor patch points which are
84  // non-global, i.e. present in this processor patch
85  mutable autoPtr<labelList> nonGlobalPatchPointsPtr_;
86 
87 
88 protected:
89 
90  // Protected Member functions
91 
92  //- Construct from components with specified name
94  (
95  const word& name,
96  const labelUList& edgeLabels,
97  const label index,
98  const faBoundaryMesh& bm,
99  const label nbrPolyPatchi,
100  const label myProcNo,
101  const label neighbProcNo,
102  const word& patchType = typeName
103  );
104 
105  //- Make patch weighting factors
106  void makeWeights(scalarField&) const;
107 
108  //- Make patch face - neighbour cell distances
109  void makeDeltaCoeffs(scalarField&) const;
110 
111  //- Find non-globa patch points
112  void makeNonGlobalPatchPoints() const;
113 
114 
115  // Geometry Functions
116 
117  //- Initialise the calculation of the patch geometry
119 
120  //- Calculate the patch geometry
122 
123  //- Initialise the patches for moving points
125 
126  //- Correct patches after moving points
127  void movePoints(PstreamBuffers&, const pointField&);
128 
129  //- Initialise the update of the patch topology
130  virtual void initUpdateMesh(PstreamBuffers&);
131 
132  //- Update of the patch topology
133  virtual void updateMesh(PstreamBuffers&);
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("processor");
140 
141 
142  // Constructors
143 
144  //- Construct from components with automatically generated standard name
146  (
147  const labelUList& edgeLabels,
148  const label index,
149  const faBoundaryMesh& bm,
150  const label nbrPolyPatchi,
151  const label myProcNo,
152  const label neighbProcNo,
153  const word& patchType = typeName
154  );
155 
156  //- Construct from dictionary
158  (
159  const word& name,
160  const dictionary& dict,
161  const label index,
162  const faBoundaryMesh& bm,
163  const word& patchType = typeName
164  );
165 
166 
167  //- Destructor
168  virtual ~processorFaPatch();
169 
170 
171  // Member Functions
172 
173  //- Return interface size
174  virtual label interfaceSize() const noexcept
175  {
176  return size();
177  }
178 
179  //- Return processor number
180  int myProcNo() const noexcept
181  {
182  return myProcNo_;
183  }
184 
185  //- Return neighbour processor number
186  int neighbProcNo() const noexcept
187  {
188  return neighbProcNo_;
189  }
190 
191  //- Return true if running parallel
192  virtual bool coupled() const
193  {
194  return UPstream::parRun();
195  }
196 
197  //- Does this side own the patch ?
198  virtual bool owner() const noexcept
199  {
200  return (myProcNo_ < neighbProcNo_);
201  }
202 
203 
204  //- The message tag to use for communication
205  virtual int tag() const
206  {
207  return UPstream::msgType();
208  }
209 
210  //- Return communicator used for communication
211  virtual label comm() const;
212 
213 
214  //- Return face transformation tensor
215  virtual const tensorField& forwardT() const
216  {
217  return coupledFaPatch::forwardT();
218  }
219 
220  //- Return delta (P to N) vectors across coupled patch
221  virtual tmp<vectorField> delta() const;
222 
224  //- Return processor-neighbour patch edge centres
225  const vectorField& neighbEdgeCentres() const noexcept
226  {
227  return neighbEdgeCentres_;
228  }
229 
230  //- Return processor-neighbour patch edge lengths
232  {
233  return neighbEdgeLengths_;
234  }
235 
236  //- Return processor-neighbour patch edge unit normals
238 
239  //- Return processor-neighbour patch neighbour face centres
241  {
242  return neighbEdgeFaceCentres_;
243  }
244 
245  //- Return neighbour point labels. This is for my local point the
246  // corresponding local point on the other side. Call
247  // faBoundaryMesh::updateMesh() on all processors
248  // before using this.
249  const labelList& neighbPoints() const;
250 
251  //- Return the set of labels of the processor patch points which are
252  // non-global, i.e. present in this processorFaPatch
253  const labelList& nonGlobalPatchPoints() const;
254 
255 
256  // Interface transfer functions
257 
258  //- Return the values of the given internal data adjacent to
259  //- the interface as a field
261  (
262  const labelUList& internalData
263  ) const;
264 
265  //- Return the values of the given internal data adjacent to
266  //- the interface as a field using edgeFaces
268  (
269  const labelUList& internalData,
271  ) const;
272 
273  //- Initialise interface data transfer
274  virtual void initTransfer
275  (
276  const Pstream::commsTypes commsType,
277  const labelUList& interfaceData
278  ) const;
279 
280  //- Transfer and return neighbour field
281  virtual tmp<labelField> transfer
282  (
283  const Pstream::commsTypes commsType,
284  const labelUList& interfaceData
285  ) const;
286 
287  //- Initialise neighbour field transfer
288  virtual void initInternalFieldTransfer
289  (
290  const Pstream::commsTypes commsType,
291  const labelUList& internalData
292  ) const;
293 
294  //- Return neighbour field
296  (
297  const Pstream::commsTypes commsType,
298  const labelUList& internalData
299  ) const;
300 
301  //- Return neighbour field using mapping
303  (
304  const Pstream::commsTypes commsType,
305  const labelUList& internalData,
306  const labelUList& edgeCells
307  ) const;
308 
309  //- Write the patch data as a dictionary
310  virtual void write(Ostream& os) const;
311 };
312 
313 
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 
316 } // End namespace Foam
317 
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319 
320 #endif
321 
322 // ************************************************************************* //
processorFaPatch(const word &name, const labelUList &edgeLabels, const label index, const faBoundaryMesh &bm, const label nbrPolyPatchi, const label myProcNo, const label neighbProcNo, const word &patchType=typeName)
Construct from components with specified name.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
dictionary dict
virtual const tensorField & forwardT() const
Return face transformation tensor.
TypeName("processor")
Runtime type information.
commsTypes
Communications types.
Definition: UPstream.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const vectorField & neighbEdgeLengths() const noexcept
Return processor-neighbour patch edge lengths.
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
const labelList & nonGlobalPatchPoints() const
Return the set of labels of the processor patch points which are.
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
virtual int tag() const
The message tag to use for communication.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
const labelList & neighbPoints() const
Return neighbour point labels. This is for my local point the.
virtual label size() const
Patch size is the number of edge labels, but can be overloaded.
Definition: faPatch.H:392
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:1229
virtual label comm() const
Return communicator used for communication.
const labelList & edgeLabels() const noexcept
Return the list of edges.
Definition: faPatch.H:335
virtual bool coupled() const
Return true if running parallel.
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to the interface as a field.
virtual label interfaceSize() const noexcept
Return interface size.
const vectorField & neighbEdgeCentres() const noexcept
Return processor-neighbour patch edge centres.
A class for handling words, derived from Foam::string.
Definition: word.H:63
tmp< vectorField > neighbEdgeNormals() const
Return processor-neighbour patch edge unit normals.
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition: faPatch.C:433
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
void makeDeltaCoeffs(scalarField &) const
Make patch face - neighbour cell distances.
const word & name() const noexcept
The patch name.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
virtual void write(Ostream &os) const
Write the patch data as a dictionary.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
An abstract base class for processor coupled interfaces.
OBJstream os(runTime.globalPath()/outputName)
void makeNonGlobalPatchPoints() const
Find non-globa patch points.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
int neighbProcNo() const noexcept
Return neighbour processor number.
void makeWeights(scalarField &) const
Make patch weighting factors.
virtual bool owner() const noexcept
Does this side own the patch ?
coupledFaPatch is an abstract base class for patches that couple regions of the computational domain ...
Finite area boundary mesh.
virtual void initInternalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Initialise neighbour field transfer.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void initTransfer(const Pstream::commsTypes commsType, const labelUList &interfaceData) const
Initialise interface data transfer.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const tensorField & forwardT() const
Return face transformation tensor.
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
virtual tmp< labelField > transfer(const Pstream::commsTypes commsType, const labelUList &interfaceData) const
Transfer and return neighbour field.
label index() const noexcept
The index of this patch in the boundaryMesh.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const vectorField & neighbEdgeFaceCentres() const noexcept
Return processor-neighbour patch neighbour face centres.
Namespace for OpenFOAM.
Processor patch.
int myProcNo() const noexcept
Return processor number.
virtual ~processorFaPatch()
Destructor.