runTimeCondition.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) 2015 OpenFOAM Foundation
9 Copyright (C) 2016-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::functionObjects::runTimeControls::runTimeCondition
29
30Description
31 Base class for run time conditions
32
33SourceFiles
34 runTimeCondition.C
35 runTimeConditionNew.C
36 runTimeCondition.H
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef functionObjects_runTimeControls_runTimeCondition_H
41#define functionObjects_runTimeControls_runTimeCondition_H
42
43#include "stateFunctionObject.H"
44#include "dictionary.H"
45#include "autoPtr.H"
47#include "Switch.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53namespace functionObjects
54{
55namespace runTimeControls
56{
57
58/*---------------------------------------------------------------------------*\
59 Class runTimeCondition Declaration
60\*---------------------------------------------------------------------------*/
63{
64
65protected:
66
67 // Protected data
68
69 //- Condition name
70 word name_;
71
72 //- Reference to the object registry
73 const objectRegistry& obr_;
74
75 //- State
77
78 //- On/off switch
79 bool active_;
80
81 //- Reference to the condition dictionary
83
84 //- Group index - if applied, all conditions in a group must be
85 // satisfied before condition is met
86 label groupID_;
87
88
89 // Protected Member Functions
90
91 //- Set the condition dictionary (create if necessary)
93
94 //- Return const access to the conditions dictionary
95 const dictionary& conditionDict() const;
96
97 //- Return non-const access to the conditions dictionary
99
100
101public:
102
103 //- Runtime type information
104 TypeName("runTimeCondition");
105
106 //- Declare runtime constructor selection table
108 (
109 autoPtr,
112 (
113 const word& name,
114 const objectRegistry& obr,
115 const dictionary& dict,
117 ),
118 (name, obr, dict, state)
119 );
120
121
122 //- Constructor
124 (
125 const word& name,
126 const objectRegistry& obr,
127 const dictionary& dict,
129 );
130
131 //- Destructor
132 virtual ~runTimeCondition() = default;
133
134 //- Selector
136 (
137 const word& conditionName,
138 const objectRegistry& obr,
139 const dictionary& dict,
141 );
142
143 // Public Data
144
145 //- Switch to send output to Info
146 Switch log;
147
148
149 // Public Member Functions
150
151 //- Return the condition name
152 virtual const word& name() const;
153
154 //- Return the active flag
155 virtual bool active() const;
156
157 //- Return the group index
158 virtual label groupID() const;
159
160 //- Apply the condition
161 virtual bool apply() = 0;
162
163 //- Write
164 virtual void write() = 0;
165
166 //- Reset
167 virtual void reset() = 0;
168};
169
170
171// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172
173} // End namespace runTimeControls
174} // End namespace functionObjects
175} // End namespace Foam
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179#endif
180
181// ************************************************************************* //
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:78
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
declareRunTimeSelectionTable(autoPtr, runTimeCondition, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state),(name, obr, dict, state))
Declare runtime constructor selection table.
const objectRegistry & obr_
Reference to the object registry.
dictionary & conditionDict_
Reference to the condition dictionary.
dictionary & setConditionDict()
Set the condition dictionary (create if necessary)
label groupID_
Group index - if applied, all conditions in a group must be.
virtual label groupID() const
Return the group index.
const dictionary & conditionDict() const
Return const access to the conditions dictionary.
virtual bool apply()=0
Apply the condition.
static autoPtr< runTimeCondition > New(const word &conditionName, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Selector.
virtual bool active() const
Return the active flag.
TypeName("runTimeCondition")
Runtime type information.
virtual const word & name() const
Return the condition name.
Base class for function objects, adding functionality to read/write state information (data required ...
Registry of regIOobjects.
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73