Loading...
Searching...
No Matches
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-2024 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 Foam_Function1Types_FunctionObjectTrigger_H
62#define Foam_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>
80:
81 public Function1<Type>
82{
83 // Private Data
84
85 //- Trigger indices when it is considered active
86 labelList triggers_;
87
88 //- Treatment for unactivated trigger state (true/false)
89 bool defaultValue_;
90
91
92 // Private Member Functions
93
94 //- Is the trigger considered active?
95 inline bool active() const;
96
97 //- Read the coefficients from the given dictionary
98 void read(const dictionary& coeffs);
99
100
101public:
102
103 //- Runtime type information
104 TypeName("functionObjectTrigger");
105
106
107 // Generated Methods
108
109 //- No copy assignment
110 void operator=(const FunctionObjectTrigger<Type>&) = delete;
111
112
113 // Constructors
114
115 //- Construct from entry name, dictionary and optional registry
117 (
118 const word& entryName,
119 const dictionary& dict,
120 const objectRegistry* obrPtr = nullptr
121 );
122
123 //- Copy construct
125
126 //- Return a clone
127 virtual tmp<Function1<Type>> clone() const
128 {
129 return Function1<Type>::Clone(*this);
130 }
132
133 //- Destructor
134 virtual ~FunctionObjectTrigger() = default;
135
136
137 // Member Functions
138
139 //- Return the trigger indices
140 inline const labelList& triggers() const noexcept;
141
142 //- Change the trigger indices
143 inline void resetTriggers(const labelUList& indices);
144
145
146 //- Return 0/1 value at current time
147 virtual inline Type value(const scalar /*unused*/) const;
148
149 //- Integrate between two (scalar) values. Not implemented!
150 virtual inline Type integrate(const scalar, const scalar) const;
151
152 //- Write in dictionary format
153 virtual void writeData(Ostream& os) const;
155 //- Write coefficient entries in dictionary format
156 virtual void writeEntries(Ostream& os) const;
157};
158
159
160// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161
162} // End namespace Function1Types
163} // End namespace Foam
164
165// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
167#include "FunctionObjectTriggerI.H"
168
169#ifdef NoRepository
170 #include "FunctionObjectTrigger.C"
171#endif
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175#endif
176
177// ************************************************************************* //
Returns a 0/1 value corresponding to function object trigger levels.
virtual tmp< Function1< Type > > clone() const
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.
FunctionObjectTrigger(const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from entry name, dictionary and optional registry.
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.
Function1(const word &entryName, const objectRegistry *obrPtr=nullptr)
Construct from entry name.
Definition Function1.C:31
static tmp< Function1< Type > > Clone(const Derived &fun)
Clone a Function1.
Definition Function1.H:190
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Registry of regIOobjects.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68