FreeFOAM The Cross-Platform CFD Toolkit
coupledPolyPatch.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::coupledPolyPatch
26 
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.
31 
32 SourceFiles
33  coupledPolyPatch.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef coupledPolyPatch_H
38 #define coupledPolyPatch_H
39 
40 #include <OpenFOAM/polyPatch.H>
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class coupledPolyPatch Declaration
49 \*---------------------------------------------------------------------------*/
50 
52 :
53  public polyPatch
54 {
55 public:
56 
58  {
62  };
64 
65 
66 private:
67 
68  // Private data
69 
70  //- offset (distance) vector from one side of the couple to the other
71  mutable vectorField separation_;
72 
73  //- Face transformation tensor
74  mutable tensorField forwardT_;
75 
76  //- Neighbour-cell transformation tensor
77  mutable tensorField reverseT_;
78 
79 public:
80 
81  // Static data members
82 
83  //- Relative tolerance (for geometric matching).
84  static scalar matchTol;
85 
86 
87 protected:
88 
89  // Protected Member Functions
90 
91  //- Calculate the transformation tensors
92  // smallDist : matching distance per face
93  // absTol : absolute error in normal
94  // if transformType = unknown it first tries rotational, then
95  // translational transform
97  (
98  const vectorField& Cf,
99  const vectorField& Cr,
100  const vectorField& nf,
101  const vectorField& nr,
102  const scalarField& smallDist,
103  const scalar absTol = matchTol,
104  const transformType = UNKNOWN
105  ) const;
106 
107  //- Initialise the calculation of the patch geometry
108  virtual void initGeometry() = 0;
109 
110  //- Calculate the patch geometry
111  virtual void calcGeometry() = 0;
112 
113  //- Initialise the patches for moving points
114  virtual void initMovePoints(const pointField&) = 0;
115 
116  //- Correct patches after moving points
117  virtual void movePoints(const pointField&) = 0;
118 
119  //- Initialise the update of the patch topology
120  virtual void initUpdateMesh() = 0;
121 
122  //- Update of the patch topology
123  virtual void updateMesh() = 0;
124 
125 
126  //- Write point in OBJ format
127  static void writeOBJ(Ostream& os, const point& pt);
128 
129  //- Write selected points in OBJ format
130  static void writeOBJ(Ostream&, const pointField&, const labelList&);
131 
132  //- Write patch
133  static void writeOBJ
134  (
135  const fileName&,
136  const UList<face>&,
137  const pointField&
138  );
139 
140  //- Write edge in OBJ format
141  static void writeOBJ
142  (
143  Ostream& os,
144  const point& p0,
145  const point& p1,
146  label& vertI
147  );
148 
149  //- Calculate face centres
151  (
152  const UList<face>&,
153  const pointField&
154  );
155 
156  //- Get f[0] for all faces
158  (
159  const UList<face>&,
160  const pointField&
161  );
162 
163  //- Is face (in old face labels) in current patch?
164  bool inPatch
165  (
166  const labelList& oldToNew,
167  const label oldFaceI
168  ) const;
169 
170  //- Given list of starts of patches and a face label determine
171  // the patch.
172  static label whichPatch
173  (
174  const labelList& patchStarts,
175  const label faceI
176  );
177 
178  //- Calculate typical tolerance per face. Is currently max distance
179  // from face centre to any of the face vertices.
180  static scalarField calcFaceTol
181  (
182  const UList<face>& faces,
183  const pointField& points,
184  const pointField& faceCentres
185  );
186 
187  //- Get the number of vertices face f needs to be rotated such that
188  // its f[0] point aligns with given anchor (within tol).
189  static label getRotation
190  (
191  const pointField& points,
192  const face& f,
193  const point& anchor,
194  const scalar tol
195  );
196 
197 
198 public:
199 
200  //- Runtime type information
201  TypeName("coupled");
202 
203 
204  // Constructors
205 
206  //- Construct from components
208  (
209  const word& name,
210  const label size,
211  const label start,
212  const label index,
213  const polyBoundaryMesh& bm
214  );
215 
216  //- Construct from dictionary
218  (
219  const word& name,
220  const dictionary& dict,
221  const label index,
222  const polyBoundaryMesh& bm
223  );
224 
225  //- Construct as copy, resetting the boundary mesh
227 
228  //- Construct given the original patch and resetting the
229  // face list and boundary mesh information
231  (
232  const coupledPolyPatch& pp,
233  const polyBoundaryMesh& bm,
234  const label index,
235  const label newSize,
236  const label newStart
237  );
238 
239 
240  // Destructor
241 
242  virtual ~coupledPolyPatch();
243 
244 
245  // Member Functions
246 
247  // Access
248 
249  //- Return true because this patch is coupled
250  virtual bool coupled() const
251  {
252  return true;
253  }
254 
255 
256  //- Are the coupled planes separated
257  bool separated() const
258  {
259  return separation_.size();
260  }
261 
262  //- Return the offset (distance) vector from one side of the couple
263  // to the other
264  const vectorField& separation() const
265  {
266  return separation_;
267  }
268 
269 
270  //- Are the cyclic planes parallel
271  bool parallel() const
272  {
273  return forwardT_.empty();
274  }
275 
276  //- Return face transformation tensor
277  const tensorField& forwardT() const
278  {
279  return forwardT_;
280  }
281 
282  //- Return neighbour-cell transformation tensor
283  const tensorField& reverseT() const
284  {
285  return reverseT_;
286  }
287 
288 
289  //- Initialize ordering for primitivePatch. Does not
290  // refer to *this (except for name() and type() etc.)
291  virtual void initOrder(const primitivePatch&) const = 0;
292 
293  //- Return new ordering for primitivePatch.
294  // Ordering is -faceMap: for every face
295  // index of the new face -rotation:for every new face the clockwise
296  // shift of the original face. Return false if nothing changes
297  // (faceMap is identity, rotation is 0), true otherwise.
298  virtual bool order
299  (
300  const primitivePatch&,
301  labelList& faceMap,
302  labelList& rotation
303  ) const = 0;
304 };
305 
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 } // End namespace Foam
310 
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 
313 #endif
314 
315 // ************************ vim: set sw=4 sts=4 et: ************************ //