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 | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::minMaxCondition
26 
27 Description
28  Minimum/maximum run time conditions. If the value type is not scalar,
29  the magnitude of the value is used in the evaluation.
30 
31 SourceFiles
32  minMaxCondition.H
33  minMaxCondition.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef minMaxCondition_H
38 #define minMaxCondition_H
39 
40 #include "runTimeCondition.H"
41 #include "NamedEnum.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class minMaxCondition Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class minMaxCondition
53 :
54  public runTimeCondition
55 {
56 public:
57 
58  // Public enumerations
59 
60  // Mode type
61  enum modeType
62  {
64  mdMax
65  };
66 
68 
69 
70 protected:
71 
72  // Protected data
73 
74  //- Name of function object to retrueve data from
76 
77  //- Mode
79 
80  //- Field names
81  const wordList fieldNames_;
82 
83  //- Value to compare
84  const scalar value_;
85 
86  //- Helper function to retrieve the value from the state dictionary
87  template<class Type>
88  void setValue
89  (
90  const word& valueType,
91  const word& fieldName,
92  scalar& value
93  ) const;
94 
95 
96 public:
97 
98  //- Runtime type information
99  TypeName("minMax");
100 
101  //- Constructor
103  (
104  const word& name,
105  const objectRegistry& obr,
106  const dictionary& dict,
107  functionObjectState& state
108  );
109 
110  //- Destructor
111  virtual ~minMaxCondition();
112 
113 
114  // Public Member Functions
115 
116  //- Apply the condition
117  virtual bool apply();
118 
119  //- Write
120  virtual void write();
121 };
122 
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 template<>
126 void minMaxCondition::setValue<Foam::scalar>
127 (
128  const word& valueType,
129  const word& fieldName,
130  scalar& value
131 ) const;
132 
133 } // End namespace Foam
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 #ifdef NoRepository
138  #include "minMaxConditionTemplates.C"
139 #endif
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #endif
144 
145 // ************************************************************************* //
Foam::runTimeCondition
Base class for run time conditions.
Definition: runTimeCondition.H:54
Foam::minMaxCondition::modeType
modeType
Definition: minMaxCondition.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::minMaxCondition::apply
virtual bool apply()
Apply the condition.
Definition: minMaxCondition.C:89
Foam::minMaxCondition::functionObjectName_
word functionObjectName_
Name of function object to retrueve data from.
Definition: minMaxCondition.H:74
Foam::minMaxCondition::value_
const scalar value_
Value to compare.
Definition: minMaxCondition.H:83
Foam::functionObjectState
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: functionObjectState.H:54
NamedEnum.H
Foam::minMaxCondition::fieldNames_
const wordList fieldNames_
Field names.
Definition: minMaxCondition.H:80
Foam::minMaxCondition::write
virtual void write()
Write.
Definition: minMaxCondition.C:159
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
runTimeCondition.H
Foam::runTimeCondition::name
virtual const word & name() const
Return the condition name.
Definition: runTimeCondition.C:92
Foam::minMaxCondition::~minMaxCondition
virtual ~minMaxCondition()
Destructor.
Definition: minMaxCondition.C:83
Foam::minMaxCondition::minMaxCondition
minMaxCondition(const word &name, const objectRegistry &obr, const dictionary &dict, functionObjectState &state)
Constructor.
Definition: minMaxCondition.C:66
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::minMaxCondition::mdMin
@ mdMin
Definition: minMaxCondition.H:62
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::minMaxCondition
Minimum/maximum run time conditions. If the value type is not scalar, the magnitude of the value is u...
Definition: minMaxCondition.H:51
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::minMaxCondition::modeTypeNames_
static const NamedEnum< modeType, 2 > modeTypeNames_
Definition: minMaxCondition.H:66
Foam::minMaxCondition::mdMax
@ mdMax
Definition: minMaxCondition.H:63
Foam::minMaxCondition::setValue
void setValue(const word &valueType, const word &fieldName, scalar &value) const
Helper function to retrieve the value from the state dictionary.
Definition: minMaxConditionTemplates.C:30
Foam::minMaxCondition::TypeName
TypeName("minMax")
Runtime type information.
minMaxConditionTemplates.C
Foam::minMaxCondition::mode_
modeType mode_
Mode.
Definition: minMaxCondition.H:77
Foam::NamedEnum< modeType, 2 >