initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / polyPatches / constraint / processor / processorPolyPatch.H
blob246f0e466ab4763a900d0ead37fce14da1d84dd7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::processorPolyPatch
28 Description
29     Neighbour processor patch.
31     Note: morph patch face ordering comes geometric or topological.
32     Geometric: no cyclics allowed (assumes faces coincident)
33     Topological: needs unmodified faces on both sides to correspond. Also
34     needs at least one per connected patch area (so all patch faces can be
35     visited from an unmodified face)
37 SourceFiles
38     processorPolyPatch.C
39     processorPolyPatchMorph.C
41 \*---------------------------------------------------------------------------*/
43 #ifndef processorPolyPatch_H
44 #define processorPolyPatch_H
46 #include "coupledPolyPatch.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 namespace Foam
53 /*---------------------------------------------------------------------------*\
54                            Class processorPolyPatch Declaration
55 \*---------------------------------------------------------------------------*/
57 class processorPolyPatch
59     public coupledPolyPatch
61     // Private data
63         int myProcNo_;
64         int neighbProcNo_;
66         //- Processor-neighbbour patch face centres
67         vectorField neighbFaceCentres_;
69         //- Processor-neighbbour patch face areas
70         vectorField neighbFaceAreas_;
72         //- Processor-neighbbour patch neighbour cell centres
73         vectorField neighbFaceCellCentres_;
75         //- Corresponding neighbouring local point label for every local point
76         //  (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
77         mutable labelList* neighbPointsPtr_;
79         //- Corresponding neighbouring local edge label for every local edge
80         //  (so edges()[i] == neighb.edges()[neighbEdges_[i]])
81         mutable labelList* neighbEdgesPtr_;
85     // Private static data
87         //- Whether to use geometric or topological matching
88         static bool geometricMatch_;
90         //- Relative tolerance (for geometric matching only). Is factor of
91         //  maximum edge length per face.
92         static scalar matchTol_;
95 protected:
97     // Protected Member functions
99         //- Initialise the calculation of the patch geometry
100         void initGeometry();
102         //- Calculate the patch geometry
103         void calcGeometry();
105         //- Initialise the patches for moving points
106         void initMovePoints(const pointField&);
108         //- Correct patches after moving points
109         void movePoints(const pointField&);
111         //- Initialise the update of the patch topology
112         virtual void initUpdateMesh();
114         //- Update of the patch topology
115         virtual void updateMesh();
118 public:
120     //- Runtime type information
121     TypeName("processor");
124     // Constructors
126         //- Construct from components
127         processorPolyPatch
128         (
129             const word& name,
130             const label size,
131             const label start,
132             const label index,
133             const polyBoundaryMesh& bm,
134             const int myProcNo,
135             const int neighbProcNo
136         );
138         //- Construct from dictionary
139         processorPolyPatch
140         (
141             const word& name,
142             const dictionary& dict,
143             const label index,
144             const polyBoundaryMesh&
145         );
147         //- Construct as copy, resetting the boundary mesh
148         processorPolyPatch(const processorPolyPatch&, const polyBoundaryMesh&);
150         //- Construct as given the original patch and resetting the
151         //  face list and boundary mesh information
152         processorPolyPatch
153         (
154             const processorPolyPatch& pp,
155             const polyBoundaryMesh& bm,
156             const label index,
157             const label newSize,
158             const label newStart
159         );
161         //- Construct and return a clone, resetting the boundary mesh
162         virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
163         {
164             return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
165         }
167         //- Construct and return a clone, resetting the face list
168         //  and boundary mesh
169         virtual autoPtr<polyPatch> clone
170         (
171             const polyBoundaryMesh& bm,
172             const label index,
173             const label newSize,
174             const label newStart
175         ) const
176         {
177             return autoPtr<polyPatch>
178             (
179                 new processorPolyPatch
180                 (
181                     refCast<const processorPolyPatch>(*this),
182                     bm,
183                     index,
184                     newSize,
185                     newStart
186                 )
187             );
188         }
191     // Destructor
193         virtual ~processorPolyPatch();
196     // Member functions
198         //- Return processor number
199         int myProcNo() const
200         {
201             return myProcNo_;
202         }
204         //- Return neigbour processor number
205         int neighbProcNo() const
206         {
207             return neighbProcNo_;
208         }
210         //- Does the processor own the patch ?
211         bool owner() const
212         {
213             return (myProcNo_ < neighbProcNo_);
214         }
216         //- Is the processor the patch neighbour ?
217         bool neighbour() const
218         {
219             return !owner();
220         }
222         //- Return processor-neighbbour patch face centres
223         const vectorField& neighbFaceCentres() const
224         {
225             return neighbFaceCentres_;
226         }
228         //- Return processor-neighbbour patch face areas
229         const vectorField& neighbFaceAreas() const
230         {
231             return neighbFaceAreas_;
232         }
234         //- Return processor-neighbbour patch neighbour cell centres
235         const vectorField& neighbFaceCellCentres() const
236         {
237             return neighbFaceCellCentres_;
238         }
240         //- Return neighbour point labels. This is for my local point (-1 or)
241         //  the corresponding local point on the other side. It is -1 if
242         //  there are multiple corresponding points on this or the other side
243         //  (can happen for cyclics being converted into proc patches)
244         const labelList& neighbPoints() const;
246         //- Return neighbour edge labels. This is for my local edge (-1 or) the
247         //  corresponding local edge on the other side. See above for -1 cause.
248         const labelList& neighbEdges() const;
251         //- Initialize ordering for primitivePatch. Does not
252         //  refer to *this (except for name() and type() etc.)
253         virtual void initOrder(const primitivePatch&) const;
255         //- Return new ordering for primitivePatch.
256         //  Ordering is -faceMap: for every face
257         //  index of the new face -rotation:for every new face the clockwise
258         //  shift of the original face. Return false if nothing changes
259         //  (faceMap is identity, rotation is 0), true otherwise.
260         virtual bool order
261         (
262             const primitivePatch&,
263             labelList& faceMap,
264             labelList& rotation
265         ) const;
268         //- Write the polyPatch data as a dictionary
269         virtual void write(Ostream&) const;
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 } // End namespace Foam
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 #endif
281 // ************************************************************************* //