subtract.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) 2016 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::functionObjects::subtract
29
30Group
31 grpFieldFunctionObjects
32
33Description
34 Subtracts a given list of (at least one or more) fields from a field and
35 produces a new field, where the fields possess the same sizes and
36 dimensions.
37
38 \verbatim
39 fieldResult = field1 - field2 - ... - fieldN
40 \endverbatim
41
42 Operands:
43 \table
44 Operand | Type | Location
45 input | {vol,surface}<Type>Field(s) <!--
46 --> | $FOAM_CASE/<time>/<inpField>s
47 output file | - | -
48 output field | {vol,surface}<Type>Field <!--
49 --> | $FOAM_CASE/<time>/<outField>
50 \endtable
51
52 where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
53
54Usage
55 Minimal example by using \c system/controlDict.functions:
56 \verbatim
57 subtract1
58 {
59 // Mandatory entries (unmodifiable)
60 type subtract;
61 libs (fieldFunctionObjects);
62
63 // Mandatory (inherited) entry (runtime modifiable)
64 fields (<field1> <field2> ... <fieldN>);
65
66 // Optional (inherited) entries
67 ...
68 }
69 \endverbatim
70
71 where the entries mean:
72 \table
73 Property | Description | Type | Req'd | Dflt
74 type | Type name: subtract | word | yes | -
75 libs | Library name: fieldFunctionObjects | word | yes | -
76 fields | Names of the operand fields | wordList | yes | -
77 \endtable
78
79 The inherited entries are elaborated in:
80 - \link functionObject.H \endlink
81 - \link fieldsExpression.H \endlink
82
83 Minimal example by using the \c postProcess utility:
84 \verbatim
85 postProcess -func "subtract(<field1>, <field2>, ..., <fieldN>)"
86 \endverbatim
87
88See also
89 - Foam::functionObject
90 - Foam::functionObjects::fieldsExpression
91 - Foam::functionObjects::fvMeshFunctionObject
92 - ExtendedCodeGuide::functionObjects::field::subtract
93
94SourceFiles
95 subtract.C
96 subtractTemplates.C
97
98\*---------------------------------------------------------------------------*/
99
100#ifndef functionObjects_subtract_H
101#define functionObjects_subtract_H
102
103#include "fieldsExpression.H"
104
105// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106
107namespace Foam
108{
109namespace functionObjects
110{
111
112/*---------------------------------------------------------------------------*\
113 Class subtract Declaration
114\*---------------------------------------------------------------------------*/
115
116class subtract
117:
118 public fieldsExpression
119{
120 // Private Member Functions
121
122 //- Subtract the list of fields of the specified type
123 //- and return the result
124 template<class GeoFieldType>
125 tmp<GeoFieldType> calcFieldType() const;
126
127 //- Subtract the list of fields and return true if successful
128 virtual bool calc();
129
130
131public:
132
133 friend class fieldsExpression;
134
135
136 //- Runtime type information
137 TypeName("subtract");
138
139
140 // Constructors
141
142 //- Construct from Time and dictionary
144 (
145 const word& name,
146 const Time& runTime,
147 const dictionary& dict
148 );
149
150 //- No copy construct
151 subtract(const subtract&) = delete;
152
153 //- No copy assignment
154 void operator=(const subtract&) = delete;
155
156
157 //- Destructor
158 virtual ~subtract() = default;
160
161
162// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163
164} // End namespace functionObjects
165} // End namespace Foam
166
167// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168
169#ifdef NoRepository
170 #include "subtractTemplates.C"
171#endif
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175#endif
177// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Intermediate class for handling field expression function objects (e.g. add, subtract etc....
Subtracts a given list of (at least one or more) fields from a field and produces a new field,...
Definition: subtract.H:162
virtual ~subtract()=default
Destructor.
subtract(const subtract &)=delete
No copy construct.
void operator=(const subtract &)=delete
No copy assignment.
TypeName("subtract")
Runtime type information.
subtract(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: subtract.C:55
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73