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-2021 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 processorFaPatch_H
43 #define 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 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 labelList* nonGlobalPatchPointsPtr_;
86 
87 
88 protected:
89 
90  // Protected Member functions
91 
92  //- Make patch weighting factors
93  void makeWeights(scalarField&) const;
94 
95  //- Make patch face - neighbour cell distances
96  void makeDeltaCoeffs(scalarField&) const;
97 
98  //- Find non-globa patch points
99  void makeNonGlobalPatchPoints() const;
100 
101 
102  // Geometry functions
103 
104  //- Initialise the calculation of the patch geometry
105  void initGeometry();
106 
107  //- Calculate the patch geometry
108  void calcGeometry();
109 
110  //- Initialise the patches for moving points
111  void initMovePoints(const pointField&);
112 
113  //- Correct patches after moving points
114  void movePoints(const pointField&);
115 
116  //- Initialise the update of the patch topology
117  virtual void initUpdateMesh();
118 
119  //- Update of the patch topology
120  virtual void updateMesh();
121 
122 
123 public:
124 
125  //- Runtime type information
126  TypeName("processor");
127 
128 
129  // Constructors
130 
131  //- Construct from components
133  (
134  const word& name,
135  const labelList& edgeLabels,
136  const label index,
137  const faBoundaryMesh& bm,
138  const label ngbPolyPatchIndex,
139  const label myProcNo,
140  const label neighbProcNo
141  )
142  :
144  myProcNo_(myProcNo),
145  neighbProcNo_(neighbProcNo),
146  neighbEdgeCentres_(),
147  neighbEdgeLengths_(),
148  neighbEdgeFaceCentres_(),
149  neighbPointsPtr_(nullptr),
150  nonGlobalPatchPointsPtr_(nullptr)
151  {}
152 
153  //- Construct from dictionary
155  (
156  const word& name,
157  const dictionary& dict,
158  const label index,
159  const faBoundaryMesh& bm
160  )
161  :
162  coupledFaPatch(name, dict, index, bm),
163  myProcNo_(dict.get<label>("myProcNo")),
164  neighbProcNo_(dict.get<label>("neighbProcNo")),
165  neighbEdgeCentres_(),
166  neighbEdgeLengths_(),
167  neighbEdgeFaceCentres_(),
168  neighbPointsPtr_(nullptr),
169  nonGlobalPatchPointsPtr_(nullptr)
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 Pstream::parRun();
201  }
202 
203  //- Is this the master side?
204  virtual bool master() const noexcept
205  {
206  return (myProcNo_ < neighbProcNo_);
207  }
208 
209 
210  // Communications support
211 
212  //- Return communicator used for communication
213  virtual label comm() const;
214 
215  //- Return message tag to use for communication
216  virtual int tag() const;
217 
218 
219  //- Return face transformation tensor
220  virtual const tensorField& forwardT() const
221  {
222  return coupledFaPatch::forwardT();
223  }
224 
225  //- Return delta (P to N) vectors across coupled patch
226  virtual tmp<vectorField> delta() const;
227 
228 
229  //- Return processor-neighbour patch edge centres
230  const vectorField& neighbEdgeCentres() const
231  {
232  return neighbEdgeCentres_;
233  }
234 
235  //- Return processor-neighbour patch edge lengths
236  const vectorField& neighbEdgeLengths() const
237  {
238  return neighbEdgeLengths_;
239  }
240 
241  //- Return processor-neighbour patch neighbour face centres
242  const vectorField& neighbEdgeFaceCentres() const
243  {
244  return neighbEdgeFaceCentres_;
245  }
246 
247  //- Return neighbour point labels. This is for my local point the
248  // corresponding local point on the other side. Call
249  // faBoundaryMesh::updateMesh() on all processors
250  // before using this.
251  const labelList& neighbPoints() const;
252 
253  //- Return the set of labels of the processor patch points which are
254  // non-global, i.e. present in this processorFaPatch
255  const labelList& nonGlobalPatchPoints() const;
256 
257 
258  // Interface transfer functions
259 
260  //- Return the values of the given internal data adjacent to
261  //- the interface as a field
263  (
264  const labelUList& internalData
265  ) const;
266 
267  //- Return the values of the given internal data adjacent to
268  //- the interface as a field using edgeFaces
270  (
271  const labelUList& internalData,
272  const labelUList& edgeFaces
273  ) const;
274 
275  //- Initialise interface data transfer
276  virtual void initTransfer
277  (
278  const Pstream::commsTypes commsType,
279  const labelUList& interfaceData
280  ) const;
281 
282  //- Transfer and return neighbour field
283  virtual tmp<labelField> transfer
284  (
285  const Pstream::commsTypes commsType,
286  const labelUList& interfaceData
287  ) const;
288 
289  //- Initialise neighbour field transfer
290  virtual void initInternalFieldTransfer
291  (
292  const Pstream::commsTypes commsType,
293  const labelUList& internalData
294  ) const;
295 
296  //- Return neighbour field
298  (
299  const Pstream::commsTypes commsType,
300  const labelUList& internalData
301  ) const;
302 
303  //- Return neighbour field using mapping
305  (
306  const Pstream::commsTypes commsType,
307  const labelUList& internalData,
308  const labelUList& edgeCells
309  ) const;
310 
311  //- Write the patch data as a dictionary
312  virtual void write(Ostream& os) const;
313 };
314 
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 } // End namespace Foam
319 
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321 
322 #endif
323 
324 // ************************************************************************* //
Foam::processorFaPatch::comm
virtual label comm() const
Return communicator used for communication.
Definition: processorFaPatch.C:58
Foam::processorFaPatch::neighbEdgeFaceCentres
const vectorField & neighbEdgeFaceCentres() const
Return processor-neighbour patch neighbour face centres.
Definition: processorFaPatch.H:241
Foam::processorFaPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: processorFaPatch.H:219
Foam::processorFaPatch::processorFaPatch
processorFaPatch(const word &name, const labelList &edgeLabels, const label index, const faBoundaryMesh &bm, const label ngbPolyPatchIndex, const label myProcNo, const label neighbProcNo)
Construct from components.
Definition: processorFaPatch.H:132
Foam::processorFaPatch::movePoints
void movePoints(const pointField &)
Correct patches after moving points.
Definition: processorFaPatch.C:236
Foam::processorFaPatch::updateMesh
virtual void updateMesh()
Update of the patch topology.
Definition: processorFaPatch.C:285
Foam::processorFaPatch::initGeometry
void initGeometry()
Initialise the calculation of the patch geometry.
Definition: processorFaPatch.C:164
Foam::processorFaPatch::neighbEdgeCentres
const vectorField & neighbEdgeCentres() const
Return processor-neighbour patch edge centres.
Definition: processorFaPatch.H:229
Foam::processorFaPatch::master
virtual bool master() const noexcept
Is this the master side?
Definition: processorFaPatch.H:203
coupledFaPatch.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::processorFaPatch::write
virtual void write(Ostream &os) const
Write the patch data as a dictionary.
Definition: processorFaPatch.C:523
Foam::processorFaPatch::initTransfer
virtual void initTransfer(const Pstream::commsTypes commsType, const labelUList &interfaceData) const
Initialise interface data transfer.
Definition: processorFaPatch.C:473
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::processorLduInterface
An abstract base class for processor coupled interfaces.
Definition: processorLduInterface.H:53
Foam::processorFaPatch::neighbProcNo
int neighbProcNo() const noexcept
Return neighbour processor number.
Definition: processorFaPatch.H:191
Foam::coupledFaPatch::coupledFaPatch
coupledFaPatch(const word &name, const labelList &edgeLabels, const label index, const faBoundaryMesh &bm, const label ngbPolyPatchIndex)
Construct from components.
Definition: coupledFaPatch.H:112
Foam::processorFaPatch::transfer
virtual tmp< labelField > transfer(const Pstream::commsTypes commsType, const labelUList &interfaceData) const
Transfer and return neighbour field.
Definition: processorFaPatch.C:483
Foam::processorFaPatch::initInternalFieldTransfer
virtual void initInternalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Initialise neighbour field transfer.
Definition: processorFaPatch.C:493
Foam::faPatch::edgeLabels
const labelList & edgeLabels() const noexcept
Return the list of edges.
Definition: faPatch.H:225
processorLduInterface.H
Foam::faPatch::edgeFaces
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition: faPatch.C:358
Foam::processorFaPatch::neighbEdgeLengths
const vectorField & neighbEdgeLengths() const
Return processor-neighbour patch edge lengths.
Definition: processorFaPatch.H:235
Foam::processorFaPatch
Processor patch.
Definition: processorFaPatch.H:56
Foam::faBoundaryMesh
Finite area boundary mesh.
Definition: faBoundaryMesh.H:65
Foam::processorFaPatch::coupled
virtual bool coupled() const
Return true if running parallel.
Definition: processorFaPatch.H:197
Foam::Field< vector >
Foam::coupledFaPatch
coupledFaPatch is an abstract base class for patches that couple regions of the computational domain ...
Definition: coupledFaPatch.H:56
Foam::processorFaPatch::neighbPoints
const labelList & neighbPoints() const
Return neighbour point labels. This is for my local point the.
Definition: processorFaPatch.C:341
Foam::processorFaPatch::initUpdateMesh
virtual void initUpdateMesh()
Initialise the update of the patch topology.
Definition: processorFaPatch.C:242
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::coupledFaPatch::forwardT
const tensorField & forwardT() const
Return face transformation tensor.
Definition: coupledFaPatch.H:172
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchIdentifier::index
label index() const noexcept
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:147
Foam::processorFaPatch::makeNonGlobalPatchPoints
void makeNonGlobalPatchPoints() const
Find non-globa patch points.
Definition: processorFaPatch.C:70
Foam::processorFaPatch::interfaceSize
virtual label interfaceSize() const noexcept
Return interface size.
Definition: processorFaPatch.H:179
Foam::processorFaPatch::makeDeltaCoeffs
void makeDeltaCoeffs(scalarField &) const
Make patch face - neighbour cell distances.
Definition: processorFaPatch.C:394
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::processorFaPatch::nonGlobalPatchPoints
const labelList & nonGlobalPatchPoints() const
Return the set of labels of the processor patch points which are.
Definition: processorFaPatch.C:442
Foam::processorFaPatch::~processorFaPatch
virtual ~processorFaPatch()
Destructor.
Definition: processorFaPatch.C:49
Foam::processorFaPatch::interfaceInternalField
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Definition: processorFaPatch.C:454
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::processorFaPatch::myProcNo
int myProcNo() const noexcept
Return processor number.
Definition: processorFaPatch.H:185
Foam::List< label >
Foam::processorFaPatch::makeWeights
void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: processorFaPatch.C:364
Foam::processorFaPatch::internalFieldTransfer
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
Definition: processorFaPatch.C:503
Foam::UList< label >
Foam::processorFaPatch::TypeName
TypeName("processor")
Runtime type information.
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::processorFaPatch::delta
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
Definition: processorFaPatch.C:407
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::processorFaPatch::calcGeometry
void calcGeometry()
Calculate the patch geometry.
Definition: processorFaPatch.C:183
Foam::processorFaPatch::initMovePoints
void initMovePoints(const pointField &)
Initialise the patches for moving points.
Definition: processorFaPatch.C:229
Foam::processorFaPatch::tag
virtual int tag() const
Return message tag to use for communication.
Definition: processorFaPatch.C:64
Foam::faPatch::ngbPolyPatchIndex
label ngbPolyPatchIndex() const noexcept
The neighbour polyPatch index.
Definition: faPatch.H:246
Foam::faPatch::size
virtual label size() const
Patch size is the number of edge labels.
Definition: faPatch.H:264