initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / polyPatches / basic / coupled / coupledPolyPatch.H
blobde1d9cc9f98c4fe60502606c3842c1057e7c8c9c
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::coupledPolyPatch
28 Description
29     The coupledPolyPatch is an abstract base class for patches that couple
30     regions of the computational domain e.g. cyclic and processor-processor
31     links.
33 SourceFiles
34     coupledPolyPatch.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef coupledPolyPatch_H
39 #define coupledPolyPatch_H
41 #include "polyPatch.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49                       Class coupledPolyPatch Declaration
50 \*---------------------------------------------------------------------------*/
52 class coupledPolyPatch
54     public polyPatch
56     // Private data
58         //- offset (distance) vector from one side of the couple to the other
59         mutable vectorField separation_;
61         //- Face transformation tensor
62         mutable tensorField forwardT_;
64         //- Neighbour-cell transformation tensor
65         mutable tensorField reverseT_;
67 public:
69     // Static data members
71         //- Relative tolerance (for geometric matching).
72         static scalar matchTol;
75 protected:
77     // Protected Member Functions
79         //- Calculate the transformation tensors
80         //  smallDist : matching distance per face
81         //  absTol    : absolute error in normal
82         void calcTransformTensors
83         (
84             const vectorField& Cf,
85             const vectorField& Cr,
86             const vectorField& nf,
87             const vectorField& nr,
88             const scalarField& smallDist,
89             const scalar absTol = matchTol
90         ) const;
92         //- Initialise the calculation of the patch geometry
93         virtual void initGeometry() = 0;
95         //- Calculate the patch geometry
96         virtual void calcGeometry() = 0;
98         //- Initialise the patches for moving points
99         virtual void initMovePoints(const pointField&) = 0;
101         //- Correct patches after moving points
102         virtual void movePoints(const pointField&) = 0;
104         //- Initialise the update of the patch topology
105         virtual void initUpdateMesh() = 0;
107         //- Update of the patch topology
108         virtual void updateMesh() = 0;
111         //- Write point in OBJ format
112         static void writeOBJ(Ostream& os, const point& pt);
114         //- Write selected points in OBJ format
115         static void writeOBJ(Ostream&, const pointField&, const labelList&);
117         //- Write patch
118         static void writeOBJ
119         (
120             const fileName&,
121             const UList<face>&,
122             const pointField&
123         );
125         //- Write edge in OBJ format
126         static void writeOBJ
127         (
128             Ostream& os,
129             const point& p0,
130             const point& p1,
131             label& vertI
132         );
134         //- Calculate face centres
135         static pointField calcFaceCentres
136         (
137             const UList<face>&,
138             const pointField&
139         );
141         //- Get f[0] for all faces
142         static pointField getAnchorPoints
143         (
144             const UList<face>&,
145             const pointField&
146         );
148         //- Is face (in old face labels) in current patch?
149         bool inPatch
150         (
151             const labelList& oldToNew,
152             const label oldFaceI
153         ) const;
155         //- Given list of starts of patches and a face label determine
156         //  the patch.
157         static label whichPatch
158         (
159             const labelList& patchStarts,
160             const label faceI
161         );
163         //- Calculate typical tolerance per face. Is currently max distance
164         //  from face centre to any of the face vertices.
165         static scalarField calcFaceTol
166         (
167             const UList<face>& faces,
168             const pointField& points,
169             const pointField& faceCentres
170         );
172         //- Get the number of vertices face f needs to be rotated such that
173         //  its f[0] point aligns with given anchor (within tol).
174         static label getRotation
175         (
176             const pointField& points,
177             const face& f,
178             const point& anchor,
179             const scalar tol
180         );
183 public:
185     //- Runtime type information
186     TypeName("coupled");
189     // Constructors
191         //- Construct from components
192         coupledPolyPatch
193         (
194             const word& name,
195             const label size,
196             const label start,
197             const label index,
198             const polyBoundaryMesh& bm
199         );
201         //- Construct from dictionary
202         coupledPolyPatch
203         (
204             const word& name,
205             const dictionary& dict,
206             const label index,
207             const polyBoundaryMesh& bm
208         );
210         //- Construct as copy, resetting the boundary mesh
211         coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh&);
213         //- Construct given the original patch and resetting the
214         //  face list and boundary mesh information
215         coupledPolyPatch
216         (
217             const coupledPolyPatch& pp,
218             const polyBoundaryMesh& bm,
219             const label index,
220             const label newSize,
221             const label newStart
222         );
225     // Destructor
227         virtual ~coupledPolyPatch();
230     // Member Functions
232         // Access
234             //- Return true because this patch is coupled
235             virtual bool coupled() const
236             {
237                 return true;
238             }
241             //- Are the coupled planes separated
242             bool separated() const
243             {
244                 return separation_.size();
245             }
247             //- Return the offset (distance) vector from one side of the couple
248             //  to the other
249             const vectorField& separation() const
250             {
251                 return separation_;
252             }
255             //- Are the cyclic planes parallel
256             bool parallel() const
257             {
258                 return forwardT_.empty();
259             }
261             //- Return face transformation tensor
262             const tensorField& forwardT() const
263             {
264                 return forwardT_;
265             }
267             //- Return neighbour-cell transformation tensor
268             const tensorField& reverseT() const
269             {
270                 return reverseT_;
271             }
274         //- Initialize ordering for primitivePatch. Does not
275         //  refer to *this (except for name() and type() etc.)
276         virtual void initOrder(const primitivePatch&) const = 0;
278         //- Return new ordering for primitivePatch.
279         //  Ordering is -faceMap: for every face
280         //  index of the new face -rotation:for every new face the clockwise
281         //  shift of the original face. Return false if nothing changes
282         //  (faceMap is identity, rotation is 0), true otherwise.
283         virtual bool order
284         (
285             const primitivePatch&,
286             labelList& faceMap,
287             labelList& rotation
288         ) const = 0;
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 } // End namespace Foam
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 #endif
300 // ************************************************************************* //