OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen 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-2007 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 patch
00113         static void writeOBJ
00114         (
00115             const fileName&,
00116             const faceList&,
00117             const pointField&
00118         );
00119 
00120         //- Write edge in OBJ format
00121         static void writeOBJ
00122         (
00123             Ostream& os,
00124             const point& p0,
00125             const point& p1,
00126             label& vertI
00127         );
00128 
00129         //- Calculate face centres
00130         static pointField calcFaceCentres(const faceList&, const pointField&);
00131 
00132         //- Get f[0] for all faces
00133         static pointField getAnchorPoints(const faceList&, const pointField&);
00134 
00135         //- Is face (in old face labels) in current patch?
00136         bool inPatch
00137         (
00138             const labelList& oldToNew,
00139             const label oldFaceI
00140         ) const;
00141 
00142         //- Given list of starts of patches and a face label determine
00143         //  the patch.
00144         static label whichPatch
00145         (
00146             const labelList& patchStarts,
00147             const label faceI
00148         );
00149 
00150         //- Calculate typical tolerance per face. Is currently max distance
00151         //  from face centre to any of the face vertices.
00152         static scalarField calcFaceTol
00153         (
00154             const faceList& faces,
00155             const pointField& points,
00156             const pointField& faceCentres
00157         );
00158 
00159         //- Get the number of vertices face f needs to be rotated such that
00160         //  its f[0] point aligns with given anchor (within tol).
00161         static label getRotation
00162         (
00163             const pointField& points,
00164             const face& f,
00165             const point& anchor,
00166             const scalar tol
00167         );
00168 
00169 
00170 public:
00171 
00172     //- Runtime type information
00173     TypeName("coupled");
00174 
00175 
00176     // Constructors
00177 
00178         //- Construct from components
00179         coupledPolyPatch
00180         (
00181             const word& name,
00182             const label size,
00183             const label start,
00184             const label index,
00185             const polyBoundaryMesh& bm
00186         );
00187 
00188         //- Construct from Istream
00189         coupledPolyPatch
00190         (
00191             Istream&,
00192             const label index, const polyBoundaryMesh&
00193         );
00194 
00195         //- Construct from dictionary
00196         coupledPolyPatch
00197         (
00198             const word& name,
00199             const dictionary& dict,
00200             const label index,
00201             const polyBoundaryMesh& bm
00202         );
00203 
00204         //- Construct as copy, resetting the boundary mesh
00205         coupledPolyPatch(const coupledPolyPatch&, const polyBoundaryMesh&);
00206 
00207         //- Construct given the original patch and resetting the
00208         //  face list and boundary mesh information
00209         coupledPolyPatch
00210         (
00211             const coupledPolyPatch& pp,
00212             const polyBoundaryMesh& bm,
00213             const label index,
00214             const label newSize,
00215             const label newStart
00216         );
00217 
00218 
00219     // Destructor
00220 
00221         virtual ~coupledPolyPatch();
00222 
00223 
00224     // Member Functions
00225 
00226         // Access
00227 
00228             //- Return true because this patch is coupled
00229             virtual bool coupled() const
00230             {
00231                 return true;
00232             }
00233 
00234 
00235             //- Are the coupled planes separated
00236             bool separated() const
00237             {
00238                 return separation_.size();
00239             }
00240 
00241             //- Return the offset (distance) vector from one side of the couple
00242             //  to the other
00243             const vectorField& separation() const
00244             {
00245                 return separation_;
00246             }
00247 
00248 
00249             //- Are the cyclic planes parallel
00250             bool parallel() const
00251             {
00252                 return forwardT_.size() == 0;
00253             }
00254 
00255             //- Return face transformation tensor
00256             const tensorField& forwardT() const
00257             {
00258                 return forwardT_;
00259             }
00260 
00261             //- Return neighbour-cell transformation tensor
00262             const tensorField& reverseT() const
00263             {
00264                 return reverseT_;
00265             }
00266 
00267 
00268         //- Initialize ordering for primitivePatch. Does not
00269         //  refer to *this (except for name() and type() etc.)
00270         virtual void initOrder(const primitivePatch&) const = 0;
00271 
00272         //- Return new ordering for primitivePatch.
00273         //  Ordering is -faceMap: for every face
00274         //  index of the new face -rotation:for every new face the clockwise
00275         //  shift of the original face. Return false if nothing changes
00276         //  (faceMap is identity, rotation is 0), true otherwise.
00277         virtual bool order
00278         (
00279             const primitivePatch&,
00280             labelList& faceMap,
00281             labelList& rotation
00282         ) const = 0;
00283 };
00284 
00285 
00286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00287 
00288 } // End namespace Foam
00289 
00290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00291 
00292 #endif
00293 
00294 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd