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-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::schemesLookup
29 
30 Description
31  Selector class for finite area/finite volume differencing schemes.
32 
33 SourceFiles
34  schemesLookup.C
35  schemesLookupDetail.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef schemesLookup_H
40 #define schemesLookup_H
41 
42 #include "IOdictionary.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class schemesLookup Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class schemesLookup
54 :
55  public IOdictionary
56 {
57  // Private Class
58 
59  //- Lightweight grouping of scheme dictionary and default
60  struct lookupDetail
61  {
62  word name_;
63  dictionary dict_;
64  ITstream default_;
65 
66 
67  // Constructors
68 
69  //- Construct empty with given sub-dictionary name
70  lookupDetail
71  (
72  const word& dictName,
73  const fileName& parentDictPath
74  );
75 
76 
77  // Member Functions
78 
79  //- Clear dictionary and default scheme
80  void clear();
81 
82  //- Return the default scheme (if any)
83  ITstream& fallback() const;
84 
85  //- Lookup named scheme from dictionary, or return default
86  ITstream& lookup(const word& name) const;
87 
88  //- Populate dictionary and/or default
89  void populate
90  (
91  const dictionary& dict,
92  const word& defaultName,
93  const bool mandatory = false
94  );
95 
96  //- Write dictionary entry
97  void writeEntry(Ostream& os) const;
98 
99  //- Write dictionary entry if non-empty
100  void writeEntryOptional(Ostream& os) const;
101  };
102 
103 
104  // Private Data
105 
106  //- ddt
107  lookupDetail ddtSchemes_;
108 
109  //- d2dt2
110  lookupDetail d2dt2Schemes_;
111 
112  //- interpolation
113  lookupDetail interpSchemes_;
114 
115  //- div
116  lookupDetail divSchemes_;
117 
118  //- grad
119  lookupDetail gradSchemes_;
120 
121  //- lnGrad (finiteArea)
122  lookupDetail lnGradSchemes_;
123 
124  //- snGrad (finiteVolume)
125  lookupDetail snGradSchemes_;
126 
127  //- laplacian
128  lookupDetail laplacianSchemes_;
129 
130  //- flux
131  mutable dictionary fluxRequired_;
132  bool fluxRequiredDefault_;
133 
134  //- True if default ddtScheme is steady-state
135  bool steady_;
136 
137 
138  // Private Member Functions
139 
140  //- Clear dictionaries and streams before reading
141  void clear();
142 
143  //- Check if default ddtScheme is steady-state
144  void checkSteady();
145 
146  //- Read settings from the dictionary
147  void read(const dictionary& dict);
148 
149  //- No copy construct
150  schemesLookup(const schemesLookup&) = delete;
151 
152  //- No copy assignment
153  void operator=(const schemesLookup&) = delete;
154 
155 
156 public:
157 
158  //- Debug switch
159  static int debug;
160 
161 
162  // Constructors
163 
164  //- Construct for objectRegistry, system dictName, and optional
165  //- fallback dictionary content (for a NO_READ or missing file)
166  // A null dictionary pointer is treated like an empty dictionary.
168  (
169  const objectRegistry& obr,
170  const word& dictName,
171  const dictionary* fallback = nullptr
172  );
173 
174 
175  // Member Functions
176 
177  //- The current schemes dictionary, respects the "select" keyword
178  const dictionary& schemesDict() const;
179 
180  //- True if default ddtScheme is steady-state
181  bool steady() const noexcept
182  {
183  return steady_;
184  }
185 
186  //- True if default ddtScheme is not steady-state
187  bool transient() const noexcept
188  {
189  return !steady_;
190  }
191 
192 
193  // Lookup Access
194 
195  //- Get ddt scheme for given name, or default
196  ITstream& ddtScheme(const word& name) const;
197 
198  //- Get d2dt2 scheme for given name, or default
199  ITstream& d2dt2Scheme(const word& name) const;
200 
201  //- Get interpolation scheme for given name, or default
202  ITstream& interpolationScheme(const word& name) const;
203 
204  //- Get div scheme for given name, or default
205  ITstream& divScheme(const word& name) const;
206 
207  //- Get grad scheme for given name, or default
208  ITstream& gradScheme(const word& name) const;
209 
210  //- Get (finiteArea) lnGrad scheme for given name, or default
211  ITstream& lnGradScheme(const word& name) const;
212 
213  //- Get (finiteVolume) snGrad scheme for given name, or default
214  ITstream& snGradScheme(const word& name) const;
215 
216  //- Get laplacian scheme for given name, or default
217  ITstream& laplacianScheme(const word& name) const;
218 
219  //- Get flux-required for given name, or default
220  void setFluxRequired(const word& name) const;
221 
222  //- Set flux-required for given name (mutable)
223  bool fluxRequired(const word& name) const;
224 
225 
226  // Read Access
227 
228  //- Access ddt schemes dictionary
229  const dictionary& ddtSchemes() const noexcept
230  {
231  return ddtSchemes_.dict_;
232  }
233 
234  //- Access d2dt2 schemes dictionary
235  const dictionary& d2dt2Schemes() const noexcept
236  {
237  return d2dt2Schemes_.dict_;
238  }
239 
240  //- Access interpolation schemes dictionary
241  const dictionary& interpolationSchemes() const noexcept
242  {
243  return interpSchemes_.dict_;
244  }
245 
246  //- Access div schemes dictionary
247  const dictionary& divSchemes() const noexcept
248  {
249  return divSchemes_.dict_;
250  }
251 
252  //- Access grad schemes dictionary
253  const dictionary& gradSchemes() const noexcept
254  {
255  return gradSchemes_.dict_;
256  }
257 
258  //- Access lnGrad schemes dictionary (finiteArea)
259  const dictionary& lnGradSchemes() const noexcept
260  {
261  return lnGradSchemes_.dict_;
262  }
263 
264  //- Access snGrad schemes dictionary (finiteVolume)
265  const dictionary& snGradSchemes() const noexcept
266  {
267  return snGradSchemes_.dict_;
268  }
269 
270  //- Access laplacian schemes dictionary
271  const dictionary& laplacianSchemes() const noexcept
272  {
273  return laplacianSchemes_.dict_;
274  }
275 
276  //- Access to flux required dictionary
277  const dictionary& fluxRequired() const noexcept
278  {
279  return fluxRequired_;
280  }
281 
282 
283  // Edit Access
284 
285  //- Access ddt schemes dictionary
286  dictionary& ddtSchemes() noexcept
287  {
288  return ddtSchemes_.dict_;
289  }
290 
291  //- Access d2dt2 schemes dictionary
292  dictionary& d2dt2Schemes() noexcept
293  {
294  return d2dt2Schemes_.dict_;
295  }
296 
297  //- Access interpolation schemes dictionary
298  dictionary& interpolationSchemes() noexcept
299  {
300  return interpSchemes_.dict_;
301  }
302 
303  //- Access div schemes dictionary
304  dictionary& divSchemes() noexcept
305  {
306  return divSchemes_.dict_;
307  }
308 
309  //- Access grad schemes dictionary
310  dictionary& gradSchemes() noexcept
311  {
312  return gradSchemes_.dict_;
313  }
314 
315  //- Access lnGrad schemes dictionary (finiteArea)
316  dictionary& lnGradSchemes() noexcept
317  {
318  return lnGradSchemes_.dict_;
319  }
320 
321  //- Access snGrad schemes dictionary (finiteVolume)
322  dictionary& snGradSchemes() noexcept
323  {
324  return snGradSchemes_.dict_;
325  }
326 
327  //- Access laplacian schemes dictionary
328  dictionary& laplacianSchemes() noexcept
329  {
330  return laplacianSchemes_.dict_;
331  }
332 
333  //- Access to flux required dictionary
334  dictionary& fluxRequired() noexcept
335  {
336  return fluxRequired_;
337  }
338 
339 
340  // Read
341 
342  //- Read schemes from IOdictionary, respects the "select" keyword
343  bool read();
344 
345 
346  // Write
347 
348  //- Write dictionary (possibly modified) settings
349  void writeDicts(Ostream& os) const;
350 };
351 
352 
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 
355 } // End namespace Foam
356 
357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 
359 #endif
360 
361 // ************************************************************************* //
Foam::schemesLookup::d2dt2Schemes
const dictionary & d2dt2Schemes() const noexcept
Access d2dt2 schemes dictionary.
Definition: schemesLookup.H:234
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::schemesLookup::d2dt2Schemes
dictionary & d2dt2Schemes() noexcept
Access d2dt2 schemes dictionary.
Definition: schemesLookup.H:291
Foam::schemesLookup::divSchemes
const dictionary & divSchemes() const noexcept
Access div schemes dictionary.
Definition: schemesLookup.H:246
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::schemesLookup::snGradSchemes
const dictionary & snGradSchemes() const noexcept
Access snGrad schemes dictionary (finiteVolume)
Definition: schemesLookup.H:264
Foam::schemesLookup::gradScheme
ITstream & gradScheme(const word &name) const
Get grad scheme for given name, or default.
Definition: schemesLookup.C:213
Foam::schemesLookup::setFluxRequired
void setFluxRequired(const word &name) const
Get flux-required for given name, or default.
Definition: schemesLookup.C:241
Foam::schemesLookup::schemesDict
const dictionary & schemesDict() const
The current schemes dictionary, respects the "select" keyword.
Definition: schemesLookup.C:175
Foam::schemesLookup::lnGradSchemes
const dictionary & lnGradSchemes() const noexcept
Access lnGrad schemes dictionary (finiteArea)
Definition: schemesLookup.H:258
Foam::schemesLookup::laplacianSchemes
const dictionary & laplacianSchemes() const noexcept
Access laplacian schemes dictionary.
Definition: schemesLookup.H:270
Foam::schemesLookup::snGradSchemes
dictionary & snGradSchemes() noexcept
Access snGrad schemes dictionary (finiteVolume)
Definition: schemesLookup.H:321
Foam::baseIOdictionary::name
const word & name() const
Definition: baseIOdictionary.C:85
Foam::schemesLookup::gradSchemes
dictionary & gradSchemes() noexcept
Access grad schemes dictionary.
Definition: schemesLookup.H:309
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::schemesLookup::laplacianSchemes
dictionary & laplacianSchemes() noexcept
Access laplacian schemes dictionary.
Definition: schemesLookup.H:327
Foam::schemesLookup::laplacianScheme
ITstream & laplacianScheme(const word &name) const
Get laplacian scheme for given name, or default.
Definition: schemesLookup.C:234
Foam::schemesLookup::fluxRequired
const dictionary & fluxRequired() const noexcept
Access to flux required dictionary.
Definition: schemesLookup.H:276
Foam::dictionary::writeEntry
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
Definition: dictionaryIO.C:164
Foam::ITstream
An input stream of tokens.
Definition: ITstream.H:52
Foam::schemesLookup::ddtSchemes
dictionary & ddtSchemes() noexcept
Access ddt schemes dictionary.
Definition: schemesLookup.H:285
Foam::schemesLookup::interpolationScheme
ITstream & interpolationScheme(const word &name) const
Get interpolation scheme for given name, or default.
Definition: schemesLookup.C:199
Foam::schemesLookup::steady
bool steady() const noexcept
True if default ddtScheme is steady-state.
Definition: schemesLookup.H:180
Foam::dictionary::lookup
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.C:386
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::schemesLookup::snGradScheme
ITstream & snGradScheme(const word &name) const
Get (finiteVolume) snGrad scheme for given name, or default.
Definition: schemesLookup.C:227
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::schemesLookup::divScheme
ITstream & divScheme(const word &name) const
Get div scheme for given name, or default.
Definition: schemesLookup.C:206
Foam::schemesLookup::ddtSchemes
const dictionary & ddtSchemes() const noexcept
Access ddt schemes dictionary.
Definition: schemesLookup.H:228
Foam::schemesLookup::fluxRequired
dictionary & fluxRequired() noexcept
Access to flux required dictionary.
Definition: schemesLookup.H:333
IOdictionary.H
clear
patchWriters clear()
Foam::schemesLookup::ddtScheme
ITstream & ddtScheme(const word &name) const
Get ddt scheme for given name, or default.
Definition: schemesLookup.C:185
Foam::schemesLookup::interpolationSchemes
dictionary & interpolationSchemes() noexcept
Access interpolation schemes dictionary.
Definition: schemesLookup.H:297
Foam::schemesLookup::gradSchemes
const dictionary & gradSchemes() const noexcept
Access grad schemes dictionary.
Definition: schemesLookup.H:252
Foam::schemesLookup::debug
static int debug
Debug switch.
Definition: schemesLookup.H:158
Foam::schemesLookup::divSchemes
dictionary & divSchemes() noexcept
Access div schemes dictionary.
Definition: schemesLookup.H:303
Foam::schemesLookup::read
bool read()
Read schemes from IOdictionary, respects the "select" keyword.
Definition: schemesLookup.C:160
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::schemesLookup::writeDicts
void writeDicts(Ostream &os) const
Write dictionary (possibly modified) settings.
Definition: schemesLookup.C:255
Foam::schemesLookup::d2dt2Scheme
ITstream & d2dt2Scheme(const word &name) const
Get d2dt2 scheme for given name, or default.
Definition: schemesLookup.C:192
Foam::schemesLookup::interpolationSchemes
const dictionary & interpolationSchemes() const noexcept
Access interpolation schemes dictionary.
Definition: schemesLookup.H:240
Foam::schemesLookup::lnGradSchemes
dictionary & lnGradSchemes() noexcept
Access lnGrad schemes dictionary (finiteArea)
Definition: schemesLookup.H:315
Foam::schemesLookup
Selector class for finite area/finite volume differencing schemes.
Definition: schemesLookup.H:52
Foam::schemesLookup::lnGradScheme
ITstream & lnGradScheme(const word &name) const
Get (finiteArea) lnGrad scheme for given name, or default.
Definition: schemesLookup.C:220
Foam::dictionary::dictName
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionaryI.H:60