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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::Function1Types::FunctionObjectTrigger
28 
29 Description
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 
52 Note
53 - does not implement integrate()
54 
55 SourceFiles
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 
69 namespace Foam
70 {
71 namespace Function1Types
72 {
73 
74 /*---------------------------------------------------------------------------*\
75  Class FunctionObjectTrigger Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 template<class Type>
79 class 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 
92 
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 
102 public:
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
118  (
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  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 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
FunctionObjectTrigger.C
Foam::Function1::entryName
const word & entryName
Definition: Function1.H:133
Function1.H
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:134
Foam::Function1Types::FunctionObjectTrigger::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: FunctionObjectTrigger.C:93
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:291
Foam::Function1Types::FunctionObjectTrigger::~FunctionObjectTrigger
virtual ~FunctionObjectTrigger()=default
Destructor.
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
labelList.H
Foam::Function1::obrPtr
const word const dictionary const objectRegistry * obrPtr
Definition: Function1.H:136
Foam::Function1Types::FunctionObjectTrigger::triggers
const labelList & triggers() const noexcept
Return the trigger indices.
Definition: FunctionObjectTriggerI.H:51
Foam::Function1Types::FunctionObjectTrigger::resetTriggers
void resetTriggers(const labelUList &indices)
Change the trigger indices.
Definition: FunctionObjectTriggerI.H:59
Foam::Function1Types::FunctionObjectTrigger::value
virtual Type value(const scalar) const
Return 0/1 value at current time.
Definition: FunctionObjectTriggerI.H:69
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Function1Types::FunctionObjectTrigger
Returns a 0/1 value corresponding to function object trigger levels.
Definition: FunctionObjectTrigger.H:92
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Function1Types::FunctionObjectTrigger::writeEntries
void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
Definition: FunctionObjectTrigger.C:76
Foam::List< label >
Foam::UList< label >
Foam::Function1Types::FunctionObjectTrigger::operator=
void operator=(const FunctionObjectTrigger< Type > &)=delete
No copy assignment.
Foam::Function1Types::FunctionObjectTrigger::integrate
virtual Type integrate(const scalar, const scalar) const
Integrate between two (scalar) values. Not implemented!
Definition: FunctionObjectTriggerI.H:79
Foam::Function1Types::FunctionObjectTrigger::clone
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: FunctionObjectTrigger.H:141
Foam::Function1Types::FunctionObjectTrigger::TypeName
TypeName("functionObjectTrigger")
Runtime type information.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Function1Types::FunctionObjectTrigger::FunctionObjectTrigger
FunctionObjectTrigger(const word &entryName, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from entry name, dictionary and optional registry.
Definition: FunctionObjectTrigger.C:46