1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 //- Get the number of vertices face f needs to be rotated such that
160 // its f[0] point aligns with given anchor (within tol).
161 static label getRotation
163 const pointField& points,
172 //- Runtime type information
178 //- Construct from components
185 const polyBoundaryMesh& bm
188 //- Construct from dictionary
192 const dictionary& dict,
194 const polyBoundaryMesh& bm
197 //- Construct as copy, resetting the boundary mesh
198 coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh&);
200 //- Construct given the original patch and resetting the
201 // face list and boundary mesh information
204 const coupledPolyPatch& pp,
205 const polyBoundaryMesh& bm,
211 //- Construct given the original patch and a map
214 const coupledPolyPatch& pp,
215 const polyBoundaryMesh& bm,
217 const labelUList& mapAddressing,
223 virtual ~coupledPolyPatch();
230 //- Return true because this patch is coupled
231 virtual bool coupled() const
236 //- Does this side own the patch ?
237 virtual bool owner() const = 0;
239 //- Does the coupled side own the patch ?
240 virtual bool neighbour() const
245 //- Transform a patch-based position from other side to this side
246 virtual void transformPosition(pointField&) const = 0;
248 //- Transform a patch-based position from other side to this side
249 virtual void transformPosition(point&, const label facei) const = 0;
251 //- Are the planes separated.
252 virtual bool separated() const
254 return separation_.size();
257 //- If the planes are separated the separation vector.
258 virtual const vectorField& separation() const
263 //- Are the cyclic planes parallel.
264 virtual bool parallel() const
266 return forwardT_.empty();
269 //- Return face transformation tensor.
270 virtual const tensorField& forwardT() const
275 //- Return neighbour-cell transformation tensor.
276 virtual const tensorField& reverseT() const
281 //- Are faces collocated. Either size 0,1 or length of patch
282 virtual const boolList& collocated() const
287 scalar matchTolerance() const
289 return matchTolerance_;
293 //- Calculate the patch geometry
294 virtual void calcGeometry
296 const primitivePatch& referPatch,
297 const pointField& thisCtrs,
298 const vectorField& thisAreas,
299 const pointField& thisCc,
300 const pointField& nbrCtrs,
301 const vectorField& nbrAreas,
302 const pointField& nbrCc
305 //- Initialize ordering for primitivePatch. Does not
306 // refer to *this (except for name() and type() etc.)
307 virtual void initOrder
310 const primitivePatch&
313 //- Return new ordering for primitivePatch.
314 // Ordering is -faceMap: for every face
315 // index of the new face -rotation:for every new face the clockwise
316 // shift of the original face. Return false if nothing changes
317 // (faceMap is identity, rotation is 0), true otherwise.
321 const primitivePatch&,
326 //- Calculate typical tolerance per face. Is currently max distance
327 // from face centre to any of the face vertices.
328 static scalarField calcFaceTol
330 const scalar matchTol,
331 const UList<face>& faces,
332 const pointField& points,
333 const pointField& faceCentres
336 //- Write the polyPatch data as a dictionary
337 virtual void write(Ostream&) const;
341 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 } // End namespace Foam
345 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 // ************************************************************************* //