OpenFOAM logo
Open Source CFD Toolkit

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