Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
postProcessing
foamCalcFunctions
basic
addSubtract
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) 2008-2010 OpenCFD Ltd.
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 <
foamCalcFunctions/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
{
72
FIELD
,
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)
88
word
baseFieldName_;
89
90
//- Calc type as given by enumerations above
91
calcTypes
calcType_;
92
93
//- Name of field to add/subtract
94
word
addSubtractFieldName_;
95
96
//- String representation of value to add/subtract
97
string
addSubtractValueStr_;
98
99
//- Name of result field
100
word
resultName_;
101
102
//- Mode - addSubtract/subtract
103
calcModes
calcMode_;
104
105
106
// Private Member Functions
107
108
// Output
109
110
//- Calc and output field addSubtractitions
111
void
writeAddSubtractFields
112
(
113
const
Time
& runTime,
114
const
fvMesh
&
mesh
,
115
const
IOobject
& baseFieldHeader
116
);
117
118
//- Calc and output field and value addSubtractitions
119
void
writeAddSubtractValues
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>
165
void
writeAddSubtractField
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>
175
void
writeAddSubtractValue
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
198
virtual
~addSubtract
();
199
};
200
201
202
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203
204
}
// End namespace calcTypes
205
}
// End namespace Foam
206
207
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208
209
#ifdef NoRepository
210
# include "
writeAddSubtractField.C
"
211
# include "
writeAddSubtractValue.C
"
212
#endif
213
214
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215
216
#endif
217
218
// ************************ vim: set sw=4 sts=4 et: ************************ //