porting changes
[OpenFOAM-1.5.x.git] / src / conversion / meshTables / cellTable.H
blob1e15a6dc3af8686f6bcfd412092139a5f9deb6db
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::cellTable
28 Description
29     The cellTable persistent data saved as a Map<dictionary>.
31     The meshReader supports cellTable information.
33     The <tt>constant/cellTable</tt> file is an @c IOMap<dictionary> that is
34     used to save the information persistently. It contains the cellTable
35     information of the following form:
37     @verbatim
38         (
39             ID
40             {
41                 Label           WORD;
42                 MaterialType    WORD;
43                 MaterialId      INT;
44                 PorosityId      INT;
45                 ColorIdx        INT;
46                 ...
47             }
48         ...
49         )
50     @endverbatim
52     If the @a Label is missing, a value <tt>cellTable_{ID}</tt> will be
53     inferred. If the @a MaterialType is missing, the value @a fluid will
54     be inferred.
56 SourceFiles
57     cellTable.C
59 \*---------------------------------------------------------------------------*/
61 #ifndef cellTable_H
62 #define cellTable_H
64 #include "polyMesh.H"
65 #include "Map.H"
66 #include "dictionary.H"
67 #include "labelList.H"
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 namespace Foam
74 /*---------------------------------------------------------------------------*\
75                          Class cellTable Declaration
76 \*---------------------------------------------------------------------------*/
78 class cellTable
80     public Map<dictionary>
82     // Private data
84        static const char* const defaultMaterial_;
87     // Private Member Functions
89         //- Map from cellTable ID => zone number
90         Map<label> zoneMap() const;
92         //- A contiguous list of cellTable names
93         List<word> namesList() const;
95         //- Add required entries - MaterialType
96         void addDefaults();
98         void setEntry(const label& id, const word& keyWord, const word& value);
100         //- Disallow default bitwise copy construct
101         cellTable(const cellTable&);
104 public:
106     // Constructors
108         //- Construct null
109         cellTable();
111         //- Construct read from registry, name. instance
112         cellTable
113         (
114             const objectRegistry&,
115             const word& name = "cellTable",
116             const fileName& instance = "constant"
117         );
120     //- Destructor
121     ~cellTable();
124     // Member Functions
126         //- Append to the end, return index
127         label append(const dictionary&);
129         //- Return index corresponding to name
130         //  returns -1 if not found
131         label findIndex(const word& name) const;
133         //- Return the name corresponding to id
134         //  returns cellTable_ID if not otherwise defined
135         word name(const label& id) const;
137         //- Return a Map of (id => name)
138         Map<word> names() const;
140         //- Return a Map of (id => name) for materialType (fluid | solid | shell)
141         Map<word> selectType(const word& materialType) const;
143         //- Return a Map of (id => name) for fluids
144         Map<word> fluids() const;
146         //- Return a Map of (id => name) for shells
147         Map<word> shells() const;
149         //- Return a Map of (id => name) for solids
150         Map<word> solids() const;
152         //- Return a Map of (id => fluid|solid|shell)
153         Map<word> materialTypes() const;
155         //- Assign material Type
156         void setMaterial(const label&, const word&);
158         //- Assign name
159         void setName(const label&, const word&);
161         //- Assign default name if not already set
162         void setName(const label&);
164         //- Read constant/cellTable
165         void readDict
166         (
167             const objectRegistry&,
168             const word& name = "cellTable",
169             const fileName& instance = "constant"
170         );
172         //- write constant/cellTable for later reuse
173         void writeDict
174         (
175             const objectRegistry&,
176             const word& name = "cellTable",
177             const fileName& instance = "constant"
178         ) const;
181     // Member Operators
183         //- Assignment
184         void operator=(const cellTable&);
186         //- Assign from Map<dictionary>
187         void operator=(const Map<dictionary>&);
189         //- Assign from cellZones
190         void operator=(const polyMesh&);
193     // Friend Functions
195         //- Classify tableIds into cellZones according to the cellTable
196         void addCellZones(polyMesh&, const labelList& tableIds) const;
198         //- Combine tableIds together
199         //  each dictionary entry is a wordList
200         void combine(const dictionary&, labelList& tableIds);
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 } // End namespace Foam
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 #endif
211 // ************************************************************************* //