addSubtract.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) 2011 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::calcTypes::addSubtract
26 
27 Description
28  adds/subtracts a field or value to/from a base field.
29 
30  New field name specified by -resultName option, or automatically as:
31  <baseFieldName>_add_<addSubtractFieldName>
32  <baseFieldName>_add_value
33  <baseFieldName>_subtract_<addSubtractFieldName>
34  <baseFieldName>_subtract_value
35 
36  Example usage:
37  addSubtract p add -value 100000 -resultName pAbs
38  addSubtract U subtract -field U0
39 
40 SourceFiles
41  addSubtract.C
42  writeaddSubtractField.C
43  writeaddSubtractValue.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef addSubtract_H
48 #define addSubtract_H
49 
50 #include "calcType.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 namespace calcTypes
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class addSubtract Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class addSubtract
65 :
66  public calcType
67 {
68 public:
69 
70  enum calcTypes
71  {
73  VALUE
74  };
75 
76  enum calcModes
77  {
78  ADD,
79  SUBTRACT
80  };
81 
82 
83 private:
84 
85  // Private data
86 
87  //- Name of base field (to addSubtract to)
89 
90  //- Calc type as given by enumerations above
92 
93  //- Name of field to add/subtract
95 
96  //- String representation of value to add/subtract
97  string addSubtractValueStr_;
98 
99  //- Name of result field
101 
102  //- Mode - addSubtract/subtract
104 
105 
106  // Private Member Functions
107 
108  // Output
109 
110  //- Calc and output field addSubtractitions
112  (
113  const Time& runTime,
114  const fvMesh& mesh,
115  const IOobject& baseFieldHeader
116  );
117 
118  //- Calc and output field and value addSubtractitions
120  (
121  const Time& runTime,
122  const fvMesh& mesh,
123  const IOobject& baseFieldHeader
124  );
125 
126 
127  //- Disallow default bitwise copy construct
128  addSubtract(const addSubtract&);
129 
130  //- Disallow default bitwise assignment
131  void operator=(const addSubtract&);
132 
133 
134 protected:
135 
136  // Member Functions
137 
138  // Calculation routines
139 
140  //- Initialise - typically setting static variables,
141  // e.g. command line arguments
142  virtual void init();
143 
144  //- Pre-time loop calculations
145  virtual void preCalc
146  (
147  const argList& args,
148  const Time& runTime,
149  const fvMesh& mesh
150  );
151 
152  //- Time loop calculations
153  virtual void calc
154  (
155  const argList& args,
156  const Time& runTime,
157  const fvMesh& mesh
158  );
159 
160 
161  // I-O
162 
163  //- Write addSubtract field
164  template<class Type>
166  (
167  const IOobject& baseHeader,
168  const IOobject& addSubtractHeader,
169  const fvMesh& mesh,
170  bool& processed
171  );
172 
173  //- Write addSubtract value
174  template<class Type>
176  (
177  const IOobject& baseHeader,
178  const string& valueStr,
179  const fvMesh& mesh,
180  bool& processed
181  );
182 
183 
184 public:
185 
186  //- Runtime type information
187  TypeName("addSubtract");
188 
189 
190  // Constructors
191 
192  //- Construct null
193  addSubtract();
194 
195 
196  //- Destructor
197  virtual ~addSubtract();
198 };
199 
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 } // End namespace calcTypes
204 } // End namespace Foam
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #ifdef NoRepository
209 # include "writeAddSubtractField.C"
210 # include "writeAddSubtractValue.C"
211 #endif
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #endif
216 
217 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::calcTypes::addSubtract::calcModes
calcModes
Definition: addSubtract.H:75
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::calcTypes::addSubtract::writeAddSubtractValue
void writeAddSubtractValue(const IOobject &baseHeader, const string &valueStr, const fvMesh &mesh, bool &processed)
Write addSubtract value.
Definition: writeAddSubtractValue.C:28
Foam::calcTypes::addSubtract::addSubtractValueStr_
string addSubtractValueStr_
String representation of value to add/subtract.
Definition: addSubtract.H:96
Foam::calcTypes::addSubtract::operator=
void operator=(const addSubtract &)
Disallow default bitwise assignment.
Foam::calcTypes::addSubtract::TypeName
TypeName("addSubtract")
Runtime type information.
Foam::calcTypes::addSubtract::writeAddSubtractField
void writeAddSubtractField(const IOobject &baseHeader, const IOobject &addSubtractHeader, const fvMesh &mesh, bool &processed)
Write addSubtract field.
Definition: writeAddSubtractField.C:28
Foam::calcTypes::addSubtract::preCalc
virtual void preCalc(const argList &args, const Time &runTime, const fvMesh &mesh)
Pre-time loop calculations.
Definition: addSubtract.C:209
Foam::calcTypes::addSubtract::addSubtract
addSubtract()
Construct null.
Definition: addSubtract.C:177
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:97
Foam::calcTypes::addSubtract::writeAddSubtractFields
void writeAddSubtractFields(const Time &runTime, const fvMesh &mesh, const IOobject &baseFieldHeader)
Calc and output field addSubtractitions.
Definition: addSubtract.C:44
writeAddSubtractValue.C
Foam::calcTypes::addSubtract::VALUE
@ VALUE
Definition: addSubtract.H:72
Foam::calcTypes::addSubtract::calcTypes
calcTypes
Definition: addSubtract.H:69
Foam::calcTypes::addSubtract::baseFieldName_
word baseFieldName_
Name of base field (to addSubtract to)
Definition: addSubtract.H:87
Foam::calcTypes::addSubtract::FIELD
@ FIELD
Definition: addSubtract.H:71
Foam::calcTypes::addSubtract::calcType_
calcTypes calcType_
Calc type as given by enumerations above.
Definition: addSubtract.H:90
Foam::calcTypes::addSubtract::ADD
@ ADD
Definition: addSubtract.H:77
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::calcTypes::addSubtract::calcMode_
calcModes calcMode_
Mode - addSubtract/subtract.
Definition: addSubtract.H:102
Foam::calcTypes::addSubtract::init
virtual void init()
Initialise - typically setting static variables,.
Definition: addSubtract.C:197
calcType.H
writeAddSubtractField.C
Foam::calcTypes::addSubtract::addSubtractFieldName_
word addSubtractFieldName_
Name of field to add/subtract.
Definition: addSubtract.H:93
Foam::calcTypes::addSubtract::writeAddSubtractValues
void writeAddSubtractValues(const Time &runTime, const fvMesh &mesh, const IOobject &baseFieldHeader)
Calc and output field and value addSubtractitions.
Definition: addSubtract.C:119
Foam::calcTypes::addSubtract::~addSubtract
virtual ~addSubtract()
Destructor.
Definition: addSubtract.C:191
Foam::calcTypes::addSubtract::calc
virtual void calc(const argList &args, const Time &runTime, const fvMesh &mesh)
Time loop calculations.
Definition: addSubtract.C:254
Foam::calcTypes::addSubtract::SUBTRACT
@ SUBTRACT
Definition: addSubtract.H:78
Foam::calcTypes::addSubtract::resultName_
word resultName_
Name of result field.
Definition: addSubtract.H:99
Foam::calcTypes::addSubtract
adds/subtracts a field or value to/from a base field.
Definition: addSubtract.H:63
args
Foam::argList args(argc, argv)
Foam::calcType
Base class for post-processing calculation functions.
Definition: calcType.H:58