Loading...
Searching...
No Matches
meshState.C
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-2023 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
27\*---------------------------------------------------------------------------*/
28
29#include "meshState.H"
30#include "Time.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
37
38
39// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
40
41bool Foam::meshState::getBoolEntry
42(
43 const dictionary& dict,
44 const word& keyword
45)
46{
47 bool value = false;
48 return dict.readIfPresent(keyword, value) && value;
49}
50
51
52void Foam::meshState::setBoolEntry
53(
55 const word& keyword,
56 bool on
57)
58{
59 if (on)
60 {
61 dict.set(keyword, true);
62 }
63 else
64 {
65 dict.remove(keyword);
66 }
67}
68
69
70// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71
72Foam::meshState::meshState
73(
74 const word& name,
75 const objectRegistry& obr,
76 const dictionary* content
77)
78:
79 IOdictionary
80 (
81 IOobject
82 (
83 name,
84 obr.time().system(),
85 obr,
86 IOobject::NO_READ,
87 IOobject::NO_WRITE,
88 IOobject::REGISTER
89 ),
90 content
91 ),
92 prevTimeIndex_(-1)
93{
99
100// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102void Foam::meshState::reset(const meshState& ms)
103{
105}
106
111}
112
117}
118
123}
124
129}
130
135}
136
141}
142
145{
146 return getBoolEntry(controlsDict(), "firstIteration");
147}
148
151{
152 return getBoolEntry(controlsDict(), "finalIteration");
153}
154
157{
158 return setBoolEntry(controlsDict(), "firstIteration", on);
159}
160
161
163{
164 return setBoolEntry(controlsDict(), "finalIteration", on);
165}
166
167
168// ************************************************************************* //
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
@ REGISTER
Request registration (bool: true).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition IOobject.C:456
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
Definition dictionary.C:481
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition dictionary.C:441
bool remove(const word &keyword)
Remove an entry specified by keyword.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition dictionary.C:765
void operator=(const dictionary &rhs)
Copy assignment.
Definition dictionary.C:886
dictionary & meshDict()
Return the dictionary of mesh data, typically populated by the polyMesh::checkXXX functions,...
Definition meshState.C:113
static const word controlsDictName
Name for "controls" sub-dictionary.
Definition meshState.H:100
static const word meshDictName
Name for "mesh" sub-dictionary.
Definition meshState.H:105
dictionary & controlsDict()
Return the dictionary of controls.
Definition meshState.C:101
bool isFinalIteration() const
True if "finalIteration" entry exists (in controls) and is set.
Definition meshState.C:143
bool isFirstIteration() const
True if "firstIteration" entry exists (in controls) and is set.
Definition meshState.C:137
void setFinalIteration(bool on)
Add/remove "finalIteration" entry (from controls).
Definition meshState.C:155
void setFirstIteration(bool on)
Add/remove "firstIteration" entry (from controls).
Definition meshState.C:149
static const word solverPerformanceDictName
Name for "solver" (solver performance) sub-dictionary.
Definition meshState.H:110
void reset(const meshState &ms)
Reset the dictionary.
Definition meshState.C:95
dictionary & solverPerformanceDict()
Return the dictionary of solver performance data which includes initial and final residuals for conve...
Definition meshState.C:125
Registry of regIOobjects.
A class for handling words, derived from Foam::string.
Definition word.H:66
auto & name
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
Definition POSIX.C:1704
dictionary dict