FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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