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 -------------------------------------------------------------------------------
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::functionObjects::runTimeControls::runTimeCondition
29 
30 Description
31  Base class for run time conditions
32 
33 SourceFiles
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"
46 #include "runTimeSelectionTables.H"
47 #include "Switch.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 namespace functionObjects
54 {
55 namespace runTimeControls
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class runTimeCondition Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class runTimeCondition
63 {
64 
65 protected:
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 
101 public:
102 
103  //- Runtime type information
104  TypeName("runTimeCondition");
105 
106  //- Declare runtime constructor selection table
108  (
109  autoPtr,
111  dictionary,
112  (
113  const word& name,
114  const objectRegistry& obr,
115  const dictionary& dict,
116  stateFunctionObject& state
117  ),
118  (name, obr, dict, state)
119  );
120 
121 
122  //- Constructor
124  (
125  const word& name,
126  const objectRegistry& obr,
127  const dictionary& dict,
128  stateFunctionObject& state
129  );
130 
131  //- Destructor
132  virtual ~runTimeCondition() = default;
133 
134  //- Selector
136  (
137  const word& conditionName,
138  const objectRegistry& obr,
139  const dictionary& dict,
140  stateFunctionObject& state
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 } // End namespace runTimeControls
174 } // End namespace functionObjects
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
virtual bool apply()=0
Apply the condition.
dictionary dict
const objectRegistry & obr_
Reference to the object registry.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
dictionary & setConditionDict()
Set the condition dictionary (create if necessary)
declareRunTimeSelectionTable(autoPtr, runTimeCondition, dictionary,(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state),(name, obr, dict, state))
Declare runtime constructor selection table.
TypeName("runTimeCondition")
Runtime type information.
A class for handling words, derived from Foam::string.
Definition: word.H:63
dictionary & conditionDict_
Reference to the condition dictionary.
label groupID_
Group index - if applied, all conditions in a group must be.
runTimeCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
Base class for function objects, adding functionality to read/write state information (data required ...
static autoPtr< runTimeCondition > New(const word &conditionName, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Selector.
virtual bool active() const
Return the active flag.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Macros to ease declaration of run-time selection tables.
virtual label groupID() const
Return the group index.
Registry of regIOobjects.
const dictionary & conditionDict() const
Return const access to the conditions dictionary.
Namespace for OpenFOAM.
virtual const word & name() const
Return the condition name.