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 geodesic distance between P and N
109  void makeLPN(scalarField&) const;
110 
111  //- Make patch face - neighbour cell distances
112  void makeDeltaCoeffs(scalarField&) const;
113 
114  //- Make non-orthogonality correction vectors
115  void makeCorrectionVectors(vectorField&) const;
116 
117  //- Find non-globa patch points
118  void makeNonGlobalPatchPoints() const;
119 
120 
121  // Geometry Functions
122 
123  //- Initialise the calculation of the patch geometry
125 
126  //- Calculate the patch geometry
128 
129  //- Initialise the patches for moving points
131 
132  //- Correct patches after moving points
133  void movePoints(PstreamBuffers&, const pointField&);
134 
135  //- Initialise the update of the patch topology
136  virtual void initUpdateMesh(PstreamBuffers&);
137 
138  //- Update of the patch topology
139  virtual void updateMesh(PstreamBuffers&);
140 
141 
142 public:
143 
144  //- Runtime type information
145  TypeName("processor");
146 
147 
148  // Constructors
149 
150  //- Construct from components with automatically generated standard name
152  (
153  const labelUList& edgeLabels,
154  const label index,
155  const faBoundaryMesh& bm,
156  const label nbrPolyPatchi,
157  const label myProcNo,
158  const label neighbProcNo,
159  const word& patchType = typeName
160  );
161 
162  //- Construct from dictionary
164  (
165  const word& name,
166  const dictionary& dict,
167  const label index,
168  const faBoundaryMesh& bm,
169  const word& patchType = typeName
170  );
171 
172 
173  //- Destructor
174  virtual ~processorFaPatch();
175 
176 
177  // Member Functions
178 
179  //- Return interface size
180  virtual label interfaceSize() const noexcept
181  {
182  return size();
183  }
184 
185  //- Return processor number
186  int myProcNo() const noexcept
187  {
188  return myProcNo_;
189  }
190 
191  //- Return neighbour processor number
192  int neighbProcNo() const noexcept
193  {
194  return neighbProcNo_;
195  }
196 
197  //- Return true if running parallel
198  virtual bool coupled() const
199  {
200  return UPstream::parRun();
201  }
202 
203  //- Does this side own the patch ?
204  virtual bool owner() const noexcept
205  {
206  return (myProcNo_ < neighbProcNo_);
207  }
208 
209 
210  //- The message tag to use for communication
211  virtual int tag() const
212  {
213  return UPstream::msgType();
214  }
215 
216  //- Return communicator used for communication
217  virtual label comm() const;
218 
219 
220  //- Return face transformation tensor
221  virtual const tensorField& forwardT() const
222  {
223  return coupledFaPatch::forwardT();
224  }
226  //- Return delta (P to N) vectors across coupled patch
227  virtual tmp<vectorField> delta() const;
228 
229 
230  //- Return processor-neighbour patch edge centres
231  const vectorField& neighbEdgeCentres() const noexcept
232  {
233  return neighbEdgeCentres_;
234  }
235 
236  //- Return processor-neighbour patch edge lengths
237  const vectorField& neighbEdgeLengths() const noexcept
238  {
239  return neighbEdgeLengths_;
240  }
242  //- Return processor-neighbour patch edge unit normals
244 
245  //- Return processor-neighbour patch neighbour face centres
247  {
248  return neighbEdgeFaceCentres_;
249  }
250 
251  //- Return neighbour point labels. This is for my local point the
252  // corresponding local point on the other side. Call
253  // faBoundaryMesh::updateMesh() on all processors
254  // before using this.
255  const labelList& neighbPoints() const;
256 
257  //- Return the set of labels of the processor patch points which are
258  // non-global, i.e. present in this processorFaPatch
259  const labelList& nonGlobalPatchPoints() const;
260 
261 
262  // Interface transfer functions
263 
264  //- Return the values of the given internal data adjacent to
265  //- the interface as a field
267  (
268  const labelUList& internalData
269  ) const;
270 
271  //- Return the values of the given internal data adjacent to
272  //- the interface as a field using edgeFaces
274  (
275  const labelUList& internalData,
276  const labelUList& edgeFaces
277  ) const;
278 
279  //- Initialise interface data transfer
280  virtual void initTransfer
281  (
282  const Pstream::commsTypes commsType,
283  const labelUList& interfaceData
284  ) const;
285 
286  //- Transfer and return neighbour field
287  virtual tmp<labelField> transfer
288  (
289  const Pstream::commsTypes commsType,
290  const labelUList& interfaceData
291  ) const;
292 
293  //- Initialise neighbour field transfer
295  (
296  const Pstream::commsTypes commsType,
297  const labelUList& internalData
298  ) const;
299 
300  //- Return neighbour field
302  (
303  const Pstream::commsTypes commsType,
304  const labelUList& internalData
305  ) const;
306 
307  //- Return neighbour field using mapping
309  (
310  const Pstream::commsTypes commsType,
311  const labelUList& internalData,
312  const labelUList& edgeCells
313  ) const;
314 
315  //- Write the patch data as a dictionary
316  virtual void write(Ostream& os) const;
317 };
318 
319 
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321 
322 } // End namespace Foam
323 
324 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325 
326 #endif
327 
328 // ************************************************************************* //
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:77
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:1586
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:1787
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:424
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: scalarImpl.H:255
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 makeCorrectionVectors(vectorField &) const
Make non-orthogonality correction vectors.
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 ...
void makeLPN(scalarField &) const
Make patch geodesic distance between P and N.
Finite area boundary mesh, which is a faPatch list with registered IO, a reference to the associated ...
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.