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-2017 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  Provides an operation between two 'field value' function objects.
35 
36  The operation is applied to all results of each fieldValue object.
37  Accordingly, each object must generate the same number and type of results.
38 
39 Usage
40  Example of function object specification:
41  \verbatim
42  fieldValueDelta1
43  {
44  type fieldValueDelta;
45  libs ("libfieldFunctionObjects.so");
46  operation subtract;
47 
48  region1
49  {
50  ...
51  }
52  region2
53  {
54  ...
55  }
56  }
57  \endverbatim
58 
59  Where the entries comprise:
60  \table
61  Property | Description | Required | Default value
62  type | type name: fieldValueDelta | yes |
63  \endtable
64 
65  The \c operation is one of:
66  \plaintable
67  add | add
68  subtract | subtract
69  min | minimum
70  max | maximum
71  average | average
72  \endplaintable
73 
74 See also
75  Foam::functionObject
76  Foam::functionObjects::fieldValue
77  Foam::functionObjects::regionFunctionObject
78  Foam::functionObjects::writeFile
79 
80 SourceFiles
81  fieldValueDelta.C
82 
83 \*---------------------------------------------------------------------------*/
84 
85 #ifndef functionObjects_fieldValueDelta_H
86 #define functionObjects_fieldValueDelta_H
87 
88 #include "stateFunctionObject.H"
89 #include "writeFile.H"
90 #include "fieldValue.H"
91 #include "Enum.H"
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 namespace Foam
96 {
97 namespace functionObjects
98 {
99 namespace fieldValues
100 {
101 
102 /*---------------------------------------------------------------------------*\
103  Class fieldValueDelta Declaration
104 \*---------------------------------------------------------------------------*/
105 
106 class fieldValueDelta
107 :
108  public fvMeshFunctionObject,
109  public writeFile
110 {
111 public:
112  //- Operation type enumeration
113  enum operationType
114  {
115  opAdd,
116  opSubtract,
117  opMin,
118  opMax,
119  opAverage
120  };
121 
122  //- Operation type names
123  static const Enum<operationType> operationTypeNames_;
124 
125 
126 private:
127 
128  // Private data
129 
130  //- Operation to apply to values
131  operationType operation_;
132 
133  //- Field value region object 1
134  autoPtr<fieldValue> region1Ptr_;
135 
136  //- Field value region object 2
137  autoPtr<fieldValue> region2Ptr_;
138 
139 
140  // Private Member Functions
141 
142  //- Templated function to apply the operation
143  template<class Type>
144  void applyOperation
145  (
146  const word& resultType,
147  const word& name1,
148  const word& name2,
149  const word& entryName1,
150  const word& entryName2,
151  bool& found
152  );
153 
154 
155 protected:
156 
157  // Protected Member Functions
158 
159  //- Output file header information
160  virtual void writeFileHeader(Ostream& os) const;
161 
162 
163 public:
164 
165  //- Run-time type information
166  TypeName("fieldValueDelta");
167 
168 
169  // Constructors
170 
171  //- Construct from Time and dictionary
173  (
174  const word& name,
175  const Time& runTime,
176  const dictionary& dict
177  );
178 
179 
180  //- Destructor
181  virtual ~fieldValueDelta();
182 
183 
184  // Public Member Functions
185 
186  //- Read from dictionary
187  virtual bool read(const dictionary&);
188 
189  //- Do nothing
190  virtual bool execute();
191 
192  //- Calculate and write
193  virtual bool write();
194 };
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace fieldValues
200 } // End namespace functionObjects
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #ifdef NoRepository
206  #include "fieldValueDeltaTemplates.C"
207 #endif
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #endif
212 
213 // ************************************************************************* //
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
Provides an operation between two 'field value' function objects.
Definition: fieldValueDelta.H:135
Foam::functionObjects::fieldValues::fieldValueDelta::TypeName
TypeName("fieldValueDelta")
Run-time type information.
Foam::functionObjects::fieldValues::fieldValueDelta::execute
virtual bool execute()
Do nothing.
Definition: fieldValueDelta.C:227
Foam::functionObjects::fieldValues::fieldValueDelta::~fieldValueDelta
virtual ~fieldValueDelta()
Destructor.
Definition: fieldValueDelta.C:117
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::opSubtract
Subtract.
Definition: fieldValueDelta.H:145
Foam::functionObjects::fieldValues::fieldValueDelta::opAdd
Add.
Definition: fieldValueDelta.H:144
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:158
Foam::functionObjects::fieldValues::fieldValueDelta::opMin
Minimum.
Definition: fieldValueDelta.H:146
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:148
Foam::functionObjects::fieldValues::fieldValueDelta::read
virtual bool read(const dictionary &)
Read from dictionary.
Definition: fieldValueDelta.C:124
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:147
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
functionObject base class for writing single files
Definition: writeFile.H:59
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:152
Foam::functionObjects::fieldValues::fieldValueDelta::operationType
operationType
Operation type enumeration.
Definition: fieldValueDelta.H:142
Enum.H