OpenFOAM logo
Open Source CFD Toolkit

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