OpenFOAM logo
Open Source CFD Toolkit

removeFaces.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     removeFaces
00027 
00028 Description
00029     Given list of faces to remove insert all the topology changes.
00030 
00031 SourceFiles
00032     removeFaces.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef removeFaces_H
00037 #define removeFaces_H
00038 
00039 #include "mathematicalConstants.H"
00040 #include "labelList.H"
00041 #include "Map.H"
00042 #include "labelHashSet.H"
00043 #include "boolList.H"
00044 #include "typeInfo.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 // Class forward declarations
00052 class primitiveMesh;
00053 class polyMesh;
00054 class polyTopoChange;
00055 class edge;
00056 class face;
00057 class mapPolyMesh;
00058 
00059 /*---------------------------------------------------------------------------*\
00060                            Class removeFaces Declaration
00061 \*---------------------------------------------------------------------------*/
00062 
00063 class removeFaces
00064 {
00065     // Private data
00066 
00067         //- Reference to mesh
00068         const polyMesh& mesh_;
00069 
00070         //- Minimum cos of angle between faces to be considered aligned.
00071         //  (and thus candidates for merging)
00072         const scalar minCos_;
00073 
00074 
00075     // Private Static Functions
00076 
00077         //- Next index in list
00078         static label nexti(const label, const label index);
00079 
00080         //- Previous index in list
00081         static label previ(const label, const label index);
00082 
00083         //- Return true if f0 and f1 (with shared edge e) use the points
00084         //  of the edge in reverse order.
00085         static bool sameFaceOrdering
00086         (
00087             const edge& e,
00088             const face& f0,
00089             const label f0Start,    // index of edge start on f0
00090             const face& f1,
00091             const label f1Start     // index of edge start on f1
00092         );
00093 
00094 
00095     // Private Member Functions
00096 
00097         // Detection of valid coarsening patterns
00098 
00099             //- Get cos of angle between two faces shared by edge.
00100             //  If checkOrder it checks the order of shared face points and
00101             //  reverses the angle if nessecary.
00102             scalar faceCos
00103             (
00104                 const label face0I,
00105                 const label face1I,
00106                 const bool checkOrder,
00107                 const label sharedEdgeI
00108             ) const;
00109 
00110         // Detection of coarsening influence
00111 
00112             //- Get patch, zone info for faceI
00113             void getFaceInfo
00114             (
00115                 const label faceI,
00116 
00117                 label& patchID,
00118                 label& zoneID,
00119                 label& zoneFlip
00120             ) const;
00121 
00122             //- Count number of remaining faces using edgeI. Returns true if
00123             //  only two remaining and sets face0I, face1I to those two.
00124             bool getUnremovedFaces
00125             (
00126                 const labelHashSet& facesToRemove,
00127                 const label edgeI,
00128 
00129                 label& face0I,
00130                 label& face1I
00131             ) const;
00132 
00133             //- Count number of remaining edges using vertI. Returns true if 
00134             //  only two remaining and sets edge0I, edge1I to those two.
00135             bool getUnremovedEdges
00136             (
00137                 const Map<edge>& edgesToRemove,
00138                 const label vertI,
00139 
00140                 label& edge0I,
00141                 label& edge1I
00142             ) const;
00143 
00144             //- Checks vertI for if it can be removed. (so if only two edges
00145             //  using it and these two are in line).
00146             bool canBeRemoved
00147             (
00148                 const Map<edge>& edgesToRemove,
00149                 const label vertI
00150             ) const;
00151 
00152             //- Get all affected faces (including faces marked for removal)
00153             labelHashSet getFacesAffected
00154             (
00155                 const labelList& cellRegion,
00156                 const labelList& cellRegionMaster,
00157                 const labelHashSet& facesToRemove,
00158                 const Map<edge>& edgesToRemove,
00159                 const labelHashSet& pointsToRemove
00160             ) const;
00161 
00162 
00163         // Topological changes
00164 
00165             //- Return face with all pointsToRemove removed.
00166             face filterFace(const labelHashSet& pointsToRemove, const label)
00167                 const;
00168 
00169             //- Combines two faces, leaving out points on the edge they share
00170             //  and all points in pointsToRemove. Ordering of points is as
00171             //  face0.
00172             face mergeFace
00173             (
00174                 const labelHashSet& pointsToRemove,
00175                 const label face0I,
00176                 const label face1I,
00177                 const label sharedEdgeI
00178             ) const;
00179 
00180             //- Wrapper for meshMod.modifyFace. Reverses face if own>nei.
00181             void modFace
00182             (
00183                 const face& f,
00184                 const label masterFaceID,
00185                 const label own,
00186                 const label nei,
00187                 const bool flipFaceFlux,
00188                 const label newPatchID,
00189                 const bool removeFromZone,
00190                 const label zoneID,
00191                 const bool zoneFlip,
00192 
00193                 polyTopoChange& meshMod
00194             ) const;
00195 
00196 
00197         //- Change elements in cellRegion that are oldRegion to newRegion.
00198         //  Recurses to cell neighbours.
00199         void changeCellRegion
00200         (
00201             const label cellI,
00202             const label oldRegion,
00203             const label newRegion,
00204             labelList& cellRegion
00205         ) const;
00206 
00207 
00208 
00209         //- Disallow default bitwise copy construct
00210         removeFaces(const removeFaces&);
00211 
00212         //- Disallow default bitwise assignment
00213         void operator=(const removeFaces&);
00214 
00215 
00216 public:
00217 
00218     //- Runtime type information
00219     ClassName("removeFaces");
00220 
00221 
00222     // Constructors
00223 
00224         //- Construct from mesh and min cos of angle for faces/edges to be
00225         //  considered aligned.
00226         removeFaces
00227         (
00228             const polyMesh& mesh,
00229             const scalar minCos = Foam::cos(10.0/180.0 * mathematicalConstant::pi)
00230         );
00231 
00232 
00233     // Member Functions
00234 
00235         // Access
00236 
00237             scalar minCos() const
00238             {
00239                 return minCos_;
00240             }
00241 
00242         // Helper
00243 
00244             //- Given set of faces to pierce calculates:
00245             //  - region for connected cells
00246             //  - mastercell for each region
00247             //  - new set of faces which contains input set + additional ones
00248             //    where cells on both sides would have same mastercell.
00249             //  Returns number of regions.
00250             label compatibleRemoves
00251             (
00252                 const labelList& inPiercedFaces,
00253                 labelList& cellRegion,
00254                 labelList& cellRegionMaster,
00255                 labelList& outPiercedFaces
00256             ) const;
00257 
00258 
00259         // Topology changes
00260 
00261             //- Play commands into polyTopoChange to remove faces.
00262             void setRefinement
00263             (
00264                 const labelList& piercedFaces,
00265                 const labelList& cellRegion,
00266                 const labelList& cellRegionMaster,
00267                 polyTopoChange&
00268             ) const;
00269 
00270             //- Force recalculation of locally stored data on topological change
00271             void updateMesh(const mapPolyMesh&)
00272             {}
00273 };
00274 
00275 
00276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00277 
00278 } // End namespace Foam
00279 
00280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00281 
00282 #endif
00283 
00284 // ************************************************************************* //
For further information go to www.openfoam.org