fieldValueDelta.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2019 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 Description
28  Provides a differencing option between two 'field value' function objects.
29 
30  Example of function object specification:
31  \verbatim
32  fieldValueDelta1
33  {
34  type fieldValueDelta;
35  libs ("libfieldFunctionObjects.so");
36  operation subtract;
37 
38  region1
39  {
40  ...
41  }
42 
43  region2
44  {
45  ...
46  }
47  }
48  \endverbatim
49 
50 Usage
51  \table
52  Property | Description | Required | Default value
53  type | type name: fieldValueDelta | yes |
54  \endtable
55 
56  The \c operation is one of:
57  \plaintable
58  add | add
59  subtract | subtract
60  min | minimum
61  max | maximum
62  average | average
63  \endplaintable
64 
65 See also
66  Foam::functionObject
67  Foam::functionObject::fieldValue
68  Foam::functionObjects::regionFunctionObject
69  Foam::functionObjects::logFiles
70 
71 SourceFiles
72  fieldValueDelta.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef functionObjects_fieldValueDelta_H
77 #define functionObjects_fieldValueDelta_H
78 
79 #include "regionFunctionObject.H"
80 #include "logFiles.H"
81 #include "fieldValue.H"
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 namespace Foam
86 {
87 namespace functionObjects
88 {
89 namespace fieldValues
90 {
91 
92 /*---------------------------------------------------------------------------*\
93  Class fieldValueDelta Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 class fieldValueDelta
97 :
98  public regionFunctionObject,
99  public logFiles
100 {
101 public:
102  //- Operation type enumeration
103  enum class operationType
104  {
105  add,
106  subtract,
107  min,
108  max,
109  average
110  };
111 
112  //- Operation type names
113  static const NamedEnum<operationType, 5> operationTypeNames_;
114 
115 
116 private:
117 
118  // Private Data
119 
120  //- Operation to apply to values
121  operationType operation_;
122 
123  //- Field value region object 1
124  autoPtr<fieldValue> region1Ptr_;
126  //- Field value region object 2
127  autoPtr<fieldValue> region2Ptr_;
128 
129 
130  // Private Member Functions
131 
132  //- Templated function to process common fields
133  template<class Type>
134  void processFields(bool& found);
135 
136  //- Templated function to apply the operation
137  template<class Type>
138  Type applyOperation(const Type& value1, const Type& value2) const;
139 
140 
141 protected:
143  // Protected Member Functions
144 
145  //- Output file header information
146  virtual void writeFileHeader(const label i);
147 
148 
149 public:
150 
151  //- Run-time type information
152  TypeName("fieldValueDelta");
153 
154 
155  // Constructors
156 
157  //- Construct from Time and dictionary
159  (
160  const word& name,
161  const Time& runTime,
162  const dictionary& dict
163  );
164 
165 
166  //- Destructor
167  virtual ~fieldValueDelta();
168 
169 
170  // Public Member Functions
171 
172  //- Read from dictionary
173  virtual bool read(const dictionary&);
174 
175  //- Do nothing
176  virtual bool execute();
177 
178  //- Calculate and write
179  virtual bool write();
180 };
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace fieldValues
186 } // End namespace functionObjects
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #ifdef NoRepository
192  #include "fieldValueDeltaTemplates.C"
193 #endif
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
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:156
virtual bool read(const dictionary &)
Read from dictionary.
engineTime & runTime
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
void processFields(OFstream &os, const List< List< label >> &addr, const List< word > &userFieldNames, const IOobjectList &cloudObjs)
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.