OpenFOAM logo
Open Source CFD Toolkit

cyclicPolyPatch.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     cyclicPolyPatch
00027 
00028 Description
00029     Cyclic plane patch.
00030 
00031     Note: morph patch face ordering uses geometric matching so with the
00032     following restrictions:
00033         -halves should be flat planes.
00034         -no rotation in patch plane
00035 
00036     Uses a featureCos to find the two halves (or should be fully
00037     disconnected). Uses coupledPolyPatch::calcFaceTol to calculate
00038     tolerance per face which might need tweaking.
00039 
00040     Switch on 'cyclicPolyPatch' debug flag to write .obj files to show
00041     the matching.
00042 
00043 SourceFiles
00044     cyclicPolyPatch.C
00045     cyclicPolyPatchMorph.C
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 class patchZones;
00064 
00065 /*---------------------------------------------------------------------------*\
00066                       Class cyclicPolyPatch Declaration
00067 \*---------------------------------------------------------------------------*/
00068 
00069 class cyclicPolyPatch
00070 :
00071     public coupledPolyPatch
00072 {
00073 
00074     // Static data
00075 
00076         //- Morph:angle between normals of neighbouring faces.
00077         //  Used to split cyclic into halves.
00078         static scalar featureCos_;
00079 
00080 
00081     // Private data
00082 
00083         //- List of edges formed from connected points. e[0] is the point on
00084         //  the first half of the patch, e[1] the corresponding point on the
00085         //  second half.
00086         mutable edgeList* coupledPointsPtr_;
00087 
00088         //- List of connected edges. e[0] is the edge on the first half of the
00089         //  patch, e[1] the corresponding edge on the second half.
00090         mutable edgeList* coupledEdgesPtr_;
00091 
00092 
00093     // Private member functions
00094 
00095         void calcTransforms();
00096 
00097 
00098 protected:
00099 
00100     // Protected Member functions
00101 
00102         //- Initialise the calculation of the patch geometry
00103         void initGeometry();
00104 
00105         //- Calculate the patch geometry
00106         void calcGeometry();
00107 
00108         //- Initialise the patches for moving points
00109         void initMovePoints(const pointField&);
00110 
00111         //- Correct patches after moving points
00112         void movePoints(const pointField&);
00113 
00114         //- Initialise the update of the patch topology
00115         virtual void initUpdateTopology();
00116 
00117         //- Update of the patch topology
00118         virtual void updateMesh();
00119 
00120 public:
00121 
00122     //- Runtime type information
00123     TypeName("cyclic");
00124 
00125 
00126     // Static member functions
00127 
00128         //- Return feature angle
00129         static scalar featureCos();
00130 
00131         //- Set the feature angle, returning the previous value
00132         static scalar setFeatureCos(const scalar t);
00133 
00134 
00135     // Constructors
00136 
00137         //- Construct from components
00138         cyclicPolyPatch
00139         (
00140             const word& name,
00141             const label size,
00142             const label start,
00143             const label index,
00144             const polyBoundaryMesh& bm
00145         );
00146 
00147         //- Construct from Istream
00148         cyclicPolyPatch
00149         (
00150             Istream&,
00151             const label index, const polyBoundaryMesh&
00152         );
00153 
00154         //- Construct from dictionary
00155         cyclicPolyPatch
00156         (
00157             const word& name,
00158             const dictionary& dict,
00159             const label index,
00160             const polyBoundaryMesh& bm
00161         );
00162 
00163         //- Construct as copy, resetting the boundary mesh
00164         cyclicPolyPatch(const cyclicPolyPatch&, const polyBoundaryMesh&);
00165 
00166         //- Construct given the original patch and resetting the
00167         //  face list and boundary mesh information
00168         cyclicPolyPatch
00169         (
00170             const cyclicPolyPatch& pp,
00171             const polyBoundaryMesh& bm,
00172             const label index,
00173             const label newSize,
00174             const label newStart
00175         );
00176 
00177         //- Construct and return a clone, resetting the boundary mesh
00178         virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
00179         {
00180             return autoPtr<polyPatch>(new cyclicPolyPatch(*this, bm));
00181         }
00182 
00183         //- Construct and return a clone, resetting the face list
00184         //  and boundary mesh
00185         virtual autoPtr<polyPatch> clone
00186         (
00187             const polyBoundaryMesh& bm,
00188             const label index,
00189             const label newSize,
00190             const label newStart
00191         ) const
00192         {
00193             return autoPtr<polyPatch>
00194             (
00195                 new cyclicPolyPatch(*this, bm, index, newSize, newStart)
00196             );
00197         }
00198 
00199 
00200     // Destructor
00201 
00202         virtual ~cyclicPolyPatch();
00203 
00204 
00205     // Member Functions
00206 
00207         //- Return connected points (in patch local point indexing)
00208         const edgeList& coupledPoints() const;
00209 
00210         //- Return connected edges (in patch local edge indexing)
00211         const edgeList& coupledEdges() const;
00212 
00213 
00214         vector separation(const label facei) const
00215         {
00216             if (facei < size()/2)
00217             {
00218                 return coupledPolyPatch::separation()[0];
00219             }
00220             else
00221             {
00222                 return -coupledPolyPatch::separation()[0];
00223             }
00224         }
00225 
00226         const tensor& transformT(const label facei) const
00227         {
00228             if (facei < size()/2)
00229             {
00230                 return reverseT()[0];
00231             }
00232             else
00233             {
00234                 return forwardT()[0];
00235             }
00236         }
00237 
00238         template<class T>
00239         T transform(const T& t, const label facei) const
00240         {
00241             if (parallel())
00242             {
00243                 return t;
00244             }
00245             else
00246             {
00247                 return Foam::transform(transformT(facei), t);
00248             }
00249         }
00250 
00251         label transformLocalFace(const label facei) const
00252         {
00253             if (facei < size()/2)
00254             {
00255                 return facei + size()/2;
00256             }
00257             else
00258             {
00259                 return facei - size()/2;
00260             }
00261         }
00262 
00263         label transformGlobalFace(const label facei) const
00264         {
00265             if (facei - start() < size()/2)
00266             {
00267                 return facei + size()/2;
00268             }
00269             else
00270             {
00271                 return facei - size()/2;
00272             }
00273         }
00274 
00275 
00276         //- Initialize ordering for primitivePatch. Does not
00277         //  refer to *this (except for name() and type() etc.)
00278         virtual void initOrder(const primitivePatch&) const;
00279 
00280         //- Return new ordering for primitivePatch.
00281         //  Ordering is -faceMap: for every face
00282         //  index of the new face -rotation:for every new face the clockwise
00283         //  shift of the original face. Return false if nothing changes
00284         //  (faceMap is identity, rotation is 0), true otherwise.
00285         virtual bool order
00286         (
00287             const primitivePatch&,
00288             labelList& faceMap,
00289             labelList& rotation
00290         ) const;
00291 };
00292 
00293 
00294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00295 
00296 } // End namespace Foam
00297 
00298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00299 
00300 #endif
00301 
00302 // ************************************************************************* //
For further information go to www.openfoam.org