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

edgeCollapser.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     Foam::edgeCollapser
00027 
00028 Description
00029     Does polyTopoChanges to remove edges. Can remove faces due to edge
00030     collapse but can not remove cells due to face removal!
00031     Also removes unused points.
00032 
00033 SourceFiles
00034     edgeCollapser.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef edgeCollapser_H
00039 #define edgeCollapser_H
00040 
00041 #include "labelList.H"
00042 #include "DynamicList.H"
00043 #include "typeInfo.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // Forward declaration of classes
00051 class polyMesh;
00052 class polyTopoChange;
00053 class face;
00054 class mapPolyMesh;
00055 
00056 /*---------------------------------------------------------------------------*\
00057                            Class edgeCollapser Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 class edgeCollapser
00061 {
00062     // Private data
00063 
00064         //- Reference to mesh
00065         const polyMesh& mesh_;
00066 
00067         //- For every point -1 or region number
00068         labelList pointRegion_;
00069 
00070         //- -1 or master vertex for region number
00071         DynamicList<label> pointRegionMaster_;
00072 
00073         //- Stack of free region numbers. Corresponds to -1 in pointRegionMaster
00074         SLList<label> freeRegions_;
00075 
00076 
00077     // Static Functions
00078 
00079         //- Find val in list. Search starts at start, continues to size-1.
00080         static label findIndex
00081         (
00082             const labelList&,
00083             const label start,
00084             const label size,
00085             const label val
00086         );
00087 
00088 
00089     // Private Member Functions
00090 
00091         //- Determine points connected through edgesToRemove_.
00092         //  Note: Only routine that uses edgesToRemove!
00093         label changePointRegion
00094         (
00095             const label pointI,
00096             const label oldRegion,
00097             const label newRegion
00098         );
00099 
00100         //- Whether point is master of region or has been removed
00101         bool pointRemoved(const label) const;
00102 
00103         //- Renumber f with new vertices. Removes duplicates.
00104         void filterFace(const label faceI, face&) const;
00105 
00106         //- Some debugging printing
00107         void printRegions() const;
00108 
00109         //- Collapse list of edges. Tries to find master to collapse to.
00110         void collapseEdges(const labelList& edgeLabels);
00111 
00112         //- Disallow default bitwise copy construct
00113         edgeCollapser(const edgeCollapser&);
00114 
00115         //- Disallow default bitwise assignment
00116         void operator=(const edgeCollapser&);
00117 
00118 
00119 public:
00120 
00121     //- Runtime type information
00122     ClassName("edgeCollapser");
00123 
00124 
00125     // Constructors
00126 
00127         //- Construct from mesh.
00128         edgeCollapser(const polyMesh& mesh);
00129 
00130 
00131     // Member Functions
00132 
00133         // Access
00134 
00135             //- For every point the region it belongs to or -1.
00136             const labelList& pointRegion() const
00137             {
00138                 return pointRegion_;
00139             }
00140 
00141             //- For every region the master (i.e. the point the region will
00142             //  be replaced by)
00143             const DynamicList<label>& pointRegionMaster() const
00144             {
00145                 return pointRegionMaster_;
00146             }
00147 
00148             //- Check that edge is not marked for anything
00149             bool unaffectedEdge(const label edgeI) const;
00150 
00151 
00152         // Edit
00153 
00154             //- Set edge to collapse and point to collapse it to.
00155             //  Return true if collapse is valid.
00156             //  (always true at the moment)
00157             bool collapseEdge(const label edgeI, const label master);
00158 
00159             //- Play commands into polyTopoChange to create mesh. Return true
00160             //  if anything changed.
00161             bool setRefinement(polyTopoChange&);
00162 
00163             void updateMesh(const mapPolyMesh&);
00164 };
00165 
00166 
00167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00168 
00169 } // End namespace Foam
00170 
00171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00172 
00173 #endif
00174 
00175 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd