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

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