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 | Copyright (C) 2015 OpenCFD Ltd.
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 applies an operation to the output of two
32  fieldValue function objects.
33 
34  The operation is applied to all results of each fieldValue object.
35  Accordingly, each object must generate the same number and type of results.
36 
37  Example of function object specification:
38  \verbatim
39  fieldValueDelta1
40  {
41  type fieldValueDelta;
42  functionObjectLibs ("libfieldFunctionObjects.so");
43  operation subtract;
44 
45  source1
46  {
47  ...
48  }
49  source2
50  {
51  ...
52  }
53  }
54  \endverbatim
55 
56  \heading Function object usage
57  \table
58  Property | Description | Required | Default value
59  type | type name: fieldValueDelta | yes |
60  \endtable
61 
62  \linebreak
63  The \c operation is one of:
64  \plaintable
65  add | add
66  subtract | subtract
67  min | minimum
68  max | maximum
69  average | average
70  \endplaintable
71 
72 SeeAlso
73  Foam::fieldValue
74 
75 SourceFiles
76  fieldValueDelta.C
77 
78 \*---------------------------------------------------------------------------*/
79 
80 #ifndef fieldValueDelta_H
81 #define fieldValueDelta_H
82 
83 #include "functionObjectState.H"
84 #include "functionObjectFile.H"
85 #include "fieldValue.H"
86 #include "autoPtr.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 namespace fieldValues
94 {
95 
96 /*---------------------------------------------------------------------------*\
97  Class fieldValueDelta Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 class fieldValueDelta
101 :
102  public functionObjectState,
103  public functionObjectFile
104 {
105 public:
106  //- Operation type enumeration
107  enum operationType
108  {
109  opAdd,
110  opSubtract,
111  opMin,
112  opMax,
113  opAverage
114  };
115 
116  //- Operation type names
117  static const NamedEnum<operationType, 5> operationTypeNames_;
118 
119 
120 private:
121 
122  // Private data
123 
124  //- Database this class is registered to
125  const objectRegistry& obr_;
126 
127  //- Flag to indicate to load from files
128  bool loadFromFiles_;
129 
130  //- Switch to send output to Info as well as to file
131  Switch log_;
132 
133  //- Operation to apply to values
135 
136  //- Field value source object 1
138 
139  //- Field value source object 2
141 
142 
143  // Private Member Functions
144 
145  //- Templated function to apply the operation
146  template<class Type>
147  void apply
148  (
149  const word& resultType,
150  const word& name1,
151  const word& name2,
152  const word& entryName1,
153  const word& entryName2,
154  bool& found
155  );
156 
157 
158 protected:
159 
160  // Functions to be over-ridden from IOoutputFilter class
161 
162  //- Output file header information
163  virtual void writeFileHeader(Ostream& os) const;
164 
165 
166 public:
167 
168  //- Run-time type information
169  TypeName("fieldValueDelta");
170 
171 
172  //- Construct from components
174  (
175  const word& name,
176  const objectRegistry& obr,
177  const dictionary& dict,
178  const bool loadFromFiles = false
179  );
180 
181 
182  //- Destructor
183  virtual ~fieldValueDelta();
184 
185 
186  // Public Member Functions
187 
188  // Function object functions
189 
190  //- Read from dictionary
191  virtual void read(const dictionary&);
192 
193  //- Calculate and write
194  virtual void write();
195 
196  //- Execute
197  virtual void execute();
198 
199  //- Execute the at the final time-loop, currently does nothing
200  virtual void end();
201 
202  //- Called when time was set at the end of the Time::operator++
203  virtual void timeSet();
204 
205  //- Update mesh
206  virtual void updateMesh(const mapPolyMesh&);
207 
208  //- Move points
209  virtual void movePoints(const polyMesh&);
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace fieldValues
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #ifdef NoRepository
221  #include "fieldValueDeltaTemplates.C"
222 #endif
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
Foam::fieldValues::fieldValueDelta::operationType
operationType
Operation type enumeration.
Definition: fieldValueDelta.H:136
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fieldValues::fieldValueDelta::opMax
@ opMax
Definition: fieldValueDelta.H:141
Foam::functionObjectState
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: functionObjectState.H:54
functionObjectState.H
Foam::fieldValues::fieldValueDelta::opAdd
@ opAdd
Definition: fieldValueDelta.H:138
Foam::fieldValues::fieldValueDelta::apply
void apply(const word &resultType, const word &name1, const word &name2, const word &entryName1, const word &entryName2, bool &found)
Templated function to apply the operation.
Definition: fieldValueDeltaTemplates.C:30
Foam::functionObjectState::resultType
word resultType(const word &entryName) const
Retrieve the result type.
Definition: functionObjectState.C:99
Foam::fieldValues::fieldValueDelta::opSubtract
@ opSubtract
Definition: fieldValueDelta.H:139
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::fieldValues::fieldValueDelta::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: fieldValueDelta.H:160
Foam::fieldValues::fieldValueDelta::execute
virtual void execute()
Execute.
Definition: fieldValueDelta.C:164
Foam::fieldValues::fieldValueDelta::source1Ptr_
autoPtr< fieldValue > source1Ptr_
Field value source object 1.
Definition: fieldValueDelta.H:166
Foam::fieldValues::fieldValueDelta::~fieldValueDelta
virtual ~fieldValueDelta()
Destructor.
Definition: fieldValueDelta.C:117
Foam::fieldValues::fieldValueDelta::opAverage
@ opAverage
Definition: fieldValueDelta.H:142
Foam::fieldValues::fieldValueDelta::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update mesh.
Definition: fieldValueDelta.C:252
Foam::fieldValues::fieldValueDelta::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: fieldValueDelta.C:246
Foam::fieldValues::fieldValueDelta::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Output file header information.
Definition: fieldValueDelta.C:59
Foam::fieldValues::fieldValueDelta::operation_
operationType operation_
Operation to apply to values.
Definition: fieldValueDelta.H:163
Foam::fieldValues::fieldValueDelta::TypeName
TypeName("fieldValueDelta")
Run-time type information.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fieldValues::fieldValueDelta::read
virtual void read(const dictionary &)
Read from dictionary.
Definition: fieldValueDelta.C:123
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fieldValues::fieldValueDelta::movePoints
virtual void movePoints(const polyMesh &)
Move points.
Definition: fieldValueDelta.C:258
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
fieldValueDeltaTemplates.C
Foam::fieldValues::fieldValueDelta::source2Ptr_
autoPtr< fieldValue > source2Ptr_
Field value source object 2.
Definition: fieldValueDelta.H:169
functionObjectFile.H
fieldValue.H
Foam::fieldValues::fieldValueDelta::loadFromFiles_
bool loadFromFiles_
Flag to indicate to load from files.
Definition: fieldValueDelta.H:157
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::fieldValues::fieldValueDelta
This function object provides applies an operation to the output of two fieldValue function objects.
Definition: fieldValueDelta.H:129
Foam::fieldValues::fieldValueDelta::obr_
const objectRegistry & obr_
Database this class is registered to.
Definition: fieldValueDelta.H:154
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::fieldValues::fieldValueDelta::fieldValueDelta
fieldValueDelta(const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false)
Construct from components.
Definition: fieldValueDelta.C:91
Foam::functionObjectState::name
const word & name() const
Return the name.
Definition: functionObjectState.C:58
Foam::fieldValues::fieldValueDelta::operationTypeNames_
static const NamedEnum< operationType, 5 > operationTypeNames_
Operation type names.
Definition: fieldValueDelta.H:146
Foam::NamedEnum< operationType, 5 >
Foam::fieldValues::fieldValueDelta::opMin
@ opMin
Definition: fieldValueDelta.H:140
autoPtr.H
Foam::fieldValues::fieldValueDelta::end
virtual void end()
Execute the at the final time-loop, currently does nothing.
Definition: fieldValueDelta.C:240
Foam::fieldValues::fieldValueDelta::write
virtual void write()
Calculate and write.
Definition: fieldValueDelta.C:158