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. All input fields must have matching sizes and compatible
36  dimensions; otherwise, an error will be raised.
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) | <time>/inputFields
46  output file | - |-
47  output field | {vol,surface}<Type>Field | <time>/outputField
48  \endtable
49 
50  where \c Type can be one of:
51  \c Scalar, \c Vector, \c SphericalTensor, \c SymmTensor, or \c Tensor.
52 
53 Usage
54  Minimal example by using \c system/controlDict.functions:
55  \verbatim
56  addFO
57  {
58  // Mandatory entries
59  type add;
60  libs (fieldFunctionObjects);
61 
62  // Inherited entries
63  fields (<wordList>); // (<field1> <field2> ... <fieldN>);
64  ...
65  }
66  \endverbatim
67 
68  where the entries mean:
69  \table
70  Property | Description | Type | Reqd | Deflt
71  type | Type name: add | word | yes | -
72  libs | Library name: fieldFunctionObjects | word | yes | -
73  fields | Names of operand fields (at least two) | wordList | yes | -
74  \endtable
75 
76  The inherited entries are elaborated in:
77  - \link fieldsExpression.H \endlink
78 
79 SourceFiles
80  add.C
81  addTemplates.C
82 
83 \*---------------------------------------------------------------------------*/
84 
85 #ifndef Foam_functionObjects_add_H
86 #define Foam_functionObjects_add_H
87 
88 #include "fieldsExpression.H"
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 namespace Foam
93 {
94 namespace functionObjects
95 {
96 
97 /*---------------------------------------------------------------------------*\
98  Class add Declaration
99 \*---------------------------------------------------------------------------*/
100 
101 class add
102 :
103  public fieldsExpression
104 {
105  // Private Member Functions
106 
107  //- Add the list of fields of the specified type
108  //- and return the result
109  template<class GeoFieldType>
110  tmp<GeoFieldType> calcFieldType() const;
111 
112  //- Add the list of fields and return true if successful
113  virtual bool calc();
114 
115 
116 public:
117 
118  //- Grant fieldsExpression access to private and protected members
119  friend class fieldsExpression;
120 
121 
122  //- Runtime type information
123  TypeName("add");
124 
125 
126  // Constructors
127 
128  //- Construct from name, Time and dictionary
129  add
130  (
131  const word& name,
132  const Time& runTime,
133  const dictionary& dict
134  );
135 
136  //- No copy construct
137  add(const add&) = delete;
138 
139  //- No copy assignment
140  void operator=(const add&) = delete;
141 
142 
143  //- Destructor
144  virtual ~add() = default;
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace functionObjects
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #ifdef NoRepository
156  #include "addTemplates.C"
157 #endif
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 #endif
162 
163 // ************************************************************************* //
dictionary dict
engineTime & runTime
void operator=(const add &)=delete
No copy assignment.
const word & name() const noexcept
Return the name of this functionObject.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
add(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Definition: add.C:48
Sums a given list of (at least two or more) fields and outputs the result into a new field...
Definition: add.H:136
friend class fieldsExpression
Grant fieldsExpression access to private and protected members.
Definition: add.H:160
virtual ~add()=default
Destructor.
TypeName("add")
Runtime type information.
Namespace for OpenFOAM.