1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 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
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
26 Foam::coupledPolyPatch
29 The coupledPolyPatch is an abstract base class for patches that couple
30 regions of the computational domain e.g. cyclic and processor-processor
36 \*---------------------------------------------------------------------------*/
38 #ifndef coupledPolyPatch_H
39 #define coupledPolyPatch_H
41 #include "polyPatch.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 /*---------------------------------------------------------------------------*\
49 Class coupledPolyPatch Declaration
50 \*---------------------------------------------------------------------------*/
52 class coupledPolyPatch
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_;
69 // Static data members
71 //- Relative tolerance (for geometric matching).
72 static scalar matchTol;
77 // Protected Member Functions
79 //- Calculate the transformation tensors
80 // smallDist : matching distance per face
81 // absTol : absolute error in normal
82 void calcTransformTensors
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
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&);
125 //- Write edge in OBJ format
134 //- Calculate face centres
135 static pointField calcFaceCentres
141 //- Get f[0] for all faces
142 static pointField getAnchorPoints
148 //- Is face (in old face labels) in current patch?
151 const labelList& oldToNew,
155 //- Given list of starts of patches and a face label determine
157 static label whichPatch
159 const labelList& patchStarts,
163 //- Calculate typical tolerance per face. Is currently max distance
164 // from face centre to any of the face vertices.
165 static scalarField calcFaceTol
167 const UList<face>& faces,
168 const pointField& points,
169 const pointField& faceCentres
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
176 const pointField& points,
185 //- Runtime type information
191 //- Construct from components
198 const polyBoundaryMesh& bm
201 //- Construct from dictionary
205 const dictionary& dict,
207 const polyBoundaryMesh& bm
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
217 const coupledPolyPatch& pp,
218 const polyBoundaryMesh& bm,
227 virtual ~coupledPolyPatch();
234 //- Return true because this patch is coupled
235 virtual bool coupled() const
241 //- Are the coupled planes separated
242 bool separated() const
244 return separation_.size();
247 //- Return the offset (distance) vector from one side of the couple
249 const vectorField& separation() const
255 //- Are the cyclic planes parallel
256 bool parallel() const
258 return forwardT_.empty();
261 //- Return face transformation tensor
262 const tensorField& forwardT() const
267 //- Return neighbour-cell transformation tensor
268 const tensorField& reverseT() const
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.
285 const primitivePatch&,
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 } // End namespace Foam
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 // ************************************************************************* //