schemesLookup.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2020-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::schemesLookup
29
30Description
31 Selector class for finite area/finite volume differencing schemes.
32
33 The schemes data are treated as MUST_READ_IF_MODIFIED even if
34 the requested readOption is nominally MUST_READ or READ_IF_PRESENT.
35 This allows run-time modifications to behave as expected.
36
37 The optional fallback dictionary content for constructors is used
38 when a file is missing or for a NO_READ, with a null pointer being
39 treated like an empty dictionary.
40
41SourceFiles
42 schemesLookup.C
43 schemesLookupDetail.C
44
45\*---------------------------------------------------------------------------*/
46
47#ifndef Foam_schemesLookup_H
48#define Foam_schemesLookup_H
49
50#include "IOdictionary.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56
57/*---------------------------------------------------------------------------*\
58 Class schemesLookup Declaration
59\*---------------------------------------------------------------------------*/
61class schemesLookup
62:
63 public IOdictionary
64{
65 // Private Class
66
67 //- Lightweight grouping of scheme dictionary and default
68 struct lookupDetail
69 {
70 word name_;
71 dictionary dict_;
72 ITstream default_;
73
74
75 // Constructors
76
77 //- Construct empty with given sub-dictionary name
78 lookupDetail
79 (
80 const word& dictName,
81 const fileName& parentDictPath
82 );
83
84
85 // Member Functions
86
87 //- Clear dictionary and default scheme
88 void clear();
89
90 //- Return the default scheme (if any)
91 ITstream& fallback() const;
92
93 //- Lookup named scheme from dictionary, or return default
94 ITstream& lookup(const word& name) const;
95
96 //- Populate dictionary and/or default
97 void populate
98 (
99 const dictionary& dict,
100 const word& defaultName,
101 const bool mandatory = false
102 );
103
104 //- Write dictionary entry
105 void writeEntry(Ostream& os) const;
106
107 //- Write dictionary entry if non-empty
108 void writeEntryOptional(Ostream& os) const;
109 };
110
111
112 // Private Data
113
114 //- ddt
115 lookupDetail ddtSchemes_;
116
117 //- d2dt2
118 lookupDetail d2dt2Schemes_;
119
120 //- interpolation
121 lookupDetail interpSchemes_;
122
123 //- div
124 lookupDetail divSchemes_;
125
126 //- grad
127 lookupDetail gradSchemes_;
128
129 //- lnGrad (finiteArea)
130 lookupDetail lnGradSchemes_;
131
132 //- snGrad (finiteVolume)
133 lookupDetail snGradSchemes_;
134
135 //- laplacian
136 lookupDetail laplacianSchemes_;
137
138 //- flux
139 mutable dictionary fluxRequired_;
140 bool fluxRequiredDefault_;
141
142 //- True if default ddtScheme is steady-state
143 bool steady_;
144
145
146 // Private Member Functions
147
148 //- Clear dictionaries and streams before reading
149 void clear();
150
151 //- Check if default ddtScheme is steady-state
152 void checkSteady();
153
154 //- Read settings from the dictionary
155 void read(const dictionary& dict);
156
157 //- No copy construct
158 schemesLookup(const schemesLookup&) = delete;
159
160 //- No copy assignment
161 void operator=(const schemesLookup&) = delete;
162
163
164public:
165
166 //- Debug switch
167 static int debug;
168
169
170 // Constructors
171
172 //- Construct for objectRegistry, readOption, (system) dictionary name.
174 (
175 const objectRegistry& obr,
176 const IOobject::readOption rOpt,
177 const word& dictName,
178 const dictionary* fallback = nullptr
179 );
180
181 //- Construct for objectRegistry, (system) dictionary name
182 //- using the readOption from the registry.
184 (
185 const objectRegistry& obr,
186 const word& dictName,
187 const dictionary* fallback = nullptr
188 );
189
190
191 // Member Functions
192
193 //- The current schemes dictionary, respects the "select" keyword
194 const dictionary& schemesDict() const;
195
196 //- True if default ddtScheme is steady-state
197 bool steady() const noexcept
198 {
199 return steady_;
200 }
201
202 //- True if default ddtScheme is not steady-state
203 bool transient() const noexcept
204 {
205 return !steady_;
206 }
207
208
209 // Lookup Access
210
211 //- Get ddt scheme for given name, or default
212 ITstream& ddtScheme(const word& name) const;
213
214 //- Get d2dt2 scheme for given name, or default
215 ITstream& d2dt2Scheme(const word& name) const;
216
217 //- Get interpolation scheme for given name, or default
218 ITstream& interpolationScheme(const word& name) const;
219
220 //- Get div scheme for given name, or default
221 ITstream& divScheme(const word& name) const;
222
223 //- Get grad scheme for given name, or default
224 ITstream& gradScheme(const word& name) const;
225
226 //- Get (finiteArea) lnGrad scheme for given name, or default
227 ITstream& lnGradScheme(const word& name) const;
228
229 //- Get (finiteVolume) snGrad scheme for given name, or default
230 ITstream& snGradScheme(const word& name) const;
231
232 //- Get laplacian scheme for given name, or default
233 ITstream& laplacianScheme(const word& name) const;
234
235 //- Get flux-required for given name, or default
236 void setFluxRequired(const word& name) const;
237
238 //- Set flux-required for given name (mutable)
239 bool fluxRequired(const word& name) const;
240
241
242 // Read Access
243
244 //- Access ddt schemes dictionary
245 const dictionary& ddtSchemes() const noexcept
246 {
247 return ddtSchemes_.dict_;
248 }
249
250 //- Access d2dt2 schemes dictionary
251 const dictionary& d2dt2Schemes() const noexcept
252 {
253 return d2dt2Schemes_.dict_;
254 }
255
256 //- Access interpolation schemes dictionary
258 {
259 return interpSchemes_.dict_;
260 }
261
262 //- Access div schemes dictionary
263 const dictionary& divSchemes() const noexcept
264 {
265 return divSchemes_.dict_;
266 }
267
268 //- Access grad schemes dictionary
269 const dictionary& gradSchemes() const noexcept
270 {
271 return gradSchemes_.dict_;
272 }
273
274 //- Access lnGrad schemes dictionary (finiteArea)
275 const dictionary& lnGradSchemes() const noexcept
276 {
277 return lnGradSchemes_.dict_;
278 }
279
280 //- Access snGrad schemes dictionary (finiteVolume)
281 const dictionary& snGradSchemes() const noexcept
282 {
283 return snGradSchemes_.dict_;
284 }
285
286 //- Access laplacian schemes dictionary
288 {
289 return laplacianSchemes_.dict_;
290 }
291
292 //- Access to flux required dictionary
293 const dictionary& fluxRequired() const noexcept
294 {
295 return fluxRequired_;
296 }
297
298
299 // Edit Access
300
301 //- Access ddt schemes dictionary
303 {
304 return ddtSchemes_.dict_;
305 }
306
307 //- Access d2dt2 schemes dictionary
309 {
310 return d2dt2Schemes_.dict_;
311 }
312
313 //- Access interpolation schemes dictionary
315 {
316 return interpSchemes_.dict_;
317 }
318
319 //- Access div schemes dictionary
321 {
322 return divSchemes_.dict_;
323 }
324
325 //- Access grad schemes dictionary
327 {
328 return gradSchemes_.dict_;
329 }
330
331 //- Access lnGrad schemes dictionary (finiteArea)
333 {
334 return lnGradSchemes_.dict_;
335 }
336
337 //- Access snGrad schemes dictionary (finiteVolume)
339 {
340 return snGradSchemes_.dict_;
341 }
342
343 //- Access laplacian schemes dictionary
345 {
346 return laplacianSchemes_.dict_;
347 }
348
349 //- Access to flux required dictionary
351 {
352 return fluxRequired_;
353 }
354
355
356 // Read
357
358 //- Read schemes from IOdictionary, respects the "select" keyword
359 bool read();
360
361
362 // Write
363
364 //- Write dictionary (possibly modified) settings
365 void writeDicts(Ostream& os) const;
366};
367
368
369// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
370
371} // End namespace Foam
372
373// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
374
375#endif
376
377// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
readOption
Enumeration defining the read options.
Definition: IOobject.H:177
An input stream of tokens.
Definition: ITstream.H:56
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
const word & name() const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionaryI.H:60
A class for handling file names.
Definition: fileName.H:76
Registry of regIOobjects.
Lookup type of boundary radiation properties.
Definition: lookup.H:66
Selector class for finite area/finite volume differencing schemes.
Definition: schemesLookup.H:63
ITstream & ddtScheme(const word &name) const
Get ddt scheme for given name, or default.
ITstream & d2dt2Scheme(const word &name) const
Get d2dt2 scheme for given name, or default.
bool steady() const noexcept
True if default ddtScheme is steady-state.
const dictionary & interpolationSchemes() const noexcept
Access interpolation schemes dictionary.
void setFluxRequired(const word &name) const
Get flux-required for given name, or default.
const dictionary & gradSchemes() const noexcept
Access grad schemes dictionary.
ITstream & lnGradScheme(const word &name) const
Get (finiteArea) lnGrad scheme for given name, or default.
ITstream & divScheme(const word &name) const
Get div scheme for given name, or default.
ITstream & snGradScheme(const word &name) const
Get (finiteVolume) snGrad scheme for given name, or default.
const dictionary & ddtSchemes() const noexcept
Access ddt schemes dictionary.
bool transient() const noexcept
True if default ddtScheme is not steady-state.
const dictionary & d2dt2Schemes() const noexcept
Access d2dt2 schemes dictionary.
dictionary & ddtSchemes() noexcept
Access ddt schemes dictionary.
const dictionary & schemesDict() const
The current schemes dictionary, respects the "select" keyword.
dictionary & divSchemes() noexcept
Access div schemes dictionary.
const dictionary & divSchemes() const noexcept
Access div schemes dictionary.
const dictionary & laplacianSchemes() const noexcept
Access laplacian schemes dictionary.
dictionary & gradSchemes() noexcept
Access grad schemes dictionary.
dictionary & d2dt2Schemes() noexcept
Access d2dt2 schemes dictionary.
dictionary & fluxRequired() noexcept
Access to flux required dictionary.
const dictionary & lnGradSchemes() const noexcept
Access lnGrad schemes dictionary (finiteArea)
void writeDicts(Ostream &os) const
Write dictionary (possibly modified) settings.
static int debug
Debug switch.
dictionary & laplacianSchemes() noexcept
Access laplacian schemes dictionary.
ITstream & laplacianScheme(const word &name) const
Get laplacian scheme for given name, or default.
dictionary & interpolationSchemes() noexcept
Access interpolation schemes dictionary.
const dictionary & fluxRequired() const noexcept
Access to flux required dictionary.
ITstream & interpolationScheme(const word &name) const
Get interpolation scheme for given name, or default.
dictionary & snGradSchemes() noexcept
Access snGrad schemes dictionary (finiteVolume)
ITstream & gradScheme(const word &name) const
Get grad scheme for given name, or default.
bool read()
Read schemes from IOdictionary, respects the "select" keyword.
dictionary & lnGradSchemes() noexcept
Access lnGrad schemes dictionary (finiteArea)
const dictionary & snGradSchemes() const noexcept
Access snGrad schemes dictionary (finiteVolume)
A class for handling words, derived from Foam::string.
Definition: word.H:68
patchWriters clear()
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
dictionary dict