FreeFOAM The Cross-Platform CFD Toolkit
readerDatabase.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::readerDatabase
26 
27 Description
28  Singleton caching Foam database and mesh and various. Used in Fv reader
29  to keep track of data inbetween callbacks.
30 
31 SourceFiles
32  readerDatabase.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef readerDatabase_H
37 #define readerDatabase_H
38 
39 #include <OpenFOAM/wordList.H>
40 #include <OpenFOAM/Time.H>
41 #include <OpenFOAM/polyMesh.H>
42 #include <OpenFOAM/label.H>
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class fvMesh;
51 class fvMeshSubset;
52 class Time;
53 class fileName;
54 class instant;
55 
56 /*---------------------------------------------------------------------------*\
57  Class readerDatabase Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 {
62  // Private data
63 
64  //- Names for protected Fieldview keywords. Gets set at construction
65  // time.
66  // Note: Should be static but this gives problem with construction
67  // order since *this is static as well.
68  HashTable<word> fieldviewNames_;
69 
70  // Private data
71 
72  //- Cached database
73  Time* runTimePtr_;
74 
75  //- Cached mesh, guaranteed uptodate with runTime.
76  fvMeshSubset* meshPtr_;
77 
78  //- Empty string or name of current set.
79  word setName_;
80 
81  //- Cell labels of polyHedra. Uptodate with meshPtr.
82  labelList polys_;
83 
84  //- All volScalarFields in all time directories
85  wordList volScalarNames_;
86 
87  //- All volVectorFields ,,
88  wordList volVectorNames_;
89 
90 
91  // Private Member Functions
92 
93  //- Gets cell numbers of all polyHedra
94  void getPolyHedra();
95 
96  //- Disallow default bitwise copy construct
98 
99  //- Disallow default bitwise assignment
100  void operator=(const readerDatabase&);
101 
102 
103 public:
104 
105  // Static
106 
107  //- Debug flag. Note: uses envvar instead of controlDict since
108  // *this is static as well. Might be initialized before controlDict
109  // read.
110  const static bool debug_;
111 
112 
113  // Constructors
114 
115  //- Construct null
116  readerDatabase();
117 
118 
119  // Destructor
120 
121  ~readerDatabase();
122 
123 
124  // Member Functions
125 
126  // Access
127 
128  const Time& runTime() const;
129 
130  const fvMesh& mesh() const;
131 
132  const labelList& polys() const;
133 
134  const wordList& volScalarNames() const;
135 
136  const wordList& volVectorNames() const;
137 
138  //- Get fieldview compatible name.
139  const word& getFvName(const word& foamName) const;
140 
141  // Edit
142 
143  //- Create database (if nessecary).
144  // Returns true if new Time created, false if old one reused.
145  // Optional fvMeshSubset using setName.
146  bool setRunTime
147  (
148  const fileName& rootDir,
149  const fileName& caseName,
150  const word& setName
151  );
152 
153  //- Forcibly load mesh.
154  void loadMesh();
155 
156  //- Set time (use this instead of database::setTime), updates
157  // mesh as well and returns mesh update status
158  polyMesh::readUpdateState setTime(const instant&, const label);
159 
160  //- Set volScalarNames, volVectorNames.
161  void setFieldNames(const wordList&, const wordList&);
162 };
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************ vim: set sw=4 sts=4 et: ************************ //