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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2015 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::processorPolyPatch
29
30Description
31 Neighbour processor patch.
32
33 Note: morph patch face ordering tries to do a geometric ordering.
34 (assumes faces coincident) Hence will have problems when cyclics
35 are present.
36
37SourceFiles
38 processorPolyPatch.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef processorPolyPatch_H
43#define processorPolyPatch_H
44
45#include "coupledPolyPatch.H"
46#include "polyBoundaryMesh.H"
47#include "faceListFwd.H"
48#include "polyMesh.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55/*---------------------------------------------------------------------------*\
56 Class processorPolyPatch Declaration
57\*---------------------------------------------------------------------------*/
60:
61 public coupledPolyPatch
62{
63 // Private data
64
65 int myProcNo_;
66 int neighbProcNo_;
67
68 //- Processor-neighbour patch face centres
69 vectorField neighbFaceCentres_;
70
71 //- Processor-neighbour patch face areas
72 vectorField neighbFaceAreas_;
73
74 //- Processor-neighbour patch neighbour cell centres
75 vectorField neighbFaceCellCentres_;
76
77 //- Corresponding neighbouring local point label for every local point
78 // (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
79 mutable autoPtr<labelList> neighbPointsPtr_;
80
81 //- Corresponding neighbouring local edge label for every local edge
82 // (so edges()[i] == neighb.edges()[neighbEdges_[i]])
83 mutable autoPtr<labelList> neighbEdgesPtr_;
84
85protected:
86
87 // Protected constructors
88
89 //- Construct from components with specified name
91 (
92 const word& name,
93 const label size,
94 const label start,
95 const label index,
96 const polyBoundaryMesh& bm,
97 const int myProcNo,
98 const int neighbProcNo,
99 const transformType transform = UNKNOWN, // transformation type
100 const word& patchType = typeName
101 );
102
103
104 // Protected Member functions
105
106 //- Initialise the calculation of the patch geometry
108
109 //- Calculate the patch geometry
111
112 //- Calculate the patch geometry with externally
113 // provided geometry
114 virtual void calcGeometry
115 (
116 const primitivePatch& referPatch,
117 const pointField& thisCtrs,
118 const vectorField& thisAreas,
119 const pointField& thisCc,
120 const pointField& nbrCtrs,
121 const vectorField& nbrAreas,
122 const pointField& nbrCc
123 )
124 {
126 }
127
128 //- Initialise the patches for moving points
130
131 //- Correct patches after moving points
132 void movePoints(PstreamBuffers&, const pointField&);
133
134 //- Initialise the update of the patch topology
135 virtual void initUpdateMesh(PstreamBuffers&);
136
137 //- Update of the patch topology
138 virtual void updateMesh(PstreamBuffers&);
139
140
141public:
142
143 //- Runtime type information
144 TypeName("processor");
145
146
147 // Constructors
148
149 //- Construct from components with automatically generated standard name
151 (
152 const label size,
153 const label start,
154 const label index,
155 const polyBoundaryMesh& bm,
156 const int myProcNo,
157 const int neighbProcNo,
158 const transformType transform = UNKNOWN, // transformation type
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 polyBoundaryMesh&,
169 const word& patchType
170 );
171
172 //- Construct as copy, resetting the boundary mesh
174
175 //- Construct as given the original patch and resetting the
176 // face list and boundary mesh information
178 (
179 const processorPolyPatch& pp,
180 const polyBoundaryMesh& bm,
181 const label index,
182 const label newSize,
183 const label newStart
184 );
185
186 //- Construct given the original patch and a map
188 (
189 const processorPolyPatch& pp,
190 const polyBoundaryMesh& bm,
191 const label index,
192 const labelUList& mapAddressing,
193 const label newStart
194 );
195
196 //- Construct and return a clone, resetting the boundary mesh
197 virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
198 {
199 return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
200 }
201
202 //- Construct and return a clone, resetting the face list
203 // and boundary mesh
205 (
206 const polyBoundaryMesh& bm,
207 const label index,
208 const label newSize,
209 const label newStart
210 ) const
211 {
212 return autoPtr<polyPatch>
213 (
215 (
216 *this,
217 bm,
218 index,
219 newSize,
220 newStart
221 )
222 );
223 }
224
225 //- Construct and return a clone, resetting the face list
226 // and boundary mesh
228 (
229 const polyBoundaryMesh& bm,
230 const label index,
231 const labelUList& mapAddressing,
232 const label newStart
233 ) const
234 {
235 return autoPtr<polyPatch>
236 (
238 (
239 *this,
240 bm,
241 index,
242 mapAddressing,
243 newStart
244 )
245 );
246 }
247
248
249 //- Destructor
250 virtual ~processorPolyPatch();
251
252
253 // Member functions
254
255 //- Return true only if this is a parallel run
256 virtual bool coupled() const
257 {
258 return Pstream::parRun();
259 }
260
261 //- Return processor number
262 int myProcNo() const
263 {
264 return myProcNo_;
265 }
266
267 //- Return neighbour processor number
268 int neighbProcNo() const
269 {
270 return neighbProcNo_;
271 }
272
273 //- Does the processor own the patch ?
274 virtual bool owner() const
275 {
276 return (myProcNo_ < neighbProcNo_);
277 }
278
279 //- Is the processor the patch neighbour ?
280 bool neighbour() const
281 {
282 return !owner();
283 }
284
285 //- Return the name of a processorPolyPatch
286 // constructed from the processor IDs
287 static word newName
288 (
289 const label myProcNo,
290 const label neighbProcNo
291 );
292
293 //- Return processor-neighbour patch face centres
294 const vectorField& neighbFaceCentres() const
295 {
296 return neighbFaceCentres_;
297 }
298
299 //- Return processor-neighbour patch face areas
300 const vectorField& neighbFaceAreas() const
301 {
302 return neighbFaceAreas_;
303 }
304
305 //- Return processor-neighbour patch neighbour cell centres
307 {
308 return neighbFaceCellCentres_;
309 }
310
311 //- Return neighbour point labels. WIP.
312 const labelList& neighbPoints() const;
313
314 //- Return neighbour edge labels. WIP.
315 const labelList& neighbEdges() const;
316
317 //- Return message tag to use for communication
318 virtual int tag() const
319 {
320 return Pstream::msgType();
321 }
322
323 //- Return communicator used for communication
324 virtual label comm() const
325 {
326 return boundaryMesh().mesh().comm();
327 }
328
329 //- Transform a patch-based position from other side to this side
330 virtual void transformPosition(pointField& l) const
331 {}
332
333 //- Transform a patch-based position from other side to this side
334 virtual void transformPosition(point&, const label facei) const
335 {}
336
337 //- Initialize ordering for primitivePatch. Does not
338 // refer to *this (except for name() and type() etc.)
339 virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
340
341 //- Returns rotation.
342 // -1 : no match
343 // 0 : match
344 // >0 : match if rotated clockwise by this amount
345 static label matchFace
346 (
347 const face& localFace,
348 const pointField& localPts,
349 const face& masterFace,
350 const pointField& masterPts,
351 const bool sameOrientation,
352 const scalar absTolSqr,
353 scalar& matchDistSqr
354 );
355
356 //- Return new ordering for primitivePatch.
357 // Ordering is -faceMap: for every face
358 // index of the new face -rotation:for every new face the clockwise
359 // shift of the original face. Return false if nothing changes
360 // (faceMap is identity, rotation is 0), true otherwise.
361 virtual bool order
362 (
364 const primitivePatch&,
366 labelList& rotation
367 ) const;
368
369
370 //- Write the polyPatch data as a dictionary
371 virtual void write(Ostream&) const;
372};
373
374
375// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376
377} // End namespace Foam
378
379// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380
381#endif
382
383// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of faces which address into the list of points.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:556
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:63
const bMesh & mesh() const
Definition: boundaryMesh.H:206
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual transformType transform() const
Type of transform.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:364
Neighbour processor patch.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
int myProcNo() const
Return processor number.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
virtual bool owner() const
Does the processor own the patch ?
virtual bool coupled() const
Return true only if this is a parallel run.
int neighbProcNo() const
Return neighbour processor number.
virtual ~processorPolyPatch()
Destructor.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
const vectorField & neighbFaceCellCentres() const
Return processor-neighbour patch neighbour cell centres.
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
const vectorField & neighbFaceCentres() const
Return processor-neighbour patch face centres.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch.
virtual label comm() const
Return communicator used for communication.
const labelList & neighbEdges() const
Return neighbour edge labels. WIP.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
bool neighbour() const
Is the processor the patch neighbour ?
static label matchFace(const face &localFace, const pointField &localPts, const face &masterFace, const pointField &masterPts, const bool sameOrientation, const scalar absTolSqr, scalar &matchDistSqr)
Returns rotation.
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
const vectorField & neighbFaceAreas() const
Return processor-neighbour patch face areas.
virtual int tag() const
Return message tag to use for communication.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
virtual void transformPosition(point &, const label facei) const
Transform a patch-based position from other side to this side.
TypeName("processor")
Runtime type information.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Forwards for various types of face lists.
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
UList< label > labelUList
A UList of labels.
Definition: UList.H:85
runTime write()
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73