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

sortLabelledTri.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     Foam::sortLabelledTri
00026 
00027 Description
00028     Helper class which when constructed with a triSurface
00029     sorts the faces according to region number (or rather constructs a
00030     mapping).
00031 
00032 SourceFiles
00033     sortLabelledTri.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef sortLabelledTri_H
00038 #define sortLabelledTri_H
00039 
00040 #include <OpenFOAM/labelList.H>
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 class sortLabelledTri;
00048 class triSurface;
00049 
00050 /*---------------------------------------------------------------------------*\
00051                          Class surfAndLabel Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 //- Hold surface and label
00055 class surfAndLabel
00056 {
00057     const triSurface* surfPtr_;
00058 
00059     label index_;
00060 
00061     // Private Classes
00062 
00063         //- scalar comparison function used for sorting
00064         class less
00065         {
00066         public:
00067 
00068             inline bool operator()
00069             (
00070                 const surfAndLabel& one,
00071                 const surfAndLabel& two
00072             ) const;
00073         };
00074 
00075 
00076 public:
00077 
00078     friend class sortLabelledTri;
00079 
00080     // Constructors
00081 
00082         //- Construct null
00083         surfAndLabel()
00084         :
00085             surfPtr_(NULL),
00086             index_(-1)
00087         {}
00088 
00089         //- Construct from surface and index
00090         surfAndLabel(const triSurface& surf, const label index)
00091         :
00092             surfPtr_(&surf),
00093             index_(index)
00094         {}
00095 };
00096 
00097 
00098 /*---------------------------------------------------------------------------*\
00099                            Class sortLabelledTri Declaration
00100 \*---------------------------------------------------------------------------*/
00101 
00102 class sortLabelledTri
00103 :
00104     public List<surfAndLabel>
00105 {
00106 
00107 public:
00108 
00109     // Constructors
00110 
00111         //- Construct from surface, sorting the faces according to patch
00112         sortLabelledTri(const triSurface&);
00113 
00114 
00115     // Member Functions
00116 
00117         // Access
00118 
00119             //- Set the labelList to those of sorted point indices
00120             void indices(labelList&) const;
00121 
00122             //- Return the list of sorted point indices
00123             labelList indices() const;
00124 };
00125 
00126 
00127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00128 
00129 } // End namespace Foam
00130 
00131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00132 
00133 #endif
00134 
00135 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines