OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

coupledPolyPatch.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-2009 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     Foam::coupledPolyPatch
00027 
00028 Description
00029     The coupledPolyPatch is an abstract base class for patches that couple
00030     regions of the computational domain e.g. cyclic and processor-processor
00031     links.
00032 
00033 SourceFiles
00034     coupledPolyPatch.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef coupledPolyPatch_H
00039 #define coupledPolyPatch_H
00040 
00041 #include "polyPatch.H"
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 namespace Foam
00046 {
00047 
00048 /*---------------------------------------------------------------------------*\
00049                       Class coupledPolyPatch Declaration
00050 \*---------------------------------------------------------------------------*/
00051 
00052 class coupledPolyPatch
00053 :
00054     public polyPatch
00055 {
00056     // Private data
00057 
00058         //- offset (distance) vector from one side of the couple to the other
00059         mutable vectorField separation_;
00060 
00061         //- Face transformation tensor
00062         mutable tensorField forwardT_;
00063 
00064         //- Neighbour-cell transformation tensor
00065         mutable tensorField reverseT_;
00066 
00067 public:
00068 
00069     // Static data members
00070 
00071         //- Relative tolerance (for geometric matching).
00072         static scalar matchTol;
00073 
00074 
00075 protected:
00076 
00077     // Protected Member Functions
00078 
00079         //- Calculate the transformation tensors
00080         //  smallDist : matching distance per face
00081         //  absTol    : absolute error in normal
00082         void calcTransformTensors
00083         (
00084             const vectorField& Cf,
00085             const vectorField& Cr,
00086             const vectorField& nf,
00087             const vectorField& nr,
00088             const scalarField& smallDist,
00089             const scalar absTol = matchTol
00090         ) const;
00091 
00092         //- Initialise the calculation of the patch geometry
00093         virtual void initGeometry() = 0;
00094 
00095         //- Calculate the patch geometry
00096         virtual void calcGeometry() = 0;
00097 
00098         //- Initialise the patches for moving points
00099         virtual void initMovePoints(const pointField&) = 0;
00100 
00101         //- Correct patches after moving points
00102         virtual void movePoints(const pointField&) = 0;
00103 
00104         //- Initialise the update of the patch topology
00105         virtual void initUpdateMesh() = 0;
00106 
00107         //- Update of the patch topology
00108         virtual void updateMesh() = 0;
00109 
00110 
00111         //- Write point in OBJ format
00112         static void writeOBJ(Ostream& os, const point& pt);
00113 
00114         //- Write selected points in OBJ format
00115         static void writeOBJ(Ostream&, const pointField&, const labelList&);
00116 
00117         //- Write patch
00118         static void writeOBJ
00119         (
00120             const fileName&,
00121             const UList<face>&,
00122             const pointField&
00123         );
00124 
00125         //- Write edge in OBJ format
00126         static void writeOBJ
00127         (
00128             Ostream& os,
00129             const point& p0,
00130             const point& p1,
00131             label& vertI
00132         );
00133 
00134         //- Calculate face centres
00135         static pointField calcFaceCentres
00136         (
00137             const UList<face>&,
00138             const pointField&
00139         );
00140 
00141         //- Get f[0] for all faces
00142         static pointField getAnchorPoints
00143         (
00144             const UList<face>&,
00145             const pointField&
00146         );
00147 
00148         //- Is face (in old face labels) in current patch?
00149         bool inPatch
00150         (
00151             const labelList& oldToNew,
00152             const label oldFaceI
00153         ) const;
00154 
00155         //- Given list of starts of patches and a face label determine
00156         //  the patch.
00157         static label whichPatch
00158         (
00159             const labelList& patchStarts,
00160             const label faceI
00161         );
00162 
00163         //- Calculate typical tolerance per face. Is currently max distance
00164         //  from face centre to any of the face vertices.
00165         static scalarField calcFaceTol
00166         (
00167             const UList<face>& faces,
00168             const pointField& points,
00169             const pointField& faceCentres
00170         );
00171 
00172         //- Get the number of vertices face f needs to be rotated such that
00173         //  its f[0] point aligns with given anchor (within tol).
00174         static label getRotation
00175         (
00176             const pointField& points,
00177             const face& f,
00178             const point& anchor,
00179             const scalar tol
00180         );
00181 
00182 
00183 public:
00184 
00185     //- Runtime type information
00186     TypeName("coupled");
00187 
00188 
00189     // Constructors
00190 
00191         //- Construct from components
00192         coupledPolyPatch
00193         (
00194             const word& name,
00195             const label size,
00196             const label start,
00197             const label index,
00198             const polyBoundaryMesh& bm
00199         );
00200 
00201         //- Construct from dictionary
00202         coupledPolyPatch
00203         (
00204             const word& name,
00205             const dictionary& dict,
00206             const label index,
00207             const polyBoundaryMesh& bm
00208         );
00209 
00210         //- Construct as copy, resetting the boundary mesh
00211         coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh&);
00212 
00213         //- Construct given the original patch and resetting the
00214         //  face list and boundary mesh information
00215         coupledPolyPatch
00216         (
00217             const coupledPolyPatch& pp,
00218             const polyBoundaryMesh& bm,
00219             const label index,
00220             const label newSize,
00221             const label newStart
00222         );
00223 
00224 
00225     // Destructor
00226 
00227         virtual ~coupledPolyPatch();
00228 
00229 
00230     // Member Functions
00231 
00232         // Access
00233 
00234             //- Return true because this patch is coupled
00235             virtual bool coupled() const
00236             {
00237                 return true;
00238             }
00239 
00240 
00241             //- Are the coupled planes separated
00242             bool separated() const
00243             {
00244                 return separation_.size();
00245             }
00246 
00247             //- Return the offset (distance) vector from one side of the couple
00248             //  to the other
00249             const vectorField& separation() const
00250             {
00251                 return separation_;
00252             }
00253 
00254 
00255             //- Are the cyclic planes parallel
00256             bool parallel() const
00257             {
00258                 return forwardT_.empty();
00259             }
00260 
00261             //- Return face transformation tensor
00262             const tensorField& forwardT() const
00263             {
00264                 return forwardT_;
00265             }
00266 
00267             //- Return neighbour-cell transformation tensor
00268             const tensorField& reverseT() const
00269             {
00270                 return reverseT_;
00271             }
00272 
00273 
00274         //- Initialize ordering for primitivePatch. Does not
00275         //  refer to *this (except for name() and type() etc.)
00276         virtual void initOrder(const primitivePatch&) const = 0;
00277 
00278         //- Return new ordering for primitivePatch.
00279         //  Ordering is -faceMap: for every face
00280         //  index of the new face -rotation:for every new face the clockwise
00281         //  shift of the original face. Return false if nothing changes
00282         //  (faceMap is identity, rotation is 0), true otherwise.
00283         virtual bool order
00284         (
00285             const primitivePatch&,
00286             labelList& faceMap,
00287             labelList& rotation
00288         ) const = 0;
00289 };
00290 
00291 
00292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00293 
00294 } // End namespace Foam
00295 
00296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00297 
00298 #endif
00299 
00300 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd