1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Foam::processorPolyPatch
28 Neighbour processor patch.
30 Note: morph patch face ordering tries to do a geometric ordering.
31 (assumes faces coincident) Hence will have problems when cyclics
37 \*---------------------------------------------------------------------------*/
39 #ifndef processorPolyPatch_H
40 #define processorPolyPatch_H
42 #include "coupledPolyPatch.H"
43 #include "polyBoundaryMesh.H"
44 #include "faceListFwd.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 /*---------------------------------------------------------------------------*\
52 Class processorPolyPatch Declaration
53 \*---------------------------------------------------------------------------*/
55 class processorPolyPatch
57 public coupledPolyPatch
64 //- Processor-neighbbour patch face centres
65 vectorField neighbFaceCentres_;
67 //- Processor-neighbbour patch face areas
68 vectorField neighbFaceAreas_;
70 //- Processor-neighbbour patch neighbour cell centres
71 vectorField neighbFaceCellCentres_;
73 //- Corresponding neighbouring local point label for every local point
74 // (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
75 mutable autoPtr<labelList> neighbPointsPtr_;
77 //- Corresponding neighbouring local edge label for every local edge
78 // (so edges()[i] == neighb.edges()[neighbEdges_[i]])
79 mutable autoPtr<labelList> neighbEdgesPtr_;
83 // Protected Member functions
85 //- Initialise the calculation of the patch geometry
86 void initGeometry(PstreamBuffers&);
88 //- Calculate the patch geometry
89 void calcGeometry(PstreamBuffers&);
91 //- Calculate the patch geometry with externally
93 virtual void calcGeometry
95 const primitivePatch& referPatch,
96 const pointField& thisCtrs,
97 const vectorField& thisAreas,
98 const pointField& thisCc,
99 const pointField& nbrCtrs,
100 const vectorField& nbrAreas,
101 const pointField& nbrCc
104 notImplemented("processorPolyPatch::calcGeometry(..)");
107 //- Initialise the patches for moving points
108 void initMovePoints(PstreamBuffers&, const pointField&);
110 //- Correct patches after moving points
111 void movePoints(PstreamBuffers&, const pointField&);
113 //- Initialise the update of the patch topology
114 virtual void initUpdateMesh(PstreamBuffers&);
116 //- Update of the patch topology
117 virtual void updateMesh(PstreamBuffers&);
122 //- Runtime type information
123 TypeName("processor");
128 //- Construct from components
135 const polyBoundaryMesh& bm,
137 const int neighbProcNo
140 //- Construct from dictionary
144 const dictionary& dict,
146 const polyBoundaryMesh&
149 //- Construct as copy, resetting the boundary mesh
150 processorPolyPatch(const processorPolyPatch&, const polyBoundaryMesh&);
152 //- Construct as given the original patch and resetting the
153 // face list and boundary mesh information
156 const processorPolyPatch& pp,
157 const polyBoundaryMesh& bm,
163 //- Construct given the original patch and a map
166 const processorPolyPatch& pp,
167 const polyBoundaryMesh& bm,
169 const labelUList& mapAddressing,
173 //- Construct and return a clone, resetting the boundary mesh
174 virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
176 return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
179 //- Construct and return a clone, resetting the face list
181 virtual autoPtr<polyPatch> clone
183 const polyBoundaryMesh& bm,
189 return autoPtr<polyPatch>
191 new processorPolyPatch
202 //- Construct and return a clone, resetting the face list
204 virtual autoPtr<polyPatch> clone
206 const polyBoundaryMesh& bm,
208 const labelUList& mapAddressing,
212 return autoPtr<polyPatch>
214 new processorPolyPatch
227 virtual ~processorPolyPatch();
232 //- Return true only if this is a parallel run
233 virtual bool coupled() const
235 if (Pstream::parRun())
245 //- Return processor number
251 //- Return neigbour processor number
252 int neighbProcNo() const
254 return neighbProcNo_;
257 //- Does the processor own the patch ?
258 virtual bool owner() const
260 return (myProcNo_ < neighbProcNo_);
263 //- Is the processor the patch neighbour ?
264 bool neighbour() const
269 //- Return processor-neighbbour patch face centres
270 const vectorField& neighbFaceCentres() const
272 return neighbFaceCentres_;
275 //- Return processor-neighbbour patch face areas
276 const vectorField& neighbFaceAreas() const
278 return neighbFaceAreas_;
281 //- Return processor-neighbbour patch neighbour cell centres
282 const vectorField& neighbFaceCellCentres() const
284 return neighbFaceCellCentres_;
287 //- Return neighbour point labels. WIP.
288 const labelList& neighbPoints() const;
290 //- Return neighbour edge labels. WIP.
291 const labelList& neighbEdges() const;
293 //- Return message tag to use for communication
294 virtual int tag() const
296 return Pstream::msgType();
299 //- Transform a patch-based position from other side to this side
300 virtual void transformPosition(pointField& l) const
303 //- Transform a patch-based position from other side to this side
304 virtual void transformPosition(point&, const label facei) const
307 //- Initialize ordering for primitivePatch. Does not
308 // refer to *this (except for name() and type() etc.)
309 virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
311 //- Return new ordering for primitivePatch.
312 // Ordering is -faceMap: for every face
313 // index of the new face -rotation:for every new face the clockwise
314 // shift of the original face. Return false if nothing changes
315 // (faceMap is identity, rotation is 0), true otherwise.
319 const primitivePatch&,
325 //- Write the polyPatch data as a dictionary
326 virtual void write(Ostream&) const;
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 } // End namespace Foam
334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
338 // ************************************************************************* //