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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2020 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::functionObjects::fieldValues::fieldValueDelta
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Computes a selected operation between two \c fieldValue function objects.
35 
36  The operation is applied to all results of each \c fieldValue object.
37  Accordingly, each object must generate the same number and type of results.
38 
39 Usage
40  Minimal example by using \c system/controlDict.functions:
41  \verbatim
42  fieldValueDelta1
43  {
44  // Mandatory entries (unmodifiable)
45  type fieldValueDelta;
46  libs (fieldFunctionObjects);
47 
48  // Mandatory entries (runtime modifiable)
49  operation subtract;
50  region1
51  {
52  ...
53  }
54  region2
55  {
56  ...
57  }
58 
59  // Optional (inherited) entries
60  ...
61  }
62  \endverbatim
63 
64  where the entries mean:
65  \table
66  Property | Description | Type | Req'd | Dflt
67  type | Type name: fieldValueDelta | word | yes | -
68  libs | Library name: fieldFunctionObjects | word | yes | -
69  operation | Operation type to apply to values | word | yes | -
70  region1 | Region1 properties | dict | yes | -
71  region2 | Region2 properties | dict | yes | -
72  \endtable
73 
74  Options for the \c operation entry:
75  \plaintable
76  add | add
77  subtract | subtract
78  min | minimum
79  max | maximum
80  average | average
81  \endplaintable
82 
83  The inherited entries are elaborated in:
84  - \link fieldValue.H \endlink
85 
86  Usage by the \c postProcess utility is not available.
87 
88 See also
89  - Foam::functionObject
90  - Foam::functionObjects::fieldValue
91  - ExtendedCodeGuide::functionObjects::field::fieldValueDelta
92 
93 SourceFiles
94  fieldValueDelta.C
95  fieldValueDeltaTemplates.C
96 
97 \*---------------------------------------------------------------------------*/
98 
99 #ifndef functionObjects_fieldValueDelta_H
100 #define functionObjects_fieldValueDelta_H
101 
102 #include "stateFunctionObject.H"
103 #include "writeFile.H"
104 #include "fieldValue.H"
105 #include "Enum.H"
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 namespace Foam
110 {
111 namespace functionObjects
112 {
113 namespace fieldValues
114 {
115 
116 /*---------------------------------------------------------------------------*\
117  Class fieldValueDelta Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 class fieldValueDelta
121 :
122  public fvMeshFunctionObject,
123  public writeFile
124 {
125 public:
126  //- Operation type enumeration
127  enum operationType
128  {
129  opAdd,
130  opSubtract,
131  opMin,
132  opMax,
133  opAverage
134  };
135 
136  //- Operation type names
137  static const Enum<operationType> operationTypeNames_;
138 
139 
140 private:
141 
142  // Private Data
143 
144  //- Operation to apply to values
145  operationType operation_;
146 
147  //- Field value region object 1
148  autoPtr<fieldValue> region1Ptr_;
149 
150  //- Field value region object 2
151  autoPtr<fieldValue> region2Ptr_;
152 
153 
154  // Private Member Functions
155 
156  //- Templated function to apply the operation
157  template<class Type>
158  void applyOperation
159  (
160  const word& resultType,
161  const word& name1,
162  const word& name2,
163  const word& entryName1,
164  const word& entryName2,
165  bool& found
166  );
167 
168 
169 protected:
170 
171  // Protected Member Functions
172 
173  //- Output file header information
174  virtual void writeFileHeader(Ostream& os) const;
175 
176 
177 public:
178 
179  //- Run-time type information
180  TypeName("fieldValueDelta");
181 
182 
183  // Constructors
184 
185  //- Construct from Time and dictionary
187  (
188  const word& name,
189  const Time& runTime,
190  const dictionary& dict
191  );
192 
193  //- No copy construct
194  fieldValueDelta(const fieldValueDelta&) = delete;
195 
196  //- No copy assignment
197  void operator=(const fieldValueDelta&) = delete;
198 
199 
200  //- Destructor
201  virtual ~fieldValueDelta() = default;
202 
203 
204  // Public Member Functions
205 
206  //- Read from dictionary
207  virtual bool read(const dictionary&);
208 
209  //- Do nothing
210  virtual bool execute();
211 
212  //- Calculate and write
213  virtual bool write();
214 };
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 } // End namespace fieldValues
220 } // End namespace functionObjects
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #ifdef NoRepository
226  #include "fieldValueDeltaTemplates.C"
227 #endif
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #endif
232 
233 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
writeFile.H
Foam::Enum< operationType >
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::fieldValues::fieldValueDelta
Computes a selected operation between two fieldValue function objects.
Definition: fieldValueDelta.H:175
Foam::functionObjects::fieldValues::fieldValueDelta::TypeName
TypeName("fieldValueDelta")
Run-time type information.
Foam::functionObjects::fieldValues::fieldValueDelta::execute
virtual bool execute()
Do nothing.
Definition: fieldValueDelta.C:221
Foam::functionObjects::stateFunctionObject::resultType
word resultType(const word &entryName) const
Retrieve the result type.
Definition: stateFunctionObject.C:159
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::fieldValues::fieldValueDelta::~fieldValueDelta
virtual ~fieldValueDelta()=default
Destructor.
Foam::functionObjects::fieldValues::fieldValueDelta::opSubtract
Subtract.
Definition: fieldValueDelta.H:185
Foam::functionObjects::fieldValues::fieldValueDelta::opAdd
Add.
Definition: fieldValueDelta.H:184
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::fieldValues::fieldValueDelta::write
virtual bool write()
Calculate and write.
Definition: fieldValueDelta.C:152
Foam::functionObjects::fieldValues::fieldValueDelta::opMin
Minimum.
Definition: fieldValueDelta.H:186
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
fieldValueDeltaTemplates.C
Foam::functionObjects::fieldValues::fieldValueDelta::opAverage
Average.
Definition: fieldValueDelta.H:188
Foam::functionObjects::fieldValues::fieldValueDelta::operator=
void operator=(const fieldValueDelta &)=delete
No copy assignment.
Foam::functionObjects::fieldValues::fieldValueDelta::read
virtual bool read(const dictionary &)
Read from dictionary.
Definition: fieldValueDelta.C:118
Foam::functionObjects::fieldValues::fieldValueDelta::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Output file header information.
Definition: fieldValueDelta.C:64
Foam::functionObjects::fieldValues::fieldValueDelta::opMax
Maximum.
Definition: fieldValueDelta.H:187
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
fieldValue.H
Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta
fieldValueDelta(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: fieldValueDelta.C:98
stateFunctionObject.H
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::functionObjects::fieldValues::fieldValueDelta::operationTypeNames_
static const Enum< operationType > operationTypeNames_
Operation type names.
Definition: fieldValueDelta.H:192
Foam::functionObjects::fieldValues::fieldValueDelta::operationType
operationType
Operation type enumeration.
Definition: fieldValueDelta.H:182
Enum.H