initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / meshes / polyMesh / polyPatches / basic / coupled / coupledPolyPatch.H
blob3e64e96ca230ade1164a6e07ca33b4bea9f9fcbd
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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
35     coupledPolyPatchMorph.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef coupledPolyPatch_H
40 #define coupledPolyPatch_H
42 #include "polyPatch.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 /*---------------------------------------------------------------------------*\
50                        Class coupledPolyPatch Declaration
51 \*---------------------------------------------------------------------------*/
53 class coupledPolyPatch
55     public polyPatch
57     // Private data
59         //- offset (distance) vector from one side of the couple to the other
60         mutable vectorField separation_;
62         //- Face transformation tensor
63         mutable tensorField forwardT_;
65         //- Neighbour-cell transformation tensor
66         mutable tensorField reverseT_;
68 public:
70     // Static data members
72         //- Relative tolerance (for geometric matching).
73         static scalar matchTol;
76 protected:
78     // Protected Member Functions
80         //- Calculate the transformation tensors
81         //  smallDist : matching distance per face
82         //  absTol    : absolute error in normal
83         void calcTransformTensors
84         (
85             const vectorField& Cf,
86             const vectorField& Cr,
87             const vectorField& nf,
88             const vectorField& nr,
89             const scalarField& smallDist,
90             const scalar absTol = matchTol
91         ) const;
93         //- Initialise the calculation of the patch geometry
94         virtual void initGeometry() = 0;
96         //- Calculate the patch geometry
97         virtual void calcGeometry() = 0;
99         //- Initialise the patches for moving points
100         virtual void initMovePoints(const pointField&) = 0;
102         //- Correct patches after moving points
103         virtual void movePoints(const pointField&) = 0;
105         //- Initialise the update of the patch topology
106         virtual void initUpdateMesh() = 0;
108         //- Update of the patch topology
109         virtual void updateMesh() = 0;
112         //- Write point in OBJ format
113         static void writeOBJ(Ostream& os, const point& pt);
115         //- Write selected points in OBJ format
116         static void writeOBJ(Ostream&, const pointField&, const labelList&);
118         //- Write patch
119         static void writeOBJ
120         (
121             const fileName&,
122             const UList<face>&,
123             const pointField&
124         );
126         //- Write edge in OBJ format
127         static void writeOBJ
128         (
129             Ostream& os,
130             const point& p0,
131             const point& p1,
132             label& vertI
133         );
135         //- Calculate face centres
136         static pointField calcFaceCentres
137         (
138             const UList<face>&,
139             const pointField&
140         );
142         //- Get f[0] for all faces
143         static pointField getAnchorPoints
144         (
145             const UList<face>&,
146             const pointField&
147         );
149         //- Is face (in old face labels) in current patch?
150         bool inPatch
151         (
152             const labelList& oldToNew,
153             const label oldFaceI
154         ) const;
156         //- Given list of starts of patches and a face label determine
157         //  the patch.
158         static label whichPatch
159         (
160             const labelList& patchStarts,
161             const label faceI
162         );
164         //- Calculate typical tolerance per face. Is currently max distance
165         //  from face centre to any of the face vertices.
166         static scalarField calcFaceTol
167         (
168             const UList<face>& faces,
169             const pointField& points,
170             const pointField& faceCentres
171         );
173         //- Get the number of vertices face f needs to be rotated such that
174         //  its f[0] point aligns with given anchor (within tol).
175         static label getRotation
176         (
177             const pointField& points,
178             const face& f,
179             const point& anchor,
180             const scalar tol
181         );
184 public:
186     //- Runtime type information
187     TypeName("coupled");
190     // Constructors
192         //- Construct from components
193         coupledPolyPatch
194         (
195             const word& name,
196             const label size,
197             const label start,
198             const label index,
199             const polyBoundaryMesh& bm
200         );
202         //- Construct from dictionary
203         coupledPolyPatch
204         (
205             const word& name,
206             const dictionary& dict,
207             const label index,
208             const polyBoundaryMesh& bm
209         );
211         //- Construct as copy, resetting the boundary mesh
212         coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh&);
214         //- Construct given the original patch and resetting the
215         //  face list and boundary mesh information
216         coupledPolyPatch
217         (
218             const coupledPolyPatch& pp,
219             const polyBoundaryMesh& bm,
220             const label index,
221             const label newSize,
222             const label newStart
223         );
226     // Destructor
228         virtual ~coupledPolyPatch();
231     // Member Functions
233         // Access
235             //- Return true because this patch is coupled
236             virtual bool coupled() const
237             {
238                 return true;
239             }
242             //- Are the coupled planes separated
243             bool separated() const
244             {
245                 return separation_.size();
246             }
248             //- Return the offset (distance) vector from one side of the couple
249             //  to the other
250             const vectorField& separation() const
251             {
252                 return separation_;
253             }
256             //- Are the cyclic planes parallel
257             bool parallel() const
258             {
259                 return forwardT_.size() == 0;
260             }
262             //- Return face transformation tensor
263             const tensorField& forwardT() const
264             {
265                 return forwardT_;
266             }
268             //- Return neighbour-cell transformation tensor
269             const tensorField& reverseT() const
270             {
271                 return reverseT_;
272             }
275         //- Initialize ordering for primitivePatch. Does not
276         //  refer to *this (except for name() and type() etc.)
277         virtual void initOrder(const primitivePatch&) const = 0;
279         //- Return new ordering for primitivePatch.
280         //  Ordering is -faceMap: for every face
281         //  index of the new face -rotation:for every new face the clockwise
282         //  shift of the original face. Return false if nothing changes
283         //  (faceMap is identity, rotation is 0), true otherwise.
284         virtual bool order
285         (
286             const primitivePatch&,
287             labelList& faceMap,
288             labelList& rotation
289         ) const = 0;
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 } // End namespace Foam
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 #endif
301 // ************************************************************************* //