FunctionObjectTrigger.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) 2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::Function1Types::FunctionObjectTrigger
28
29Description
30 Returns a 0/1 value corresponding to function object trigger levels.
31
32 Usage:
33 \verbatim
34 <entryName> functionObjectTrigger;
35 <entryName>Coeffs
36 {
37 triggers (1 3 5);
38 defaultValue false; // Optional
39 }
40 \endverbatim
41
42 Where:
43 \table
44 Property | Description | Required
45 triggers | List of active trigger states to check for | yes |
46 defaultValue | Treatment for unactivated trigger state | no | false
47 \endtable
48
49 In some circumstances, it can be useful to treat an unactivated trigger
50 as being true. This is the role of the "defaultValue" keyword.
51
52Note
53- does not implement integrate()
54
55SourceFiles
56 FunctionObjectTrigger.C
57 FunctionObjectTriggerI.H
58
59\*---------------------------------------------------------------------------*/
60
61#ifndef Function1Types_FunctionObjectTrigger_H
62#define Function1Types_FunctionObjectTrigger_H
63
64#include "Function1.H"
65#include "labelList.H"
66
67// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68
69namespace Foam
70{
71namespace Function1Types
72{
73
74/*---------------------------------------------------------------------------*\
75 Class FunctionObjectTrigger Declaration
76\*---------------------------------------------------------------------------*/
77
78template<class Type>
79class FunctionObjectTrigger
80:
81 public Function1<Type>
82{
83
84 // Private Data
85
86 //- Trigger indices when it is considered active
87 labelList triggers_;
88
89 //- Treatment for unactivated trigger state (true/false)
90 bool defaultValue_;
91
93 // Private Member Functions
94
95 //- Is the trigger considered active?
96 inline bool active() const;
97
98 //- Read the coefficients from the given dictionary
99 void read(const dictionary& coeffs);
100
101
102public:
103
104 //- Runtime type information
105 TypeName("functionObjectTrigger");
106
107
108 // Generated Methods
109
110 //- No copy assignment
111 void operator=(const FunctionObjectTrigger<Type>&) = delete;
112
113
114 // Constructors
115
116 //- Construct from entry name, dictionary and optional registry
119 const word& entryName,
120 const dictionary& dict,
121 const objectRegistry* obrPtr = nullptr
122 );
123
124 //- Copy construct
126
127 //- Construct and return a clone
128 virtual tmp<Function1<Type>> clone() const
129 {
131 }
132
133
134 //- Destructor
135 virtual ~FunctionObjectTrigger() = default;
136
137
138 // Member Functions
139
140 //- Return the trigger indices
141 inline const labelList& triggers() const noexcept;
142
143 //- Change the trigger indices
144 inline void resetTriggers(const labelUList& indices);
145
146
147 //- Return 0/1 value at current time
148 virtual inline Type value(const scalar /*unused*/) const;
149
150 //- Integrate between two (scalar) values. Not implemented!
151 virtual inline Type integrate(const scalar, const scalar) const;
152
153 //- Write in dictionary format
154 virtual void writeData(Ostream& os) const;
155
156 //- Write coefficient entries in dictionary format
157 virtual void writeEntries(Ostream& os) const;
158};
159
160
161// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162
163} // End namespace Function1Types
164} // End namespace Foam
165
166// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167
168#include "FunctionObjectTriggerI.H"
169
170#ifdef NoRepository
171 #include "FunctionObjectTrigger.C"
172#endif
173
174// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175
176#endif
177
178// ************************************************************************* //
Returns a 0/1 value corresponding to function object trigger levels.
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
void operator=(const FunctionObjectTrigger< Type > &)=delete
No copy assignment.
virtual void writeData(Ostream &os) const
Write in dictionary format.
virtual ~FunctionObjectTrigger()=default
Destructor.
virtual void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
virtual Type value(const scalar) const
Return 0/1 value at current time.
const labelList & triggers() const noexcept
Return the trigger indices.
virtual Type integrate(const scalar, const scalar) const
Integrate between two (scalar) values. Not implemented!
void resetTriggers(const labelUList &indices)
Change the trigger indices.
TypeName("functionObjectTrigger")
Runtime type information.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
const word const dictionary & dict
Definition: Function1.H:134
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
const word & entryName
Definition: Function1.H:133
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
const direction noexcept
Definition: Scalar.H:223
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73