00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef cyclicPolyPatch_H
00050 #define cyclicPolyPatch_H
00051
00052 #include "coupledPolyPatch.H"
00053 #include "SubField.H"
00054 #include "FixedList.H"
00055 #include "edgeList.H"
00056 #include "transform.H"
00057
00058
00059
00060 namespace Foam
00061 {
00062
00063
00064
00065
00066
00067 class cyclicPolyPatch
00068 :
00069 public coupledPolyPatch
00070 {
00071 public:
00072
00073 enum transformType
00074 {
00075 UNKNOWN,
00076 ROTATIONAL,
00077 TRANSLATIONAL
00078 };
00079 static const NamedEnum<transformType, 3> transformTypeNames;
00080
00081
00082 private:
00083
00084
00085
00086
00087
00088
00089 mutable edgeList* coupledPointsPtr_;
00090
00091
00092
00093 mutable edgeList* coupledEdgesPtr_;
00094
00095
00096
00097 scalar featureCos_;
00098
00099
00100 transformType transform_;
00101
00102
00103
00104
00105 vector rotationAxis_;
00106
00107
00108 point rotationCentre_;
00109
00110
00111
00112
00113 vector separationVector_;
00114
00115
00116
00117
00118
00119 static label findMaxArea(const pointField&, const faceList&);
00120
00121 void calcTransforms();
00122
00123
00124
00125
00126
00127
00128 bool getGeometricHalves
00129 (
00130 const primitivePatch&,
00131 labelList&,
00132 labelList&
00133 ) const;
00134
00135
00136 void getCentresAndAnchors
00137 (
00138 const primitivePatch&,
00139 const faceList& half0Faces,
00140 const faceList& half1Faces,
00141
00142 pointField& ppPoints,
00143 pointField& half0Ctrs,
00144 pointField& half1Ctrs,
00145 pointField& anchors0,
00146 scalarField& tols
00147 ) const;
00148
00149
00150
00151 bool matchAnchors
00152 (
00153 const bool report,
00154 const primitivePatch&,
00155 const labelList&,
00156 const pointField&,
00157 const labelList&,
00158 const faceList&,
00159 const labelList&,
00160 const scalarField&,
00161
00162 labelList& faceMap,
00163 labelList& rotation
00164 ) const;
00165
00166
00167
00168 label getConsistentRotationFace
00169 (
00170 const pointField& faceCentres
00171 ) const;
00172
00173
00174 protected:
00175
00176
00177
00178
00179 virtual void initGeometry();
00180
00181
00182 virtual void calcGeometry();
00183
00184
00185 virtual void initMovePoints(const pointField&);
00186
00187
00188 virtual void movePoints(const pointField&);
00189
00190
00191 virtual void initUpdateMesh();
00192
00193
00194 virtual void updateMesh();
00195
00196 public:
00197
00198
00199 TypeName("cyclic");
00200
00201
00202
00203
00204
00205 cyclicPolyPatch
00206 (
00207 const word& name,
00208 const label size,
00209 const label start,
00210 const label index,
00211 const polyBoundaryMesh& bm
00212 );
00213
00214
00215 cyclicPolyPatch
00216 (
00217 const word& name,
00218 const dictionary& dict,
00219 const label index,
00220 const polyBoundaryMesh& bm
00221 );
00222
00223
00224 cyclicPolyPatch(const cyclicPolyPatch&, const polyBoundaryMesh&);
00225
00226
00227
00228 cyclicPolyPatch
00229 (
00230 const cyclicPolyPatch& pp,
00231 const polyBoundaryMesh& bm,
00232 const label index,
00233 const label newSize,
00234 const label newStart
00235 );
00236
00237
00238 virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
00239 {
00240 return autoPtr<polyPatch>(new cyclicPolyPatch(*this, bm));
00241 }
00242
00243
00244
00245 virtual autoPtr<polyPatch> clone
00246 (
00247 const polyBoundaryMesh& bm,
00248 const label index,
00249 const label newSize,
00250 const label newStart
00251 ) const
00252 {
00253 return autoPtr<polyPatch>
00254 (
00255 new cyclicPolyPatch(*this, bm, index, newSize, newStart)
00256 );
00257 }
00258
00259
00260
00261
00262 virtual ~cyclicPolyPatch();
00263
00264
00265
00266
00267
00268
00269 const edgeList& coupledPoints() const;
00270
00271
00272
00273 const edgeList& coupledEdges() const;
00274
00275
00276
00277
00278
00279 vector separation(const label facei) const
00280 {
00281 if (facei < size()/2)
00282 {
00283 return coupledPolyPatch::separation()[0];
00284 }
00285 else
00286 {
00287 return -coupledPolyPatch::separation()[0];
00288 }
00289 }
00290
00291 const tensor& transformT(const label facei) const
00292 {
00293 if (facei < size()/2)
00294 {
00295 return reverseT()[0];
00296 }
00297 else
00298 {
00299 return forwardT()[0];
00300 }
00301 }
00302
00303 template<class T>
00304 T transform(const T& t, const label facei) const
00305 {
00306 if (parallel())
00307 {
00308 return t;
00309 }
00310 else
00311 {
00312 return Foam::transform(transformT(facei), t);
00313 }
00314 }
00315
00316 label transformLocalFace(const label facei) const
00317 {
00318 if (facei < size()/2)
00319 {
00320 return facei + size()/2;
00321 }
00322 else
00323 {
00324 return facei - size()/2;
00325 }
00326 }
00327
00328 label transformGlobalFace(const label facei) const
00329 {
00330 if (facei - start() < size()/2)
00331 {
00332 return facei + size()/2;
00333 }
00334 else
00335 {
00336 return facei - size()/2;
00337 }
00338 }
00339
00340
00341 transformType transform() const
00342 {
00343 return transform_;
00344 }
00345
00346
00347 const vector& rotationAxis() const
00348 {
00349 return rotationAxis_;
00350 }
00351
00352
00353 const point& rotationCentre() const
00354 {
00355 return rotationCentre_;
00356 }
00357
00358
00359 const vector& separationVector() const
00360 {
00361 return separationVector_;
00362 }
00363
00364
00365
00366
00367
00368 virtual void initOrder(const primitivePatch&) const;
00369
00370
00371
00372
00373
00374
00375 virtual bool order
00376 (
00377 const primitivePatch&,
00378 labelList& faceMap,
00379 labelList& rotation
00380 ) const;
00381
00382
00383
00384 virtual void write(Ostream&) const;
00385 };
00386
00387
00388
00389
00390 }
00391
00392
00393
00394 #endif
00395
00396