multiply.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) 2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::functionObjects::multiply
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Multiplies a given list of (at least two or more) fields and outputs the
34 result into a new field.
35
36 \verbatim
37 fieldResult = field1 * field2 * ... * fieldN
38 \endverbatim
39
40 Operands:
41 \table
42 Operand | Type | Location
43 input | vol<Type>Field(s) <!--
44 --> |$FOAM_CASE/<time>/<inpField>s
45 output field | vol<Type>Field <!--
46 --> | $FOAM_CASE/<time>/<outField>
47 \endtable
48
49 where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
50
51Usage
52 Minimal example by using \c system/controlDict.functions:
53 \verbatim
54 multiply1
55 {
56 // Mandatory entries (unmodifiable)
57 type multiply;
58 libs (fieldFunctionObjects);
59
60 // Mandatory (inherited) entry (runtime modifiable)
61 fields (<field1> <field2> ... <fieldN>);
62
63 // Optional (inherited) entries
64 ...
65 }
66 \endverbatim
67
68 where the entries mean:
69 \table
70 Property | Description | Type | Reqd | Dflt
71 type | Type name: multiply | word | yes | -
72 libs | Library name: fieldFunctionObjects | word | yes | -
73 fields | Names of the operand fields | wordList | yes | -
74 \endtable
75
76 The inherited entries are elaborated in:
77 - \link functionObject.H \endlink
78 - \link fieldsExpression.H \endlink
79
80See also
81 - Foam::functionObject
82 - Foam::functionObjects::fieldsExpression
83 - Foam::functionObjects::fvMeshFunctionObject
84
85SourceFiles
86 multiply.C
87 multiplyTemplates.C
88
89\*---------------------------------------------------------------------------*/
90
91#ifndef functionObjects_multiply_H
92#define functionObjects_multiply_H
93
94#include "fieldsExpression.H"
95
96// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97
98namespace Foam
99{
100namespace functionObjects
101{
102
103/*---------------------------------------------------------------------------*\
104 Class multiply Declaration
105\*---------------------------------------------------------------------------*/
106
107class multiply
108:
109 public fieldsExpression
110{
111 //- Helper struct to define valid operations
112 template<class Type1, class Type2>
113 struct is_valid_op
114 {
115 static constexpr bool value =
118 };
119
120
121 // Private Member Functions
122
123 template<class Type>
124 bool initialiseResult(const word& fieldName);
125
126 template<class Type>
127 bool multiplyResult(const word& fieldName, bool& processed);
128
129 template<class Type1, class Type2>
130 typename std::enable_if
131 <
132 is_valid_op<Type1, Type2>::value, bool
133 >::type
134 multiplyFieldType
135 (
136 GeometricField<Type1, fvPatchField, volMesh>& result,
137 const word& fieldName,
138 bool& processed
139 );
140
141 template<class Type1, class Type2>
142 typename std::enable_if
143 <
144 !is_valid_op<Type1, Type2>::value, bool
145 >::type
146 multiplyFieldType
147 (
149 const word& fieldName,
150 bool& processed
151 );
152
153 //- Multiply the list of fields and return true if successful
154 virtual bool calc();
155
156
157public:
158
159 friend class fieldsExpression;
160
161
162 //- Runtime type information
163 TypeName("multiply");
164
165
166 // Constructors
167
168 //- Construct from Time and dictionary
170 (
171 const word& name,
172 const Time& runTime,
173 const dictionary& dict
174 );
175
176 //- No copy construct
177 multiply(const multiply&) = delete;
178
179 //- No copy assignment
180 void operator=(const multiply&) = delete;
181
182
183 //- Destructor
184 virtual ~multiply() = default;
185};
186
187
188// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189
190} // End namespace functionObjects
191} // End namespace Foam
192
193// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194
195#ifdef NoRepository
196 #include "multiplyTemplates.C"
197#endif
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201#endif
203// ************************************************************************* //
static constexpr direction rank
Rank of Barycentric is 1.
Definition: Barycentric.H:69
Generic GeometricField class.
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.
virtual const word & type() const =0
Runtime type information.
Intermediate class for handling field expression function objects (e.g. add, subtract etc....
Multiplies a given list of (at least two or more) fields and outputs the result into a new field.
Definition: multiply.H:149
void operator=(const multiply &)=delete
No copy assignment.
TypeName("multiply")
Runtime type information.
multiply(const multiply &)=delete
No copy construct.
virtual ~multiply()=default
Destructor.
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73