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

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