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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::processorFaPatch
28 
29 Description
30  Processor patch.
31 
32 Author
33  Zeljko Tukovic, FMENA
34  Hrvoje Jasak, Wikki Ltd.
35 
36 SourceFiles
37  processorFaPatch.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef processorFaPatch_H
42 #define processorFaPatch_H
43 
44 #include "coupledFaPatch.H"
45 #include "processorLduInterface.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class processorFaPatch Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class processorFaPatch
57 :
58  public coupledFaPatch,
60 {
61  // Private data
62 
63  //- My processor number
64  int myProcNo_;
65 
66  //- Neighbour processor number
67  int neighbProcNo_;
68 
69  //- Processor-neighbour patch edge centres
70  vectorField neighbEdgeCentres_;
71 
72  //- Processor-neighbour patch edge lengths
73  vectorField neighbEdgeLengths_;
74 
75  //- Processor-neighbour patch neighbour face centres
76  vectorField neighbEdgeFaceCentres_;
77 
78  //- Corresponding neighbouring local point label for every local point
79  // (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
80  mutable labelList* neighbPointsPtr_;
81 
82  //- The set of labels of the processor patch points which are
83  // non-global, i.e. present in this processor patch
84  mutable labelList* nonGlobalPatchPointsPtr_;
85 
86 
87 protected:
88 
89  // Protected Member functions
90 
91  //- Make patch weighting factors
92  void makeWeights(scalarField&) const;
93 
94  //- Make patch face - neighbour cell distances
95  void makeDeltaCoeffs(scalarField&) const;
96 
97  //- Find non-globa patch points
98  void makeNonGlobalPatchPoints() const;
99 
100 
101  // Geometry functions
102 
103  //- Initialise the calculation of the patch geometry
104  void initGeometry();
105 
106  //- Calculate the patch geometry
107  void calcGeometry();
108 
109  //- Initialise the patches for moving points
110  void initMovePoints(const pointField&);
111 
112  //- Correct patches after moving points
113  void movePoints(const pointField&);
114 
115  //- Initialise the update of the patch topology
116  virtual void initUpdateMesh();
117 
118  //- Update of the patch topology
119  virtual void updateMesh();
120 
121 
122 public:
123 
124  //- Runtime type information
125 // TypeName(processorPolyPatch::typeName_());
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  :
143  coupledFaPatch(name, edgeLabels, index, bm, ngbPolyPatchIndex),
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
181  {
182  return size();
183  }
184 
185  //- Return processor number
186  int myProcNo() const
187  {
188  return myProcNo_;
189  }
190 
191  //- Return neighbour processor number
192  int neighbProcNo() const
193  {
194  return neighbProcNo_;
195  }
196 
197  //- Return true if running parallel
198  virtual bool coupled() const
199  {
200  if (Pstream::parRun())
201  {
202  return true;
203  }
204  else
205  {
206  return false;
207  }
208  }
209 
210  //- Is this the master side?
211  virtual bool master() const
212  {
213  return (myProcNo_ < neighbProcNo_);
214  }
215 
216 
217  // Communications support
218 
219  //- Return communicator used for communication
220  virtual label comm() const;
221 
222  //- Return message tag to use for communication
223  virtual int tag() const;
224 
225 
226  //- Return face transformation tensor
227  virtual const tensorField& forwardT() const
228  {
229  return coupledFaPatch::forwardT();
230  }
231 
232  //- Return delta (P to N) vectors across coupled patch
233  virtual tmp<vectorField> delta() const;
234 
235 
236  //- Return processor-neighbour patch edge centres
237  const vectorField& neighbEdgeCentres() const
238  {
239  return neighbEdgeCentres_;
240  }
241 
242  //- Return processor-neighbour patch edge lengths
243  const vectorField& neighbEdgeLengths() const
244  {
245  return neighbEdgeLengths_;
246  }
247 
248  //- Return processor-neighbour patch neighbour face centres
249  const vectorField& neighbEdgeFaceCentres() const
250  {
251  return neighbEdgeFaceCentres_;
252  }
253 
254  //- Return neighbour point labels. This is for my local point the
255  // corresponding local point on the other side. Call
256  // faBoundaryMesh::updateMesh() on all processors
257  // before using this.
258  const labelList& neighbPoints() const;
259 
260  //- Return the set of labels of the processor patch points which are
261  // non-global, i.e. present in this processorFaPatch
262  const labelList& nonGlobalPatchPoints() const;
263 
264 
265  // Interface transfer functions
266 
267  //- Return the values of the given internal data adjacent to
268  // the interface as a field
270  (
271  const labelUList& internalData
272  ) const;
273 
274  //- Initialise interface data transfer
275  virtual void initTransfer
276  (
277  const Pstream::commsTypes commsType,
278  const labelUList& interfaceData
279  ) const;
280 
281  //- Transfer and return neighbour field
282  virtual tmp<labelField> transfer
283  (
284  const Pstream::commsTypes commsType,
285  const labelUList& interfaceData
286  ) const;
287 
288  //- Initialise neighbour field transfer
289  virtual void initInternalFieldTransfer
290  (
291  const Pstream::commsTypes commsType,
292  const labelUList& internalData
293  ) const;
294 
295  //- Return neighbour field
297  (
298  const Pstream::commsTypes commsType,
299  const labelUList& internalData
300  ) const;
301 
302  //- Write the patch data as a dictionary
303  virtual void write(Ostream&) const;
304 };
305 
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 } // End namespace Foam
310 
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 
313 #endif
314 
315 // ************************************************************************* //
Foam::processorFaPatch::comm
virtual label comm() const
Return communicator used for communication.
Definition: processorFaPatch.C:57
Foam::processorFaPatch::neighbEdgeFaceCentres
const vectorField & neighbEdgeFaceCentres() const
Return processor-neighbour patch neighbour face centres.
Definition: processorFaPatch.H:248
Foam::processorFaPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: processorFaPatch.H:226
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:241
Foam::processorFaPatch::updateMesh
virtual void updateMesh()
Update of the patch topology.
Definition: processorFaPatch.C:290
Foam::faPatch::ngbPolyPatchIndex
label ngbPolyPatchIndex() const
Return neighbour polyPatch index.
Definition: faPatch.C:120
Foam::processorFaPatch::initGeometry
void initGeometry()
Initialise the calculation of the patch geometry.
Definition: processorFaPatch.C:169
Foam::processorFaPatch::neighbEdgeCentres
const vectorField & neighbEdgeCentres() const
Return processor-neighbour patch edge centres.
Definition: processorFaPatch.H:236
coupledFaPatch.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::processorFaPatch::initTransfer
virtual void initTransfer(const Pstream::commsTypes commsType, const labelUList &interfaceData) const
Initialise interface data transfer.
Definition: processorFaPatch.C:468
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::UPstream::parRun
static bool & parRun()
Test if this a parallel run, or allow modify access.
Definition: UPstream.H:434
Foam::processorFaPatch::master
virtual bool master() const
Is this the master side?
Definition: processorFaPatch.H:210
Foam::processorFaPatch::myProcNo
int myProcNo() const
Return processor number.
Definition: processorFaPatch.H:185
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:478
Foam::processorFaPatch::initInternalFieldTransfer
virtual void initInternalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Initialise neighbour field transfer.
Definition: processorFaPatch.C:488
processorLduInterface.H
Foam::processorFaPatch::neighbEdgeLengths
const vectorField & neighbEdgeLengths() const
Return processor-neighbour patch edge lengths.
Definition: processorFaPatch.H:242
Foam::processorFaPatch
Processor patch.
Definition: processorFaPatch.H:55
Foam::faBoundaryMesh
Finite area boundary mesh.
Definition: faBoundaryMesh.H:66
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:346
Foam::processorFaPatch::initUpdateMesh
virtual void initUpdateMesh()
Initialise the update of the patch topology.
Definition: processorFaPatch.C:247
Foam::processorFaPatch::neighbProcNo
int neighbProcNo() const
Return neighbour processor number.
Definition: processorFaPatch.H:191
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:121
Foam::coupledFaPatch::forwardT
const tensorField & forwardT() const
Return face transformation tensor.
Definition: coupledFaPatch.H:172
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::processorFaPatch::makeNonGlobalPatchPoints
void makeNonGlobalPatchPoints() const
Find non-globa patch points.
Definition: processorFaPatch.C:69
Foam::processorFaPatch::write
virtual void write(Ostream &) const
Write the patch data as a dictionary.
Definition: processorFaPatch.C:507
Foam::processorFaPatch::makeDeltaCoeffs
void makeDeltaCoeffs(scalarField &) const
Make patch face - neighbour cell distances.
Definition: processorFaPatch.C:399
Foam::processorFaPatch::nonGlobalPatchPoints
const labelList & nonGlobalPatchPoints() const
Return the set of labels of the processor patch points which are.
Definition: processorFaPatch.C:447
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::processorFaPatch::~processorFaPatch
virtual ~processorFaPatch()
Destructor.
Definition: processorFaPatch.C:48
Foam::processorFaPatch::interfaceInternalField
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to.
Definition: processorFaPatch.C:459
Foam::List< label >
Foam::processorFaPatch::makeWeights
void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: processorFaPatch.C:369
Foam::processorFaPatch::internalFieldTransfer
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
Definition: processorFaPatch.C:498
Foam::UList< label >
Foam::processorFaPatch::TypeName
TypeName("processor")
Runtime type information.
Foam::processorFaPatch::delta
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
Definition: processorFaPatch.C:412
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:188
Foam::patchIdentifier::name
const word & name() const
The patch name.
Definition: patchIdentifier.H:134
Foam::patchIdentifier::index
label index() const
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:158
Foam::processorFaPatch::initMovePoints
void initMovePoints(const pointField &)
Initialise the patches for moving points.
Definition: processorFaPatch.C:234
Foam::processorFaPatch::tag
virtual int tag() const
Return message tag to use for communication.
Definition: processorFaPatch.C:63
Foam::processorFaPatch::interfaceSize
virtual label interfaceSize() const
Return interface size.
Definition: processorFaPatch.H:179
Foam::faPatch::size
virtual label size() const
Patch size.
Definition: faPatch.H:249