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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::functionObjects::subtract
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
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 
54 Usage
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 
88 See also
89  - Foam::functionObject
90  - Foam::functionObjects::fieldsExpression
91  - Foam::functionObjects::fvMeshFunctionObject
92  - ExtendedCodeGuide::functionObjects::field::subtract
93 
94 SourceFiles
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 
107 namespace Foam
108 {
109 namespace functionObjects
110 {
111 
112 /*---------------------------------------------------------------------------*\
113  Class subtract Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 class 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 
131 public:
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
143  subtract
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;
159 };
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
176 
177 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::functionObjects::subtract::~subtract
virtual ~subtract()=default
Destructor.
Foam::subtract
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:940
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::subtract::TypeName
TypeName("subtract")
Runtime type information.
Foam::functionObjects::subtract::subtract
subtract(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: subtract.C:55
fieldsExpression.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::subtract::fieldsExpression
friend class fieldsExpression
Definition: subtract.H:176
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
subtractTemplates.C
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::fieldsExpression
Intermediate class for handling field expression function objects (e.g. add, subtract etc....
Definition: fieldsExpression.H:103
Foam::functionObjects::subtract
Subtracts a given list of (at least one or more) fields from a field and produces a new field,...
Definition: subtract.H:159
Foam::functionObjects::subtract::operator=
void operator=(const subtract &)=delete
No copy assignment.