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