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

topoSet.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::topoSet
00026 
00027 Description
00028     General set of labels of mesh quantity (points, cells, faces).
00029 
00030     Contains various 'notImplemented' functions, but I do not want to make
00031     this class abstract since it is quite handy to work on topoSets.
00032 
00033 SourceFiles
00034     topoSet.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef topoSet_H
00039 #define topoSet_H
00040 
00041 #include <OpenFOAM/HashSet.H>
00042 #include <OpenFOAM/regIOobject.H>
00043 #include <OpenFOAM/labelList.H>
00044 #include <OpenFOAM/typeInfo.H>
00045 #include <OpenFOAM/autoPtr.H>
00046 #include <OpenFOAM/pointField.H>
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 
00054 class mapPolyMesh;
00055 class polyMesh;
00056 class primitiveMesh;
00057 
00058 /*---------------------------------------------------------------------------*\
00059                            Class topoSet Declaration
00060 \*---------------------------------------------------------------------------*/
00061 
00062 class topoSet
00063 :
00064     public regIOobject,
00065     public labelHashSet
00066 {
00067 
00068 protected:
00069 
00070     // Protected Member Functions
00071 
00072         //- Update map from map. Used to update cell/face labels
00073         //  after morphing
00074         void updateLabels(const labelList& map);
00075 
00076         //- Check validity of contents.
00077         void check(const label maxLabel);
00078 
00079         //- Write part of contents nicely formatted. Prints labels only.
00080         void writeDebug
00081         (
00082             Ostream& os,
00083             const label maxElem,
00084             topoSet::const_iterator& iter,
00085             label& elemI
00086         ) const;
00087 
00088         //- Write part of contents nicely formatted. Prints label
00089         //  and corresponding coordinate.
00090         void writeDebug
00091         (
00092             Ostream& os,
00093             const pointField& coords,
00094             const label maxElem,
00095             topoSet::const_iterator& iter,
00096             label& elemI
00097         ) const;
00098 
00099         //- Write labels and coordinates columnwise to os. Truncate to maxLen.
00100         void writeDebug
00101         (
00102             Ostream& os,
00103             const pointField& coords,
00104             const label maxLen
00105         ) const;
00106 
00107 
00108         //- Disallow default bitwise copy construct
00109         topoSet(const topoSet&);
00110 
00111 public:
00112 
00113     //- Runtime type information
00114     TypeName("topoSet");
00115 
00116 
00117     // Static
00118 
00119         //- Name of file set will use.
00120         static fileName localPath(const polyMesh& mesh, const word& name);
00121 
00122 
00123     // Declare run-time constructor selection table
00124 
00125         // For the direct constructor
00126         declareRunTimeSelectionTable
00127         (
00128             autoPtr,
00129             topoSet,
00130             word,
00131             (
00132                 const polyMesh& mesh,
00133                 const word& name,
00134                 readOption r,
00135                 writeOption w
00136             ),
00137             (mesh, name, r, w)
00138         );
00139 
00140         // For the constructor from size
00141         declareRunTimeSelectionTable
00142         (
00143             autoPtr,
00144             topoSet,
00145             size,
00146             (
00147                 const polyMesh& mesh,
00148                 const word& name,
00149                 const label size,
00150                 writeOption w
00151             ),
00152             (mesh, name, size, w)
00153         );
00154 
00155         // For the constructor as copy
00156         declareRunTimeSelectionTable
00157         (
00158             autoPtr,
00159             topoSet,
00160             set,
00161             (
00162                 const polyMesh& mesh,
00163                 const word& name,
00164                 const topoSet& set,
00165                 writeOption w
00166             ),
00167             (mesh, name, set, w)
00168         );
00169 
00170 
00171     // Constructors
00172 
00173 
00174         //- Construct from IOobject as explicitly passed type.
00175         //  Can't use typeName info here since subclasses not yet instantiated
00176         topoSet(const IOobject&, const word& wantedType);
00177 
00178         //- Construct from polyMesh and name
00179         topoSet
00180         (
00181             const polyMesh& mesh,
00182             const word& wantedType,
00183             const word& name,
00184             readOption r=MUST_READ,
00185             writeOption w=NO_WRITE
00186         );
00187 
00188         //- Construct empty from additional size of labelHashSet
00189         topoSet
00190         (
00191             const polyMesh& mesh,
00192             const word& name,
00193             const label,
00194             writeOption w=NO_WRITE
00195         );
00196 
00197         //- Construct empty from additional labelHashSet
00198         topoSet
00199         (
00200             const polyMesh& mesh,
00201             const word& name,
00202             const labelHashSet&,
00203             writeOption w=NO_WRITE
00204         );
00205 
00206         //- Construct empty from IOobject and size
00207         topoSet(const IOobject&, const label size);
00208 
00209         //- Construct from IOobject and labelHashSet
00210         topoSet(const IOobject&, const labelHashSet&);
00211 
00212 
00213 
00214         //- Clone
00215         autoPtr<topoSet> clone() const
00216         {
00217             notImplemented("autoPtr<topoSet> clone() const");
00218             return autoPtr<topoSet>(NULL);
00219         }
00220 
00221 
00222     // Selectors
00223 
00224         //- Return a pointer to a toposet read from file
00225         static autoPtr<topoSet> New
00226         (
00227             const word& setType,
00228             const polyMesh& mesh,
00229             const word& name,
00230             readOption r=MUST_READ,
00231             writeOption w=NO_WRITE
00232         );
00233 
00234         //- Return a pointer to a new toposet of given size
00235         static autoPtr<topoSet> New
00236         (
00237             const word& setType,
00238             const polyMesh& mesh,
00239             const word& name,
00240             const label size,
00241             writeOption w=NO_WRITE
00242         );
00243 
00244         //- Return a pointer to a new toposet as copy of another toposet
00245         static autoPtr<topoSet> New
00246         (
00247             const word& setType,
00248             const polyMesh& mesh,
00249             const word& name,
00250             const topoSet& set,
00251             writeOption w=NO_WRITE
00252         );
00253 
00254 
00255     // Destructor
00256 
00257         virtual ~topoSet();
00258 
00259 
00260     // Member functions
00261 
00262         //- Invert contents. (insert all members 0..maxLen-1 which were not in
00263         //  set)
00264         virtual void invert(const label maxLen);
00265 
00266         //- Subset contents. Only elements present in both sets remain.
00267         virtual void subset(const topoSet& set);
00268 
00269         //- Add elements present in set.
00270         virtual void addSet(const topoSet& set);
00271 
00272         //- Delete elements present in set.
00273         virtual void deleteSet(const topoSet& set);
00274 
00275         //- Sync set across coupled patches.
00276         virtual void sync(const polyMesh& mesh);
00277 
00278         //- Write labels columnwise to os. Truncate to maxLen.
00279         virtual void writeDebug(Ostream& os, const label maxLen) const;
00280 
00281         //- Like above but also writes mesh related quantity
00282         //  (usually coordinate).
00283         virtual void writeDebug
00284         (
00285             Ostream& os,
00286             const primitiveMesh&,
00287             const label maxLen
00288         ) const;    // = 0;
00289 
00290         //- Write contents.
00291         virtual bool writeData(Ostream&) const;
00292 
00293         //- Update any stored data for new labels. Not implemented.
00294         virtual void updateMesh(const mapPolyMesh& morphMap);
00295 
00296         //- Return max allowable index (+1). Not implemented.
00297         virtual label maxSize(const polyMesh& mesh) const;  // = 0;
00298 
00299 
00300 
00301     // Member operators
00302 
00303         //- Copy labelHashSet part only
00304         void operator=(const topoSet&);
00305 
00306 };
00307 
00308 
00309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00310 
00311 } // End namespace Foam
00312 
00313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00314 
00315 #endif
00316 
00317 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines