processorPolyPatch.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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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
67 
68  //- Processor-neighbour patch face areas
70 
71  //- Processor-neighbour patch neighbour cell centres
73 
74  //- Corresponding neighbouring local point label for every local point
75  // (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
77 
78  //- Corresponding neighbouring local edge label for every local edge
79  // (so edges()[i] == neighb.edges()[neighbEdges_[i]])
81 
82 protected:
83 
84  // Protected Member functions
85 
86  //- Initialise the calculation of the patch geometry
88 
89  //- Calculate the patch geometry
91 
92  //- Calculate the patch geometry with externally
93  // provided geometry
94  virtual void calcGeometry
95  (
96  const primitivePatch& referPatch,
97  const pointField& thisCtrs,
98  const vectorField& thisAreas,
99  const pointField& thisCc,
100  const pointField& nbrCtrs,
101  const vectorField& nbrAreas,
102  const pointField& nbrCc
103  )
104  {
106  }
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 initUpdateMesh(PstreamBuffers&);
116 
117  //- Update of the patch topology
118  virtual void updateMesh(PstreamBuffers&);
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("processor");
125 
126 
127  // Constructors
128 
129  //- Construct from components
131  (
132  const word& name,
133  const label size,
134  const label start,
135  const label index,
136  const polyBoundaryMesh& bm,
137  const int myProcNo,
138  const int neighbProcNo,
139  const transformType transform = UNKNOWN, // transformation type
140  const word& patchType = typeName
141  );
142 
143  //- Construct from dictionary
145  (
146  const word& name,
147  const dictionary& dict,
148  const label index,
149  const polyBoundaryMesh&,
150  const word& patchType
151  );
152 
153  //- Construct as copy, resetting the boundary mesh
155 
156  //- Construct as given the original patch and resetting the
157  // face list and boundary mesh information
159  (
160  const processorPolyPatch& pp,
161  const polyBoundaryMesh& bm,
162  const label index,
163  const label newSize,
164  const label newStart
165  );
166 
167  //- Construct given the original patch and a map
169  (
170  const processorPolyPatch& pp,
171  const polyBoundaryMesh& bm,
172  const label index,
173  const labelUList& mapAddressing,
174  const label newStart
175  );
176 
177  //- Construct and return a clone, resetting the boundary mesh
178  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
179  {
180  return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
181  }
182 
183  //- Construct and return a clone, resetting the face list
184  // and boundary mesh
186  (
187  const polyBoundaryMesh& bm,
188  const label index,
189  const label newSize,
190  const label newStart
191  ) const
192  {
193  return autoPtr<polyPatch>
194  (
196  (
197  *this,
198  bm,
199  index,
200  newSize,
201  newStart
202  )
203  );
204  }
205 
206  //- Construct and return a clone, resetting the face list
207  // and boundary mesh
209  (
210  const polyBoundaryMesh& bm,
211  const label index,
212  const labelUList& mapAddressing,
213  const label newStart
214  ) const
215  {
216  return autoPtr<polyPatch>
217  (
219  (
220  *this,
221  bm,
222  index,
223  mapAddressing,
224  newStart
225  )
226  );
227  }
228 
229 
230  //- Destructor
231  virtual ~processorPolyPatch();
232 
233 
234  // Member functions
235 
236  //- Return true only if this is a parallel run
237  virtual bool coupled() const
238  {
239  if (Pstream::parRun())
240  {
241  return true;
242  }
243  else
244  {
245  return false;
246  }
247  }
248 
249  //- Return processor number
250  int myProcNo() const
251  {
252  return myProcNo_;
253  }
254 
255  //- Return neigbour processor number
256  int neighbProcNo() const
257  {
258  return neighbProcNo_;
259  }
260 
261  //- Does the processor own the patch ?
262  virtual bool owner() const
263  {
264  return (myProcNo_ < neighbProcNo_);
265  }
266 
267  //- Is the processor the patch neighbour ?
268  bool neighbour() const
269  {
270  return !owner();
271  }
272 
273  //- Return processor-neighbour patch face centres
274  const vectorField& neighbFaceCentres() const
275  {
276  return neighbFaceCentres_;
277  }
278 
279  //- Return processor-neighbour patch face areas
280  const vectorField& neighbFaceAreas() const
281  {
282  return neighbFaceAreas_;
283  }
284 
285  //- Return processor-neighbour patch neighbour cell centres
286  const vectorField& neighbFaceCellCentres() const
287  {
288  return neighbFaceCellCentres_;
289  }
290 
291  //- Return neighbour point labels. WIP.
292  const labelList& neighbPoints() const;
293 
294  //- Return neighbour edge labels. WIP.
295  const labelList& neighbEdges() const;
296 
297  //- Return message tag to use for communication
298  virtual int tag() const
299  {
300  return Pstream::msgType();
301  }
302 
303  //- Return communicator used for communication
304  virtual label comm() const
305  {
306  return boundaryMesh().mesh().comm();
307  }
308 
309  //- Transform a patch-based position from other side to this side
310  virtual void transformPosition(pointField& l) const
311  {}
312 
313  //- Transform a patch-based position from other side to this side
314  virtual void transformPosition(point&, const label facei) const
315  {}
316 
317  //- Initialize ordering for primitivePatch. Does not
318  // refer to *this (except for name() and type() etc.)
319  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
320 
321  static label matchFace
322  (
323  const face& localFace,
324  const pointField& localPts,
325  const face& masterFace,
326  const pointField& masterPts,
327  const bool sameOrientation,
328  const scalar absTolSqr,
329  scalar& matchDistSqr
330  );
331 
332  //- Return new ordering for primitivePatch.
333  // Ordering is -faceMap: for every face
334  // index of the new face -rotation:for every new face the clockwise
335  // shift of the original face. Return false if nothing changes
336  // (faceMap is identity, rotation is 0), true otherwise.
337  virtual bool order
338  (
340  const primitivePatch&,
342  labelList& rotation
343  ) const;
344 
345 
346  //- Write the polyPatch data as a dictionary
347  virtual void write(Ostream&) const;
348 };
349 
350 
351 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
352 
353 } // End namespace Foam
354 
355 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356 
357 #endif
358 
359 // ************************************************************************* //
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::processorPolyPatch::initMovePoints
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: processorPolyPatch.C:283
Foam::processorPolyPatch::neighbFaceAreas_
vectorField neighbFaceAreas_
Processor-neighbour patch face areas.
Definition: processorPolyPatch.H:68
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:85
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::processorPolyPatch::neighbProcNo
int neighbProcNo() const
Return neigbour processor number.
Definition: processorPolyPatch.H:255
Foam::polyMesh::comm
label comm() const
Return communicator used for parallel communication.
Definition: polyMesh.C:1161
Foam::processorPolyPatch::neighbEdges
const labelList & neighbEdges() const
Return neighbour edge labels. WIP.
Definition: processorPolyPatch.C:474
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:51
Foam::processorPolyPatch::neighbFaceCentres_
vectorField neighbFaceCentres_
Processor-neighbour patch face centres.
Definition: processorPolyPatch.H:65
polyMesh.H
Foam::processorPolyPatch::neighbFaceCellCentres_
vectorField neighbFaceCellCentres_
Processor-neighbour patch neighbour cell centres.
Definition: processorPolyPatch.H:71
Foam::processorPolyPatch::calcGeometry
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: processorPolyPatch.C:166
Foam::processorPolyPatch::neighbFaceAreas
const vectorField & neighbFaceAreas() const
Return processor-neighbour patch face areas.
Definition: processorPolyPatch.H:279
Foam::processorPolyPatch::neighbPointsPtr_
autoPtr< labelList > neighbPointsPtr_
Corresponding neighbouring local point label for every local point.
Definition: processorPolyPatch.H:75
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::processorPolyPatch::matchFace
static label matchFace(const face &localFace, const pointField &localPts, const face &masterFace, const pointField &masterPts, const bool sameOrientation, const scalar absTolSqr, scalar &matchDistSqr)
Definition: processorPolyPatch.C:575
Foam::processorPolyPatch::neighbFaceCellCentres
const vectorField & neighbFaceCellCentres() const
Return processor-neighbour patch neighbour cell centres.
Definition: processorPolyPatch.H:285
coupledPolyPatch.H
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:302
Foam::processorPolyPatch::clone
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: processorPolyPatch.H:177
Foam::processorPolyPatch::initGeometry
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: processorPolyPatch.C:152
Foam::coupledPolyPatch::UNKNOWN
@ UNKNOWN
Definition: coupledPolyPatch.H:59
Foam::processorPolyPatch
Neighbour processor patch.
Definition: processorPolyPatch.H:55
Foam::polyBoundaryMesh::mesh
const polyMesh & mesh() const
Return the mesh reference.
Definition: polyBoundaryMesh.H:140
Foam::processorPolyPatch::coupled
virtual bool coupled() const
Return true only if this is a parallel run.
Definition: processorPolyPatch.H:236
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::processorPolyPatch::owner
virtual bool owner() const
Does the processor own the patch ?
Definition: processorPolyPatch.H:261
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::processorPolyPatch::neighbFaceCentres
const vectorField & neighbFaceCentres() const
Return processor-neighbour patch face centres.
Definition: processorPolyPatch.H:273
Foam::processorPolyPatch::myProcNo_
int myProcNo_
Definition: processorPolyPatch.H:61
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::coupledPolyPatch::transform
virtual transformType transform() const
Type of transform.
Definition: coupledPolyPatch.H:256
Foam::processorPolyPatch::movePoints
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Definition: processorPolyPatch.C:294
Foam::processorPolyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: processorPolyPatch.C:303
Foam::processorPolyPatch::tag
virtual int tag() const
Return message tag to use for communication.
Definition: processorPolyPatch.H:297
Foam::processorPolyPatch::processorPolyPatch
processorPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const transformType transform=UNKNOWN, const word &patchType=typeName)
Construct from components.
Definition: processorPolyPatch.C:51
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::UPstream::msgType
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:452
Foam::processorPolyPatch::neighbPoints
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
Definition: processorPolyPatch.C:462
Foam::processorPolyPatch::neighbProcNo_
int neighbProcNo_
Definition: processorPolyPatch.H:62
Foam::processorPolyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: processorPolyPatch.C:1076
Foam::processorPolyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: processorPolyPatch.C:487
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::processorPolyPatch::comm
virtual label comm() const
Return communicator used for communication.
Definition: processorPolyPatch.H:303
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::processorPolyPatch::transformPosition
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Definition: processorPolyPatch.H:309
polyBoundaryMesh.H
Foam::processorPolyPatch::transformPosition
virtual void transformPosition(point &, const label facei) const
Transform a patch-based position from other side to this side.
Definition: processorPolyPatch.H:313
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Foam::processorPolyPatch::myProcNo
int myProcNo() const
Return processor number.
Definition: processorPolyPatch.H:249
Foam::processorPolyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: processorPolyPatch.C:350
faceListFwd.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::processorPolyPatch::~processorPolyPatch
virtual ~processorPolyPatch()
Destructor.
Definition: processorPolyPatch.C:143
Foam::coupledPolyPatch::transformType
transformType
Definition: coupledPolyPatch.H:57
Foam::processorPolyPatch::neighbEdgesPtr_
autoPtr< labelList > neighbEdgesPtr_
Corresponding neighbouring local edge label for every local edge.
Definition: processorPolyPatch.H:79
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::processorPolyPatch::neighbour
bool neighbour() const
Is the processor the patch neighbour ?
Definition: processorPolyPatch.H:267
Foam::processorPolyPatch::TypeName
TypeName("processor")
Runtime type information.
Foam::processorPolyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: processorPolyPatch.C:685
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88