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

meshDualiser.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     meshDualiser
00026 
00027 Description
00028     Creates dual of polyMesh. Every point becomes a cell (or multiple cells
00029     for feature points), a walk around every edge creates faces between them.
00030 
00031     Put all points you want in the final mesh into featurePoints; all edge(mid)s
00032     you want in the final mesh into featureEdges; all face(centre)s in
00033     faceFaces.
00034 
00035     Usually to preserve boundaries:
00036         - all boundary faces are featureFaces
00037         - all edges and points inbetween different patches are
00038           featureEdges/points.
00039 
00040     In same way you can also preserve internal faces (e.g. faceZones)
00041 
00042 SourceFiles
00043     meshDualiser.C
00044 
00045 \*---------------------------------------------------------------------------*/
00046 
00047 #ifndef meshDualiser_H
00048 #define meshDualiser_H
00049 
00050 #include <OpenFOAM/DynamicList.H>
00051 #include <OpenFOAM/PackedBoolList.H>
00052 #include <OpenFOAM/boolList.H>
00053 #include <OpenFOAM/typeInfo.H>
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 namespace Foam
00058 {
00059 
00060 class polyMesh;
00061 class polyTopoChange;
00062 
00063 /*---------------------------------------------------------------------------*\
00064                            Class meshDualiser Declaration
00065 \*---------------------------------------------------------------------------*/
00066 
00067 class meshDualiser
00068 {
00069     // Private data
00070 
00071         const polyMesh& mesh_;
00072 
00073         //- From point on cell to dual cell. Either single entry or
00074         //  one entry per pointCells
00075         labelListList pointToDualCells_;
00076 
00077         //- From point to dual point (or -1 if not feature point).
00078         labelList pointToDualPoint_;
00079 
00080         //- From cell to dual point. All cells become point
00081         labelList cellToDualPoint_;
00082 
00083         //- From face to dual point (or -1 if not feature face)
00084         labelList faceToDualPoint_;
00085 
00086         //- From edge to dual point (or -1 if not feature edge)
00087         labelList edgeToDualPoint_;
00088 
00089 
00090     // Private Member Functions
00091 
00092         static void checkPolyTopoChange(const polyTopoChange&);
00093 
00094         static void dumpPolyTopoChange(const polyTopoChange&, const fileName&);
00095 
00096         //- Find dual cell given point and cell
00097         label findDualCell(const label cellI, const label pointI) const;
00098 
00099         //- Helper function to generate dualpoints on all boundary edges
00100         //  emanating from (boundary & feature) point
00101         void generateDualBoundaryEdges
00102         (
00103             const PackedBoolList&,
00104             const label pointI,
00105             polyTopoChange&
00106         );
00107 
00108         //- Check that owner and neighbour of face have same dual cell
00109         bool sameDualCell
00110         (
00111             const label faceI,
00112             const label pointI
00113         ) const;
00114 
00115         //- Add internal face
00116         label addInternalFace
00117         (
00118             const label masterPointI,
00119             const label masterEdgeI,
00120             const label masterFaceI,
00121 
00122             const bool edgeOrder,
00123             const label dualCell0,
00124             const label dualCell1,
00125             const DynamicList<label>& verts,
00126             polyTopoChange& meshMod
00127         ) const;
00128 
00129         //- Add boundary face
00130         label addBoundaryFace
00131         (
00132             const label masterPointI,
00133             const label masterEdgeI,
00134             const label masterFaceI,
00135 
00136             const label dualCellI,
00137             const label patchI,
00138             const DynamicList<label>& verts,
00139             polyTopoChange& meshMod
00140         ) const;
00141 
00142         //- Create internal faces walking around edge
00143         void createFacesAroundEdge
00144         (
00145             const bool splitFace,
00146             const PackedBoolList&,
00147             const label edgeI,
00148             const label startFaceI,
00149             polyTopoChange&,
00150             boolList& doneEFaces
00151         ) const;
00152 
00153         //- Create single internal face from internal face
00154         void createFaceFromInternalFace
00155         (
00156             const label faceI,
00157             label& fp,
00158             polyTopoChange&
00159         ) const;
00160 
00161         //- Creates boundary faces walking around point on patchI.
00162         void createFacesAroundBoundaryPoint
00163         (
00164             const label patchI,
00165             const label patchPointI,
00166             const label startFaceI,
00167             polyTopoChange&,
00168             boolList& donePFaces            // pFaces visited
00169         ) const;
00170 
00171         //- Disallow default bitwise copy construct
00172         meshDualiser(const meshDualiser&);
00173 
00174         //- Disallow default bitwise assignment
00175         void operator=(const meshDualiser&);
00176 
00177 
00178 public:
00179 
00180     //- Runtime type information
00181     ClassName("meshDualiser");
00182 
00183 
00184     // Constructors
00185 
00186         //- Construct from mesh
00187         meshDualiser(const polyMesh&);
00188 
00189 
00190     // Member Functions
00191 
00192         // Access
00193 
00194             //- From point on cell to dual cell. Either single entry or
00195             //  one entry per pointCells.
00196             const labelListList& pointToDualCells() const
00197             {
00198                 return pointToDualCells_;
00199             }
00200 
00201             //- From point to dual point (or -1 if not feature point).
00202             const labelList& pointToDualPoint() const
00203             {
00204                 return pointToDualPoint_;
00205             }
00206 
00207             //- From cell to dual point (at cell centre). All cells become
00208             //  points.
00209             const labelList& cellToDualPoint() const
00210             {
00211                 return cellToDualPoint_;
00212             }
00213 
00214             //- From face to dual point (at face centre; or -1 if not
00215             //  feature face).
00216             const labelList& faceToDualPoint() const
00217             {
00218                 return faceToDualPoint_;
00219             }
00220 
00221             //- From edge to dual point (at edge mid; or -1 if not feature
00222             //  edge).
00223             const labelList& edgeToDualPoint() const
00224             {
00225                 return edgeToDualPoint_;
00226             }
00227 
00228 
00229         // Edit
00230 
00231 
00232             //- Insert all changes into meshMod to convert the polyMesh into
00233             //  its dual.
00234             //  featureFaces  : faces where we want a point at the face centre
00235             //  featureEdges  : edges           ,,                 edge mid
00236             //  featurePoints : points          ,,    point. Two variants:
00237             //      singleCellFeaturePoints : point becomes one dualcell.
00238             //          Use this for e.g. convex boundary points.
00239             //      multiCellFeaturePoints : one dualcell per original cell
00240             //          around point. Use this for e.g. concave boundary points
00241             //          since it prevents big concave boundary cells.
00242             void setRefinement
00243             (
00244                 const bool splitFace,
00245                 const labelList& featureFaces,
00246                 const labelList& featureEdges,
00247                 const labelList& singleCellFeaturePoints,
00248                 const labelList& multiCellFeaturePoints,
00249                 polyTopoChange& meshMod
00250             );
00251 };
00252 
00253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00254 
00255 } // End namespace Foam
00256 
00257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00258 
00259 #endif
00260 
00261 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines