fieldValueDelta.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) 2012-2016 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::functionObjects::fieldValues::fieldValueDelta
26 
27 Group
28  grpFieldFunctionObjects
29 
30 Description
31  This function object provides a differencing option between two 'field
32  value' function objects.
33 
34  Example of function object specification:
35  \verbatim
36  fieldValueDelta1
37  {
38  type fieldValueDelta;
39  libs ("libfieldFunctionObjects.so");
40  operation subtract;
41 
42  fieldValue1
43  {
44  ...
45  }
46  fieldValue2
47  {
48  ...
49  }
50  }
51  \endverbatim
52 
53 Usage
54  \table
55  Property | Description | Required | Default value
56  type | type name: fieldValueDelta | yes |
57  \endtable
58 
59  The \c operation is one of:
60  \plaintable
61  add | add
62  subtract | subtract
63  min | minimum
64  max | maximum
65  average | average
66  \endplaintable
67 
68 See also
69  Foam::fieldValue
70 
71 SourceFiles
72  fieldValueDelta.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef functionObjects_fieldValueDelta_H
77 #define functionObjects_fieldValueDelta_H
78 
79 #include "writeFiles.H"
80 #include "fieldValue.H"
81 
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83 
84 namespace Foam
85 {
86 namespace functionObjects
87 {
88 namespace fieldValues
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class fieldValueDelta Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 class fieldValueDelta
96 :
97  public writeFiles
98 {
99 public:
100  //- Operation type enumeration
101  enum operationType
102  {
103  opAdd,
104  opSubtract,
105  opMin,
106  opMax,
107  opAverage
108  };
109 
110  //- Operation type names
111  static const NamedEnum<operationType, 5> operationTypeNames_;
112 
113 
114 private:
115 
116  // Private data
117 
118  //- Operation to apply to values
119  operationType operation_;
120 
121  //- Field value region object 1
122  autoPtr<fieldValue> region1Ptr_;
123 
124  //- Field value region object 2
125  autoPtr<fieldValue> region2Ptr_;
126 
127 
128  // Private Member Functions
129 
130  //- Templated function to process common fields
131  template<class Type>
132  void processFields(bool& found);
134  //- Templated function to apply the operation
135  template<class Type>
136  Type applyOperation(const Type& value1, const Type& value2) const;
137 
138 
139 protected:
141  // Protected Member Functions
142 
143  //- Output file header information
144  virtual void writeFileHeader(const label i);
145 
146 
147 public:
148 
149  //- Run-time type information
150  TypeName("fieldValueDelta");
151 
152 
153  // Constructors
154 
155  //- Construct from Time and dictionary
157  (
158  const word& name,
159  const Time& runTime,
160  const dictionary& dict
161  );
162 
163 
164  //- Destructor
165  virtual ~fieldValueDelta();
166 
167 
168  // Public Member Functions
169 
170  //- Read from dictionary
171  virtual bool read(const dictionary&);
172 
173  //- Do nothing
174  virtual bool execute();
175 
176  //- Calculate and write
177  virtual bool write();
178 };
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 } // End namespace fieldValues
184 } // End namespace functionObjects
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #ifdef NoRepository
190  #include "fieldValueDeltaTemplates.C"
191 #endif
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #endif
196 
197 // ************************************************************************* //
virtual void writeFileHeader(const label i)
Output file header information.
dictionary dict
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual bool read(const dictionary &)
Read from dictionary.
static const NamedEnum< operationType, 5 > operationTypeNames_
Operation type names.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const word & name() const
Return the name of this functionObject.
A class for handling words, derived from string.
Definition: word.H:59
fieldValueDelta(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
TypeName("fieldValueDelta")
Run-time type information.
virtual bool write()
Calculate and write.
bool found
Namespace for OpenFOAM.