Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / foam / meshes / polyMesh / polyPatches / basic / coupled / coupledPolyPatch.H
blobfc105ad8a5dcd15c43c84812b2536af692d03072
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::coupledPolyPatch
27 Description
28     The coupledPolyPatch is an abstract base class for patches that couple
29     regions of the computational domain e.g. cyclic and processor-processor
30     links.
32 SourceFiles
33     coupledPolyPatch.C
34     coupledPolyPatchMorph.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 protected:
58     // Protected data
60         // Alowing derived classes to create their own transformation
61         // HJ, 24/Oct/2008
63         //- Offset (distance) vector from one side of the couple to the other
64         mutable vectorField separation_;
66         //- Face transformation tensor
67         mutable tensorField forwardT_;
69         //- Neighbour-cell transformation tensor
70         mutable tensorField reverseT_;
73     // Protected Member Functions
75         //- Calculate the transformation tensors
76         //  smallDist : matching distance per face
77         //  absTol    : absolute error in normal
78         void calcTransformTensors
79         (
80             const vectorField& Cf,
81             const vectorField& Cr,
82             const vectorField& nf,
83             const vectorField& nr,
84             const scalarField& smallDist,
85             const scalar absTol = matchTol_()
86         ) const;
88         //- Initialise the calculation of the patch addressing
89         virtual void initAddressing() = 0;
91         //- Calculate the patch addressing
92         virtual void calcAddressing() = 0;
94         //- Initialise the calculation of the patch geometry
95         virtual void initGeometry() = 0;
97         //- Calculate the patch geometry
98         virtual void calcGeometry() = 0;
100         //- Initialise the patches for moving points
101         virtual void initMovePoints(const pointField&) = 0;
103         //- Correct patches after moving points
104         virtual void movePoints(const pointField&) = 0;
107 public:
109     //- Runtime type information
110     TypeName("coupled");
113     // Constructors
115         //- Construct from components
116         coupledPolyPatch
117         (
118             const word& name,
119             const label size,
120             const label start,
121             const label index,
122             const polyBoundaryMesh& bm
123         );
125         //- Construct from dictionary
126         coupledPolyPatch
127         (
128             const word& name,
129             const dictionary& dict,
130             const label index,
131             const polyBoundaryMesh& bm
132         );
134         //- Construct as copy, resetting the boundary mesh
135         coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh&);
137         //- Construct given the original patch and resetting the
138         //  face list and boundary mesh information
139         coupledPolyPatch
140         (
141             const coupledPolyPatch& pp,
142             const polyBoundaryMesh& bm,
143             const label index,
144             const label newSize,
145             const label newStart
146         );
149     // Destructor
151         virtual ~coupledPolyPatch();
154     // Member Functions
156         // Access
158             //- Return true if patch is coupled
159             virtual bool coupled() const
160             {
161                 return true;
162             }
165             //- Are the coupled planes separated
166             bool separated() const
167             {
168                 return separation_.size();
169             }
171             //- Return the offset (distance) vector from one side of the couple
172             //  to the other
173             const vectorField& separation() const
174             {
175                 return separation_;
176             }
179             //- Are the cyclic planes parallel
180             bool parallel() const
181             {
182                 return forwardT_.empty();
183             }
185             //- Return face transformation tensor
186             const tensorField& forwardT() const
187             {
188                 return forwardT_;
189             }
191             //- Return neighbour-cell transformation tensor
192             const tensorField& reverseT() const
193             {
194                 return reverseT_;
195             }
198         //- Initialize ordering for primitivePatch. Does not
199         //  refer to *this (except for name() and type() etc.)
200         virtual void initOrder(const primitivePatch&) const = 0;
202         //- Return new ordering for primitivePatch.
203         //  Ordering is -faceMap: for every face
204         //  index of the new face -rotation:for every new face the clockwise
205         //  shift of the original face. Return false if nothing changes
206         //  (faceMap is identity, rotation is 0), true otherwise.
207         virtual bool order
208         (
209             const primitivePatch&,
210             labelList& faceMap,
211             labelList& rotation
212         ) const = 0;
214         //- Synchronise communications of ordering for primitivePatch
215         //  Used in cases when no topological change happens locally,
216         //  but is happening on other processors
217         virtual void syncOrder() const = 0;
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 } // End namespace Foam
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 #endif
229 // ************************************************************************* //