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

cellTable.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::cellTable
00027 
00028 Description
00029     The cellTable persistent data saved as a Map<dictionary>.
00030 
00031     The meshReader supports cellTable information.
00032 
00033     The <tt>constant/cellTable</tt> file is an @c IOMap<dictionary> that is
00034     used to save the information persistently. It contains the cellTable
00035     information of the following form:
00036 
00037     @verbatim
00038         (
00039             ID
00040             {
00041                 Label           WORD;
00042                 MaterialType    WORD;
00043                 MaterialId      INT;
00044                 PorosityId      INT;
00045                 ColorIdx        INT;
00046                 ...
00047             }
00048         ...
00049         )
00050     @endverbatim
00051 
00052     If the @a Label is missing, a value <tt>cellTable_{ID}</tt> will be
00053     inferred. If the @a MaterialType is missing, the value @a fluid will
00054     be inferred.
00055 
00056 SourceFiles
00057     cellTable.C
00058 
00059 \*---------------------------------------------------------------------------*/
00060 
00061 #ifndef cellTable_H
00062 #define cellTable_H
00063 
00064 #include "polyMesh.H"
00065 #include "Map.H"
00066 #include "dictionary.H"
00067 #include "labelList.H"
00068 #include "wordReList.H"
00069 
00070 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00071 
00072 namespace Foam
00073 {
00074 
00075 /*---------------------------------------------------------------------------*\
00076                          Class cellTable Declaration
00077 \*---------------------------------------------------------------------------*/
00078 
00079 class cellTable
00080 :
00081     public Map<dictionary>
00082 {
00083     // Private data
00084 
00085        static const char* const defaultMaterial_;
00086 
00087 
00088     // Private Member Functions
00089 
00090         //- Map from cellTable ID => zone number
00091         Map<label> zoneMap() const;
00092 
00093         //- A contiguous list of cellTable names
00094         List<word> namesList() const;
00095 
00096         //- Add required entries - MaterialType
00097         void addDefaults();
00098 
00099         void setEntry(const label& id, const word& keyWord, const word& value);
00100 
00101         //- Disallow default bitwise copy construct
00102         cellTable(const cellTable&);
00103 
00104 
00105 public:
00106 
00107     // Constructors
00108 
00109         //- Construct null
00110         cellTable();
00111 
00112         //- Construct read from registry, name. instance
00113         cellTable
00114         (
00115             const objectRegistry&,
00116             const word& name = "cellTable",
00117             const fileName& instance = "constant"
00118         );
00119 
00120 
00121     //- Destructor
00122     ~cellTable();
00123 
00124 
00125     // Member Functions
00126 
00127         //- Append to the end, return index
00128         label append(const dictionary&);
00129 
00130         //- Return index corresponding to name
00131         //  returns -1 if not found
00132         label findIndex(const word& name) const;
00133 
00134         //- Return the name corresponding to id
00135         //  returns cellTable_ID if not otherwise defined
00136         word name(const label& id) const;
00137 
00138         //- Return a Map of (id => name)
00139         Map<word> names() const;
00140 
00141         //- Return a Map of (id => names) selected by patterns
00142         Map<word> names(const List<wordRe>& patterns) const;
00143 
00144         //- Return a Map of (id => name) for materialType (fluid | solid | shell)
00145         Map<word> selectType(const word& materialType) const;
00146 
00147         //- Return a Map of (id => name) for fluids
00148         Map<word> fluids() const;
00149 
00150         //- Return a Map of (id => name) for shells
00151         Map<word> shells() const;
00152 
00153         //- Return a Map of (id => name) for solids
00154         Map<word> solids() const;
00155 
00156         //- Return a Map of (id => fluid|solid|shell)
00157         Map<word> materialTypes() const;
00158 
00159         //- Assign material Type
00160         void setMaterial(const label&, const word&);
00161 
00162         //- Assign name
00163         void setName(const label&, const word&);
00164 
00165         //- Assign default name if not already set
00166         void setName(const label&);
00167 
00168         //- Read constant/cellTable
00169         void readDict
00170         (
00171             const objectRegistry&,
00172             const word& name = "cellTable",
00173             const fileName& instance = "constant"
00174         );
00175 
00176         //- write constant/cellTable for later reuse
00177         void writeDict
00178         (
00179             const objectRegistry&,
00180             const word& name = "cellTable",
00181             const fileName& instance = "constant"
00182         ) const;
00183 
00184 
00185     // Member Operators
00186 
00187         //- Assignment
00188         void operator=(const cellTable&);
00189 
00190         //- Assign from Map<dictionary>
00191         void operator=(const Map<dictionary>&);
00192 
00193         //- Assign from cellZones
00194         void operator=(const polyMesh&);
00195 
00196 
00197     // Friend Functions
00198 
00199         //- Classify tableIds into cellZones according to the cellTable
00200         void addCellZones(polyMesh&, const labelList& tableIds) const;
00201 
00202         //- Combine tableIds together
00203         //  each dictionary entry is a wordList
00204         void combine(const dictionary&, labelList& tableIds);
00205 };
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 } // End namespace Foam
00210 
00211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00212 
00213 #endif
00214 
00215 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd