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  Provides a differencing option between two 'field value' function objects.
32 
33  Example of function object specification:
34  \verbatim
35  fieldValueDelta1
36  {
37  type fieldValueDelta;
38  libs ("libfieldFunctionObjects.so");
39  operation subtract;
40 
41  region1
42  {
43  ...
44  }
45 
46  region2
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::functionObject
70  Foam::functionObject::fieldValue
71  Foam::functionObjects::regionFunctionObject
72  Foam::functionObjects::logFiles
73 
74 SourceFiles
75  fieldValueDelta.C
76 
77 \*---------------------------------------------------------------------------*/
78 
79 #ifndef functionObjects_fieldValueDelta_H
80 #define functionObjects_fieldValueDelta_H
81 
82 #include "regionFunctionObject.H"
83 #include "logFiles.H"
84 #include "fieldValue.H"
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 namespace Foam
89 {
90 namespace functionObjects
91 {
92 namespace fieldValues
93 {
94 
95 /*---------------------------------------------------------------------------*\
96  Class fieldValueDelta Declaration
97 \*---------------------------------------------------------------------------*/
98 
99 class fieldValueDelta
100 :
101  public regionFunctionObject,
102  public logFiles
103 {
104 public:
105  //- Operation type enumeration
106  enum operationType
107  {
108  opAdd,
109  opSubtract,
110  opMin,
111  opMax,
112  opAverage
113  };
114 
115  //- Operation type names
116  static const NamedEnum<operationType, 5> operationTypeNames_;
117 
118 
119 private:
120 
121  // Private data
122 
123  //- Operation to apply to values
124  operationType operation_;
125 
126  //- Field value region object 1
127  autoPtr<fieldValue> region1Ptr_;
129  //- Field value region object 2
130  autoPtr<fieldValue> region2Ptr_;
131 
132 
133  // Private Member Functions
134 
135  //- Templated function to process common fields
136  template<class Type>
137  void processFields(bool& found);
139  //- Templated function to apply the operation
140  template<class Type>
141  Type applyOperation(const Type& value1, const Type& value2) const;
142 
143 
144 protected:
146  // Protected Member Functions
147 
148  //- Output file header information
149  virtual void writeFileHeader(const label i);
150 
151 
152 public:
153 
154  //- Run-time type information
155  TypeName("fieldValueDelta");
156 
157 
158  // Constructors
159 
160  //- Construct from Time and dictionary
162  (
163  const word& name,
164  const Time& runTime,
165  const dictionary& dict
166  );
167 
168 
169  //- Destructor
170  virtual ~fieldValueDelta();
171 
172 
173  // Public Member Functions
174 
175  //- Read from dictionary
176  virtual bool read(const dictionary&);
177 
178  //- Do nothing
179  virtual bool execute();
180 
181  //- Calculate and write
182  virtual bool write();
183 };
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace fieldValues
189 } // End namespace functionObjects
190 } // End namespace Foam
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #ifdef NoRepository
195  #include "fieldValueDeltaTemplates.C"
196 #endif
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 #endif
201 
202 // ************************************************************************* //
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
const word & name() const
Return the name of this functionObject.
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
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:52
TypeName("fieldValueDelta")
Run-time type information.
virtual bool write()
Calculate and write.
bool found
Namespace for OpenFOAM.