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