1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Foam::coupledPolyPatch
28 The coupledPolyPatch is an abstract base class for patches that couple
29 regions of the computational domain e.g. cyclic and processor-processor
35 \*---------------------------------------------------------------------------*/
37 #ifndef coupledPolyPatch_H
38 #define coupledPolyPatch_H
40 #include "polyPatch.H"
41 #include "diagTensorField.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 /*---------------------------------------------------------------------------*\
49 Class coupledPolyPatch Declaration
50 \*---------------------------------------------------------------------------*/
52 class coupledPolyPatch
60 UNKNOWN, // unspecified; automatic ordering
61 ROTATIONAL, // rotation along coordinate axis
62 TRANSLATIONAL, // translation
63 NOORDERING // unspecified, no automatic ordering
65 static const NamedEnum<transformType, 4> transformTypeNames;
72 //- default matching tolerance
73 static const scalar defaultMatchTol_;
75 //- local matching tolerance
76 const scalar matchTolerance_;
78 //- offset (distance) vector from one side of the couple to the other
79 mutable vectorField separation_;
81 //- Face transformation tensor
82 mutable tensorField forwardT_;
84 //- Neighbour-cell transformation tensor
85 mutable tensorField reverseT_;
87 //- Are faces collocated. Either size 0,1 or length of patch.
88 mutable boolList collocated_;
92 // Protected Member Functions
94 //- Calculate the transformation tensors
95 // smallDist : matching distance per face
96 // absTol : absolute error in normal
97 // if transformType = unknown it first tries rotational, then
98 // translational transform
99 void calcTransformTensors
101 const vectorField& Cf,
102 const vectorField& Cr,
103 const vectorField& nf,
104 const vectorField& nr,
105 const scalarField& smallDist,
107 const transformType = UNKNOWN
110 //- Initialise the calculation of the patch geometry
111 virtual void initGeometry(PstreamBuffers&) = 0;
113 //- Calculate the patch geometry
114 virtual void calcGeometry(PstreamBuffers&) = 0;
116 //- Initialise the patches for moving points
117 virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0;
119 //- Correct patches after moving points
120 virtual void movePoints(PstreamBuffers&, const pointField&) = 0;
122 //- Initialise the update of the patch topology
123 virtual void initUpdateMesh(PstreamBuffers&) = 0;
125 //- Update of the patch topology
126 virtual void updateMesh(PstreamBuffers&) = 0;
129 //- Write point in OBJ format
130 static void writeOBJ(Ostream& os, const point& pt);
132 //- Write selected points in OBJ format
133 static void writeOBJ(Ostream&, const pointField&, const labelList&);
143 //- Write edge in OBJ format
152 //- Get f[0] for all faces
153 static pointField getAnchorPoints
159 //- Calculate typical tolerance per face. Is currently max distance
160 // from face centre to any of the face vertices.
161 static scalarField calcFaceTol
163 const scalar matchTol,
164 const UList<face>& faces,
165 const pointField& points,
166 const pointField& faceCentres
169 //- Get the number of vertices face f needs to be rotated such that
170 // its f[0] point aligns with given anchor (within tol).
171 static label getRotation
173 const pointField& points,
182 //- Runtime type information
188 //- Construct from components
195 const polyBoundaryMesh& bm
198 //- Construct from dictionary
202 const dictionary& dict,
204 const polyBoundaryMesh& bm
207 //- Construct as copy, resetting the boundary mesh
208 coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh&);
210 //- Construct given the original patch and resetting the
211 // face list and boundary mesh information
214 const coupledPolyPatch& pp,
215 const polyBoundaryMesh& bm,
221 //- Construct given the original patch and a map
224 const coupledPolyPatch& pp,
225 const polyBoundaryMesh& bm,
227 const labelUList& mapAddressing,
233 virtual ~coupledPolyPatch();
240 //- Return true because this patch is coupled
241 virtual bool coupled() const
246 //- Does this side own the patch ?
247 virtual bool owner() const = 0;
249 //- Does the coupled side own the patch ?
250 virtual bool neighbour() const
255 //- Transform a patch-based position from other side to this side
256 virtual void transformPosition(pointField&) const = 0;
258 //- Transform a patch-based position from other side to this side
259 virtual void transformPosition(point&, const label facei) const = 0;
261 //- Are the planes separated.
262 virtual bool separated() const
264 return separation_.size();
267 //- If the planes are separated the separation vector.
268 virtual const vectorField& separation() const
273 //- Are the cyclic planes parallel.
274 virtual bool parallel() const
276 return forwardT_.empty();
279 //- Return face transformation tensor.
280 virtual const tensorField& forwardT() const
285 //- Return neighbour-cell transformation tensor.
286 virtual const tensorField& reverseT() const
291 //- Are faces collocated. Either size 0,1 or length of patch
292 virtual const boolList& collocated() const
297 scalar matchTolerance() const
299 return matchTolerance_;
303 //- Calculate the patch geometry
304 virtual void calcGeometry
306 const primitivePatch& referPatch,
307 const pointField& thisCtrs,
308 const vectorField& thisAreas,
309 const pointField& thisCc,
310 const pointField& nbrCtrs,
311 const vectorField& nbrAreas,
312 const pointField& nbrCc
315 //- Initialize ordering for primitivePatch. Does not
316 // refer to *this (except for name() and type() etc.)
317 virtual void initOrder
320 const primitivePatch&
323 //- Return new ordering for primitivePatch.
324 // Ordering is -faceMap: for every face
325 // index of the new face -rotation:for every new face the clockwise
326 // shift of the original face. Return false if nothing changes
327 // (faceMap is identity, rotation is 0), true otherwise.
331 const primitivePatch&,
336 //- Write the polyPatch data as a dictionary
337 virtual void write(Ostream&) const;
341 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 } // End namespace Foam
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 // ************************************************************************* //