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-2013 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::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  functionObjectLibs ("libfieldFunctionObjects.so");
40  operation subtract;
41 
42  fieldValue1
43  {
44  ...
45  }
46  fieldValue2
47  {
48  ...
49  }
50  }
51  \endverbatim
52 
53  \heading Function object usage
54  \table
55  Property | Description | Required | Default value
56  type | type name: fieldValueDelta | yes |
57  \endtable
58 
59  \linebreak
60  The \c operation is one of:
61  \plaintable
62  add | add
63  subtract | subtract
64  min | minimum
65  max | maximum
66  average | average
67  \endplaintable
68 SeeAlso
69  Foam::fieldValue
70 
71 SourceFiles
72  fieldValueDelta.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef fieldValueDelta_H
77 #define fieldValueDelta_H
78 
79 #include "functionObjectFile.H"
80 #include "fieldValue.H"
81 #include "autoPtr.H"
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 namespace Foam
86 {
87 
88 namespace fieldValues
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class fieldValueDelta Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 class fieldValueDelta
96 :
97  public functionObjectFile
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  //- Name of this fieldValue object
119  word name_;
120 
121  //- Database this class is registered to
122  const objectRegistry& obr_;
123 
124  //- Flag to indicate to load from files
125  bool loadFromFiles_;
126 
127  //- Switch to send output to Info as well as to file
128  Switch log_;
129 
130  //- Operation to apply to values
131  operationType operation_;
133  //- Field value source object 1
134  autoPtr<fieldValue> source1Ptr_;
136  //- Field value source object 2
137  autoPtr<fieldValue> source2Ptr_;
138 
139 
140  // Private Member Functions
141 
142  //- Templated function to process common fields
143  template<class Type>
144  void processFields(bool& found);
145 
146  //- Templated function to apply the operation
147  template<class Type>
148  Type applyOperation(const Type& value1, const Type& value2) const;
149 
150 
151 protected:
152 
153  // Functions to be over-ridden from IOoutputFilter class
154 
155  //- Output file header information
156  virtual void writeFileHeader(const label i);
157 
158 
159 public:
160 
161  //- Run-time type information
162  TypeName("fieldValueDelta");
163 
164 
165  //- Construct from components
167  (
168  const word& name,
169  const objectRegistry& obr,
170  const dictionary& dict,
171  const bool loadFromFiles = false
172  );
173 
174 
175  //- Destructor
176  virtual ~fieldValueDelta();
177 
178 
179  // Public Member Functions
180 
181  // Function object functions
182 
183  //- Read from dictionary
184  virtual void read(const dictionary&);
185 
186  //- Calculate and write
187  virtual void write();
188 
189  //- Execute
190  virtual void execute();
191 
192  //- Execute the at the final time-loop, currently does nothing
193  virtual void end();
194 
195  //- Called when time was set at the end of the Time::operator++
196  virtual void timeSet();
197 
198  //- Update mesh
199  virtual void updateMesh(const mapPolyMesh&);
200 
201  //- Move points
202  virtual void movePoints(const polyMesh&);
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace fieldValues
209 } // End namespace Foam
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #ifdef NoRepository
214  #include "fieldValueDeltaTemplates.C"
215 #endif
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************************************************************* //
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual void execute()
Execute.
A class for handling words, derived from string.
Definition: word.H:59
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
virtual void updateMesh(const mapPolyMesh &)
Update mesh.
virtual void write()
Calculate and write.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
virtual void read(const dictionary &)
Read from dictionary.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
TypeName("fieldValueDelta")
Run-time type information.
Namespace for OpenFOAM.
dictionary dict
static const NamedEnum< operationType, 5 > operationTypeNames_
Operation type names.
fieldValueDelta(const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false)
Construct from components.
bool found
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Registry of regIOobjects.
virtual void movePoints(const polyMesh &)
Move points.
operationType
Operation type enumeration.
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
virtual ~fieldValueDelta()
Destructor.
virtual void end()
Execute the at the final time-loop, currently does nothing.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
virtual void writeFileHeader(const label i)
Output file header information.