minMaxCondition.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) 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::minMaxCondition
29 
30 Description
31  Minimum/maximum run time conditions. If the value type is not scalar,
32  the magnitude of the value is used in the evaluation.
33 
34 SourceFiles
35  minMaxCondition.H
36  minMaxCondition.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef functionObjects_runTimeControls_minMaxCondition_H
41 #define functionObjects_runTimeControls_minMaxCondition_H
42 
43 #include "runTimeCondition.H"
44 #include "Enum.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace functionObjects
51 {
52 namespace runTimeControls
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class minMaxCondition Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class minMaxCondition
60 :
61  public runTimeCondition
62 {
63 public:
64 
65  // Public enumerations
66 
67  // Mode type
68  enum modeType
69  {
70  mdMin,
71  mdMax
72  };
73 
74  static const Enum<modeType> modeTypeNames_;
75 
76 
77 protected:
78 
79  // Protected data
80 
81  //- Name of function object to retrueve data from
83 
84  //- Mode
86 
87  //- Field names
88  const wordList fieldNames_;
89 
90  //- Value to compare
91  const scalar value_;
92 
93  //- Helper function to retrieve the value from the state dictionary
94  template<class Type>
95  void setValue
96  (
97  const word& valueType,
98  const word& fieldName,
99  scalar& value
100  ) const;
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("minMax");
107 
108  //- Constructor
110  (
111  const word& name,
112  const objectRegistry& obr,
113  const dictionary& dict,
114  stateFunctionObject& state
115  );
116 
117  //- Destructor
118  virtual ~minMaxCondition() = default;
119 
120 
121  // Public Member Functions
122 
123  //- Apply the condition
124  virtual bool apply();
125 
126  //- Write
127  virtual void write();
128 
129  //- Reset
130  virtual void reset();
131 };
132 
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 template<>
136 void minMaxCondition::setValue<Foam::scalar>
137 (
138  const word& valueType,
139  const word& fieldName,
140  scalar& value
141 ) const;
142 
143 } // End namespace runTimeControls
144 } // End namespace functionObjects
145 } // End namespace Foam
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 #ifdef NoRepository
150  #include "minMaxConditionTemplates.C"
151 #endif
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #endif
156 
157 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
TypeName("minMax")
Runtime type information.
A class for handling words, derived from Foam::string.
Definition: word.H:63
word functionObjectName_
Name of function object to retrueve data from.
void setValue(const word &valueType, const word &fieldName, scalar &value) const
Helper function to retrieve the value from the state dictionary.
Base class for function objects, adding functionality to read/write state information (data required ...
Registry of regIOobjects.
minMaxCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
Namespace for OpenFOAM.
virtual const word & name() const
Return the condition name.