Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
meshes
polyMesh
polyPatches
constraint
cyclic
cyclicPolyPatch.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::cyclicPolyPatch
26
27
Description
28
Cyclic plane patch.
29
30
Note: morph patch face ordering uses geometric matching so with the
31
following restrictions:
32
-halves should be flat planes.
33
-no rotation in patch plane
34
35
Uses a featureCos to find the two halves (or should be fully
36
disconnected). Uses coupledPolyPatch::calcFaceTol to calculate
37
tolerance per face which might need tweaking.
38
39
Switch on 'cyclicPolyPatch' debug flag to write .obj files to show
40
the matching.
41
42
SourceFiles
43
cyclicPolyPatch.C
44
cyclicPolyPatchMorph.C
45
46
\*---------------------------------------------------------------------------*/
47
48
#ifndef cyclicPolyPatch_H
49
#define cyclicPolyPatch_H
50
51
#include <
OpenFOAM/coupledPolyPatch.H
>
52
#include <
OpenFOAM/SubField.H
>
53
#include <
OpenFOAM/FixedList.H
>
54
#include <
OpenFOAM/edgeList.H
>
55
#include <
OpenFOAM/transform.H
>
56
57
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59
namespace
Foam
60
{
61
62
/*---------------------------------------------------------------------------*\
63
Class cyclicPolyPatch Declaration
64
\*---------------------------------------------------------------------------*/
65
66
class
cyclicPolyPatch
67
:
68
public
coupledPolyPatch
69
{
70
// Private data
71
72
//- List of edges formed from connected points. e[0] is the point on
73
// the first half of the patch, e[1] the corresponding point on the
74
// second half.
75
mutable
edgeList
* coupledPointsPtr_;
76
77
//- List of connected edges. e[0] is the edge on the first half of the
78
// patch, e[1] the corresponding edge on the second half.
79
mutable
edgeList
* coupledEdgesPtr_;
80
81
//- Morph:angle between normals of neighbouring faces.
82
// Used to split cyclic into halves.
83
scalar featureCos_;
84
85
//- Type of transformation - rotational or translational
86
transformType
transform_;
87
88
// For rotation
89
90
//- Axis of rotation for rotational cyclics
91
vector
rotationAxis_;
92
93
//- point on axis of rotation for rotational cyclics
94
point
rotationCentre_;
95
96
// For translation
97
98
//- Translation vector
99
vector
separationVector_;
100
101
102
// Private member functions
103
104
//- Find amongst selected faces the one with the largest area
105
static
label findMaxArea(
const
pointField
&,
const
faceList
&);
106
107
void
calcTransforms();
108
109
110
// Face ordering
111
112
//- Find the two parts of the faces of pp using feature edges.
113
// Returns true if successfull.
114
bool
getGeometricHalves
115
(
116
const
primitivePatch
&,
117
labelList
&,
118
labelList
&
119
)
const
;
120
121
//- Calculate geometric factors of the two halves.
122
void
getCentresAndAnchors
123
(
124
const
primitivePatch
&,
125
const
faceList
& half0Faces,
126
const
faceList
& half1Faces,
127
128
pointField
& ppPoints,
129
pointField
& half0Ctrs,
130
pointField
& half1Ctrs,
131
pointField
& anchors0,
132
scalarField
& tols
133
)
const
;
134
135
//- Given matched faces matches the anchor point. Sets faceMap,
136
// rotation. Returns true if all matched.
137
bool
matchAnchors
138
(
139
const
bool
report,
140
const
primitivePatch
&,
141
const
labelList
&,
142
const
pointField
&,
143
const
labelList
&,
144
const
faceList
&,
145
const
labelList
&,
146
const
scalarField
&,
147
148
labelList
& faceMap,
149
labelList
& rotation
150
)
const
;
151
152
//- For rotational cases, try to find a unique face on each side
153
// of the cyclic.
154
label getConsistentRotationFace
155
(
156
const
pointField
&
faceCentres
157
)
const
;
158
159
160
protected
:
161
162
// Protected Member functions
163
164
//- Initialise the calculation of the patch geometry
165
virtual
void
initGeometry
();
166
167
//- Calculate the patch geometry
168
virtual
void
calcGeometry
();
169
170
//- Initialise the patches for moving points
171
virtual
void
initMovePoints
(
const
pointField
&);
172
173
//- Correct patches after moving points
174
virtual
void
movePoints
(
const
pointField
&);
175
176
//- Initialise the update of the patch topology
177
virtual
void
initUpdateMesh
();
178
179
//- Update of the patch topology
180
virtual
void
updateMesh
();
181
182
public
:
183
184
//- Runtime type information
185
TypeName
(
"cyclic"
);
186
187
188
// Constructors
189
190
//- Construct from components
191
cyclicPolyPatch
192
(
193
const
word
&
name
,
194
const
label size,
195
const
label
start
,
196
const
label
index
,
197
const
polyBoundaryMesh
& bm
198
);
199
200
//- Construct from dictionary
201
cyclicPolyPatch
202
(
203
const
word
& name,
204
const
dictionary
& dict,
205
const
label index,
206
const
polyBoundaryMesh
& bm
207
);
208
209
//- Construct as copy, resetting the boundary mesh
210
cyclicPolyPatch
(
const
cyclicPolyPatch
&,
const
polyBoundaryMesh
&);
211
212
//- Construct given the original patch and resetting the
213
// face list and boundary mesh information
214
cyclicPolyPatch
215
(
216
const
cyclicPolyPatch
& pp,
217
const
polyBoundaryMesh
& bm,
218
const
label index,
219
const
label newSize,
220
const
label newStart
221
);
222
223
//- Construct and return a clone, resetting the boundary mesh
224
virtual
autoPtr<polyPatch>
clone
(
const
polyBoundaryMesh
& bm)
const
225
{
226
return
autoPtr<polyPatch>
(
new
cyclicPolyPatch
(*
this
, bm));
227
}
228
229
//- Construct and return a clone, resetting the face list
230
// and boundary mesh
231
virtual
autoPtr<polyPatch>
clone
232
(
233
const
polyBoundaryMesh
& bm,
234
const
label index,
235
const
label newSize,
236
const
label newStart
237
)
const
238
{
239
return
autoPtr<polyPatch>
240
(
241
new
cyclicPolyPatch
(*
this
, bm, index, newSize, newStart)
242
);
243
}
244
245
246
// Destructor
247
248
virtual
~cyclicPolyPatch
();
249
250
251
// Member Functions
252
253
//- Return connected points (in patch local point indexing). Demand
254
// driven calculation. Does primitivePatch::clearOut after calculation!
255
const
edgeList
&
coupledPoints
()
const
;
256
257
//- Return connected edges (in patch local edge indexing). Demand
258
// driven calculation. Does primitivePatch::clearOut after calculation!
259
const
edgeList
&
coupledEdges
()
const
;
260
261
262
263
// Transformation
264
265
vector
separation
(
const
label facei)
const
266
{
267
if
(facei < size()/2)
268
{
269
return
coupledPolyPatch::separation
()[0];
270
}
271
else
272
{
273
return
-
coupledPolyPatch::separation
()[0];
274
}
275
}
276
277
const
tensor
&
transformT
(
const
label facei)
const
278
{
279
if
(facei < size()/2)
280
{
281
return
reverseT
()[0];
282
}
283
else
284
{
285
return
forwardT
()[0];
286
}
287
}
288
289
template
<
class
T>
290
T
transform
(
const
T
& t,
const
label facei)
const
291
{
292
if
(
parallel
())
293
{
294
return
t;
295
}
296
else
297
{
298
return
Foam::transform
(
transformT
(facei), t);
299
}
300
}
301
302
label
transformLocalFace
(
const
label facei)
const
303
{
304
if
(facei < size()/2)
305
{
306
return
facei + size()/2;
307
}
308
else
309
{
310
return
facei - size()/2;
311
}
312
}
313
314
label
transformGlobalFace
(
const
label facei)
const
315
{
316
if
(facei -
start
() < size()/2)
317
{
318
return
facei + size()/2;
319
}
320
else
321
{
322
return
facei - size()/2;
323
}
324
}
325
326
//- Type of transform
327
transformType
transform
()
const
328
{
329
return
transform_;
330
}
331
332
//- Axis of rotation for rotational cyclics
333
const
vector
&
rotationAxis
()
const
334
{
335
return
rotationAxis_;
336
}
337
338
//- point on axis of rotation for rotational cyclics
339
const
point
&
rotationCentre
()
const
340
{
341
return
rotationCentre_;
342
}
343
344
//- Translation vector for translational cyclics
345
const
vector
&
separationVector
()
const
346
{
347
return
separationVector_;
348
}
349
350
351
352
//- Initialize ordering for primitivePatch. Does not
353
// refer to *this (except for name() and type() etc.)
354
virtual
void
initOrder
(
const
primitivePatch
&)
const
;
355
356
//- Return new ordering for primitivePatch.
357
// Ordering is -faceMap: for every face
358
// index of the new face -rotation:for every new face the clockwise
359
// shift of the original face. Return false if nothing changes
360
// (faceMap is identity, rotation is 0), true otherwise.
361
virtual
bool
order
362
(
363
const
primitivePatch
&,
364
labelList
& faceMap,
365
labelList
& rotation
366
)
const
;
367
368
369
//- Write the polyPatch data as a dictionary
370
virtual
void
write
(
Ostream
&)
const
;
371
};
372
373
374
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375
376
}
// End namespace Foam
377
378
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379
380
#endif
381
382
// ************************ vim: set sw=4 sts=4 et: ************************ //