OpenFOAM logo
Open Source CFD Toolkit

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